From ed9acf714babcad9445b20d4a56b81012d0704fe Mon Sep 17 00:00:00 2001 From: punker76 Date: Sun, 3 Nov 2024 21:30:47 +0100 Subject: [PATCH] remove unused stuff --- .../Converter/DataTypeValueConverter.cs | 39 --------------- .../Converter/FlipToScaleXValueConverter.cs | 49 ------------------- .../Converter/FlipToScaleYValueConverter.cs | 48 ------------------ .../Converter/MarkupConverter.cs | 4 +- .../NullToDoNothingValueConverter.cs | 39 --------------- .../Converter/NullToUnsetValueConverter.cs | 39 --------------- .../PackIconKindToImageConverterBase.cs | 23 +++------ .../PackIconImageExtension.cs | 2 +- .../Converter/PackIconKindToImageConverter.cs | 2 +- .../PackIconImageExtension.cs | 2 +- 10 files changed, 12 insertions(+), 235 deletions(-) delete mode 100644 src/IconPacks.Avalonia.Core/Converter/DataTypeValueConverter.cs delete mode 100644 src/IconPacks.Avalonia.Core/Converter/FlipToScaleXValueConverter.cs delete mode 100644 src/IconPacks.Avalonia.Core/Converter/FlipToScaleYValueConverter.cs delete mode 100644 src/IconPacks.Avalonia.Core/Converter/NullToDoNothingValueConverter.cs delete mode 100644 src/IconPacks.Avalonia.Core/Converter/NullToUnsetValueConverter.cs diff --git a/src/IconPacks.Avalonia.Core/Converter/DataTypeValueConverter.cs b/src/IconPacks.Avalonia.Core/Converter/DataTypeValueConverter.cs deleted file mode 100644 index b1bf660..0000000 --- a/src/IconPacks.Avalonia.Core/Converter/DataTypeValueConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Avalonia.Data; -using System; -using System.Globalization; - -namespace IconPacks.Avalonia.Converter -{ - public class DataTypeValueConverter : MarkupConverter - { - // Explicit static constructor to tell C# compiler - // not to mark type as beforefieldinit - static DataTypeValueConverter() - { - } - - private DataTypeValueConverter() - { - } - - public static DataTypeValueConverter Instance { get; } = new(); - - /// - public override object ProvideValue(IServiceProvider serviceProvider) - { - return Instance; - } - - /// - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value?.GetType(); - } - - /// - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return BindingNotification.UnsetValue; - } - } -} \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/Converter/FlipToScaleXValueConverter.cs b/src/IconPacks.Avalonia.Core/Converter/FlipToScaleXValueConverter.cs deleted file mode 100644 index 0367bb2..0000000 --- a/src/IconPacks.Avalonia.Core/Converter/FlipToScaleXValueConverter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Avalonia.Data; -using System; -using System.Globalization; - -namespace IconPacks.Avalonia.Converter -{ - /// - /// ValueConverter which converts the PackIconFlipOrientation enumeration value to ScaleX value of a ScaleTransformation. - /// - public class FlipToScaleXValueConverter : MarkupConverter - { - // Explicit static constructor to tell C# compiler - // not to mark type as beforefieldinit - static FlipToScaleXValueConverter() - { - } - - private FlipToScaleXValueConverter() - { - } - - public static FlipToScaleXValueConverter Instance { get; } = new(); - - /// - public override object ProvideValue(IServiceProvider serviceProvider) - { - return Instance; - } - - /// - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is PackIconFlipOrientation flip) - { - return flip is PackIconFlipOrientation.Horizontal or PackIconFlipOrientation.Both - ? -1 - : 1; - } - - return 1; - } - - /// - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return BindingNotification.UnsetValue; - } - } -} \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/Converter/FlipToScaleYValueConverter.cs b/src/IconPacks.Avalonia.Core/Converter/FlipToScaleYValueConverter.cs deleted file mode 100644 index 710e167..0000000 --- a/src/IconPacks.Avalonia.Core/Converter/FlipToScaleYValueConverter.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Avalonia.Data; -using System; -using System.Globalization; - -namespace IconPacks.Avalonia.Converter -{ - /// - /// ValueConverter which converts the PackIconFlipOrientation enumeration value to ScaleY value of a ScaleTransformation. - /// - public class FlipToScaleYValueConverter : MarkupConverter - { - // Explicit static constructor to tell C# compiler - // not to mark type as beforefieldinit - static FlipToScaleYValueConverter() - { - } - - private FlipToScaleYValueConverter() - { - } - - public static FlipToScaleYValueConverter Instance { get; } = new(); - - /// - public override object ProvideValue(IServiceProvider serviceProvider) - { - return Instance; - } - - /// - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is PackIconFlipOrientation flip) - { - var scaleY = flip == PackIconFlipOrientation.Vertical || flip == PackIconFlipOrientation.Both ? -1 : 1; - return scaleY; - } - - return 1; - } - - /// - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return BindingNotification.UnsetValue; - } - } -} \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/Converter/MarkupConverter.cs b/src/IconPacks.Avalonia.Core/Converter/MarkupConverter.cs index c2b7f12..b9e2187 100644 --- a/src/IconPacks.Avalonia.Core/Converter/MarkupConverter.cs +++ b/src/IconPacks.Avalonia.Core/Converter/MarkupConverter.cs @@ -56,7 +56,7 @@ object IValueConverter.Convert(object value, Type targetType, object parameter, } catch { - return BindingNotification.UnsetValue; + return BindingOperations.DoNothing; } } @@ -69,7 +69,7 @@ object IValueConverter.ConvertBack(object value, Type targetType, object paramet } catch { - return BindingNotification.UnsetValue; + return BindingOperations.DoNothing; } } } diff --git a/src/IconPacks.Avalonia.Core/Converter/NullToDoNothingValueConverter.cs b/src/IconPacks.Avalonia.Core/Converter/NullToDoNothingValueConverter.cs deleted file mode 100644 index 88dc679..0000000 --- a/src/IconPacks.Avalonia.Core/Converter/NullToDoNothingValueConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Avalonia.Data; -using System; -using System.Globalization; - -namespace IconPacks.Avalonia.Converter -{ - public class NullToDoNothingValueConverter : MarkupConverter - { - // Explicit static constructor to tell C# compiler - // not to mark type as beforefieldinit - static NullToDoNothingValueConverter() - { - } - - public NullToDoNothingValueConverter() - { - } - - public static NullToDoNothingValueConverter Instance { get; } = new(); - - /// - public override object ProvideValue(IServiceProvider serviceProvider) - { - return Instance; - } - - /// - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value ?? BindingOperations.DoNothing; - } - - /// - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return BindingOperations.DoNothing; - } - } -} \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/Converter/NullToUnsetValueConverter.cs b/src/IconPacks.Avalonia.Core/Converter/NullToUnsetValueConverter.cs deleted file mode 100644 index ae7d30e..0000000 --- a/src/IconPacks.Avalonia.Core/Converter/NullToUnsetValueConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Avalonia.Data; -using System; -using System.Globalization; - -namespace IconPacks.Avalonia.Converter -{ - public class NullToUnsetValueConverter : MarkupConverter - { - // Explicit static constructor to tell C# compiler - // not to mark type as beforefieldinit - static NullToUnsetValueConverter() - { - } - - private NullToUnsetValueConverter() - { - } - - public static NullToUnsetValueConverter Instance { get; } = new(); - - /// - public override object ProvideValue(IServiceProvider serviceProvider) - { - return Instance; - } - - /// - protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value ?? BindingNotification.UnsetValue; - } - - /// - protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return BindingNotification.UnsetValue; - } - } -} \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/Converter/PackIconKindToImageConverterBase.cs b/src/IconPacks.Avalonia.Core/Converter/PackIconKindToImageConverterBase.cs index ebaef14..bb25e22 100644 --- a/src/IconPacks.Avalonia.Core/Converter/PackIconKindToImageConverterBase.cs +++ b/src/IconPacks.Avalonia.Core/Converter/PackIconKindToImageConverterBase.cs @@ -45,8 +45,8 @@ protected Transform GetTransformGroup(object iconKind) var transformGroup = new TransformGroup(); transformGroup.Children.Add(this.GetScaleTransform(iconKind)); // scale transformGroup.Children.Add(new ScaleTransform( - this.Flip == PackIconFlipOrientation.Horizontal || this.Flip == PackIconFlipOrientation.Both ? -1 : 1, - this.Flip == PackIconFlipOrientation.Vertical || this.Flip == PackIconFlipOrientation.Both ? -1 : 1 + this.Flip is PackIconFlipOrientation.Horizontal or PackIconFlipOrientation.Both ? -1 : 1, + this.Flip is PackIconFlipOrientation.Vertical or PackIconFlipOrientation.Both ? -1 : 1 )); // flip transformGroup.Children.Add(new RotateTransform(this.RotationAngle)); // rotate @@ -60,7 +60,7 @@ protected virtual DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroun { var geometryDrawing = new GeometryDrawing { - Geometry = Geometry.Parse(path), + Geometry = StreamGeometry.Parse(path), Brush = foregroundBrush }; @@ -92,24 +92,15 @@ protected IImage CreateImageSource(object iconKind, IBrush foregroundBrush) /// protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value is not Enum) - { - return BindingNotification.UnsetValue; - } - - var imageSource = CreateImageSource(value, parameter as IBrush ?? this.Brush ?? Brushes.Black); - if (imageSource is null) - { - return BindingNotification.UnsetValue; - } - - return imageSource; + return value is not Enum + ? null + : CreateImageSource(value, parameter as IBrush ?? this.Brush ?? Brushes.Black); } /// protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return BindingNotification.UnsetValue; + throw new NotSupportedException("Two way bindings are not supported with an image"); } } } \ No newline at end of file diff --git a/src/IconPacks.Avalonia.Core/PackIconImageExtension.cs b/src/IconPacks.Avalonia.Core/PackIconImageExtension.cs index cbeae61..35705bf 100644 --- a/src/IconPacks.Avalonia.Core/PackIconImageExtension.cs +++ b/src/IconPacks.Avalonia.Core/PackIconImageExtension.cs @@ -58,7 +58,7 @@ protected virtual DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroun { var geometryDrawing = new GeometryDrawing { - Geometry = Geometry.Parse(path), + Geometry = StreamGeometry.Parse(path), Brush = foregroundBrush }; diff --git a/src/IconPacks.Avalonia/Converter/PackIconKindToImageConverter.cs b/src/IconPacks.Avalonia/Converter/PackIconKindToImageConverter.cs index 0bb3b22..c3c1047 100644 --- a/src/IconPacks.Avalonia/Converter/PackIconKindToImageConverter.cs +++ b/src/IconPacks.Avalonia/Converter/PackIconKindToImageConverter.cs @@ -153,7 +153,7 @@ protected override DrawingGroup GetDrawingGroup(object iconKind, IBrush foregrou { var geometryDrawing = new GeometryDrawing { - Geometry = Geometry.Parse(path) + Geometry = StreamGeometry.Parse(path) }; // if (iconKind is PackIconFeatherIconsKind) diff --git a/src/IconPacks.Avalonia/PackIconImageExtension.cs b/src/IconPacks.Avalonia/PackIconImageExtension.cs index 7575155..a3ad1ab 100644 --- a/src/IconPacks.Avalonia/PackIconImageExtension.cs +++ b/src/IconPacks.Avalonia/PackIconImageExtension.cs @@ -171,7 +171,7 @@ protected override DrawingGroup GetDrawingGroup(object iconKind, IBrush foregrou { var geometryDrawing = new GeometryDrawing { - Geometry = Geometry.Parse(path) + Geometry = StreamGeometry.Parse(path) }; // if (iconKind is PackIconFeatherIconsKind)