mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:16:30 +00:00
better view for class distribution
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user