From 7be7af59800aac2d6f9c4bd443d488299642eb5a Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Thu, 22 Feb 2018 12:03:53 -0500 Subject: [PATCH] Add support for an about menu --- Library/FloatingStatusWindow.cs | 9 +++++++++ Library/IWindowSource.cs | 2 ++ Library/Properties/Resources.Designer.cs | 9 +++++++++ Library/Properties/Resources.resx | 3 +++ TestWindow/WindowSource1.cs | 8 ++++++++ TestWindow/WindowSource2.cs | 8 ++++++++ TestWindow/WindowSource3.cs | 8 ++++++++ TestWindow/WindowSource4.cs | 8 ++++++++ 8 files changed, 55 insertions(+) diff --git a/Library/FloatingStatusWindow.cs b/Library/FloatingStatusWindow.cs index b52e082..4cf4666 100644 --- a/Library/FloatingStatusWindow.cs +++ b/Library/FloatingStatusWindow.cs @@ -118,6 +118,15 @@ namespace FloatingStatusWindowLibrary contextMenu.Items.Add(new Separator()); + if (_windowSource.HasAboutMenu) + { + menuItem = new MenuItem { Header = Resources.ContextMenuAbout }; + menuItem.Click += (sender, args) => _windowSource.ShowAbout(); + contextMenu.Items.Add(menuItem); + + contextMenu.Items.Add(new Separator()); + } + menuItem = new MenuItem { Name = "contextMenuItemExit", diff --git a/Library/IWindowSource.cs b/Library/IWindowSource.cs index 35adca3..4567313 100644 --- a/Library/IWindowSource.cs +++ b/Library/IWindowSource.cs @@ -10,8 +10,10 @@ namespace FloatingStatusWindowLibrary bool HasSettingsMenu { get; } bool HasRefreshMenu { get; } + bool HasAboutMenu { get; } void ShowSettings(); void Refresh(); + void ShowAbout(); } } diff --git a/Library/Properties/Resources.Designer.cs b/Library/Properties/Resources.Designer.cs index e8803a2..b3f436e 100644 --- a/Library/Properties/Resources.Designer.cs +++ b/Library/Properties/Resources.Designer.cs @@ -105,6 +105,15 @@ namespace FloatingStatusWindowLibrary.Properties { } } + /// + /// Looks up a localized string similar to About. + /// + public static string ContextMenuAbout { + get { + return ResourceManager.GetString("ContextMenuAbout", resourceCulture); + } + } + /// /// Looks up a localized string similar to Start with Windows. /// diff --git a/Library/Properties/Resources.resx b/Library/Properties/Resources.resx index f49de81..0237748 100644 --- a/Library/Properties/Resources.resx +++ b/Library/Properties/Resources.resx @@ -132,6 +132,9 @@ Change Appearance + + About + Start with Windows diff --git a/TestWindow/WindowSource1.cs b/TestWindow/WindowSource1.cs index 3e8c6bb..8092ae8 100644 --- a/TestWindow/WindowSource1.cs +++ b/TestWindow/WindowSource1.cs @@ -1,6 +1,7 @@ using FloatingStatusWindowLibrary; using System; using System.Globalization; +using System.Reflection; using System.Timers; using System.Windows.Threading; @@ -53,6 +54,13 @@ namespace TestWindow get { return true; } } + public bool HasAboutMenu => true; + + public void ShowAbout() + { + _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString()); + } + public void ShowSettings() { diff --git a/TestWindow/WindowSource2.cs b/TestWindow/WindowSource2.cs index 1087d39..b7b0a68 100644 --- a/TestWindow/WindowSource2.cs +++ b/TestWindow/WindowSource2.cs @@ -1,6 +1,7 @@ using FloatingStatusWindowLibrary; using System; using System.Globalization; +using System.Reflection; using System.Timers; using System.Windows.Threading; @@ -53,6 +54,13 @@ namespace TestWindow get { return true; } } + public bool HasAboutMenu => true; + + public void ShowAbout() + { + _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString()); + } + public void ShowSettings() { diff --git a/TestWindow/WindowSource3.cs b/TestWindow/WindowSource3.cs index 50a35b2..95a9d41 100644 --- a/TestWindow/WindowSource3.cs +++ b/TestWindow/WindowSource3.cs @@ -1,6 +1,7 @@ using FloatingStatusWindowLibrary; using System; using System.Globalization; +using System.Reflection; using System.Timers; using System.Windows.Threading; @@ -53,6 +54,13 @@ namespace TestWindow get { return true; } } + public bool HasAboutMenu => true; + + public void ShowAbout() + { + _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString()); + } + public void ShowSettings() { diff --git a/TestWindow/WindowSource4.cs b/TestWindow/WindowSource4.cs index 949ecc2..585dfc9 100644 --- a/TestWindow/WindowSource4.cs +++ b/TestWindow/WindowSource4.cs @@ -1,6 +1,7 @@ using FloatingStatusWindowLibrary; using System; using System.Globalization; +using System.Reflection; using System.Timers; using System.Windows.Threading; @@ -53,6 +54,13 @@ namespace TestWindow get { return true; } } + public bool HasAboutMenu => true; + + public void ShowAbout() + { + _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString()); + } + public void ShowSettings() {