public void Execute(object parameter) { var p = GetParameter(parameter).Value; DesktopPanelToolService.LoadLayoutSettings(); if (p && AppSettings.EnableNotifications) NotificationBarService.Notify("settings have been loaded"); }
public void Execute(object parameter) { var p = GetParameter(parameter).Value; var path = AppSettings.SettingsSaveLastPath; if (path == null) { path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) , AppSettings.AppLocalDataFolderName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } var title = "Save layout settings"; var dial = new OpenFileDialog() { InitialDirectory = path, DefaultExt = AppSettings.SettingsFilesExt, Filter = AppSettings.SettingsFileDialogFilter, CheckFileExists = false, CheckPathExists = true, Title = title }; if (dial.ShowDialog() == DialogResult.OK) { var fn = dial.FileName; if (Path.GetExtension(fn) == string.Empty) { fn += AppSettings.SettingsFilesExt; } if (!File.Exists(fn) || w.MessageBox.Show( $"File {fn} already exists. Replace it ?", title, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.OK) == MessageBoxResult.OK) { DesktopPanelToolService.SaveSettingsAs(fn); if (p && AppSettings.EnableNotifications) { NotificationBarService.Notify("settings have been saved"); } } } }
protected override void OnExit(ExitEventArgs e) { try { base.OnExit(e); DesktopPanelToolService.SaveSettings(); } #if DEBUG catch (Exception ex) { DesktopPanelTool.Lib.Debug.WriteLine($"{ex}"); #else catch (Exception) { #endif } NotificationBarService.HideNotifyIcon(); // fix visual studio designer exception (bug) Environment.Exit(0); }
void InitializeServices() { DesktopPanelToolService.Initialize(); NotificationBarService.Initialize(DesktopPanelToolService.DesktopPanelToolViewModel); }