Skip to content

Commit

Permalink
Some cleanup and possible bug fix in DeleteFilesForm
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Jan 27, 2024
1 parent 293f1d6 commit 74b12a3
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions Shoko.Desktop/Forms/DeleteFilesForm.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,14 @@ private void HandleEsc(object sender, KeyEventArgs e)

private void HandleCheck(object sender, RoutedEventArgs e)
{
CheckBox cb = sender as CheckBox;

if (cb.Name == "cb_AutoClose_DeleteFilesForm")
if (sender is CheckBox { Name: "cb_AutoClose_DeleteFilesForm" })
{
AppSettings.AutoClose_DeleteFilesForm = true;
}
}
private void HandleUnchecked(object sender, RoutedEventArgs e)
{
CheckBox cb = sender as CheckBox;

if (cb.Name == "cb_AutoClose_DeleteFilesForm")
if (sender is CheckBox { Name: "cb_AutoClose_DeleteFilesForm" })
{
AppSettings.AutoClose_DeleteFilesForm = false;
}
Expand All @@ -149,8 +145,8 @@ void DeleteFilesForm_Closing(object sender, CancelEventArgs e)

void btnOK_Click(object sender, RoutedEventArgs e)
{
string msg = string.Format(Commons.Properties.Resources.DeleteFiles_Confirm, vids.SelectMany(a => a.Places).Count());
MessageBoxResult res = MessageBox.Show(msg, Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);
var msg = string.Format(Commons.Properties.Resources.DeleteFiles_Confirm, vids.SelectMany(a => a.Places).Count());
var res = MessageBox.Show(msg, Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (res == MessageBoxResult.Yes)
{
Expand Down Expand Up @@ -189,18 +185,18 @@ void deleteFilesWorker_DoWork(object sender, DoWorkEventArgs e)
{
if (vids == null) return;

int i = 0;
List<string> errors = new List<string>();
List<CL_VideoLocal_Place[]> files = vids.SelectMany(a => a.Places).GroupBy(a => Path.GetDirectoryName(a.FilePath))
var i = 0;
var errors = new List<string>();
var files = vids.SelectMany(a => a.Places).GroupBy(a => Path.GetDirectoryName(a.FilePath))
.Select(a => a.ToArray()).ToList();
int total = files.Sum(a => a.Length);
foreach (CL_VideoLocal_Place[] vid in files)
var total = files.Sum(a => a.Length);
foreach (var vid in files)
{
for (int index = 0; index < vid.Length; index++)
for (var index = 0; index < vid.Length; index++)
{
var n = vid[index];
i++;
string msg = string.Format(Commons.Properties.Resources.DeleteFiles_Deleting, i, total);
var msg = string.Format(Commons.Properties.Resources.DeleteFiles_Deleting, i, total);
deleteFilesWorker.ReportProgress(0, msg);
try
{
Expand Down Expand Up @@ -240,7 +236,9 @@ public void Init(int animeID, CL_GroupVideoQuality gvq)
{

vids = VM_ShokoServer.Instance.ShokoServices.GetFilesByGroupAndResolution(AnimeID,
string.IsNullOrEmpty(GroupVideoQuality.GroupName) ? "null" : GroupVideoQuality.GroupName, GroupVideoQuality.Resolution, GroupVideoQuality.VideoSource, GroupVideoQuality.VideoBitDepth, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList<VM_VideoDetailed>();
string.IsNullOrEmpty(GroupVideoQuality.GroupName) ? "null" : GroupVideoQuality.GroupName,
GroupVideoQuality.Resolution, GroupVideoQuality.VideoSource, GroupVideoQuality.VideoBitDepth,
VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList<VM_VideoDetailed>();
FileCount = vids.Count;
lbFiles.ItemsSource = vids;
GroupName = GroupVideoQuality.GroupName;
Expand Down Expand Up @@ -268,7 +266,8 @@ public void Init(int animeID, VM_GroupFileSummary gfs)
try
{
vids = VM_ShokoServer.Instance.ShokoServices.GetFilesByGroup(AnimeID,
GroupFileSummary.GroupName, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList<VM_VideoDetailed>();
string.IsNullOrEmpty(GroupFileSummary.GroupName) ? "null" : GroupFileSummary.GroupName,
VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList<VM_VideoDetailed>();

FileCount = vids.Count;
lbFiles.ItemsSource = vids;
Expand Down

0 comments on commit 74b12a3

Please sign in to comment.