mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
Handle window closing event
This commit is contained in:
parent
35eafd6784
commit
bae81d20d5
2 changed files with 13 additions and 3 deletions
|
@ -210,7 +210,7 @@ namespace SourceGit
|
|||
]
|
||||
}
|
||||
};
|
||||
|
||||
icons[0].Clicked += (_, _) => ShowWindow();
|
||||
TrayIcon.SetIcons(Current, icons);
|
||||
}
|
||||
}
|
||||
|
@ -576,11 +576,15 @@ namespace SourceGit
|
|||
if (desktop.Args != null && desktop.Args.Length == 1 && Directory.Exists(desktop.Args[0]))
|
||||
startupRepo = desktop.Args[0];
|
||||
|
||||
var pref = ViewModels.Preference.Instance;
|
||||
if (pref.SystemTrayIcon) {
|
||||
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||
}
|
||||
|
||||
_launcher = new ViewModels.Launcher(startupRepo);
|
||||
desktop.MainWindow = new Views.Launcher() { DataContext = _launcher };
|
||||
|
||||
#if !DISABLE_UPDATE_DETECTION
|
||||
var pref = ViewModels.Preference.Instance;
|
||||
if (pref.ShouldCheck4UpdateOnStartup())
|
||||
Check4Update();
|
||||
#endif
|
||||
|
|
|
@ -255,7 +255,13 @@ namespace SourceGit.Views
|
|||
|
||||
protected override void OnClosing(WindowClosingEventArgs e)
|
||||
{
|
||||
var pref = ViewModels.Preference.Instance;
|
||||
if (pref.SystemTrayIcon) {
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
} else {
|
||||
(DataContext as ViewModels.Launcher)?.Quit(Width, Height);
|
||||
}
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue