diff --git a/src/Ursa.Themes.Semi/Controls/Timeline.axaml b/src/Ursa.Themes.Semi/Controls/Timeline.axaml index d0dc9f9..98631f7 100644 --- a/src/Ursa.Themes.Semi/Controls/Timeline.axaml +++ b/src/Ursa.Themes.Semi/Controls/Timeline.axaml @@ -22,14 +22,6 @@ - - diff --git a/src/Ursa.Themes.Semi/Converters/BooleansToOpacityConverter.cs b/src/Ursa.Themes.Semi/Converters/BooleansToOpacityConverter.cs index f172fe9..aee4eaf 100644 --- a/src/Ursa.Themes.Semi/Converters/BooleansToOpacityConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/BooleansToOpacityConverter.cs @@ -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; } diff --git a/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs b/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs index 13f072c..a13d426 100644 --- a/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs @@ -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; } diff --git a/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs b/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs index 68e890a..30c47d2 100644 --- a/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs @@ -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; } diff --git a/src/Ursa.Themes.Semi/Converters/CornerRadiusTakeConverter.cs b/src/Ursa.Themes.Semi/Converters/CornerRadiusTakeConverter.cs deleted file mode 100644 index 6ce9156..0000000 --- a/src/Ursa.Themes.Semi/Converters/CornerRadiusTakeConverter.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Converters/FormContentHeightToAlignmentConverter.cs b/src/Ursa.Themes.Semi/Converters/FormContentHeightToAlignmentConverter.cs index 30db804..a881640 100644 --- a/src/Ursa.Themes.Semi/Converters/FormContentHeightToAlignmentConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/FormContentHeightToAlignmentConverter.cs @@ -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; } diff --git a/src/Ursa.Themes.Semi/Converters/FormContentHeightToMarginConverter.cs b/src/Ursa.Themes.Semi/Converters/FormContentHeightToMarginConverter.cs index 43be772..239f078 100644 --- a/src/Ursa.Themes.Semi/Converters/FormContentHeightToMarginConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/FormContentHeightToMarginConverter.cs @@ -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); } diff --git a/src/Ursa.Themes.Semi/Converters/NavMenuMarginConverter.cs b/src/Ursa.Themes.Semi/Converters/NavMenuMarginConverter.cs index 89e851b..92e14e8 100644 --- a/src/Ursa.Themes.Semi/Converters/NavMenuMarginConverter.cs +++ b/src/Ursa.Themes.Semi/Converters/NavMenuMarginConverter.cs @@ -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 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; } } \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Converters/ThicknessTakeConverter.cs b/src/Ursa.Themes.Semi/Converters/ThicknessTakeConverter.cs deleted file mode 100644 index 4d49c49..0000000 --- a/src/Ursa.Themes.Semi/Converters/ThicknessTakeConverter.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Converters/TimelineItemTypeToIconForegroundConverter.cs b/src/Ursa.Themes.Semi/Converters/TimelineItemTypeToIconForegroundConverter.cs deleted file mode 100644 index a228e9f..0000000 --- a/src/Ursa.Themes.Semi/Converters/TimelineItemTypeToIconForegroundConverter.cs +++ /dev/null @@ -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 DefaultBrushProperty = AvaloniaProperty.Register( - nameof(DefaultBrush)); - - public IBrush DefaultBrush - { - get => GetValue(DefaultBrushProperty); - set => SetValue(DefaultBrushProperty, value); - } - - public static readonly StyledProperty OngoingBrushProperty = AvaloniaProperty.Register( - nameof(OngoingBrush)); - - public IBrush OngoingBrush - { - get => GetValue(OngoingBrushProperty); - set => SetValue(OngoingBrushProperty, value); - } - - public static readonly StyledProperty SuccessBrushProperty = AvaloniaProperty.Register( - nameof(SuccessBrush)); - - public IBrush SuccessBrush - { - get => GetValue(SuccessBrushProperty); - set => SetValue(SuccessBrushProperty, value); - } - - public static readonly StyledProperty WarningBrushProperty = AvaloniaProperty.Register( - nameof(WarningBrush)); - - public IBrush WarningBrush - { - get => GetValue(WarningBrushProperty); - set => SetValue(WarningBrushProperty, value); - } - - public static readonly StyledProperty ErrorBrushProperty = AvaloniaProperty.Register( - nameof(ErrorBrush)); - - public IBrush ErrorBrush - { - get => GetValue(ErrorBrushProperty); - set => SetValue(ErrorBrushProperty, value); - } - - - public object Convert(IList 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; - } -} \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml b/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml index ede09ca..9b22784 100644 --- a/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml +++ b/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml @@ -1,9 +1,4 @@ - - - - - \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml b/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml index ede09ca..9b22784 100644 --- a/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml +++ b/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml @@ -1,9 +1,4 @@ - - - - - \ No newline at end of file diff --git a/src/Ursa/Converters/CornerRadiusConverter.cs b/src/Ursa/Converters/CornerRadiusConverter.cs deleted file mode 100644 index 7a1fda9..0000000 --- a/src/Ursa/Converters/CornerRadiusConverter.cs +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/src/Ursa/Converters/SelectionBoxTemplateConverter.cs b/src/Ursa/Converters/SelectionBoxTemplateConverter.cs index 906e3cc..845d478 100644 --- a/src/Ursa/Converters/SelectionBoxTemplateConverter.cs +++ b/src/Ursa/Converters/SelectionBoxTemplateConverter.cs @@ -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 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; } } \ No newline at end of file diff --git a/src/Ursa/Converters/ThicknessConverter.cs b/src/Ursa/Converters/ThicknessConverter.cs deleted file mode 100644 index 4cce92c..0000000 --- a/src/Ursa/Converters/ThicknessConverter.cs +++ /dev/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(); - } -} \ No newline at end of file