mirror of
https://github.com/ckaczor/FloatingStatusWindow.git
synced 2026-01-14 01:25:36 -05:00
Auto start support
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user