Skip to content

Commit

Permalink
Improve tooltip message display when optimizing images
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 11, 2021
1 parent 70715d2 commit bb8b518
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions PicView/ImageHandling/ImageFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,8 @@ internal static async Task OptimizeImageAsyncWithErrorChecking()
{
if (Error_Handling.CheckOutOfRange()) { return; }

var preloadValue = Preloader.Get(Navigation.Pics[Navigation.FolderIndex]);
if (preloadValue == null)
{
await Preloader.AddAsync(Navigation.FolderIndex).ConfigureAwait(false);
}

bool toCenter = false;

var success = await OptimizeImageAsync(Navigation.Pics[Navigation.FolderIndex]).ConfigureAwait(false);

await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, () =>
{
toCenter = UC.QuickSettingsMenuOpen;
Expand All @@ -62,6 +54,8 @@ await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threa

Tooltip.ShowTooltipMessage(Application.Current.Resources["Applying"] as string, toCenter);

var success = await OptimizeImageAsync(Navigation.Pics[Navigation.FolderIndex]).ConfigureAwait(false);

if (success)
{
await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, () =>
Expand All @@ -73,6 +67,17 @@ await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threa
Tooltip.CloseToolTipMessage();
});
}
else
{
Tooltip.ShowTooltipMessage($"0%", toCenter);
return;
}

var preloadValue = Preloader.Get(Navigation.Pics[Navigation.FolderIndex]);
if (preloadValue == null)
{
await Preloader.AddAsync(Navigation.FolderIndex).ConfigureAwait(false);
}

var fileInfo = new System.IO.FileInfo(Navigation.Pics[Navigation.FolderIndex]);
var readablePrevSize = FileHandling.FileFunctions.GetSizeReadable(preloadValue.fileInfo.Length);
Expand Down

0 comments on commit bb8b518

Please sign in to comment.