Skip to content

Commit

Permalink
Show window when minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Jan 10, 2025
1 parent 356fc31 commit 320719e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 15 deletions.
64 changes: 57 additions & 7 deletions src/PicView.Avalonia.MacOS/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using PicView.Avalonia.StartUp;
using PicView.Avalonia.UI;
using PicView.Avalonia.ViewModels;
using PicView.Avalonia.WindowBehavior;
using PicView.Core.Config;
using PicView.Core.FileHandling;
using PicView.Core.Localization;
Expand Down Expand Up @@ -148,7 +149,14 @@ void Set()
}
else
{
_aboutWindow.Activate();
if (_aboutWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_aboutWindow);
}
else
{
_aboutWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -186,7 +194,14 @@ void Set()
}
else
{
_exifWindow.Activate();
if (_exifWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_exifWindow);
}
else
{
_exifWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -224,7 +239,14 @@ void Set()
}
else
{
_keybindingsWindow.Activate();
if (_keybindingsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_keybindingsWindow);
}
else
{
_keybindingsWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -260,7 +282,14 @@ void Set()
}
else
{
_settingsWindow.Activate();
if (_settingsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_settingsWindow);
}
else
{
_settingsWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();

Expand Down Expand Up @@ -296,7 +325,14 @@ void Set()
}
else
{
_effectsWindow.Activate();
if (_effectsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_effectsWindow);
}
else
{
_effectsWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down Expand Up @@ -331,7 +367,14 @@ void Set()
}
else
{
_singleImageResizeWindow.Activate();
if (_singleImageResizeWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_singleImageResizeWindow);
}
else
{
_singleImageResizeWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down Expand Up @@ -366,7 +409,14 @@ void Set()
}
else
{
_batchResizeWindow.Activate();
if (_batchResizeWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_batchResizeWindow);
}
else
{
_batchResizeWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down
64 changes: 57 additions & 7 deletions src/PicView.Avalonia.Win32/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using PicView.Avalonia.UI;
using PicView.Avalonia.ViewModels;
using PicView.Avalonia.Win32.Views;
using PicView.Avalonia.WindowBehavior;
using PicView.Core.Config;
using PicView.Core.FileHandling;
using PicView.Core.Localization;
Expand Down Expand Up @@ -191,7 +192,14 @@ void Set()
}
else
{
_aboutWindow.Activate();
if (_aboutWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_aboutWindow);
}
else
{
_aboutWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -229,7 +237,14 @@ void Set()
}
else
{
_exifWindow.Activate();
if (_exifWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_exifWindow);
}
else
{
_exifWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -267,7 +282,14 @@ void Set()
}
else
{
_keybindingsWindow.Activate();
if (_keybindingsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_keybindingsWindow);
}
else
{
_keybindingsWindow.Show();
}
}

_ = FunctionsHelper.CloseMenus();
Expand Down Expand Up @@ -303,7 +325,14 @@ void Set()
}
else
{
_settingsWindow.Activate();
if (_settingsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_settingsWindow);
}
else
{
_settingsWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();

Expand Down Expand Up @@ -339,7 +368,14 @@ void Set()
}
else
{
_singleImageResizeWindow.Activate();
if (_singleImageResizeWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_singleImageResizeWindow);
}
else
{
_singleImageResizeWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down Expand Up @@ -374,7 +410,14 @@ void Set()
}
else
{
_batchResizeWindow.Show();
if (_batchResizeWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_batchResizeWindow);
}
else
{
_batchResizeWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down Expand Up @@ -409,7 +452,14 @@ void Set()
}
else
{
_effectsWindow.Show();
if (_effectsWindow.WindowState == WindowState.Minimized)
{
WindowFunctions.ShowMinimizedWindow(_effectsWindow);
}
else
{
_effectsWindow.Show();
}
}
_= FunctionsHelper.CloseMenus();
}
Expand Down
10 changes: 9 additions & 1 deletion src/PicView.Avalonia/WindowBehavior/WindowFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ public static async Task WindowClosingBehavior(Window window)
Environment.Exit(0);
}

#region Window State Management
#region Window State

public static void ShowMinimizedWindow(Window window)
{
window.BringIntoView();
window.WindowState = WindowState.Normal;
window.Activate();
window.Focus();
}

public static async Task ToggleTopMost(MainViewModel vm)
{
Expand Down

0 comments on commit 320719e

Please sign in to comment.