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:
34
FloatingStatusWindowLibrary/StartManager.cs
Normal file
34
FloatingStatusWindowLibrary/StartManager.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user