private async void RunOnBoot_Checkbox(object sender, RoutedEventArgs e) { if (sender is CheckBox box) { ConfigHelper.RunOnBoot = box.IsChecked == true; EnableSave(); //Run proecess if not running try { bool choice = box.IsChecked == true; //Show Dialog on disabling if (box.IsChecked == false) { choice = !(await Dialog.ShowAskDialog(strings.disablingTrayWarning)); RunOnBoot.IsChecked = choice; } InstallerHelper.Autostart(choice); } catch { await Dialog.ShowOkDialog(strings.error, strings.trayServiceStartFail); } } }
private async void Load() { _window?.ShowProgressIndicator(); //Update Loading Indicator _window?.SetProgressStatus(strings.loadConf); try { Settings settings = ConfigHelper.JsonConfig; bool usePrint = settings.UsePrint; bool runOnBoot = settings.RunOnBoot; bool autoUpdate = settings.AutoUpdate; string language = settings.Language; Key imgKey = settings.ShortcutImgKey; Key gifKey = settings.ShortcutGifKey; //Use Print Key instead of default Shortcut PrintKeyBox.IsChecked = usePrint; //Run ImgurSniper on boot if (runOnBoot) { RunOnBoot.IsChecked = true; InstallerHelper.Autostart(true); } //Auto search for Updates if (autoUpdate) { AutoUpdateBox.IsChecked = true; } //Set correct Language for Current Language Box switch (language) { case "en": LanguageBox.SelectedItem = En; break; case "de": LanguageBox.SelectedItem = De; break; } LanguageBox.SelectionChanged += LanguageBox_SelectionChanged; //GIF Hotkey HotkeyGifBox.Text = gifKey.ToString(); //Image Hotkey HotkeyImgBox.Text = imgKey.ToString(); } catch { await Dialog.ShowOkDialog(strings.couldNotLoad, string.Format(strings.errorConfig, ConfigHelper.ConfigPath)); } //Search for Updates if (_window != null) { _window.SetProgressStatus(strings.checkingUpdate); BtnUpdate.IsEnabled = await InstallerHelper.CheckForUpdates(_window, false); } //Remove Loading Indicator _window?.HideProgressIndicator(); }