From 12ac49c192843bb47f35dcf986e700e049b4f97d Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Fri, 16 Feb 2018 22:41:18 -0500 Subject: [PATCH] Add context menu choice to reset window position/size --- Library/FloatingStatusWindow.cs | 20 ++++++++++++++++++-- Library/Properties/Resources.Designer.cs | 9 +++++++++ Library/Properties/Resources.resx | 11 +++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Library/FloatingStatusWindow.cs b/Library/FloatingStatusWindow.cs index a4a0bbf..b52e082 100644 --- a/Library/FloatingStatusWindow.cs +++ b/Library/FloatingStatusWindow.cs @@ -100,12 +100,20 @@ namespace FloatingStatusWindowLibrary optionsMenu.Items.Add(new Separator()); + menuItem = new MenuItem + { + Name = "contextMenuResetPosition", + Header = Resources.ContextMenuResetPosition + }; + menuItem.Click += HandleResetPositionMenuItemClick; + optionsMenu.Items.Add(menuItem); + menuItem = new MenuItem { Name = "contextMenuChangeAppearance", Header = Resources.ContextMenuChangeAppearance }; - menuItem.Click += HandleChangeAppearancemMenuItemClick; + menuItem.Click += HandleChangeAppearanceMenuItemClick; optionsMenu.Items.Add(menuItem); contextMenu.Items.Add(new Separator()); @@ -134,6 +142,14 @@ namespace FloatingStatusWindowLibrary _mainWindow.Show(); } + private void HandleResetPositionMenuItemClick(object sender, RoutedEventArgs e) + { + _mainWindow.Left = 0; + _mainWindow.Top = 0; + _mainWindow.Width = 300; + _mainWindow.Height = 300; + } + private void HandleWindowLockStateChanged(object sender, EventArgs e) { Save(); @@ -151,7 +167,7 @@ namespace FloatingStatusWindowLibrary Save(); } - private void HandleChangeAppearancemMenuItemClick(object sender, RoutedEventArgs e) + private void HandleChangeAppearanceMenuItemClick(object sender, RoutedEventArgs e) { var appearanceWindow = new AppearanceWindow(_mainWindow.WindowSettings); appearanceWindow.ShowDialog(); diff --git a/Library/Properties/Resources.Designer.cs b/Library/Properties/Resources.Designer.cs index 0ed1b35..374861e 100644 --- a/Library/Properties/Resources.Designer.cs +++ b/Library/Properties/Resources.Designer.cs @@ -168,6 +168,15 @@ namespace FloatingStatusWindowLibrary.Properties { } } + /// + /// Looks up a localized string similar to Reset Position. + /// + public static string ContextMenuResetPosition { + get { + return ResourceManager.GetString("ContextMenuResetPosition", resourceCulture); + } + } + /// /// Looks up a localized string similar to Settings.... /// diff --git a/Library/Properties/Resources.resx b/Library/Properties/Resources.resx index b82f344..9abfb5f 100644 --- a/Library/Properties/Resources.resx +++ b/Library/Properties/Resources.resx @@ -153,6 +153,9 @@ Refresh + + Reset Position + Settings... @@ -168,6 +171,10 @@ _Foreground color: + + + ..\Resources\gear.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + _Horizontal alignment: @@ -192,8 +199,4 @@ Window - - - ..\Resources\gear.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file