private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!Settings.CanCloseWindow) { ShowInTaskbar = !ShowInTaskbar; e.Cancel = true; MainVM.Hide(); return; } SysTray.Close(); string json = JsonConvert.SerializeObject(Settings, Formatting.Indented); using (StreamWriter stream = new StreamWriter(SettingsPath)) { stream.Write(json); } Log.Trace("Settings saved"); }