diff --git a/ImageChecker/Controls/MultiSelectDataGrid.xaml.cs b/ImageChecker/Controls/MultiSelectDataGrid.xaml.cs index 4edbda0..95f7ac1 100644 --- a/ImageChecker/Controls/MultiSelectDataGrid.xaml.cs +++ b/ImageChecker/Controls/MultiSelectDataGrid.xaml.cs @@ -6,7 +6,6 @@ namespace ImageChecker.Controls; public partial class MultiSelectDataGrid : DataGrid { - public MultiSelectDataGrid() { SelectionChanged += MultiSelectDataGrid_SelectionChanged; @@ -16,7 +15,6 @@ void MultiSelectDataGrid_SelectionChanged(object sender, SelectionChangedEventAr { SelectedItemsList = SelectedItems; } - #region SelectedItemsList public IList SelectedItemsList { @@ -24,8 +22,5 @@ public IList SelectedItemsList set => SetValue(SelectedItemsListProperty, value); } - public static readonly DependencyProperty SelectedItemsListProperty = - DependencyProperty.Register("SelectedItemsList", typeof(IList), typeof(MultiSelectDataGrid), new PropertyMetadata(null)); - - #endregion + public static readonly DependencyProperty SelectedItemsListProperty = DependencyProperty.Register(nameof(SelectedItemsList), typeof(IList), typeof(MultiSelectDataGrid), new PropertyMetadata(null)); } diff --git a/ImageChecker/Converter/InverseBoolConverter.cs b/ImageChecker/Converter/InverseBoolConverter.cs index 97b5e88..bc1a813 100644 --- a/ImageChecker/Converter/InverseBoolConverter.cs +++ b/ImageChecker/Converter/InverseBoolConverter.cs @@ -2,7 +2,7 @@ namespace ImageChecker.Converter; -class InverseBoolConverter : IValueConverter +public class InverseBoolConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { diff --git a/ImageChecker/Switch/SwitchConverter.cs b/ImageChecker/Converter/SwitchConverter.cs similarity index 52% rename from ImageChecker/Switch/SwitchConverter.cs rename to ImageChecker/Converter/SwitchConverter.cs index 5cd2f46..b2a9600 100644 --- a/ImageChecker/Switch/SwitchConverter.cs +++ b/ImageChecker/Converter/SwitchConverter.cs @@ -1,7 +1,9 @@ -using System.Windows.Data; +using System; +using System.Collections.Generic; +using System.Windows.Data; using System.Windows.Markup; -namespace ImageChecker.Switch; +namespace ImageChecker.Converter; /// /// A converter that accepts s and converts them to the @@ -10,11 +12,14 @@ namespace ImageChecker.Switch; [ContentProperty("Cases")] public class SwitchConverter : IValueConverter { + // Converter instances. + private List _cases; + #region Public Properties. /// /// Gets or sets an array of s that this converter can use to produde values from. /// - public List Cases { get; set; } + public List Cases { get { return _cases; } set { _cases = value; } } public object Default { get; set; } #endregion #region Construction. @@ -24,7 +29,7 @@ public class SwitchConverter : IValueConverter public SwitchConverter() { // Create the cases array. - Cases = new List(); + _cases = new List(); } #endregion @@ -40,40 +45,66 @@ public SwitchConverter() /// public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - bool isSame; + try + { + bool isSame; - if (Cases != null && Cases.Count > 0) - for (int i = 0; i < Cases.Count; i++) - { - SwitchConverterCase targetCase = Cases[i]; + if (_cases != null && _cases.Count > 0) + for (var i = 0; i < _cases.Count; i++) + { + var targetCase = _cases[i]; - if (value == null && targetCase.When == null) - return targetCase.Then; + if (value == null && targetCase.When == null) + return targetCase.Then; - if (value != null && targetCase.When != null) - { - if ((value.GetType().IsValueType || value.GetType() == typeof(string)) && (targetCase.When.GetType().IsValueType || targetCase.When.GetType() == typeof(string))) + if (value != null && targetCase.When != null) { - isSame = (value.ToString() == targetCase.When.ToString()); + if (bool.TryParse(value.ToString(), out var bValue) && bool.TryParse(targetCase.When.ToString(), out var bWhenValue)) + { + isSame = bValue == bWhenValue; + } + else if ((value.GetType().IsValueType || value.GetType() == typeof(string)) && (targetCase.When.GetType().IsValueType || targetCase.When.GetType() == typeof(string))) + { + isSame = value.ToString() == targetCase.When.ToString(); - // wenn beide numeric sind, dann a - b == 0? - if (!isSame && Decimal.TryParse(value.ToString(), out var a) && Decimal.TryParse(targetCase.When.ToString(), out var b)) + // wenn beide numeric sind, dann a - b == 0? + if (!isSame && decimal.TryParse(value.ToString(), out var a) && decimal.TryParse(targetCase.When.ToString(), out var b)) + { + isSame = a - b == 0; + } + else if (!isSame && targetCase.When.GetType().IsEnum) + { + try + { + isSame = System.Convert.ToInt64(value) == System.Convert.ToInt64(targetCase.When); + } + catch (Exception) + { + isSame = false; + } + } + } + else if (value is Type == false && targetCase.When is Type t) + { // der value ist kein type, aber der case.when ist ein type. dann prüfen, ob der type des values zum type im case.when passt. + isSame = t.IsAssignableFrom(value?.GetType()); + } + else { - isSame = (a - b == 0); + isSame = value.Equals(targetCase.When); } - } - else - { - isSame = value.Equals(targetCase.When); - } - if (isSame) - { - return targetCase.Then; + if (isSame) + { + return targetCase.Then; + } } } - } + } + catch (Exception) + { + return Default; + } return Default; } @@ -101,18 +132,18 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste public class SwitchConverterCase { // case instances. - object _when; - object _then; + private object _when; + private object _then; #region Public Properties. /// /// Gets or sets the condition of the case. /// - public object When { get => _when; set => _when = value; } + public object When { get { return _when; } set { _when = value; } } /// /// Gets or sets the results of this case when run through a /// - public object Then { get => _then; set => _then = value; } + public object Then { get { return _then; } set { _then = value; } } #endregion #region Construction. /// @@ -135,10 +166,10 @@ public SwitchConverterCase(object when, object then) #endregion /// - /// Returns a that represents this instance. + /// Returns a that represents this instance. /// /// - /// A that represents this instance. + /// A that represents this instance. /// public override string ToString() { diff --git a/ImageChecker/Icon/fullscreen.png b/ImageChecker/Icon/fullscreen.png new file mode 100644 index 0000000..f028b31 Binary files /dev/null and b/ImageChecker/Icon/fullscreen.png differ diff --git a/ImageChecker/ImageChecker.csproj b/ImageChecker/ImageChecker.csproj index ff450c7..dd06d75 100644 --- a/ImageChecker/ImageChecker.csproj +++ b/ImageChecker/ImageChecker.csproj @@ -9,7 +9,7 @@ enable https://github.com/marcelgoldstein/ImageChecker https://github.com/marcelgoldstein/ImageChecker - 1.0.9.1 + 1.0.9.2 diff --git a/ImageChecker/View/ErrorFiles.xaml b/ImageChecker/View/ErrorFiles.xaml index c7affeb..b4f67e5 100644 --- a/ImageChecker/View/ErrorFiles.xaml +++ b/ImageChecker/View/ErrorFiles.xaml @@ -23,11 +23,10 @@ @@ -54,8 +53,15 @@ - + @@ -66,11 +72,18 @@ - + - - + @@ -78,15 +91,28 @@ - - - - diff --git a/ImageChecker/View/ImageChecker.xaml b/ImageChecker/View/ImageChecker.xaml index f067127..32d7f53 100644 --- a/ImageChecker/View/ImageChecker.xaml +++ b/ImageChecker/View/ImageChecker.xaml @@ -4,16 +4,22 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:switch="clr-namespace:ImageChecker.Switch" xmlns:behavior="clr-namespace:ImageChecker.Behavior" xmlns:converter="clr-namespace:ImageChecker.Converter" mc:Ignorable="d" - Height="Auto" Width="Auto" MinHeight="320" MinWidth="600" d:DesignWidth="600" d:DesignHeight="320" - AllowDrop="True" behavior:DropBehavior.PreviewDropCommand="{Binding DropFolderCommand}" + Height="Auto" Width="Auto" MinHeight="320" MinWidth="600" + d:DesignWidth="600" d:DesignHeight="320" + AllowDrop="True" + behavior:DropBehavior.PreviewDropCommand="{Binding DropFolderCommand}" xmlns:viewmodel="clr-namespace:ImageChecker.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:VMImageChecker}" > + + + + + @@ -28,25 +34,43 @@ VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,1,7,-14" - Click="btnMenu_Click" + Click="BtnMenu_Click" Width="32" Height="18" Padding="0" > - + - - + + - + - + @@ -55,20 +79,60 @@ - - - - - - - - + @@ -78,37 +142,115 @@ - + SelectedItem="{Binding SelectedFolder, Mode=TwoWay}" + /> - + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + - - - - + + - -