Skip to content

Commit

Permalink
Update Duplicate Files Utility
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Jan 8, 2024
1 parent c94dccc commit 84fe58e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 67 deletions.
11 changes: 0 additions & 11 deletions Shoko.Desktop/UserControls/DuplicateFileDetailControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,8 @@


<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0">

<!-- delete entry button-->
<Button Margin="0,0,5,0" Style="{DynamicResource FlatButtonStyle}" Command="{DynamicResource DeleteFileDBCommand}" CommandParameter="{Binding}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<Image Height="16" Width="16" Source="/Images/16_cancel.png" Margin="0,0,0,0"/>
</StackPanel>
<Button.ToolTip>
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Tooltip_DeleteDuplicateFileEntry}"/>
</Button.ToolTip>
</Button>
<TextBlock Text="{Binding Path=AnimeName}" FontWeight="DemiBold" Foreground="Black" VerticalAlignment="Center" />
<TextBlock Text="{Binding Path=EpisodeNumberAndName}" FontWeight="Normal" Foreground="Black" VerticalAlignment="Center" Margin="10,0,0,0" />

</StackPanel>

<!-- Row 1 -->
Expand Down
14 changes: 0 additions & 14 deletions Shoko.Desktop/UserControls/DuplicateFilesControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<RoutedUICommand x:Key="OpenFolder2Command" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=OpenFolder2Command}" />
<RoutedUICommand x:Key="DeleteFile1Command" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=DeleteFile1Command}" />
<RoutedUICommand x:Key="DeleteFile2Command" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=DeleteFile2Command}" />
<RoutedUICommand x:Key="DeleteFileDBCommand" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=DeleteFileDBCommand}" />
<RoutedUICommand x:Key="PlayVideo1Command" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=PlayVideo1Command}" />
<RoutedUICommand x:Key="PlayVideo2Command" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=PlayVideo2Command}" />

Expand All @@ -30,7 +29,6 @@
<CommandBinding Command="{StaticResource OpenFolder2Command}" Executed="CommandBinding_OpenFolder2" />
<CommandBinding Command="{StaticResource DeleteFile1Command}" Executed="CommandBinding_DeleteFile1" />
<CommandBinding Command="{StaticResource DeleteFile2Command}" Executed="CommandBinding_DeleteFile2" />
<CommandBinding Command="{StaticResource DeleteFileDBCommand}" Executed="CommandBinding_DeleteFileDB" />
<CommandBinding Command="{StaticResource PlayVideo1Command}" Executed="CommandBinding_PlayVideo1" />
<CommandBinding Command="{StaticResource PlayVideo2Command}" Executed="CommandBinding_PlayVideo2" />
</UserControl.CommandBindings>
Expand Down Expand Up @@ -60,18 +58,6 @@
<TextBlock VerticalAlignment="Center" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Refresh}" Margin="0,0,5,0"/>
</StackPanel>
</Button>

<!-- Reevaluate -->
<Button Name="btnReevaluate" Margin="2,2,2,2" Style="{DynamicResource FlatButtonStyle}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<Image Height="16" Width="16" Source="/Images/32_sync.png" Margin="0,0,5,0"/>
<TextBlock VerticalAlignment="Center" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=ReevaluateDuplicateFiles}" Margin="0,0,5,0"/>
</StackPanel>
<Button.ToolTip>
<TextBlock Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Tooltip_ReevaluateDuplicateFiles}"/>
</Button.ToolTip>
</Button>

<TextBlock VerticalAlignment="Center" Text="{Binding Path=FileCount, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type usercontrols:DuplicateFilesControl}}}" Margin="10,0,0,0" Foreground="DarkGray" />
<TextBlock VerticalAlignment="Center" Text="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Anime_Episodes}" Margin="5,0,0,0" Foreground="DarkGray"/>
</StackPanel>
Expand Down
44 changes: 2 additions & 42 deletions Shoko.Desktop/UserControls/DuplicateFilesControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void CommandBinding_DeleteFile1(object sender, ExecutedRoutedEventArgs e
if (res == MessageBoxResult.Yes)
{
Cursor = Cursors.Wait;
string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.DuplicateFileID, 1);
string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.File1VideoLocalPlaceID);
if (result.Length > 0)
MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
else
Expand Down Expand Up @@ -274,47 +274,7 @@ private void CommandBinding_DeleteFile2(object sender, ExecutedRoutedEventArgs e
if (res == MessageBoxResult.Yes)
{
Cursor = Cursors.Wait;
string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.DuplicateFileID, 2);
if (result.Length > 0)
MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
else
{
DuplicateFilesCollection.Remove(df);
FileCount = DuplicateFilesCollection.Count;
//RefreshDuplicateFiles();
}
}

}
}
catch (Exception ex)
{
Utils.ShowErrorMessage(ex);
}
finally
{
Cursor = Cursors.Arrow;
}
}

private void CommandBinding_DeleteFileDB(object sender, ExecutedRoutedEventArgs e)
{
object obj = e.Parameter;
if (obj == null) return;

try
{
if (obj.GetType() == typeof(VM_DuplicateFile))
{
VM_DuplicateFile df = obj as VM_DuplicateFile;

MessageBoxResult res = MessageBox.Show(string.Format(Shoko.Commons.Properties.Resources.DuplicateFiles_DeleteEntry),
Shoko.Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question);

if (res == MessageBoxResult.Yes)
{
Cursor = Cursors.Wait;
string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.DuplicateFileID, 0);
string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.File2VideoLocalPlaceID);
if (result.Length > 0)
MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
else
Expand Down

0 comments on commit 84fe58e

Please sign in to comment.