mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
Handle system tray menu items
Show main window Open preferences
This commit is contained in:
parent
dce6db3a13
commit
35eafd6784
2 changed files with 12 additions and 3 deletions
|
@ -37,7 +37,8 @@ namespace SourceGit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly Command OpenPreferenceCommand = new Command(_ => { OpenDialog(new Views.Preference()); });
|
public static readonly Command Unminimize = new Command(_ => ShowWindow());
|
||||||
|
public static readonly Command OpenPreferenceCommand = new Command(_ => { ShowWindow(); OpenDialog(new Views.Preference()); });
|
||||||
public static readonly Command OpenHotkeysCommand = new Command(_ => OpenDialog(new Views.Hotkeys()));
|
public static readonly Command OpenHotkeysCommand = new Command(_ => OpenDialog(new Views.Hotkeys()));
|
||||||
public static readonly Command OpenAppDataDirCommand = new Command(_ => Native.OS.OpenInFileManager(Native.OS.DataDir));
|
public static readonly Command OpenAppDataDirCommand = new Command(_ => Native.OS.OpenInFileManager(Native.OS.DataDir));
|
||||||
public static readonly Command OpenAboutCommand = new Command(_ => OpenDialog(new Views.About()));
|
public static readonly Command OpenAboutCommand = new Command(_ => OpenDialog(new Views.About()));
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace SourceGit
|
||||||
new TrayIcon {
|
new TrayIcon {
|
||||||
Icon = new WindowIcon(new Bitmap(AssetLoader.Open(new Uri("avares://SourceGit/App.ico")))),
|
Icon = new WindowIcon(new Bitmap(AssetLoader.Open(new Uri("avares://SourceGit/App.ico")))),
|
||||||
Menu = [
|
Menu = [
|
||||||
new NativeMenuItem(Text("Open")),
|
new NativeMenuItem(Text("Open")) {Command = Unminimize},
|
||||||
new NativeMenuItem(Text("Preference")) {Command = OpenPreferenceCommand},
|
new NativeMenuItem(Text("Preference")) {Command = OpenPreferenceCommand},
|
||||||
new NativeMenuItemSeparator(),
|
new NativeMenuItemSeparator(),
|
||||||
new NativeMenuItem(Text("Quit")) {Command = QuitCommand},
|
new NativeMenuItem(Text("Quit")) {Command = QuitCommand},
|
||||||
|
@ -214,7 +214,15 @@ namespace SourceGit
|
||||||
TrayIcon.SetIcons(Current, icons);
|
TrayIcon.SetIcons(Current, icons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void ShowWindow()
|
||||||
|
{
|
||||||
|
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
|
||||||
|
desktop.MainWindow.WindowState = WindowState.Normal;
|
||||||
|
desktop.MainWindow.Show();
|
||||||
|
desktop.MainWindow.BringIntoView();
|
||||||
|
desktop.MainWindow.Focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void SetFonts(string defaultFont, string monospaceFont, bool onlyUseMonospaceFontInEditor)
|
public static void SetFonts(string defaultFont, string monospaceFont, bool onlyUseMonospaceFontInEditor)
|
||||||
{
|
{
|
||||||
var app = Current as App;
|
var app = Current as App;
|
||||||
|
|
Loading…
Reference in a new issue