Reorganize context menu

This commit is contained in:
2014-05-05 17:32:39 -04:00
parent 838cf322b5
commit 539b2283e7
3 changed files with 34 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ namespace FloatingStatusWindowLibrary
public class FloatingStatusWindow : IDisposable 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 MainWindow _mainWindow;
private readonly TaskbarIcon _taskbarIcon; private readonly TaskbarIcon _taskbarIcon;
@@ -26,30 +27,8 @@ namespace FloatingStatusWindowLibrary
var contextMenu = new ContextMenu(); var contextMenu = new ContextMenu();
contextMenu.Opened += HandleContextMenuOpened; contextMenu.Opened += HandleContextMenuOpened;
if (StartManager.ManageAutoStart) var optionsMenu = new MenuItem { Name = "contextMenuItemOptions", Header = "Window" };
{ contextMenu.Items.Add(optionsMenu);
_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());
_lockMenuItem = new MenuItem _lockMenuItem = new MenuItem
{ {
@@ -58,7 +37,32 @@ namespace FloatingStatusWindowLibrary
Header = Properties.Resources.ContextMenuLocked Header = Properties.Resources.ContextMenuLocked
}; };
_lockMenuItem.Click += HandleLockedMenuItemClicked; _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()); contextMenu.Items.Add(new Separator());
@@ -97,6 +101,8 @@ namespace FloatingStatusWindowLibrary
private void HandleMainWindowClosed(object sender, EventArgs e) private void HandleMainWindowClosed(object sender, EventArgs e)
{ {
WindowClosed(null, new EventArgs());
_taskbarIcon.Dispose(); _taskbarIcon.Dispose();
} }

View File

@@ -106,7 +106,7 @@ namespace FloatingStatusWindowLibrary.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Change Appearance. /// Looks up a localized string similar to Change Appearance....
/// </summary> /// </summary>
public static string ContextMenuChangeAppearance { public static string ContextMenuChangeAppearance {
get { get {

View File

@@ -133,7 +133,7 @@
<value>Start with Windows</value> <value>Start with Windows</value>
</data> </data>
<data name="ContextMenuChangeAppearance" xml:space="preserve"> <data name="ContextMenuChangeAppearance" xml:space="preserve">
<value>Change Appearance</value> <value>Change Appearance...</value>
</data> </data>
<data name="ContextMenuExit" xml:space="preserve"> <data name="ContextMenuExit" xml:space="preserve">
<value>Exit</value> <value>Exit</value>