From 8b0d2153b029bfefa178792f8badfe6e19647ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 8 Jun 2025 02:09:48 +0200 Subject: [PATCH] Save all window positions --- Properties/Settings.Designer.cs | 78 +++++++++++++++++++++++++++++++-- Properties/Settings.settings | 22 +++++++++- Views/MainWindow.xaml.cs | 2 + Views/Radios.xaml | 2 +- Views/Radios.xaml.cs | 3 ++ Views/Settings.xaml | 2 +- Views/Settings.xaml.cs | 4 +- Views/Shuffle.xaml | 2 +- Views/Shuffle.xaml.cs | 3 ++ 9 files changed, 109 insertions(+), 9 deletions(-) diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 50119fd..708bde1 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace unison.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -289,7 +289,7 @@ namespace unison.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("100")] + [global::System.Configuration.DefaultSettingValueAttribute("10")] public double MainWindowTop { get { return ((double)(this["MainWindowTop"])); @@ -301,7 +301,7 @@ namespace unison.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("100")] + [global::System.Configuration.DefaultSettingValueAttribute("10")] public double MainWindowLeft { get { return ((double)(this["MainWindowLeft"])); @@ -310,5 +310,77 @@ namespace unison.Properties { this["MainWindowLeft"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("10")] + public double RadiosWindowTop { + get { + return ((double)(this["RadiosWindowTop"])); + } + set { + this["RadiosWindowTop"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1000")] + public double RadiosWindowLeft { + get { + return ((double)(this["RadiosWindowLeft"])); + } + set { + this["RadiosWindowLeft"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("10")] + public double ShuffleWindowTop { + get { + return ((double)(this["ShuffleWindowTop"])); + } + set { + this["ShuffleWindowTop"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("330")] + public double ShuffleWindowLeft { + get { + return ((double)(this["ShuffleWindowLeft"])); + } + set { + this["ShuffleWindowLeft"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("330")] + public double SettingsWindowTop { + get { + return ((double)(this["SettingsWindowTop"])); + } + set { + this["SettingsWindowTop"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("600")] + public double SettingsWindowLeft { + get { + return ((double)(this["SettingsWindowLeft"])); + } + set { + this["SettingsWindowLeft"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 56e8a74..a2eb64f 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -69,10 +69,28 @@ 13 - 100 + 10 - 100 + 10 + + + 10 + + + 1000 + + + 10 + + + 330 + + + 330 + + + 600 \ No newline at end of file diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index a476f93..4449e65 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -30,7 +30,9 @@ namespace unison InitHwnd(); InitializeComponent(); DefaultState(true); + WindowState = WindowState.Minimized; + Top = Properties.Settings.Default.MainWindowTop; Left = Properties.Settings.Default.MainWindowLeft; diff --git a/Views/Radios.xaml b/Views/Radios.xaml index 76ef4f8..02c5e10 100644 --- a/Views/Radios.xaml +++ b/Views/Radios.xaml @@ -6,7 +6,7 @@ xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" xmlns:properties="clr-namespace:unison.Resources" mc:Ignorable="d" - Title="Radios" Closing="Window_Closing" SizeToContent="WidthAndHeight" ResizeMode="NoResize"> + Title="Radios" Closing="Window_Closing" LocationChanged="Window_LocationChanged" SizeToContent="WidthAndHeight" ResizeMode="NoResize"> diff --git a/Views/Radios.xaml.cs b/Views/Radios.xaml.cs index ed5fa98..ff0764e 100644 --- a/Views/Radios.xaml.cs +++ b/Views/Radios.xaml.cs @@ -26,6 +26,9 @@ namespace unison InitHwnd(); WindowState = WindowState.Minimized; + + Top = Properties.Settings.Default.RadiosWindowTop; + Left = Properties.Settings.Default.RadiosWindowLeft; } public async void Initialize() diff --git a/Views/Settings.xaml b/Views/Settings.xaml index e8589eb..72858fe 100644 --- a/Views/Settings.xaml +++ b/Views/Settings.xaml @@ -6,7 +6,7 @@ xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" xmlns:properties="clr-namespace:unison.Resources" xmlns:sys="clr-namespace:System;assembly=System.Runtime" mc:Ignorable="d" - Closing="Window_Closing" Title="{x:Static properties:Resources.Settings}" ResizeMode="CanMinimize" Icon="/Resources/icon-full.ico" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight"> + Title="{x:Static properties:Resources.Settings}" Closing="Window_Closing" LocationChanged="Window_LocationChanged" ResizeMode="CanMinimize" Icon="/Resources/icon-full.ico" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight"> diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs index bef8415..d753b5b 100644 --- a/Views/Settings.xaml.cs +++ b/Views/Settings.xaml.cs @@ -45,11 +45,13 @@ namespace unison { InitHwnd(); InitializeComponent(); + Initialize(); DataContext = this; WindowState = WindowState.Minimized; - Initialize(); + Top = Properties.Settings.Default.SettingsWindowTop; + Left = Properties.Settings.Default.SettingsWindowLeft; } void Initialize() diff --git a/Views/Shuffle.xaml b/Views/Shuffle.xaml index cc8d78d..73507fa 100644 --- a/Views/Shuffle.xaml +++ b/Views/Shuffle.xaml @@ -6,7 +6,7 @@ xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" xmlns:properties="clr-namespace:unison.Resources" xmlns:sys="clr-namespace:System;assembly=System.Runtime" mc:Ignorable="d" - Title="Shuffle" Closing="Window_Closing" SizeToContent="WidthAndHeight" ResizeMode="NoResize"> + Title="Shuffle" Closing="Window_Closing" LocationChanged="Window_LocationChanged" SizeToContent="WidthAndHeight" ResizeMode="NoResize"> diff --git a/Views/Shuffle.xaml.cs b/Views/Shuffle.xaml.cs index b1e8706..3da49ef 100644 --- a/Views/Shuffle.xaml.cs +++ b/Views/Shuffle.xaml.cs @@ -41,6 +41,9 @@ namespace unison WindowState = WindowState.Minimized; + Top = Properties.Settings.Default.ShuffleWindowTop; + Left = Properties.Settings.Default.ShuffleWindowLeft; + _mpd = (MPDHandler)Application.Current.Properties["mpd"]; _shuffle = (ShuffleHandler)Application.Current.Properties["shuffle"]; }