mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
d842466594
put cryptography lib to fixed version fix race condition bug in queue handler add lock to db writing and backup to file db on each write
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace Azaion.Dataset.Controls
|
|
{
|
|
public class ProportionToWidthConverter : IMultiValueConverter
|
|
{
|
|
private const double MinPixelBarWidth = 2.0;
|
|
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (values == null || values.Length < 2 ||
|
|
!(values[0] is double proportion) ||
|
|
!(values[1] is double containerActualWidth))
|
|
return MinPixelBarWidth; // Default or fallback width
|
|
|
|
if (containerActualWidth <= 0 || !double.IsFinite(containerActualWidth) || double.IsNaN(containerActualWidth))
|
|
return MinPixelBarWidth; // Container not ready or invalid
|
|
|
|
double calculatedWidth = proportion * containerActualWidth;
|
|
|
|
if (proportion >= 0 && calculatedWidth < MinPixelBarWidth)
|
|
return MinPixelBarWidth;
|
|
|
|
return Math.Max(0, calculatedWidth); // Ensure width is not negative
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) =>
|
|
[value];
|
|
}
|
|
} |