// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2014 OxyPlot contributors // // // Converts from to the maximum thicknesses. // // -------------------------------------------------------------------------------------------------------------------- namespace OxyPlot.Avalonia.Converters { using global::Avalonia; using global::Avalonia.Data.Converters; using System; using System.Globalization; /// /// Converts from to the maximum thicknesses. /// /// This is used in the to convert BorderThickness properties to Path.StrokeThickness (double). /// The maximum thickness value is used. public class ThicknessConverter : IValueConverter { public static readonly ThicknessConverter Instance = new ThicknessConverter(); /// /// Converts a value. /// /// The value produced by the binding source. /// The type of the binding target property. /// The converter parameter to use. /// The culture to use in the converter. /// A converted value. If the method returns null, the valid null value is used. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Thickness t && targetType == typeof(double)) { return Math.Max(Math.Max(t.Left, t.Right), Math.Max(t.Top, t.Bottom)); } return value; } /// /// Converts a value. /// /// The value that is produced by the binding target. /// The type to convert to. /// The converter parameter to use. /// The culture to use in the converter. /// A converted value. If the method returns null, the valid null value is used. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } } }