misc: update converter namespaces and clean up code formatting.
This commit is contained in:
@@ -22,14 +22,6 @@
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<converters:TimelineItemTypeToIconForegroundConverter
|
||||
x:Key="ForegroundConverter"
|
||||
DefaultBrush="{DynamicResource DefaultTimelineIconForeground}"
|
||||
ErrorBrush="{DynamicResource ErrorTimelineIconForeground}"
|
||||
OngoingBrush="{DynamicResource OngoingTimelineIconForeground}"
|
||||
SuccessBrush="{DynamicResource SuccessTimelineIconForeground}"
|
||||
WarningBrush="{DynamicResource WarningTimelineIconForeground}" />
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:TimelineItem}" TargetType="u:TimelineItem">
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
|
||||
@@ -3,14 +3,15 @@ using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class BooleansToOpacityConverter: IValueConverter
|
||||
public class BooleansToOpacityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool b)
|
||||
{
|
||||
return b? 1.0: 0.0;
|
||||
return b ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using Avalonia.Media;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class BrushToColorConverter: IValueConverter
|
||||
public class BrushToColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
@@ -12,6 +12,7 @@ public class BrushToColorConverter: IValueConverter
|
||||
{
|
||||
return b.Color;
|
||||
}
|
||||
|
||||
return Colors.Transparent;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class ClockHandLengthConverter(double ratio) : IValueConverter
|
||||
{
|
||||
public static ClockHandLengthConverter Hour { get; } = new(1-0.618);
|
||||
public static ClockHandLengthConverter Hour { get; } = new(1 - 0.618);
|
||||
public static ClockHandLengthConverter Minute { get; } = new(0.618);
|
||||
public static ClockHandLengthConverter Second { get; } = new(1);
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ClockHandLengthConverter(double ratio) : IValueConverter
|
||||
{
|
||||
return d * ratio / 2;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
[Obsolete("This converter is deprecated. Use CornerRadiusMixerConverter instead.")]
|
||||
public class CornerRadiusTakeConverter: IValueConverter
|
||||
{
|
||||
private readonly Dock _dock;
|
||||
internal CornerRadiusTakeConverter(Dock dock)
|
||||
{
|
||||
_dock = dock;
|
||||
}
|
||||
public static CornerRadiusTakeConverter Left { get; } = new(Dock.Left);
|
||||
public static CornerRadiusTakeConverter Top { get; } = new(Dock.Top);
|
||||
public static CornerRadiusTakeConverter Right { get; } = new(Dock.Right);
|
||||
public static CornerRadiusTakeConverter Bottom { get; } = new(Dock.Bottom);
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is not CornerRadius c) return AvaloniaProperty.UnsetValue;
|
||||
return _dock switch
|
||||
{
|
||||
Dock.Left => new CornerRadius(c.TopLeft, 0, 0, c.BottomLeft),
|
||||
Dock.Top => new CornerRadius(c.TopLeft, c.TopRight, 0, 0),
|
||||
Dock.Right => new CornerRadius(0, c.TopRight, c.BottomRight, 0),
|
||||
Dock.Bottom => new CornerRadius(0, 0, c.BottomRight, c.BottomLeft),
|
||||
_ => AvaloniaProperty.UnsetValue
|
||||
};
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Layout;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class FormContentHeightToAlignmentConverter: IValueConverter
|
||||
public class FormContentHeightToAlignmentConverter : IValueConverter
|
||||
{
|
||||
public static FormContentHeightToAlignmentConverter Instance = new(32);
|
||||
public double Threshold { get; set; }
|
||||
@@ -14,18 +13,18 @@ public class FormContentHeightToAlignmentConverter: IValueConverter
|
||||
{
|
||||
Threshold = 32;
|
||||
}
|
||||
|
||||
|
||||
// ReSharper disable once ConvertToPrimaryConstructor
|
||||
// Justification: need to keep the default constructor for XAML
|
||||
public FormContentHeightToAlignmentConverter(double threshold)
|
||||
{
|
||||
Threshold = threshold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is not double d) return VerticalAlignment.Center;
|
||||
if (value is not double d) return VerticalAlignment.Center;
|
||||
return d > Threshold ? VerticalAlignment.Top : VerticalAlignment.Center;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class FormContentHeightToMarginConverter: IValueConverter
|
||||
public class FormContentHeightToMarginConverter : IValueConverter
|
||||
{
|
||||
public static FormContentHeightToMarginConverter Instance = new();
|
||||
public double Threshold { get; set; }
|
||||
@@ -13,17 +13,17 @@ public class FormContentHeightToMarginConverter: IValueConverter
|
||||
{
|
||||
Threshold = 32;
|
||||
}
|
||||
|
||||
|
||||
// ReSharper disable once ConvertToPrimaryConstructor
|
||||
// Justification: need to keep the default constructor for XAML
|
||||
public FormContentHeightToMarginConverter(double threshold)
|
||||
{
|
||||
Threshold = threshold;
|
||||
}
|
||||
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is not double d) return new Thickness(0);
|
||||
if (value is not double d) return new Thickness(0);
|
||||
return d > Threshold ? new Thickness(0, 8, 8, 0) : new Thickness(0, 0, 8, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,15 @@ using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class NavMenuMarginConverter: IMultiValueConverter
|
||||
public class NavMenuMarginConverter : IMultiValueConverter
|
||||
{
|
||||
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (values[0] is double indent && values[1] is int level && values[2] is bool b)
|
||||
{
|
||||
return b ? new Thickness() : new Thickness(indent * (level-1), 0, 0, 0);
|
||||
return b ? new Thickness() : new Thickness(indent * (level - 1), 0, 0, 0);
|
||||
}
|
||||
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
[Obsolete("This converter is deprecated. Use ThicknessMixerConverter instead.")]
|
||||
public class ThicknessTakeConverter: IValueConverter
|
||||
{
|
||||
private readonly Dock _dock;
|
||||
internal ThicknessTakeConverter(Dock dock)
|
||||
{
|
||||
_dock = dock;
|
||||
}
|
||||
public static ThicknessTakeConverter Left { get; } = new(Dock.Left);
|
||||
public static ThicknessTakeConverter Top { get; } = new(Dock.Top);
|
||||
public static ThicknessTakeConverter Right { get; } = new(Dock.Right);
|
||||
public static ThicknessTakeConverter Bottom { get; } = new(Dock.Bottom);
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is not Thickness t) return AvaloniaProperty.UnsetValue;
|
||||
return _dock switch
|
||||
{
|
||||
Dock.Left => new Thickness(t.Left, 0, 0, 0),
|
||||
Dock.Top => new Thickness(0, t.Top, 0, 0),
|
||||
Dock.Right => new Thickness(0, 0, t.Right, 0),
|
||||
Dock.Bottom => new Thickness(0, 0, 0, t.Bottom),
|
||||
_ => AvaloniaProperty.UnsetValue
|
||||
};
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class TimelineItemTypeToIconForegroundConverter: AvaloniaObject, IMultiValueConverter
|
||||
{
|
||||
public static readonly StyledProperty<IBrush> DefaultBrushProperty = AvaloniaProperty.Register<TimelineItemTypeToIconForegroundConverter, IBrush>(
|
||||
nameof(DefaultBrush));
|
||||
|
||||
public IBrush DefaultBrush
|
||||
{
|
||||
get => GetValue(DefaultBrushProperty);
|
||||
set => SetValue(DefaultBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> OngoingBrushProperty = AvaloniaProperty.Register<TimelineItemTypeToIconForegroundConverter, IBrush>(
|
||||
nameof(OngoingBrush));
|
||||
|
||||
public IBrush OngoingBrush
|
||||
{
|
||||
get => GetValue(OngoingBrushProperty);
|
||||
set => SetValue(OngoingBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> SuccessBrushProperty = AvaloniaProperty.Register<TimelineItemTypeToIconForegroundConverter, IBrush>(
|
||||
nameof(SuccessBrush));
|
||||
|
||||
public IBrush SuccessBrush
|
||||
{
|
||||
get => GetValue(SuccessBrushProperty);
|
||||
set => SetValue(SuccessBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> WarningBrushProperty = AvaloniaProperty.Register<TimelineItemTypeToIconForegroundConverter, IBrush>(
|
||||
nameof(WarningBrush));
|
||||
|
||||
public IBrush WarningBrush
|
||||
{
|
||||
get => GetValue(WarningBrushProperty);
|
||||
set => SetValue(WarningBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> ErrorBrushProperty = AvaloniaProperty.Register<TimelineItemTypeToIconForegroundConverter, IBrush>(
|
||||
nameof(ErrorBrush));
|
||||
|
||||
public IBrush ErrorBrush
|
||||
{
|
||||
get => GetValue(ErrorBrushProperty);
|
||||
set => SetValue(ErrorBrushProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (values[0] is TimelineItemType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TimelineItemType.Error:
|
||||
return ErrorBrush;
|
||||
case TimelineItemType.Warning:
|
||||
return WarningBrush;
|
||||
case TimelineItemType.Success:
|
||||
return SuccessBrush;
|
||||
case TimelineItemType.Ongoing:
|
||||
return OngoingBrush;
|
||||
case TimelineItemType.Default:
|
||||
if (values[1] is IBrush brush)
|
||||
{
|
||||
return brush;
|
||||
}
|
||||
return DefaultBrush;
|
||||
}
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StaticResource x:Key="TimelineHeaderForeground" ResourceKey="SemiColorText0" />
|
||||
<StaticResource x:Key="DefaultTimelineIconForeground" ResourceKey="SemiColorFill2" />
|
||||
<StaticResource x:Key="OngoingTimelineIconForeground" ResourceKey="SemiColorPrimary" />
|
||||
<StaticResource x:Key="SuccessTimelineIconForeground" ResourceKey="SemiColorSuccess" />
|
||||
<StaticResource x:Key="WarningTimelineIconForeground" ResourceKey="SemiColorWarning" />
|
||||
<StaticResource x:Key="ErrorTimelineIconForeground" ResourceKey="SemiColorDanger" />
|
||||
<StaticResource x:Key="TimelineLineBrush" ResourceKey="SemiColorFill2" />
|
||||
</ResourceDictionary>
|
||||
@@ -1,9 +1,4 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StaticResource x:Key="TimelineHeaderForeground" ResourceKey="SemiColorText0" />
|
||||
<StaticResource x:Key="DefaultTimelineIconForeground" ResourceKey="SemiColorFill2" />
|
||||
<StaticResource x:Key="OngoingTimelineIconForeground" ResourceKey="SemiColorPrimary" />
|
||||
<StaticResource x:Key="SuccessTimelineIconForeground" ResourceKey="SemiColorSuccess" />
|
||||
<StaticResource x:Key="WarningTimelineIconForeground" ResourceKey="SemiColorWarning" />
|
||||
<StaticResource x:Key="ErrorTimelineIconForeground" ResourceKey="SemiColorDanger" />
|
||||
<StaticResource x:Key="TimelineLineBrush" ResourceKey="SemiColorFill2" />
|
||||
</ResourceDictionary>
|
||||
@@ -1,87 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Converters;
|
||||
|
||||
[Obsolete("This converter is deprecated. Use CornerRadiusMixerConverter instead.")]
|
||||
[Flags]
|
||||
public enum CornerRadiusPosition
|
||||
{
|
||||
TopLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomLeft = 4,
|
||||
BottomRight = 8,
|
||||
Top = 3,
|
||||
Left = 5,
|
||||
Right = 10,
|
||||
Bottom = 12,
|
||||
}
|
||||
|
||||
[Obsolete("This converter is deprecated. Use CornerRadiusMixerConverter instead.")]
|
||||
public class CornerRadiusIncludeConverter(CornerRadiusPosition position) : IValueConverter
|
||||
{
|
||||
public static CornerRadiusIncludeConverter TopLeft { get; } = new( CornerRadiusPosition.TopLeft );
|
||||
public static CornerRadiusIncludeConverter TopRight { get; } = new( CornerRadiusPosition.TopRight );
|
||||
public static CornerRadiusIncludeConverter BottomLeft { get; } = new( CornerRadiusPosition.BottomLeft );
|
||||
public static CornerRadiusIncludeConverter BottomRight { get; } = new( CornerRadiusPosition.BottomRight );
|
||||
public static CornerRadiusIncludeConverter Top { get; } = new( CornerRadiusPosition.Top );
|
||||
public static CornerRadiusIncludeConverter Left { get; } = new( CornerRadiusPosition.Left );
|
||||
public static CornerRadiusIncludeConverter Right { get; } = new( CornerRadiusPosition.Right );
|
||||
public static CornerRadiusIncludeConverter Bottom { get; } = new( CornerRadiusPosition.Bottom );
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is CornerRadius r)
|
||||
{
|
||||
double topLeft = position.HasFlag(CornerRadiusPosition.TopLeft) ? r.TopLeft : 0;
|
||||
double topRight = position.HasFlag(CornerRadiusPosition.TopRight) ? r.TopRight : 0;
|
||||
double bottomLeft = position.HasFlag(CornerRadiusPosition.BottomLeft) ? r.BottomLeft : 0;
|
||||
double bottomRight = position.HasFlag(CornerRadiusPosition.BottomRight) ? r.BottomRight : 0;
|
||||
return new CornerRadius(topLeft, topRight, bottomRight, bottomLeft);
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("This converter is deprecated. Use CornerRadiusMixerConverter instead.")]
|
||||
public class CornerRadiusExcludeConverter : IValueConverter
|
||||
{
|
||||
public static CornerRadiusExcludeConverter TopLeft { get; } = new( CornerRadiusPosition.TopLeft );
|
||||
public static CornerRadiusExcludeConverter TopRight { get; } = new( CornerRadiusPosition.TopRight );
|
||||
public static CornerRadiusExcludeConverter BottomLeft { get; } = new( CornerRadiusPosition.BottomLeft );
|
||||
public static CornerRadiusExcludeConverter BottomRight { get; } = new( CornerRadiusPosition.BottomRight );
|
||||
public static CornerRadiusExcludeConverter Top { get; } = new( CornerRadiusPosition.Top );
|
||||
public static CornerRadiusExcludeConverter Left { get; } = new( CornerRadiusPosition.Left );
|
||||
public static CornerRadiusExcludeConverter Right { get; } = new( CornerRadiusPosition.Right );
|
||||
public static CornerRadiusExcludeConverter Bottom { get; } = new( CornerRadiusPosition.Bottom );
|
||||
|
||||
private readonly CornerRadiusPosition _position;
|
||||
|
||||
public CornerRadiusExcludeConverter(CornerRadiusPosition position)
|
||||
{
|
||||
_position = position;
|
||||
}
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is CornerRadius r)
|
||||
{
|
||||
double topLeft = _position.HasFlag(CornerRadiusPosition.TopLeft) ? 0 : r.TopLeft;
|
||||
double topRight = _position.HasFlag(CornerRadiusPosition.TopRight) ? 0 : r.TopRight;
|
||||
double bottomLeft = _position.HasFlag(CornerRadiusPosition.BottomLeft) ? 0 : r.BottomLeft;
|
||||
double bottomRight = _position.HasFlag(CornerRadiusPosition.BottomRight) ? 0 : r.BottomRight;
|
||||
return new CornerRadius(topLeft, topRight, bottomRight, bottomLeft);
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,17 @@ using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Converters;
|
||||
|
||||
public class SelectionBoxTemplateConverter: IMultiValueConverter
|
||||
public class SelectionBoxTemplateConverter : IMultiValueConverter
|
||||
{
|
||||
public static SelectionBoxTemplateConverter Instance { get; } = new();
|
||||
|
||||
|
||||
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
if (values[i] is IDataTemplate template) return template;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Converters;
|
||||
|
||||
[Obsolete("This converter is deprecated. Use ThicknessMixerConverter instead.")]
|
||||
[Flags]
|
||||
public enum ThicknessPosition
|
||||
{
|
||||
Left = 1,
|
||||
Top = 2,
|
||||
Right = 4,
|
||||
Bottom = 8,
|
||||
TopLeft = 3,
|
||||
TopRight = 6,
|
||||
BottomLeft = 9,
|
||||
BottomRight = 12,
|
||||
}
|
||||
|
||||
[Obsolete("This converter is deprecated. Use ThicknessMixerConverter instead.")]
|
||||
public class ThicknessExcludeConverter(ThicknessPosition position) : IValueConverter
|
||||
{
|
||||
public static ThicknessExcludeConverter Left { get; } = new( ThicknessPosition.Left );
|
||||
public static ThicknessExcludeConverter Top { get; } = new( ThicknessPosition.Top );
|
||||
public static ThicknessExcludeConverter Right { get; } = new( ThicknessPosition.Right );
|
||||
public static ThicknessExcludeConverter Bottom { get; } = new( ThicknessPosition.Bottom );
|
||||
public static ThicknessExcludeConverter TopLeft { get; } = new( ThicknessPosition.TopLeft );
|
||||
public static ThicknessExcludeConverter TopRight { get; } = new( ThicknessPosition.TopRight );
|
||||
public static ThicknessExcludeConverter BottomLeft { get; } = new( ThicknessPosition.BottomLeft );
|
||||
public static ThicknessExcludeConverter BottomRight { get; } = new( ThicknessPosition.BottomRight );
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Thickness t)
|
||||
{
|
||||
double left = position.HasFlag(ThicknessPosition.Left) ? 0d: t.Left;
|
||||
double top = position.HasFlag(ThicknessPosition.Top) ? 0d : t.Top;
|
||||
double right = position.HasFlag(ThicknessPosition.Right) ? 0d : t.Right;
|
||||
double bottom = position.HasFlag(ThicknessPosition.Bottom) ? 0d : t.Bottom;
|
||||
|
||||
return new Thickness(left, top, right, bottom);
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("This converter is deprecated. Use ThicknessMixerConverter instead.")]
|
||||
public class ThicknessIncludeConverter(ThicknessPosition position) : IValueConverter
|
||||
{
|
||||
public static ThicknessIncludeConverter Left { get; } = new( ThicknessPosition.Left );
|
||||
public static ThicknessIncludeConverter Top { get; } = new( ThicknessPosition.Top );
|
||||
public static ThicknessIncludeConverter Right { get; } = new( ThicknessPosition.Right );
|
||||
public static ThicknessIncludeConverter Bottom { get; } = new( ThicknessPosition.Bottom );
|
||||
public static ThicknessIncludeConverter TopLeft { get; } = new( ThicknessPosition.TopLeft );
|
||||
public static ThicknessIncludeConverter TopRight { get; } = new( ThicknessPosition.TopRight );
|
||||
public static ThicknessIncludeConverter BottomLeft { get; } = new( ThicknessPosition.BottomLeft );
|
||||
public static ThicknessIncludeConverter BottomRight { get; } = new( ThicknessPosition.BottomRight );
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Thickness t)
|
||||
{
|
||||
var left = position.HasFlag(ThicknessPosition.Left) ? t.Left : 0d;
|
||||
var top = position.HasFlag(ThicknessPosition.Top) ? t.Top : 0d;
|
||||
var right = position.HasFlag(ThicknessPosition.Right) ? t.Right : 0d;
|
||||
var bottom = position.HasFlag(ThicknessPosition.Bottom) ? t.Bottom : 0d;
|
||||
return new Thickness(left, top, right, bottom);
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user