Skip to content

Commit

Permalink
fix null bug in quick dlg
Browse files Browse the repository at this point in the history
  • Loading branch information
yonixw committed Aug 4, 2023
1 parent 3006338 commit 3317c6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions MangaPrinter.Core/MangaObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class MangaPage : ModelBaseWpf
public MangaChapter Chapter { get { return _baseGet(); } set { _baseSet(value); } }
public int ChildIndexStart { get { return _baseGet(); } set { _baseSet(value); } }
public int ChildIndexEnd { get { return _baseGet(); } set { _baseSet(value); } }

public MangaPage()
{
Effects = new PageEffects();
}
}

public class ActionMangaPage<R> : ModelBaseWpf
Expand Down
8 changes: 5 additions & 3 deletions MangaPrinter.WpfGUI/Dialogs/dlgBluredImageListActions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace MangaPrinter.WpfGUI.Dialogs
/// </summary>
public partial class dlgBluredImageListActions : Window
{
private MangaPage _page;
private MangaPage _debounce_page;
public string CustomTitle {get;set;}

public ObservableCollection<ActionMangaPage<bool>> Pages { get; set; }
Expand Down Expand Up @@ -74,7 +74,7 @@ void LoadImage(MangaPage page)
}


System.Drawing.Bitmap bm = MagickImaging.BitmapFromUrlExt(_page);
System.Drawing.Bitmap bm = MagickImaging.BitmapFromUrlExt(page);
imgMain.DataContext = myImage = new MyImageBind()
{
Image = dlgBluredImage.Bitmap2BitmapImage(
Expand Down Expand Up @@ -125,13 +125,14 @@ private void DebounceTimer_Tick(object sender, EventArgs e)
debounceTimer.IsEnabled = false;

if (
_debounce_page != null &&
myImage != null &&
(int)(this.Width * myImage.Zoom) > 0 &&
(int)(this.Height * myImage.Zoom) > 0
)
{
imgMain.DataContext = null;
System.Drawing.Bitmap bm = MagickImaging.BitmapFromUrlExt(_page);
System.Drawing.Bitmap bm = MagickImaging.BitmapFromUrlExt(_debounce_page);
myImage.Image = dlgBluredImage.Bitmap2BitmapImage(
GraphicsUtils.sameAspectResize(bm,
(int)( myImage.Zoom *1.0f * bm.Width * (1.0f* cnvsImage.RenderSize.Height / bm.Height)),
Expand Down Expand Up @@ -239,6 +240,7 @@ private void lstPages_SelectionChanged(object sender, SelectionChangedEventArgs
if (lstPages.SelectedIndex > -1)
{
ActionMangaPage<bool> p = (ActionMangaPage<bool>)lstPages.SelectedItem;
_debounce_page = p.Page;
LoadImage(p.Page);
}
}
Expand Down
8 changes: 4 additions & 4 deletions MangaPrinter.WpfGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,19 +1279,19 @@ private void mnuQuickDelete_Click(object sender, RoutedEventArgs e)
// Add first/lest 3
if (addFirstLast3 && (i < 3 || i + 3 >= ch.Pages.Count))
{
pagesToInspect.Add(p);
if (!pagesToInspect.Contains(p)) pagesToInspect.Add(p);
}
else if (p.Page.WhiteBlackRatio < CoreConf.I.Common_Alerts_InkFillLow || p.Page.WhiteBlackRatio > CoreConf.I.Common_Alerts_InkFillHigh)
{
pagesToInspect.Add(p);
if (!pagesToInspect.Contains(p)) pagesToInspect.Add(p);
}
else if (p.Page.AspectRatio < CoreConf.I.Common_Alerts_TooVertical)
{
pagesToInspect.Add(p);
if (!pagesToInspect.Contains(p)) pagesToInspect.Add(p);
}
else if (p.Page.IsChecked || p.Page.Chapter.IsChecked)
{
pagesToInspect.Add(p);
if (!pagesToInspect.Contains(p)) pagesToInspect.Add(p);
}
i++;
});
Expand Down

0 comments on commit 3317c6a

Please sign in to comment.