From 539b2283e7de3e700fe93198dc85a215b5463754 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Mon, 5 May 2014 17:32:39 -0400 Subject: [PATCH] Reorganize context menu --- .../FloatingStatusWindow.cs | 58 ++++++++++--------- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Resources.resx | 2 +- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs index 2424cd7..20d3398 100644 --- a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs +++ b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs @@ -9,7 +9,8 @@ namespace FloatingStatusWindowLibrary { public class FloatingStatusWindow : IDisposable { - public event EventHandler WindowResized = delegate { }; + public event EventHandler WindowResized = delegate { }; + public event EventHandler WindowClosed = delegate { }; private readonly MainWindow _mainWindow; private readonly TaskbarIcon _taskbarIcon; @@ -26,30 +27,8 @@ namespace FloatingStatusWindowLibrary var contextMenu = new ContextMenu(); contextMenu.Opened += HandleContextMenuOpened; - if (StartManager.ManageAutoStart) - { - _autoStartMenuItem = new MenuItem - { - Name = "contextMenuItemAutoStart", - IsChecked = StartManager.AutoStartEnabled, - Header = Properties.Resources.ContextMenuAutoStart - - }; - _autoStartMenuItem.Click += (sender, args) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled; - contextMenu.Items.Add(_autoStartMenuItem); - - contextMenu.Items.Add(new Separator()); - } - - var menuItem = new MenuItem - { - Name = "contextMenuChangeAppearance", - Header = Properties.Resources.ContextMenuChangeAppearance - }; - menuItem.Click += HandleChangeAppearancemMenuItemClick; - contextMenu.Items.Add(menuItem); - - contextMenu.Items.Add(new Separator()); + var optionsMenu = new MenuItem { Name = "contextMenuItemOptions", Header = "Window" }; + contextMenu.Items.Add(optionsMenu); _lockMenuItem = new MenuItem { @@ -58,7 +37,32 @@ namespace FloatingStatusWindowLibrary Header = Properties.Resources.ContextMenuLocked }; _lockMenuItem.Click += HandleLockedMenuItemClicked; - contextMenu.Items.Add(_lockMenuItem); + optionsMenu.Items.Add(_lockMenuItem); + + if (StartManager.ManageAutoStart) + { + optionsMenu.Items.Add(new Separator()); + + _autoStartMenuItem = new MenuItem + { + Name = "contextMenuItemAutoStart", + IsChecked = StartManager.AutoStartEnabled, + Header = Properties.Resources.ContextMenuAutoStart + + }; + _autoStartMenuItem.Click += (sender, args) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled; + optionsMenu.Items.Add(_autoStartMenuItem); + } + + optionsMenu.Items.Add(new Separator()); + + var menuItem = new MenuItem + { + Name = "contextMenuChangeAppearance", + Header = Properties.Resources.ContextMenuChangeAppearance + }; + menuItem.Click += HandleChangeAppearancemMenuItemClick; + optionsMenu.Items.Add(menuItem); contextMenu.Items.Add(new Separator()); @@ -97,6 +101,8 @@ namespace FloatingStatusWindowLibrary private void HandleMainWindowClosed(object sender, EventArgs e) { + WindowClosed(null, new EventArgs()); + _taskbarIcon.Dispose(); } diff --git a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs index c8bafcf..905e843 100644 --- a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs +++ b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs @@ -106,7 +106,7 @@ namespace FloatingStatusWindowLibrary.Properties { } /// - /// Looks up a localized string similar to Change Appearance. + /// Looks up a localized string similar to Change Appearance.... /// public static string ContextMenuChangeAppearance { get { diff --git a/FloatingStatusWindowLibrary/Properties/Resources.resx b/FloatingStatusWindowLibrary/Properties/Resources.resx index 8f905c2..0d2ddcc 100644 --- a/FloatingStatusWindowLibrary/Properties/Resources.resx +++ b/FloatingStatusWindowLibrary/Properties/Resources.resx @@ -133,7 +133,7 @@ Start with Windows - Change Appearance + Change Appearance... Exit