mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-13 02:00:25 +08:00
refactor: simplify tray menu ctor calling
This commit is contained in:
@@ -35,19 +35,7 @@ internal partial class TrayIconManager : IDisposable
|
|||||||
|
|
||||||
private readonly TrayIconHost _icon;
|
private readonly TrayIconHost _icon;
|
||||||
|
|
||||||
private readonly TrayMenuItem _itemAutorun =
|
private readonly TrayMenuItem _itemAutorun = null!;
|
||||||
new()
|
|
||||||
{
|
|
||||||
Header = TranslationHelper.Get("Icon_RunAtStartup"),
|
|
||||||
Command = new RelayCommand(() =>
|
|
||||||
{
|
|
||||||
if (AutoStartupHelper.IsAutorun())
|
|
||||||
AutoStartupHelper.RemoveAutorunShortcut();
|
|
||||||
else
|
|
||||||
AutoStartupHelper.CreateAutorunShortcut();
|
|
||||||
}),
|
|
||||||
IsEnabled = !App.IsUWP,
|
|
||||||
};
|
|
||||||
|
|
||||||
private TrayIconManager()
|
private TrayIconManager()
|
||||||
{
|
{
|
||||||
@@ -79,7 +67,18 @@ internal partial class TrayIconManager : IDisposable
|
|||||||
Header = TranslationHelper.Get("Icon_OpenDataFolder"),
|
Header = TranslationHelper.Get("Icon_OpenDataFolder"),
|
||||||
Command = new RelayCommand(() => Process.Start("explorer.exe", SettingHelper.LocalDataPath)),
|
Command = new RelayCommand(() => Process.Start("explorer.exe", SettingHelper.LocalDataPath)),
|
||||||
},
|
},
|
||||||
_itemAutorun,
|
_itemAutorun = new TrayMenuItem()
|
||||||
|
{
|
||||||
|
Header = TranslationHelper.Get("Icon_RunAtStartup"),
|
||||||
|
Command = new RelayCommand(() =>
|
||||||
|
{
|
||||||
|
if (AutoStartupHelper.IsAutorun())
|
||||||
|
AutoStartupHelper.RemoveAutorunShortcut();
|
||||||
|
else
|
||||||
|
AutoStartupHelper.CreateAutorunShortcut();
|
||||||
|
}),
|
||||||
|
IsEnabled = !App.IsUWP,
|
||||||
|
},
|
||||||
new TrayMenuItem()
|
new TrayMenuItem()
|
||||||
{
|
{
|
||||||
Header = TranslationHelper.Get("Icon_Restart"),
|
Header = TranslationHelper.Get("Icon_Restart"),
|
||||||
@@ -94,7 +93,10 @@ internal partial class TrayIconManager : IDisposable
|
|||||||
IsVisible = SettingHelper.Get("ShowTrayIcon", true)
|
IsVisible = SettingHelper.Get("ShowTrayIcon", true)
|
||||||
};
|
};
|
||||||
|
|
||||||
_icon.RightDown += (sender, e) => { _itemAutorun.IsChecked = AutoStartupHelper.IsAutorun(); };
|
_icon.RightDown += (_, _) =>
|
||||||
|
{
|
||||||
|
_itemAutorun.IsChecked = AutoStartupHelper.IsAutorun();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|||||||
Reference in New Issue
Block a user