diff --git a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs
index d00e619..977be44 100644
--- a/FloatingStatusWindowLibrary/FloatingStatusWindow.cs
+++ b/FloatingStatusWindowLibrary/FloatingStatusWindow.cs
@@ -9,7 +9,9 @@ namespace FloatingStatusWindowLibrary
{
private readonly MainWindow _mainWindow;
private readonly TaskbarIcon _taskbarIcon;
+
private readonly MenuItem _lockMenuItem;
+ private readonly MenuItem _autoStartMenuItem;
private readonly IWindowSource _windowSource;
@@ -20,6 +22,21 @@ 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",
@@ -81,6 +98,9 @@ namespace FloatingStatusWindowLibrary
private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
{
_lockMenuItem.IsChecked = _mainWindow.WindowSettings.Locked;
+
+ if (_autoStartMenuItem != null)
+ _autoStartMenuItem.IsChecked = StartManager.AutoStartEnabled;
}
public void SetText(string text)
diff --git a/FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj b/FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj
index 57092f8..41267fb 100644
--- a/FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj
+++ b/FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj
@@ -72,6 +72,7 @@
True
Resources.resx
+
PublicResXFileCodeGenerator
diff --git a/FloatingStatusWindowLibrary/IWindowSource.cs b/FloatingStatusWindowLibrary/IWindowSource.cs
index d8e7e74..d57b711 100644
--- a/FloatingStatusWindowLibrary/IWindowSource.cs
+++ b/FloatingStatusWindowLibrary/IWindowSource.cs
@@ -6,7 +6,6 @@ namespace FloatingStatusWindowLibrary
{
string Name { get; }
string WindowSettings { get; set; }
-
Icon Icon { get; }
}
}
diff --git a/FloatingStatusWindowLibrary/MainWindow.xaml b/FloatingStatusWindowLibrary/MainWindow.xaml
index dedd86e..a88e345 100644
--- a/FloatingStatusWindowLibrary/MainWindow.xaml
+++ b/FloatingStatusWindowLibrary/MainWindow.xaml
@@ -1,7 +1,6 @@
diff --git a/FloatingStatusWindowLibrary/MainWindow.xaml.cs b/FloatingStatusWindowLibrary/MainWindow.xaml.cs
index 8020fbd..68ce79b 100644
--- a/FloatingStatusWindowLibrary/MainWindow.xaml.cs
+++ b/FloatingStatusWindowLibrary/MainWindow.xaml.cs
@@ -69,8 +69,6 @@ namespace FloatingStatusWindowLibrary
// Apply the stored settings
_windowSettings.Apply();
-
- HtmlLabel.Text = "Testing";
}
protected override void OnLocationChanged(EventArgs e)
diff --git a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs
index c0af1c3..c8bafcf 100644
--- a/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs
+++ b/FloatingStatusWindowLibrary/Properties/Resources.Designer.cs
@@ -96,6 +96,15 @@ namespace FloatingStatusWindowLibrary.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Start with Windows.
+ ///
+ public static string ContextMenuAutoStart {
+ get {
+ return ResourceManager.GetString("ContextMenuAutoStart", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Change Appearance.
///
diff --git a/FloatingStatusWindowLibrary/Properties/Resources.resx b/FloatingStatusWindowLibrary/Properties/Resources.resx
index 8c72924..8f905c2 100644
--- a/FloatingStatusWindowLibrary/Properties/Resources.resx
+++ b/FloatingStatusWindowLibrary/Properties/Resources.resx
@@ -129,6 +129,9 @@
Change Appearance
+
+ Start with Windows
+
Change Appearance
diff --git a/FloatingStatusWindowLibrary/StartManager.cs b/FloatingStatusWindowLibrary/StartManager.cs
new file mode 100644
index 0000000..1e01afc
--- /dev/null
+++ b/FloatingStatusWindowLibrary/StartManager.cs
@@ -0,0 +1,34 @@
+using Common.Wpf.Extensions;
+using System;
+using System.Windows;
+
+namespace FloatingStatusWindowLibrary
+{
+ public static class StartManager
+ {
+ public delegate void AutoStartChangedEventHandler(bool autoStart);
+
+ public static event AutoStartChangedEventHandler AutoStartChanged = delegate { };
+
+ public static bool ManageAutoStart { get; set; }
+
+ private static bool _autoStartEnabled;
+ public static bool AutoStartEnabled
+ {
+ get
+ {
+ return ManageAutoStart && _autoStartEnabled;
+ }
+ set
+ {
+ if (!ManageAutoStart)
+ throw new InvalidOperationException("Cannot set AutoStartEnabled when ManageAutoStart is False");
+
+ _autoStartEnabled = value;
+
+ Application.Current.SetStartWithWindows(_autoStartEnabled);
+ AutoStartChanged(_autoStartEnabled);
+ }
+ }
+ }
+}
diff --git a/FloatingStatusWindowLibrary/WindowSettings.cs b/FloatingStatusWindowLibrary/WindowSettings.cs
index 86b5e1c..9c79164 100644
--- a/FloatingStatusWindowLibrary/WindowSettings.cs
+++ b/FloatingStatusWindowLibrary/WindowSettings.cs
@@ -1,6 +1,5 @@
using Common.Wpf.HtmlLabelControl;
using System;
-using System.Configuration;
using System.IO;
using System.Text;
using System.Windows;
diff --git a/TestWindow/App.config b/TestWindow/App.config
index 20444dd..de657c2 100644
--- a/TestWindow/App.config
+++ b/TestWindow/App.config
@@ -13,6 +13,9 @@
+
+ True
+
\ No newline at end of file
diff --git a/TestWindow/App.xaml.cs b/TestWindow/App.xaml.cs
index 1184bef..5d9791c 100644
--- a/TestWindow/App.xaml.cs
+++ b/TestWindow/App.xaml.cs
@@ -1,5 +1,7 @@
-using System.Collections.Generic;
+using FloatingStatusWindowLibrary;
+using System.Collections.Generic;
using System.Windows;
+using Settings = TestWindow.Properties.Settings;
namespace TestWindow
{
@@ -11,7 +13,20 @@ namespace TestWindow
{
base.OnStartup(e);
- _windowSourceList = new List { new WindowSource(), new WindowSource(), new WindowSource() };
+ StartManager.ManageAutoStart = true;
+ StartManager.AutoStartEnabled = Settings.Default.AutoStart;
+ StartManager.AutoStartChanged += (value =>
+ {
+ Settings.Default.AutoStart = value;
+ Settings.Default.Save();
+ });
+
+ _windowSourceList = new List
+ {
+ //new WindowSource(),
+ //new WindowSource(),
+ new WindowSource()
+ };
}
protected override void OnExit(ExitEventArgs e)
diff --git a/TestWindow/Properties/Settings.Designer.cs b/TestWindow/Properties/Settings.Designer.cs
index aadb094..6842f21 100644
--- a/TestWindow/Properties/Settings.Designer.cs
+++ b/TestWindow/Properties/Settings.Designer.cs
@@ -34,5 +34,17 @@ namespace TestWindow.Properties {
this["WindowSettings"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool AutoStart {
+ get {
+ return ((bool)(this["AutoStart"]));
+ }
+ set {
+ this["AutoStart"] = value;
+ }
+ }
}
}
diff --git a/TestWindow/Properties/Settings.settings b/TestWindow/Properties/Settings.settings
index a32f033..986b0b1 100644
--- a/TestWindow/Properties/Settings.settings
+++ b/TestWindow/Properties/Settings.settings
@@ -5,5 +5,8 @@
+
+ True
+
\ No newline at end of file