diff --git a/Directory.Build.props b/Directory.Build.props index 7b983407..22599bef 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,10 +45,10 @@ - + - + \ No newline at end of file diff --git a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj index 5ac68aae..7d92f013 100644 --- a/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj +++ b/sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj @@ -51,8 +51,8 @@ - - + + diff --git a/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj b/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj index 26d03f1c..1b423041 100644 --- a/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj +++ b/src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj @@ -48,8 +48,8 @@ - - + + diff --git a/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs index b13ac52a..e2609644 100644 --- a/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs +++ b/src/Atc.Wpf.Controls/BaseControls/Internal/ValueConverters/ImageLocationToMarginValueConverter.cs @@ -8,7 +8,11 @@ internal sealed class ImageLocationToMarginValueConverter : IValueConverter { public static readonly ImageLocationToMarginValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is not ImageLocation imageLocation) { @@ -26,8 +30,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/DecimalToDoubleValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/DecimalToDoubleValueConverter.cs index 563f64c3..e81a9f71 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/DecimalToDoubleValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/DecimalToDoubleValueConverter.cs @@ -8,14 +8,22 @@ internal sealed class DecimalToDoubleValueConverter : IValueConverter { public static readonly DecimalToDoubleValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) => value switch { decimal d => d, _ => 0D, }; - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) => value switch { double d => d, diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/IntegerToDoubleValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/IntegerToDoubleValueConverter.cs index b60e718b..4d2c2c54 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/IntegerToDoubleValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/IntegerToDoubleValueConverter.cs @@ -9,7 +9,11 @@ internal sealed class IntegerToDoubleValueConverter : IValueConverter { public static readonly IntegerToDoubleValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) => value switch { int i => i, @@ -17,8 +21,12 @@ public object Convert(object? value, Type targetType, object? parameter, Culture _ => 0D, }; - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - => value switch + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => value switch { double d => d, _ => 0, diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasForValidationToGridExRowsValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasForValidationToGridExRowsValueConverter.cs index 31cdad97..3fe39688 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasForValidationToGridExRowsValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasForValidationToGridExRowsValueConverter.cs @@ -8,14 +8,14 @@ public sealed class LabelControlHideAreasForValidationToGridExRowsValueConverter { public static readonly LabelControlHideAreasForValidationToGridExRowsValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { - if (value is not LabelControlHideAreasType currentHideAreasType) - { - throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); - } - - if (parameter is not Orientation orientation) + if (value is not LabelControlHideAreasType currentHideAreasType || + parameter is not Orientation orientation) { throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); } @@ -32,8 +32,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture : "Auto,Auto,Auto,10"; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToBoolValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToBoolValueConverter.cs index 13ab5c12..e676f398 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToBoolValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToBoolValueConverter.cs @@ -8,14 +8,14 @@ internal sealed class LabelControlHideAreasToBoolValueConverter : IValueConverte { public static readonly LabelControlHideAreasToBoolValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { - if (value is not LabelControlHideAreasType currentHideAreasType) - { - throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); - } - - if (parameter is not LabelControlHideAreasType requiredHideAreasType) + if (value is not LabelControlHideAreasType currentHideAreasType || + parameter is not LabelControlHideAreasType requiredHideAreasType) { throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); } @@ -28,8 +28,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture return !currentHideAreasType.HasFlag(requiredHideAreasType); } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToShowToolTipValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToShowToolTipValueConverter.cs index a104157a..8d99d2f4 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToShowToolTipValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToShowToolTipValueConverter.cs @@ -5,7 +5,11 @@ internal sealed class LabelControlHideAreasToShowToolTipValueConverter : IValueC { public static readonly LabelControlHideAreasToShowToolTipValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is not LabelControlHideAreasType currentHideAreasType) { @@ -15,8 +19,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture return currentHideAreasType.HasFlag(LabelControlHideAreasType.Validation); } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToTreeGridExColumnsValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToTreeGridExColumnsValueConverter.cs index 9d4f1684..cec0a4b0 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToTreeGridExColumnsValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToTreeGridExColumnsValueConverter.cs @@ -9,7 +9,11 @@ internal sealed class LabelControlHideAreasToTreeGridExColumnsValueConverter : I public static readonly LabelControlHideAreasToTreeGridExColumnsValueConverter Instance = new(); [SuppressMessage("Design", "MA0076:Do not use implicit culture-sensitive ToString in interpolated strings", Justification = "OK.")] - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is not LabelControlHideAreasType currentHideAreasType) { @@ -31,8 +35,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture return $"{widthLeft},*,{widthRight}"; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToVisibilityValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToVisibilityValueConverter.cs index 903fa2d8..cf5ab313 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToVisibilityValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHideAreasToVisibilityValueConverter.cs @@ -8,14 +8,14 @@ internal sealed class LabelControlHideAreasToVisibilityValueConverter : IValueCo { public static readonly LabelControlHideAreasToVisibilityValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { - if (value is not LabelControlHideAreasType currentHideAreasType) - { - throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); - } - - if (parameter is not LabelControlHideAreasType requiredHideAreasType) + if (value is not LabelControlHideAreasType currentHideAreasType || + parameter is not LabelControlHideAreasType requiredHideAreasType) { throw new InvalidEnumArgumentException(nameof(value), 0, typeof(LabelControlHideAreasType)); } @@ -30,8 +30,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture : Visibility.Collapsed; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHorizontalToWidthMultiValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHorizontalToWidthMultiValueConverter.cs index 0109b0c1..95daa564 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHorizontalToWidthMultiValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlHorizontalToWidthMultiValueConverter.cs @@ -9,7 +9,11 @@ internal sealed class LabelControlHorizontalToWidthMultiValueConverter : IMultiV { public static readonly LabelControlHorizontalToWidthMultiValueConverter Instance = new(); - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + public object Convert( + object[] values, + Type targetType, + object parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(values); @@ -54,8 +58,10 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur } } - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object[] ConvertBack( + object value, + Type[] targetTypes, + object parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleMultiValueConverter.cs similarity index 65% rename from src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleMultiValueConverter.cs index fc0ce96d..49fdf2c1 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlInformationMultiBoolToVisibilityVisibleMultiValueConverter.cs @@ -1,11 +1,15 @@ namespace Atc.Wpf.Controls.LabelControls.Internal.ValueConverters; -internal class LabelControlInformationMultiBoolToVisibilityVisibleValueConverter : IMultiValueConverter +internal class LabelControlInformationMultiBoolToVisibilityVisibleMultiValueConverter : IMultiValueConverter { - public static readonly LabelControlInformationMultiBoolToVisibilityVisibleValueConverter Instance = new(); + public static readonly LabelControlInformationMultiBoolToVisibilityVisibleMultiValueConverter Instance = new(); /// - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + public object Convert( + object[] values, + Type targetType, + object parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(values); @@ -25,8 +29,10 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur } /// - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object[] ConvertBack( + object value, + Type[] targetTypes, + object parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToAsteriskMarginValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToAsteriskMarginValueConverter.cs index 5ebe772d..6c5fd1bb 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToAsteriskMarginValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToAsteriskMarginValueConverter.cs @@ -8,7 +8,11 @@ internal sealed class LabelControlOrientationToAsteriskMarginValueConverter : IV { public static readonly LabelControlOrientationToAsteriskMarginValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is null) { @@ -28,8 +32,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToInformationIconMarginValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToInformationIconMarginValueConverter.cs index 891491d9..c072e865 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToInformationIconMarginValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToInformationIconMarginValueConverter.cs @@ -8,7 +8,11 @@ internal sealed class LabelControlOrientationToInformationIconMarginValueConvert { public static readonly LabelControlOrientationToInformationIconMarginValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is null) { @@ -28,8 +32,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToMarginValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToMarginValueConverter.cs index 6d931e64..72fe2b54 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToMarginValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToMarginValueConverter.cs @@ -8,7 +8,11 @@ internal sealed class LabelControlOrientationToMarginValueConverter : IValueConv { public static readonly LabelControlOrientationToMarginValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is null) { @@ -39,8 +43,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToVisibilityValueConverter.cs b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToVisibilityValueConverter.cs index f7e48745..c3fe0d9d 100644 --- a/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToVisibilityValueConverter.cs +++ b/src/Atc.Wpf.Controls/LabelControls/Internal/ValueConverters/LabelControlOrientationToVisibilityValueConverter.cs @@ -8,7 +8,11 @@ internal sealed class LabelControlOrientationToVisibilityValueConverter : IValue { public static readonly LabelControlOrientationToVisibilityValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is null) { @@ -31,8 +35,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture : Visibility.Collapsed; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Controls/LabelControls/LabelContent.xaml b/src/Atc.Wpf.Controls/LabelControls/LabelContent.xaml index 9fa63f23..39fa8952 100644 --- a/src/Atc.Wpf.Controls/LabelControls/LabelContent.xaml +++ b/src/Atc.Wpf.Controls/LabelControls/LabelContent.xaml @@ -129,7 +129,7 @@ - + throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.FontIcons/ValueConverters/FontIconImageSourceValueConverter.cs b/src/Atc.Wpf.FontIcons/ValueConverters/FontIconImageSourceValueConverter.cs index 3fb46fcd..d865219f 100644 --- a/src/Atc.Wpf.FontIcons/ValueConverters/FontIconImageSourceValueConverter.cs +++ b/src/Atc.Wpf.FontIcons/ValueConverters/FontIconImageSourceValueConverter.cs @@ -9,7 +9,11 @@ public override object ProvideValue(IServiceProvider serviceProvider) return this; } - public object? Convert(object? value, Type? targetType, object? parameter, CultureInfo? culture) + public object? Convert( + object? value, + Type? targetType, + object? parameter, + CultureInfo? culture) { var brush = parameter as Brush ?? Brushes.Black; var emSize = parameter as double? ?? 100; @@ -26,8 +30,10 @@ public override object ProvideValue(IServiceProvider serviceProvider) }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Theming/Controls/Icons/IconElement.cs b/src/Atc.Wpf.Theming/Controls/Icons/IconElement.cs index 8f049156..64ce74ef 100644 --- a/src/Atc.Wpf.Theming/Controls/Icons/IconElement.cs +++ b/src/Atc.Wpf.Theming/Controls/Icons/IconElement.cs @@ -45,7 +45,7 @@ private void UpdateInheritsForegroundFromVisualParent() = isForegroundPropertyDefaultOrInherited && Parent is not null && VisualParent is not null - && Parent != VisualParent; + && !Parent.Equals(VisualParent); } internal static readonly DependencyPropertyKey InheritsForegroundFromVisualParentPropertyKey = DependencyProperty.RegisterReadOnly( diff --git a/src/Atc.Wpf.Theming/Controls/Selectors/RenderColorIndicatorTypeToVisibilityValueConverter.cs b/src/Atc.Wpf.Theming/Controls/Selectors/RenderColorIndicatorTypeToVisibilityValueConverter.cs index 63dd92e1..c8b3b67d 100644 --- a/src/Atc.Wpf.Theming/Controls/Selectors/RenderColorIndicatorTypeToVisibilityValueConverter.cs +++ b/src/Atc.Wpf.Theming/Controls/Selectors/RenderColorIndicatorTypeToVisibilityValueConverter.cs @@ -8,16 +8,16 @@ public sealed class RenderColorIndicatorTypeToVisibilityValueConverter : IValueC { public static readonly RenderColorIndicatorTypeToVisibilityValueConverter Instance = new(); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); - if (value is not RenderColorIndicatorType actualRenderMode) - { - throw new UnexpectedTypeException($"Type {value.GetType().FullName} is not typeof({nameof(RenderColorIndicatorType)})"); - } - - if (parameter is not RenderColorIndicatorType wantedRenderMode) + if (value is not RenderColorIndicatorType actualRenderMode || + parameter is not RenderColorIndicatorType wantedRenderMode) { throw new UnexpectedTypeException($"Type {value.GetType().FullName} is not typeof({nameof(RenderColorIndicatorType)})"); } @@ -27,8 +27,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture : Visibility.Collapsed; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Theming/ValueConverters/ColorToNameValueConverter.cs b/src/Atc.Wpf.Theming/ValueConverters/ColorToNameValueConverter.cs index d081f7e0..c6d9e6b6 100644 --- a/src/Atc.Wpf.Theming/ValueConverters/ColorToNameValueConverter.cs +++ b/src/Atc.Wpf.Theming/ValueConverters/ColorToNameValueConverter.cs @@ -1,9 +1,12 @@ +// ReSharper disable ConditionalAccessQualifierIsNonNullableAccordingToAPIContract namespace Atc.Wpf.Theming.ValueConverters; [MarkupExtensionReturnType(typeof(ColorToNameValueConverter))] [ValueConversion(typeof(Color), typeof(string))] public sealed class ColorToNameValueConverter : MarkupMultiValueConverterBase { + public static readonly ColorToNameValueConverter Instance = new(); + /// /// Converts a given to its Name /// @@ -12,15 +15,14 @@ public sealed class ColorToNameValueConverter : MarkupMultiValueConverterBase /// Optional: A /// The culture. /// The name of the color or the Hex-Code if no name is available - public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - if (value is Color color) - { - return ColorHelper.GetColorNameFromColor(color); - } - - return Colors.Pink; - } + public override object? Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => value is Color color + ? ColorHelper.GetColorNameFromColor(color) + : Colors.Pink; /// /// Converts a given to its Name @@ -35,15 +37,14 @@ public sealed class ColorToNameValueConverter : MarkupMultiValueConverterBase /// The parameter. /// The culture. /// The name of the color or the Hex-Code if no name is available - public override object? Convert(object[]? values, Type targetType, object? parameter, CultureInfo culture) - { - if (values?.FirstOrDefault(x => x?.GetType() == typeof(Color)) is Color color) - { - return ColorHelper.GetColorNameFromColor(color, CultureInfo.InvariantCulture); - } - - return Colors.Pink; - } + public override object? Convert( + object[]? values, + Type targetType, + object? parameter, + CultureInfo culture) + => values?.FirstOrDefault(x => x?.GetType() == typeof(Color)) is Color color + ? ColorHelper.GetColorNameFromColor(color, CultureInfo.InvariantCulture) + : Colors.Pink; /// /// Converts a given back to a @@ -53,7 +54,11 @@ public sealed class ColorToNameValueConverter : MarkupMultiValueConverterBase /// Optional: A /// The culture. /// - public override object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + public override object? ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is string text) { @@ -72,8 +77,10 @@ public sealed class ColorToNameValueConverter : MarkupMultiValueConverterBase /// The parameter. /// The culture. /// - public override object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public override object[] ConvertBack( + object? value, + Type[] targetTypes, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusBindingValueConverter.cs b/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusBindingValueConverter.cs index 05b692d1..23aed36d 100644 --- a/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusBindingValueConverter.cs +++ b/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusBindingValueConverter.cs @@ -7,7 +7,11 @@ public sealed class CornerRadiusBindingValueConverter : IValueConverter public RadiusType IgnoreRadius { get; set; } = RadiusType.None; - public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object? Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is not CornerRadius cornerRadius) { @@ -34,8 +38,10 @@ public sealed class CornerRadiusBindingValueConverter : IValueConverter }; } - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return DependencyProperty.UnsetValue; - } + public object? ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => DependencyProperty.UnsetValue; } \ No newline at end of file diff --git a/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusFilterValueConverter.cs b/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusFilterValueConverter.cs index 695a1847..7077cc90 100644 --- a/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusFilterValueConverter.cs +++ b/src/Atc.Wpf.Theming/ValueConverters/CornerRadiusFilterValueConverter.cs @@ -8,7 +8,11 @@ public sealed class CornerRadiusFilterValueConverter : IValueConverter public RadiusType Filter { get; set; } = RadiusType.None; - public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object? Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { if (value is not CornerRadius cornerRadius) { @@ -35,8 +39,10 @@ public sealed class CornerRadiusFilterValueConverter : IValueConverter }; } - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return DependencyProperty.UnsetValue; - } + public object? ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => DependencyProperty.UnsetValue; } \ No newline at end of file diff --git a/src/Atc.Wpf.Theming/ValueConverters/TreeViewMarginValueConverter.cs b/src/Atc.Wpf.Theming/ValueConverters/TreeViewMarginValueConverter.cs index 25a708eb..60bc6c72 100644 --- a/src/Atc.Wpf.Theming/ValueConverters/TreeViewMarginValueConverter.cs +++ b/src/Atc.Wpf.Theming/ValueConverters/TreeViewMarginValueConverter.cs @@ -7,15 +7,19 @@ public sealed class TreeViewMarginValueConverter : IValueConverter public double Length { get; set; } - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return value is TreeViewItem item + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => value is TreeViewItem item ? new Thickness(Length * item.GetDepth(), 0, 0, 0) : new Thickness(0); - } - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return DependencyProperty.UnsetValue; - } + public object? ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => DependencyProperty.UnsetValue; } \ No newline at end of file diff --git a/src/Atc.Wpf/Atc.Wpf.csproj b/src/Atc.Wpf/Atc.Wpf.csproj index f6596636..3b1de635 100644 --- a/src/Atc.Wpf/Atc.Wpf.csproj +++ b/src/Atc.Wpf/Atc.Wpf.csproj @@ -1014,8 +1014,8 @@ - - + + diff --git a/src/Atc.Wpf/Extensions/DependencyObjectExtensions.cs b/src/Atc.Wpf/Extensions/DependencyObjectExtensions.cs index 2aa734f9..8a00538b 100644 --- a/src/Atc.Wpf/Extensions/DependencyObjectExtensions.cs +++ b/src/Atc.Wpf/Extensions/DependencyObjectExtensions.cs @@ -324,7 +324,7 @@ public static bool IsDescendantOf( while (currentNode is not null) { - if (currentNode == reference) + if (currentNode.Equals(reference)) { return true; } diff --git a/src/Atc.Wpf/GlobalUsings.cs b/src/Atc.Wpf/GlobalUsings.cs index 2028ca25..e2cc3a2b 100644 --- a/src/Atc.Wpf/GlobalUsings.cs +++ b/src/Atc.Wpf/GlobalUsings.cs @@ -61,5 +61,6 @@ global using Atc.Wpf.WindowsNative.Structs; global using Atc.Wpf.WindowsNative.User32; global using Atc.XamlToolkit.Controls.Attributes; +global using Atc.XamlToolkit.Resolvers; global using Microsoft.Extensions.Logging; \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/@Readme.md b/src/Atc.Wpf/ValueConverters/@Readme.md index 370143e0..2df5ca89 100644 --- a/src/Atc.Wpf/ValueConverters/@Readme.md +++ b/src/Atc.Wpf/ValueConverters/@Readme.md @@ -1,17 +1,42 @@ # ValueConverters in Atc.Wpf -## ValueConverters - Bool to X +## 🧹 Usage + +To use a converter in WPF by ResourceDictionary and and key: + +```xml + +xmlns:atcToolkitValueConverters="clr-namespace:Atc.XamlToolkit.ValueConverters;assembly=Atc.XamlToolkit.Wpf" + + + + + + + + + + +``` + +Or by the ValueConverter's Instance: + +```xml + +``` + +## #️⃣ ValueConverters - Bool to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | -| Bool -> Bool | BoolToInverseBoolValueConverter | True -> False and False -> True | False -> True and False -> False | -| Bool -> Visibility | BoolToVisibilityCollapsedValueConverter | True -> Collapsed and False -> Visible | Collapsed -> True and Visible -> False | -| Bool -> Visibility | BoolToVisibilityVisibleValueConverter | True -> Visible and False -> Collapsed | Visible -> True and Collapsed -> False | -| Bool -> With | BoolToWidthValueConverter | true, 10 -> 10 and true, "Auto" -> * | Not supported | +| Bool -> Bool | BoolToInverseBoolValueConverter | True -> False
False -> True | False -> True
False -> False | +| Bool -> Visibility | BoolToVisibilityCollapsedValueConverter | True -> Collapsed
False -> Visible | Collapsed -> True
Visible -> False | +| Bool -> Visibility | BoolToVisibilityVisibleValueConverter | True -> Visible
False -> Collapsed | Visible -> True
Collapsed -> False | +| Bool -> With | BoolToWidthValueConverter | true
10 -> 10
true
"Auto" -> * | Not supported | | Bool[] -> Bool | MultiBoolToBoolValueConverter | All-True -> True | Not supported | | Bool[] -> Visibility | MultiBoolToVisibilityVisibleValueConverter | All-True -> Visible | Not supported | -## ValueConverters - String to X +## #️⃣ ValueConverters - String to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | @@ -25,7 +50,7 @@ | String -> String | ToLowerValueConverter | String -> String | Binding.DoNothing | | String -> String | ToUpperValueConverter | String -> String | Binding.DoNothing | -## ValueConverters - ICollection to X +## #️⃣ ValueConverters - ICollection to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | @@ -34,23 +59,23 @@ | ICollection -> Visibility | CollectionNullOrEmptyToVisibilityCollapsedValueConverter | NULL or empty -> Collapsed | Not supported | | ICollection -> Visibility | CollectionNullOrEmptyToVisibilityVisibleValueConverter | NULL or empty -> Visible | Not supported | -## ValueConverters - Object to X +## #️⃣ ValueConverters - Object to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | -| Object -> Bool | IsNotNullValueConverter | <>Null -> True and Null -> False | Not supported | -| Object -> Bool | IsNullValueConverter | Null -> True and <>Null -> False | Not supported | +| Object -> Bool | IsNotNullValueConverter | ! Null -> True
Null -> False | Not supported | +| Object -> Bool | IsNullValueConverter | Null -> True
! Null -> False | Not supported | | Null -> X | NullCheckValueConverter | NULL -> Parameter if set | Not supported | | Null -> UnsetValue | NullToUnsetValueConverter | NULL -> DependencyProperty.UnsetValue | Object -> DependencyProperty.UnsetValue | | Object -> Bool | ObjectNotNullToBoolValueConverter | NotNULL -> True | Not supported | -| Object -> Visibility | ObjectNotNullToVisibilityCollapsedValueConverter | NotNULL -> Collapsed | Not supported | +| Object -> Visibility | ObjectNotNullToVisibilityCollapsedValueConverter | NotNULL -> Collapsed | Not supported | | Object -> Visibility | ObjectNotNullToVisibilityVisibleValueConverter | NotNULL -> Visible | Not supported | | Object -> Visibility | ObjectNullToVisibilityCollapsedValueConverter | NULL -> Collapsed | Not supported | | Object -> Visibility | ObjectNullToVisibilityVisibleValueConverter | NULL -> Visible | Not supported | | Object[] -> Visibility | MultiObjectNullToVisibilityCollapsedValueConverter | All-NULL -> Collapsed | Not supported | | Object -> Bool | ObjectNullToBoolValueConverter | NULL => True | Not supported | -### ValueConverters - Markup to X +## #️⃣ ValueConverters - Markup to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | @@ -58,7 +83,7 @@ | | MarkupValueConverter | | | | | MarkupValueConverterBase | | | -### ValueConverters - Others to X +## #️⃣ ValueConverters - Others to [...] | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | @@ -70,7 +95,7 @@ | Hex-Brush -> Brush-Key | HexBrushToBrushKeyValueConverter | "#FF00FF00" -> "Green" | "Green" -> Brushs.Green | | Hex-Color -> Color-Key | HexColorToColorKeyValueConverter | "#FF00FF00" -> "Green" | "Green" -> Color.Green | | Enum -> String | EnumDescriptionToStringValueConverter | DayOfWeek.Monday -> Monday | Not supported | -| Int -> Visibility | IntegerGreaterThenZeroToVisibilityVisibleValueConverter | 0 -> Collapsed and 1 -> Visible | Not supported | +| Int -> Visibility | IntegerGreaterThenZeroToVisibilityVisibleValueConverter | 0 -> Collapsed
1 -> Visible | Not supported | | Int -> TimeSpan | IntegerToTimeSpanValueConverter | 100 -> TimeSpan.FromMilliseconds(100) | Not supported | | LogCategoryType -> Brush | LogCategoryTypeToBrushValueConverter | Information -> DodgerBlue | Not supported | | LogCategoryType -> Color | LogCategoryTypeToColorValueConverter | Information -> DodgerBlue | Not supported | @@ -83,7 +108,7 @@ | Errors -> String | ValidationErrorsToStringValueConverter | | Not supported | | | WindowResizeModeMinMaxButtonVisibilityMultiValueConverter| | | -## ValueConverters - Math +## #️⃣ ValueConverters - Math | Category | Type | Convert Examples | ConvertBack Examples | | ------------------------- | -------------------------------------------------------- | --------------------------------------- | --------------------------------------- | diff --git a/src/Atc.Wpf/ValueConverters/BoolToInverseBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToInverseBoolValueConverter.cs similarity index 59% rename from src/Atc.Wpf/ValueConverters/BoolToInverseBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/BoolTo/BoolToInverseBoolValueConverter.cs index 4c828f8a..a8e96817 100644 --- a/src/Atc.Wpf/ValueConverters/BoolToInverseBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToInverseBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -9,18 +10,23 @@ public sealed class BoolToInverseBoolValueConverter : IValueConverter public static readonly BoolToInverseBoolValueConverter Instance = new(); /// - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return Convert(value); - } + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => Convert(value); /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return Convert(value); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => Convert(value); - private static bool Convert(object? value) + private static bool Convert( + object? value) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/Atc.Wpf/ValueConverters/BoolToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverter.cs similarity index 76% rename from src/Atc.Wpf/ValueConverters/BoolToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverter.cs index b1f8d766..8e332c5f 100644 --- a/src/Atc.Wpf/ValueConverters/BoolToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -9,7 +10,11 @@ public sealed class BoolToVisibilityCollapsedValueConverter : IValueConverter public static readonly BoolToVisibilityCollapsedValueConverter Instance = new(); /// - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); @@ -24,7 +29,11 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/Atc.Wpf/ValueConverters/BoolToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverter.cs similarity index 76% rename from src/Atc.Wpf/ValueConverters/BoolToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverter.cs index 6c6c8311..3aad213f 100644 --- a/src/Atc.Wpf/ValueConverters/BoolToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -9,7 +10,11 @@ public sealed class BoolToVisibilityVisibleValueConverter : IValueConverter public static readonly BoolToVisibilityVisibleValueConverter Instance = new(); /// - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); @@ -24,7 +29,11 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); diff --git a/src/Atc.Wpf/ValueConverters/BoolToWidthValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToWidthValueConverter.cs similarity index 77% rename from src/Atc.Wpf/ValueConverters/BoolToWidthValueConverter.cs rename to src/Atc.Wpf/ValueConverters/BoolTo/BoolToWidthValueConverter.cs index 1814bd2d..ab3d0edc 100644 --- a/src/Atc.Wpf/ValueConverters/BoolToWidthValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/BoolTo/BoolToWidthValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -9,7 +10,11 @@ public sealed class BoolToWidthValueConverter : IValueConverter public static readonly BoolToWidthValueConverter Instance = new(); /// - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) { ArgumentNullException.ThrowIfNull(value); @@ -45,8 +50,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToBoolValueConverter.cs new file mode 100644 index 00000000..374b98b1 --- /dev/null +++ b/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToBoolValueConverter.cs @@ -0,0 +1,43 @@ +// ReSharper disable SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault +// // ReSharper disable CheckNamespace +namespace Atc.Wpf.ValueConverters; + +/// +/// ValueConverter: Multi Bool To Bool. +/// +[ValueConversion(typeof(List), typeof(bool))] +public sealed class MultiBoolToBoolValueConverter : IMultiValueConverter +{ + public static readonly MultiBoolToBoolValueConverter Instance = new(); + + public BooleanOperatorType DefaultOperator { get; set; } = BooleanOperatorType.AND; + + /// + public object Convert( + object?[] values, + Type targetType, + object parameter, + CultureInfo culture) + { + var operatorType = BooleanOperatorTypeResolver.Resolve( + parameter, + DefaultOperator); + + var boolValues = values.Select(v => v is true); + + return operatorType switch + { + BooleanOperatorType.AND => boolValues.All(b => b), + BooleanOperatorType.OR => boolValues.Any(b => b), + _ => throw new SwitchCaseDefaultException(nameof(operatorType)), + }; + } + + /// + public object[] ConvertBack( + object value, + Type[] targetTypes, + object parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); +} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverter.cs new file mode 100644 index 00000000..16a87f1c --- /dev/null +++ b/src/Atc.Wpf/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverter.cs @@ -0,0 +1,46 @@ +// ReSharper disable SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault +// ReSharper disable InvertIf +// ReSharper disable CheckNamespace +namespace Atc.Wpf.ValueConverters; + +/// +/// MultiValueConverter: Multi Bool To Visibility-Visible. +/// +[ValueConversion(typeof(List), typeof(Visibility))] +public sealed class MultiBoolToVisibilityVisibleValueConverter : IMultiValueConverter +{ + public static readonly MultiBoolToVisibilityVisibleValueConverter Instance = new(); + + public BooleanOperatorType DefaultOperator { get; set; } = BooleanOperatorType.AND; + + /// + public object Convert( + object?[] values, + Type targetType, + object parameter, + CultureInfo culture) + { + ArgumentNullException.ThrowIfNull(values); + + var operatorType = BooleanOperatorTypeResolver.Resolve( + parameter, + DefaultOperator); + + var boolValues = values.Select(v => v is true); + + return operatorType switch + { + BooleanOperatorType.AND => boolValues.All(b => b), + BooleanOperatorType.OR => boolValues.Any(b => b), + _ => throw new SwitchCaseDefaultException(nameof(operatorType)), + }; + } + + /// + public object[] ConvertBack( + object value, + Type[] targetTypes, + object parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); +} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToBoolValueConverter.cs deleted file mode 100644 index 1e73cf48..00000000 --- a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToBoolValueConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Atc.Wpf.ValueConverters; - -/// -/// ValueConverter: ICollection Null Or Empty To Bool. -/// -[ValueConversion(typeof(ICollection), typeof(bool))] -public sealed class CollectionNullOrEmptyToBoolValueConverter : IValueConverter -{ - public static readonly CollectionNullOrEmptyToBoolValueConverter Instance = new(); - - /// - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return value is not ICollection collectionValue || collectionValue.Count == 0; - } - - /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } -} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverter.cs new file mode 100644 index 00000000..6c59abae --- /dev/null +++ b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverter.cs @@ -0,0 +1,28 @@ +// ReSharper disable CheckNamespace +namespace Atc.Wpf.ValueConverters; + +/// +/// ValueConverter: ICollection Null Or Empty To Bool. +/// +[ValueConversion(typeof(ICollection), typeof(bool))] +public sealed class CollectionNullOrEmptyToBoolValueConverter : IValueConverter +{ + public static readonly CollectionNullOrEmptyToBoolValueConverter Instance = new(); + + /// + public object Convert( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => value is not ICollection collectionValue || + collectionValue.Count == 0; + + /// + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); +} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverter.cs similarity index 71% rename from src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverter.cs index 84148f09..20cb0196 100644 --- a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -15,8 +16,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs similarity index 74% rename from src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs index 5bdc67b0..44ac8f65 100644 --- a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs similarity index 74% rename from src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs index 7e6410bf..f2d9f55d 100644 --- a/src/Atc.Wpf/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/EnumDescriptionToStringValueConverter.cs b/src/Atc.Wpf/ValueConverters/EnumDescriptionToStringValueConverter.cs index 32180a3e..a2c98520 100644 --- a/src/Atc.Wpf/ValueConverters/EnumDescriptionToStringValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/EnumDescriptionToStringValueConverter.cs @@ -79,8 +79,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/IntegerGreaterThenZeroToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/IntegerGreaterThenZeroToVisibilityVisibleValueConverter.cs index 37b27cf0..56595a0c 100644 --- a/src/Atc.Wpf/ValueConverters/IntegerGreaterThenZeroToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/IntegerGreaterThenZeroToVisibilityVisibleValueConverter.cs @@ -27,8 +27,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/IntegerToTimeSpanValueConverter.cs b/src/Atc.Wpf/ValueConverters/IntegerToTimeSpanValueConverter.cs index 744075e6..7a7895c6 100644 --- a/src/Atc.Wpf/ValueConverters/IntegerToTimeSpanValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/IntegerToTimeSpanValueConverter.cs @@ -20,8 +20,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture return TimeSpan.FromMilliseconds(intValue); } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/IsNotNullValueConverter.cs b/src/Atc.Wpf/ValueConverters/IsNotNullValueConverter.cs index 3434a146..71ec59ae 100644 --- a/src/Atc.Wpf/ValueConverters/IsNotNullValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/IsNotNullValueConverter.cs @@ -15,8 +15,10 @@ public sealed class IsNotNullValueConverter : IValueConverter } /// - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/IsNullValueConverter.cs b/src/Atc.Wpf/ValueConverters/IsNullValueConverter.cs index 8bc3dbdb..cd4b2df0 100644 --- a/src/Atc.Wpf/ValueConverters/IsNullValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/IsNullValueConverter.cs @@ -15,8 +15,10 @@ public sealed class IsNullValueConverter : IValueConverter } /// - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/LogCategoryTypeToBrushValueConverter.cs b/src/Atc.Wpf/ValueConverters/LogCategoryTypeToBrushValueConverter.cs index 884e5cd4..229191a1 100644 --- a/src/Atc.Wpf/ValueConverters/LogCategoryTypeToBrushValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/LogCategoryTypeToBrushValueConverter.cs @@ -36,8 +36,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/LogCategoryTypeToColorValueConverter.cs b/src/Atc.Wpf/ValueConverters/LogCategoryTypeToColorValueConverter.cs index ff81a276..304e9e4b 100644 --- a/src/Atc.Wpf/ValueConverters/LogCategoryTypeToColorValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/LogCategoryTypeToColorValueConverter.cs @@ -36,8 +36,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/LogLevelToBrushValueConverter.cs b/src/Atc.Wpf/ValueConverters/LogLevelToBrushValueConverter.cs index 66900c0e..e97dcf18 100644 --- a/src/Atc.Wpf/ValueConverters/LogLevelToBrushValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/LogLevelToBrushValueConverter.cs @@ -32,8 +32,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/LogLevelToColorValueConverter.cs b/src/Atc.Wpf/ValueConverters/LogLevelToColorValueConverter.cs index c3fba23f..b40807c3 100644 --- a/src/Atc.Wpf/ValueConverters/LogLevelToColorValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/LogLevelToColorValueConverter.cs @@ -32,8 +32,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture }; } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/MultiBoolToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/MultiBoolToBoolValueConverter.cs deleted file mode 100644 index 888789f9..00000000 --- a/src/Atc.Wpf/ValueConverters/MultiBoolToBoolValueConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Atc.Wpf.ValueConverters; - -/// -/// ValueConverter: Multi Bool To Bool. -/// -[ValueConversion(typeof(List), typeof(bool))] -public sealed class MultiBoolToBoolValueConverter : IMultiValueConverter -{ - public static readonly MultiBoolToBoolValueConverter Instance = new(); - - /// - public object Convert(object?[] values, Type targetType, object parameter, CultureInfo culture) - { - ArgumentNullException.ThrowIfNull(values); - - return values.All(value => value is not bool boolValue || boolValue); - } - - /// - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } -} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/MultiBoolToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/MultiBoolToVisibilityVisibleValueConverter.cs deleted file mode 100644 index e894afa7..00000000 --- a/src/Atc.Wpf/ValueConverters/MultiBoolToVisibilityVisibleValueConverter.cs +++ /dev/null @@ -1,50 +0,0 @@ -// ReSharper disable InvertIf -namespace Atc.Wpf.ValueConverters; - -/// -/// MultiValueConverter: Multi Bool To Visibility-Visible. -/// -[ValueConversion(typeof(List), typeof(Visibility))] -public sealed class MultiBoolToVisibilityVisibleValueConverter : IMultiValueConverter -{ - public static readonly MultiBoolToVisibilityVisibleValueConverter Instance = new(); - - /// - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - { - ArgumentNullException.ThrowIfNull(values); - - var visible = true; - foreach (var value in values) - { - if (value == DependencyProperty.UnsetValue && - DesignerProperties.GetIsInDesignMode(new DependencyObject())) - { - continue; - } - - if (value is not bool boolValue) - { - throw new UnexpectedTypeException($"Type {value.GetType().FullName} is not typeof(bool)"); - } - - if (boolValue) - { - continue; - } - - visible = false; - break; - } - - return visible - ? Visibility.Visible - : Visibility.Collapsed; - } - - /// - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } -} \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/NullCheckValueConverter.cs b/src/Atc.Wpf/ValueConverters/NullCheckValueConverter.cs index 643d0147..49c39393 100644 --- a/src/Atc.Wpf/ValueConverters/NullCheckValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/NullCheckValueConverter.cs @@ -17,8 +17,10 @@ public sealed class NullCheckValueConverter : IValueConverter } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverter.cs similarity index 89% rename from src/Atc.Wpf/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverter.cs index edfa05e9..eae3c058 100644 --- a/src/Atc.Wpf/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -35,7 +36,5 @@ public object[] ConvertBack( Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNotNullToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverter.cs similarity index 67% rename from src/Atc.Wpf/ValueConverters/ObjectNotNullToBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverter.cs index 52bfc947..c484c922 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNotNullToBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -15,8 +16,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverter.cs similarity index 78% rename from src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverter.cs index e855cb61..e5cbb679 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -26,8 +27,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverter.cs similarity index 78% rename from src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverter.cs index 84deeb77..f8044062 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -26,8 +27,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNullToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToBoolValueConverter.cs similarity index 66% rename from src/Atc.Wpf/ValueConverters/ObjectNullToBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToBoolValueConverter.cs index 28f56880..2adb4271 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNullToBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -15,8 +16,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverter.cs similarity index 71% rename from src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverter.cs index 93532886..4f65d5b4 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverter.cs similarity index 71% rename from src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverter.cs index e9f1b808..25a1b7bb 100644 --- a/src/Atc.Wpf/ValueConverters/ObjectNullToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ObservableDictionaryToDictionaryOfStringsValueConverter.cs b/src/Atc.Wpf/ValueConverters/ObservableDictionaryToDictionaryOfStringsValueConverter.cs index 9ec9611c..bea30d14 100644 --- a/src/Atc.Wpf/ValueConverters/ObservableDictionaryToDictionaryOfStringsValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ObservableDictionaryToDictionaryOfStringsValueConverter.cs @@ -50,8 +50,10 @@ value is not ObservableDictionary && } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/StandardNumericFormatTypeToFormatStringValueConverter.cs b/src/Atc.Wpf/ValueConverters/StandardNumericFormatTypeToFormatStringValueConverter.cs index 5b1aaf64..9bcf62f1 100644 --- a/src/Atc.Wpf/ValueConverters/StandardNumericFormatTypeToFormatStringValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StandardNumericFormatTypeToFormatStringValueConverter.cs @@ -37,8 +37,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverter.cs similarity index 69% rename from src/Atc.Wpf/ValueConverters/StringNullOrEmptyToBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverter.cs index 93b8494d..753da825 100644 --- a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -15,8 +16,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToInverseBoolValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverter.cs similarity index 70% rename from src/Atc.Wpf/ValueConverters/StringNullOrEmptyToInverseBoolValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverter.cs index 3ee77bdd..52d37bc6 100644 --- a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToInverseBoolValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -15,8 +16,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs similarity index 73% rename from src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs index 47c2508d..63dd3c84 100644 --- a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverter.cs similarity index 73% rename from src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverter.cs index 4f9548d3..b8c663e9 100644 --- a/src/Atc.Wpf/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// @@ -17,8 +18,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/src/Atc.Wpf/ValueConverters/ToLowerValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/ToLowerValueConverter.cs similarity index 95% rename from src/Atc.Wpf/ValueConverters/ToLowerValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/ToLowerValueConverter.cs index 3ceb7c5c..3a71118f 100644 --- a/src/Atc.Wpf/ValueConverters/ToLowerValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/ToLowerValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// diff --git a/src/Atc.Wpf/ValueConverters/ToUpperValueConverter.cs b/src/Atc.Wpf/ValueConverters/StringTo/ToUpperValueConverter.cs similarity index 95% rename from src/Atc.Wpf/ValueConverters/ToUpperValueConverter.cs rename to src/Atc.Wpf/ValueConverters/StringTo/ToUpperValueConverter.cs index c2845c4d..adbeab2e 100644 --- a/src/Atc.Wpf/ValueConverters/ToUpperValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/StringTo/ToUpperValueConverter.cs @@ -1,3 +1,4 @@ +// ReSharper disable CheckNamespace namespace Atc.Wpf.ValueConverters; /// diff --git a/src/Atc.Wpf/ValueConverters/ValidationErrorsToStringValueConverter.cs b/src/Atc.Wpf/ValueConverters/ValidationErrorsToStringValueConverter.cs index 89203140..6a146c84 100644 --- a/src/Atc.Wpf/ValueConverters/ValidationErrorsToStringValueConverter.cs +++ b/src/Atc.Wpf/ValueConverters/ValidationErrorsToStringValueConverter.cs @@ -29,8 +29,10 @@ public object Convert(object? value, Type targetType, object? parameter, Culture } /// - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotSupportedException("This is a OneWay converter."); - } + public object ConvertBack( + object? value, + Type targetType, + object? parameter, + CultureInfo culture) + => throw new NotSupportedException("This is a OneWay converter."); } \ No newline at end of file diff --git a/test/Atc.Wpf.Controls.Tests/Atc.Wpf.Controls.Tests.csproj b/test/Atc.Wpf.Controls.Tests/Atc.Wpf.Controls.Tests.csproj index bc7e3793..0f7b6541 100644 --- a/test/Atc.Wpf.Controls.Tests/Atc.Wpf.Controls.Tests.csproj +++ b/test/Atc.Wpf.Controls.Tests/Atc.Wpf.Controls.Tests.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Atc.Wpf.Tests/Atc.Wpf.Tests.csproj b/test/Atc.Wpf.Tests/Atc.Wpf.Tests.csproj index 71c8eeef..8462a75a 100644 --- a/test/Atc.Wpf.Tests/Atc.Wpf.Tests.csproj +++ b/test/Atc.Wpf.Tests/Atc.Wpf.Tests.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolToInverseBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToInverseBoolValueConverterTests.cs similarity index 94% rename from test/Atc.Wpf.Tests/ValueConverters/BoolToInverseBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToInverseBoolValueConverterTests.cs index d35cfa24..14cdcf35 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/BoolToInverseBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToInverseBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class BoolToInverseBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverterTests.cs index b306a27b..85637a5a 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class BoolToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityVisibleValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverterTests.cs index 24e84388..811e3d83 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/BoolToVisibilityVisibleValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToVisibilityVisibleValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class BoolToVisibilityVisibleValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolToWidthValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToWidthValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/BoolToWidthValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToWidthValueConverterTests.cs index 8ab6d96f..c35afd41 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/BoolToWidthValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BoolToWidthValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class BoolToWidthValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/BrushToColorValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BrushToColorValueConverterTests.cs similarity index 97% rename from test/Atc.Wpf.Tests/ValueConverters/BrushToColorValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/BoolTo/BrushToColorValueConverterTests.cs index baf139f2..eab8b5b5 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/BrushToColorValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/BrushToColorValueConverterTests.cs @@ -1,4 +1,5 @@ // ReSharper disable PossibleNullReferenceException +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class BrushToColorValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToBoolValueConverterTests.cs new file mode 100644 index 00000000..002ae086 --- /dev/null +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToBoolValueConverterTests.cs @@ -0,0 +1,72 @@ +// ReSharper disable once CheckNamespace +namespace Atc.Wpf.Tests.ValueConverters; + +public sealed class MultiBoolToBoolValueConverterTests +{ + private readonly IMultiValueConverter converter = new MultiBoolToBoolValueConverter(); + + private static readonly object[] AllTrue = [true, true, true]; + private static readonly object[] OneFalse = [true, false, true]; + private static readonly object[] AllFalse = [false, false, false]; + private static readonly object[] Empty = []; + + [Theory] + [InlineData(true, nameof(AllTrue))] + [InlineData(false, nameof(OneFalse))] + [InlineData(true, nameof(Empty))] + public void Convert_AND_DefaultOperator(bool expected, string inputSetName) + { + // Arrange + var input = GetInput(inputSetName); + + // Act + var actual = converter.Convert(input, targetType: null!, parameter: null, culture: CultureInfo.InvariantCulture); + + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(true, nameof(AllTrue))] + [InlineData(true, nameof(OneFalse))] + [InlineData(false, nameof(AllFalse))] + [InlineData(false, nameof(Empty))] + public void Convert_OR_WithEnumParameter(bool expected, string inputSetName) + { + // Arrange + var input = GetInput(inputSetName); + + // Act + var actual = converter.Convert( + input, + targetType: null!, + parameter: BooleanOperatorType.OR, + culture: CultureInfo.InvariantCulture); + + // Assert + Assert.Equal(expected, actual); + } + + [Fact] + public void Convert_OR_WithStringParameter() + { + // Act + var actual = converter.Convert( + OneFalse, + targetType: null!, + parameter: "or", + culture: CultureInfo.InvariantCulture); + + // Assert + Assert.True((bool)actual!); + } + + private static object[] GetInput(string name) => name switch + { + nameof(AllTrue) => AllTrue, + nameof(OneFalse) => OneFalse, + nameof(AllFalse) => AllFalse, + nameof(Empty) => Empty, + _ => throw new ArgumentOutOfRangeException(nameof(name)), + }; +} \ No newline at end of file diff --git a/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverterTests.cs new file mode 100644 index 00000000..6a140f54 --- /dev/null +++ b/test/Atc.Wpf.Tests/ValueConverters/BoolTo/MultiBoolToVisibilityVisibleValueConverterTests.cs @@ -0,0 +1,72 @@ +// ReSharper disable once CheckNamespace +namespace Atc.Wpf.Tests.ValueConverters; + +public sealed class MultiBoolToVisibilityVisibleValueConverterTests +{ + private readonly IMultiValueConverter converter = new MultiBoolToVisibilityVisibleValueConverter(); + + private static readonly object[] AllTrue = [true, true, true]; + private static readonly object[] OneFalse = [true, false, true]; + private static readonly object[] AllFalse = [false, false, false]; + private static readonly object[] Empty = []; + + [Theory] + [InlineData(true, nameof(AllTrue))] + [InlineData(false, nameof(OneFalse))] + [InlineData(true, nameof(Empty))] + public void Convert_AND_DefaultOperator(bool expected, string inputSetName) + { + // Arrange + var input = GetInput(inputSetName); + + // Act + var actual = converter.Convert(input, targetType: null!, parameter: null, culture: CultureInfo.InvariantCulture); + + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(true, nameof(AllTrue))] + [InlineData(true, nameof(OneFalse))] + [InlineData(false, nameof(AllFalse))] + [InlineData(false, nameof(Empty))] + public void Convert_OR_WithEnumParameter(bool expected, string inputSetName) + { + // Arrange + var input = GetInput(inputSetName); + + // Act + var actual = converter.Convert( + input, + targetType: null!, + parameter: BooleanOperatorType.OR, + culture: CultureInfo.InvariantCulture); + + // Assert + Assert.Equal(expected, actual); + } + + [Fact] + public void Convert_OR_WithStringParameter() + { + // Act + var actual = converter.Convert( + OneFalse, + targetType: null!, + parameter: "or", + culture: CultureInfo.InvariantCulture); + + // Assert + Assert.True((bool)actual!); + } + + private static object[] GetInput(string name) => name switch + { + nameof(AllTrue) => AllTrue, + nameof(OneFalse) => OneFalse, + nameof(AllFalse) => AllFalse, + nameof(Empty) => Empty, + _ => throw new ArgumentOutOfRangeException(nameof(name)), + }; +} \ No newline at end of file diff --git a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverterTests.cs index d8cbdf48..5e34bde5 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class CollectionNullOrEmptyToBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs index 83864b80..6ae10484 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToInverseBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class CollectionNullOrEmptyToInverseBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs index 6bfec553..fe4a6bb6 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class CollectionNullOrEmptyToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs index accf288d..a772d5e8 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/CollectionTo/CollectionNullOrEmptyToVisibilityVisibleValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class CollectionNullOrEmptyToVisibilityVisibleValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToBoolValueConverterTests.cs deleted file mode 100644 index a43e124a..00000000 --- a/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToBoolValueConverterTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Atc.Wpf.Tests.ValueConverters; - -public sealed class MultiBoolToBoolValueConverterTests -{ - private readonly IMultiValueConverter converter = new MultiBoolToBoolValueConverter(); - private readonly object[] inputSet1 = { true, true, true }; - private readonly object[] inputSet2 = { true, false, true }; - - [Theory] - [InlineData(true, 1)] - [InlineData(false, 2)] - public void Convert(bool expected, int inputSetNumber) - { - // Arrange - var input = inputSetNumber switch - { - 1 => inputSet1, - 2 => inputSet2, - _ => [], - }; - - // Atc - var actual = converter.Convert(input, targetType: null, parameter: null, culture: null); - - // Arrange - Assert.Equal(expected, actual); - } - - [Fact] - public void ConvertBack_Should_Throw_Exception() - { - // Act - var exception = Record.Exception(() => converter.ConvertBack(value: null, targetTypes: null, parameter: null, culture: null)); - - // Assert - Assert.IsType(exception); - Assert.Equal("This is a OneWay converter.", exception.Message); - } -} \ No newline at end of file diff --git a/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToVisibilityVisibleValueConverterTests.cs deleted file mode 100644 index f352fd0e..00000000 --- a/test/Atc.Wpf.Tests/ValueConverters/MultiBoolToVisibilityVisibleValueConverterTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Atc.Wpf.Tests.ValueConverters; - -public sealed class MultiBoolToVisibilityVisibleValueConverterTests -{ - private readonly IMultiValueConverter converter = new MultiBoolToVisibilityVisibleValueConverter(); - - private readonly object[] inputSet1 = { true, true, true }; - private readonly object[] inputSet2 = { true, false, true }; - - [Theory] - [InlineData(Visibility.Visible, 1)] - [InlineData(Visibility.Collapsed, 2)] - public void Convert(Visibility expected, int inputSetNumber) - { - // Arrange - var input = inputSetNumber switch - { - 1 => inputSet1, - 2 => inputSet2, - _ => Array.Empty(), - }; - - // Atc - var actual = converter.Convert(input, targetType: null, parameter: null, culture: null); - - // Arrange - Assert.Equal(expected, actual); - } - - [Fact] - public void ConvertBack_Should_Throw_Exception() - { - // Act - var exception = Record.Exception(() => converter.ConvertBack(value: null, targetTypes: null, parameter: null, culture: null)); - - // Assert - Assert.IsType(exception); - Assert.Equal("This is a OneWay converter.", exception.Message); - } -} \ No newline at end of file diff --git a/test/Atc.Wpf.Tests/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs index 956f3e26..8be32de2 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/MultiObjectNullToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class MultiObjectNullToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverterTests.cs index 2dd0ccca..35be35b2 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNotNullToBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs similarity index 97% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs index efcd9b18..22e47541 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNotNullToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverterTests.cs similarity index 97% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverterTests.cs index 550ad500..e88bb64c 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNotNullToVisibilityVisibleValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNotNullToVisibilityVisibleValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNotNullToVisibilityVisibleValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNullToBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToBoolValueConverterTests.cs index fbfae595..ccfd2f48 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNullToBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverterTests.cs index 620fd1b1..698e56ef 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNullToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityVisibleValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverterTests.cs index 8bf11607..9416b521 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/ObjectNullToVisibilityVisibleValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/ObjectTo/ObjectNullToVisibilityVisibleValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class ObjectNullToVisibilityVisibleValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverterTests.cs index a4b7fe1e..c0e125cc 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class StringNullOrEmptyToBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToInverseBoolValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToInverseBoolValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverterTests.cs index 47f3b8ac..1dfc2728 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToInverseBoolValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToInverseBoolValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class StringNullOrEmptyToInverseBoolValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs index c6200dfa..8e5cdf73 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityCollapsedValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class StringNullOrEmptyToVisibilityCollapsedValueConverterTests diff --git a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs similarity index 95% rename from test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs rename to test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs index 5d1d2bb4..b7a5a926 100644 --- a/test/Atc.Wpf.Tests/ValueConverters/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs +++ b/test/Atc.Wpf.Tests/ValueConverters/StringTo/StringNullOrEmptyToVisibilityVisibleValueConverterTests.cs @@ -1,3 +1,4 @@ +// ReSharper disable once CheckNamespace namespace Atc.Wpf.Tests.ValueConverters; public sealed class StringNullOrEmptyToVisibilityVisibleValueConverterTests diff --git a/test/Atc.Wpf.Theming.Tests/Atc.Wpf.Theming.Tests.csproj b/test/Atc.Wpf.Theming.Tests/Atc.Wpf.Theming.Tests.csproj index b7058d0f..2747dd9a 100644 --- a/test/Atc.Wpf.Theming.Tests/Atc.Wpf.Theming.Tests.csproj +++ b/test/Atc.Wpf.Theming.Tests/Atc.Wpf.Theming.Tests.csproj @@ -11,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj b/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj index 70e056f6..b73a08b3 100644 --- a/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj +++ b/tool/Atc.Wpf.Generator.FontIconResources/Atc.Wpf.Generator.FontIconResources.csproj @@ -9,8 +9,8 @@ - - + + NU1701