1544587a10
- The navigation pane, window size/position/maximized state, and the process list filters, sort and columns now survive a restart. They live in ui-state.json, apart from settings.json, so they never mark the Settings page as unsaved or travel in exported configurations. A corrupt file falls back to defaults; tests write to a temp file. - Fixes the pane re-opening on every start (it was hard-coded open). - Tweaks use a native-looking Windows 11 switch (40x20 track, sliding thumb) with On/Off written beside it. - New test: every on/off setting survives save and reload.
54 lines
2.1 KiB
C#
54 lines
2.1 KiB
C#
namespace ThreadPilot
|
|
{
|
|
using System.Windows;
|
|
using ThreadPilot.Services;
|
|
|
|
public partial class MainWindow
|
|
{
|
|
// Puts the menu and the window back the way the user left them. A position that is now
|
|
// off-screen (unplugged monitor) is pulled back by EnsureDashboardVisibleOnScreen at startup.
|
|
private void RestoreUiState()
|
|
{
|
|
var state = UiStateStore.Current;
|
|
this.RootNavigation.IsPaneOpen = state.NavigationPaneOpen;
|
|
this.RootNavigation.PaneOpened += (_, _) => UiStateStore.Update(s => s with { NavigationPaneOpen = true });
|
|
this.RootNavigation.PaneClosed += (_, _) => UiStateStore.Update(s => s with { NavigationPaneOpen = false });
|
|
|
|
if (state.WindowWidth is > 0 && state.WindowHeight is > 0 && state.WindowLeft.HasValue && state.WindowTop.HasValue)
|
|
{
|
|
this.WindowStartupLocation = WindowStartupLocation.Manual;
|
|
this.Left = state.WindowLeft.Value;
|
|
this.Top = state.WindowTop.Value;
|
|
this.Width = state.WindowWidth.Value;
|
|
this.Height = state.WindowHeight.Value;
|
|
}
|
|
|
|
if (state.WindowMaximized)
|
|
{
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
private void SaveWindowPlacement()
|
|
{
|
|
// RestoreBounds is the normal-size rectangle even while maximized or minimized.
|
|
var bounds = this.WindowState == WindowState.Normal
|
|
? new Rect(this.Left, this.Top, this.ActualWidth, this.ActualHeight)
|
|
: this.RestoreBounds;
|
|
if (bounds.IsEmpty || bounds.Width <= 0 || bounds.Height <= 0 || double.IsNaN(bounds.Left))
|
|
{
|
|
return;
|
|
}
|
|
|
|
UiStateStore.Update(s => s with
|
|
{
|
|
WindowLeft = bounds.Left,
|
|
WindowTop = bounds.Top,
|
|
WindowWidth = bounds.Width,
|
|
WindowHeight = bounds.Height,
|
|
WindowMaximized = this.WindowState == WindowState.Maximized,
|
|
});
|
|
}
|
|
}
|
|
}
|