From 97cd3ce9dd23f0c70d2680ffa6919aa180b25ae8 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Fri, 27 Jan 2017 15:38:09 -0500 Subject: [PATCH] Add options for settings and refresh menus --- .../FloatingStatusWindow.cs | 22 ++++++++++++++++++- FloatingStatusWindowLibrary/IWindowSource.cs | 6 +++++ .../Properties/Resources.Designer.cs | 20 ++++++++++++++++- .../Properties/Resources.resx | 6 +++++ TestWindow/WindowSource1.cs | 20 +++++++++++++++++ TestWindow/WindowSource2.cs | 20 +++++++++++++++++ TestWindow/WindowSource3.cs | 20 +++++++++++++++++ TestWindow/WindowSource4.cs | 20 +++++++++++++++++ 8 files changed, 132 insertions(+), 2 deletions(-) diff --git a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs index 1c89575..031e32d 100644 --- a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs +++ b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs @@ -31,10 +31,30 @@ namespace FloatingStatusWindowLibrary var contextMenu = new ContextMenu(); contextMenu.Opened += HandleContextMenuOpened; + MenuItem menuItem; + + if (_windowSource.HasSettingsMenu) + { + menuItem = new MenuItem { Header = Resources.ContextMenuSettings }; + menuItem.Click += (sender, args) => _windowSource.ShowSettings(); + contextMenu.Items.Add(menuItem); + + contextMenu.Items.Add(new Separator()); + } + + if (_windowSource.HasRefreshMenu) + { + menuItem = new MenuItem { Header = Resources.ContextMenuRefresh }; + menuItem.Click += (sender, args) => _windowSource.Refresh(); + contextMenu.Items.Add(menuItem); + + contextMenu.Items.Add(new Separator()); + } + _allWindowsMenuItem = new MenuItem { Header = Resources.AllWindowsMenu }; contextMenu.Items.Add(_allWindowsMenuItem); - var menuItem = new MenuItem { Header = Resources.ContextMenuLock }; + menuItem = new MenuItem { Header = Resources.ContextMenuLock }; menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(true); _allWindowsMenuItem.Items.Add(menuItem); diff --git a/FloatingStatusWindowLibrary/IWindowSource.cs b/FloatingStatusWindowLibrary/IWindowSource.cs index d57b711..35adca3 100644 --- a/FloatingStatusWindowLibrary/IWindowSource.cs +++ b/FloatingStatusWindowLibrary/IWindowSource.cs @@ -7,5 +7,11 @@ namespace FloatingStatusWindowLibrary string Name { get; } string WindowSettings { get; set; } Icon Icon { get; } + + bool HasSettingsMenu { get; } + bool HasRefreshMenu { get; } + + void ShowSettings(); + void Refresh(); } } diff --git a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs index 5760027..d44e75b 100644 --- a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs +++ b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -159,6 +159,24 @@ namespace FloatingStatusWindowLibrary.Properties { } } + /// + /// Looks up a localized string similar to Refresh. + /// + public static string ContextMenuRefresh { + get { + return ResourceManager.GetString("ContextMenuRefresh", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settings.... + /// + public static string ContextMenuSettings { + get { + return ResourceManager.GetString("ContextMenuSettings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Unlock. /// diff --git a/FloatingStatusWindowLibrary/Properties/Resources.resx b/FloatingStatusWindowLibrary/Properties/Resources.resx index e889322..0cdd187 100644 --- a/FloatingStatusWindowLibrary/Properties/Resources.resx +++ b/FloatingStatusWindowLibrary/Properties/Resources.resx @@ -150,6 +150,12 @@ Locked + + Refresh + + + Settings... + Unlock diff --git a/TestWindow/WindowSource1.cs b/TestWindow/WindowSource1.cs index 1effd97..3e8c6bb 100644 --- a/TestWindow/WindowSource1.cs +++ b/TestWindow/WindowSource1.cs @@ -48,6 +48,26 @@ namespace TestWindow get { return Properties.Resources.ApplicationIcon; } } + public bool HasSettingsMenu + { + get { return true; } + } + + public void ShowSettings() + { + + } + + public bool HasRefreshMenu + { + get { return true; } + } + + public void Refresh() + { + + } + public string WindowSettings { get diff --git a/TestWindow/WindowSource2.cs b/TestWindow/WindowSource2.cs index c07e848..1087d39 100644 --- a/TestWindow/WindowSource2.cs +++ b/TestWindow/WindowSource2.cs @@ -48,6 +48,26 @@ namespace TestWindow get { return Properties.Resources.ApplicationIcon; } } + public bool HasSettingsMenu + { + get { return true; } + } + + public void ShowSettings() + { + + } + + public bool HasRefreshMenu + { + get { return true; } + } + + public void Refresh() + { + + } + public string WindowSettings { get diff --git a/TestWindow/WindowSource3.cs b/TestWindow/WindowSource3.cs index 0b158cc..50a35b2 100644 --- a/TestWindow/WindowSource3.cs +++ b/TestWindow/WindowSource3.cs @@ -48,6 +48,26 @@ namespace TestWindow get { return Properties.Resources.ApplicationIcon; } } + public bool HasSettingsMenu + { + get { return true; } + } + + public void ShowSettings() + { + + } + + public bool HasRefreshMenu + { + get { return true; } + } + + public void Refresh() + { + + } + public string WindowSettings { get diff --git a/TestWindow/WindowSource4.cs b/TestWindow/WindowSource4.cs index 8ca2faa..949ecc2 100644 --- a/TestWindow/WindowSource4.cs +++ b/TestWindow/WindowSource4.cs @@ -48,6 +48,26 @@ namespace TestWindow get { return Properties.Resources.ApplicationIcon; } } + public bool HasSettingsMenu + { + get { return true; } + } + + public void ShowSettings() + { + + } + + public bool HasRefreshMenu + { + get { return true; } + } + + public void Refresh() + { + + } + public string WindowSettings { get