Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ImageChecker/Controls/MultiSelectDataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace ImageChecker.Controls;

public partial class MultiSelectDataGrid : DataGrid
{

public MultiSelectDataGrid()
{
SelectionChanged += MultiSelectDataGrid_SelectionChanged;
Expand All @@ -16,16 +15,12 @@ void MultiSelectDataGrid_SelectionChanged(object sender, SelectionChangedEventAr
{
SelectedItemsList = SelectedItems;
}
#region SelectedItemsList

public IList SelectedItemsList
{
get => (IList)GetValue(SelectedItemsListProperty);
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));
}
2 changes: 1 addition & 1 deletion ImageChecker/Converter/InverseBoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// A converter that accepts <see cref="SwitchConverterCase"/>s and converts them to the
Expand All @@ -10,11 +12,14 @@ namespace ImageChecker.Switch;
[ContentProperty("Cases")]
public class SwitchConverter : IValueConverter
{
// Converter instances.
private List<SwitchConverterCase> _cases;

#region Public Properties.
/// <summary>
/// Gets or sets an array of <see cref="SwitchConverterCase"/>s that this converter can use to produde values from.
/// </summary>
public List<SwitchConverterCase> Cases { get; set; }
public List<SwitchConverterCase> Cases { get { return _cases; } set { _cases = value; } }
public object Default { get; set; }
#endregion
#region Construction.
Expand All @@ -24,7 +29,7 @@ public class SwitchConverter : IValueConverter
public SwitchConverter()
{
// Create the cases array.
Cases = new List<SwitchConverterCase>();
_cases = new List<SwitchConverterCase>();
}
#endregion

Expand All @@ -40,40 +45,66 @@ public SwitchConverter()
/// </returns>
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;
}
Expand Down Expand Up @@ -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.
/// <summary>
/// Gets or sets the condition of the case.
/// </summary>
public object When { get => _when; set => _when = value; }
public object When { get { return _when; } set { _when = value; } }
/// <summary>
/// Gets or sets the results of this case when run through a <see cref="SwitchConverter"/>
/// </summary>
public object Then { get => _then; set => _then = value; }
public object Then { get { return _then; } set { _then = value; } }
#endregion
#region Construction.
/// <summary>
Expand All @@ -135,10 +166,10 @@ public SwitchConverterCase(object when, object then)
#endregion

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
Expand Down
Binary file added ImageChecker/Icon/fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ImageChecker/ImageChecker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<PackageProjectUrl>https://github.com/marcelgoldstein/ImageChecker</PackageProjectUrl>
<RepositoryUrl>https://github.com/marcelgoldstein/ImageChecker</RepositoryUrl>
<AssemblyVersion>1.0.9.1</AssemblyVersion>
<AssemblyVersion>1.0.9.2</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
58 changes: 42 additions & 16 deletions ImageChecker/View/ErrorFiles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
</AlternationConverter>

<Style x:Key="alternatingWithBinding" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(ItemsControl.AlternationIndex),
Converter={StaticResource BackgroundConverter}}"/>

<Setter
Property="Background"
Value="{Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex), Converter={StaticResource BackgroundConverter}}"
/>
</Style>

</Grid.Resources>
Expand All @@ -54,8 +53,15 @@
</Button>
</Grid>

<ListBox Margin="5,0,5,5" Grid.Row="1" ItemsSource="{Binding ErrorFiles}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Center"
AlternationCount="2" ItemContainerStyle="{StaticResource alternatingWithBinding}">
<ListBox
Margin="5,0,5,5"
Grid.Row="1"
ItemsSource="{Binding ErrorFiles}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Center"
AlternationCount="2"
ItemContainerStyle="{StaticResource alternatingWithBinding}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid >
Expand All @@ -66,27 +72,47 @@
</Grid.ColumnDefinitions>

<Grid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding RelativeSource={RelativeSource AncestorType=ListBox}, Path=DataContext.OpenImageCommand}" CommandParameter="{Binding }" />
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding RelativeSource={RelativeSource AncestorType=ListBox}, Path=DataContext.OpenImageCommand}"
CommandParameter="{Binding }"
/>
</Grid.InputBindings>


<TextBlock Text="{Binding Name}" Grid.Column="0" VerticalAlignment="Center">
<TextBlock
Text="{Binding Name}"
Grid.Column="0"
VerticalAlignment="Center"
>
<TextBlock.ToolTip>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding FullName}" />
<TextBlock Text="{Binding Length, StringFormat={}filesize: {0} Bytes}" />
</StackPanel>
</TextBlock.ToolTip>
</TextBlock>



<Button ToolTip="open containing folder" Grid.Column="1" Width="22" Grid.Row="0" Grid.RowSpan="2" Margin="0,0,5,0"
Command="{Binding DataContext.OpenFolderCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding }" >
<Button
ToolTip="open containing folder"
Grid.Column="1"
Width="22"
Grid.Row="0"
Grid.RowSpan="2"
Margin="0,0,5,0"
Command="{Binding DataContext.OpenFolderCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding }"
>
<Image Source="/ImageChecker;component/Icon/openFolder.png" />
</Button>
<Button ToolTip="delete file" Grid.Column="2" Width="22" Grid.Row="0" Grid.RowSpan="2"
Command="{Binding DataContext.DeleteFileCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding }" >
<Button
ToolTip="delete file"
Grid.Column="2"
Width="22"
Grid.Row="0"
Grid.RowSpan="2"
Command="{Binding DataContext.DeleteFileCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding }"
>
<Image Source="/ImageChecker;component/Icon/trash.png" />
</Button>
</Grid>
Expand Down
Loading