Skip to content

Commit

Permalink
quick delete of certain aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
yonixw committed Aug 4, 2023
1 parent 3317c6a commit 631d1ed
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
2 changes: 2 additions & 0 deletions MangaPrinter.WpfGUI/Dialogs/dlgChooseCutoffRatio.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<DockPanel Grid.Row="3" LastChildFill="False">
<Button DockPanel.Dock="Right" Margin="5" Padding="5"
Name="btnAccept" Click="BtnAccept_Click">Accept</Button>
<Button DockPanel.Dock="Right" Margin="5" Padding="5"
Name="btnSmartDel" Click="btnSmartDel_Click">Quick Delete</Button>
<Button DockPanel.Dock="Right" Margin="5" Padding="5" Background="LightPink"
Name="btnCancel" Click="BtnCancel_Click">Cancel</Button>
</DockPanel>
Expand Down
10 changes: 9 additions & 1 deletion MangaPrinter.WpfGUI/Dialogs/dlgChooseCutoffRatio.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public dlgChooseCutoffRatio()

private int maxCount = 1;

public bool doSmartDelete = false;

private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (InputBuckets != null && InputBuckets.Count > 0)
Expand Down Expand Up @@ -99,7 +101,7 @@ private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<d
BucketIndex = (int)sldCutoff.Value;

lstExampleItems.ItemsSource = null;
lstExampleItems.ItemsSource = InputBuckets[BucketIndex].bucketItemsDesc;
lstExampleItems.ItemsSource = InputBuckets[BucketIndex].bucketPagesDesc;

IEnumerable<double> _x2 = new double[] { InputBuckets[BucketIndex].value, InputBuckets[BucketIndex].value };
IEnumerable<double> _y2 = new double[] { 0, maxCount };
Expand All @@ -125,5 +127,11 @@ private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
}

private void btnSmartDel_Click(object sender, RoutedEventArgs e)
{
doSmartDelete = true;
DialogResult = false;
}
}
}
35 changes: 30 additions & 5 deletions MangaPrinter.WpfGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,12 @@ private IEnumerable<BucketInfo> plotData(IEnumerable<MangaChapter> chapters, int
var b = buckets.Last((bucket) => page.AspectRatio >= bucket.value);
//Console.WriteLine("{0}.{1}: {2}", page.Chapter.Name, page.Name, page.AspectRatio);
b.count++;
b.bucketItemsDesc.Add(
!page.IsDouble?
b.bucketPages.Add(page);
b.bucketPagesDesc.Add(!page.IsDouble ?
String.Format("{0}] {1}, p.{2} ({3})",
b.bucketItemsDesc.Count, page.Chapter.Name, page.ChildIndexStart, page.AspectRatio) :
b.bucketPagesDesc.Count, page.Chapter.Name, page.ChildIndexStart, page.AspectRatio) :
String.Format("{0}] {1}, p.{2}-p.{3} ({4})",
b.bucketItemsDesc.Count, page.Chapter.Name, page.ChildIndexStart, page.ChildIndexEnd, page.AspectRatio)
);
b.bucketPagesDesc.Count, page.Chapter.Name, page.ChildIndexStart, page.ChildIndexEnd, page.AspectRatio));
}

return buckets;
Expand All @@ -437,12 +436,38 @@ private void BtnNewCutoffRatio_Click(object sender, RoutedEventArgs e)
},
isProgressKnwon: false);
dlg.ShowDialog();

if ((dlg.DialogResult ?? false) && (dlg.InputBuckets != null) && (dlg.InputBuckets.Count > 0))
{
double newAspectCutoff = Math.Round(dlg.InputBuckets[dlg.BucketIndex].value, 2);
txtPageMaxWidth.Text = newAspectCutoff.ToString();
UpdateApectCutoff(newAspectCutoff);
}

if (!(dlg.DialogResult ?? false) && dlg.doSmartDelete
&& (dlg.InputBuckets != null) && (dlg.InputBuckets.Count > 0))
{
//dlg.InputBuckets[dlg.BucketIndex].bucketPages

dlgBluredImageListActions dlg2 = new dlgBluredImageListActions();
dlg2.CustomTitle = "Quick Delete pages (Aspect ratio)";

dlg2.Pages = new ObservableCollection<ActionMangaPage<bool>>(
dlg.InputBuckets[dlg.BucketIndex].bucketPages
.Select(_p => new ActionMangaPage<bool>() { Page = _p, Result = false })
);

if (dlg2.ShowDialog() ?? false)
{
dlg2.Pages
.Where(p => p.Result == true)
.ForEach(p => {
p.Page.Chapter.Pages.Remove(p.Page);
p.Page.Chapter.updateChapterStats();
});
}
}

}

private void UpdateApectCutoff(double newAspectCutoff)
Expand Down
8 changes: 5 additions & 3 deletions MangaPrinter.WpfGUI/Utils/BucketInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using MangaPrinter.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -10,6 +11,7 @@ public class BucketInfo {
public int index = 0;
public double value = 0;
public int count = 0;
public List<string> bucketItemsDesc = new List<string>();
public List<string> bucketPagesDesc = new List<string>();
public List<MangaPage> bucketPages = new List<MangaPage>();
};
}
}

0 comments on commit 631d1ed

Please sign in to comment.