private void HotkeyGifBoxMDown(object sender, RoutedEventArgs e) { TextBox box = sender as TextBox; if (box == null) { return; } try { HotKeySelector sel = new HotKeySelector(); try { sel.Owner = this; } catch { } bool?result = sel.ShowDialog(); if (result == true) { FileIO.ShortcutGifKey = sel.key; HotkeyGifBox.Text = sel.key.ToString(); InstallerHelper.KillImgurSniper(false); InstallerHelper.StartImgurSniper(); } } catch { } }
//Save Changes Button private async void Save(object s, RoutedEventArgs e) { try { Cursor = Cursors.Wait; ConfigHelper.Save(); //Restart for applied changes InstallerHelper.KillImgurSniper(false); //If not Tray Service, do not start if (ConfigHelper.RunOnBoot) { try { InstallerHelper.StartImgurSniper(); } catch { await ErrorToast.ShowAsync(str.trayServiceNotRunning, TimeSpan.FromSeconds(3)); } } SuccessToast.Show(str.applied, TimeSpan.FromSeconds(2)); BtnSave.IsEnabled = false; } catch { ErrorToast.Show(str.couldNotApply, TimeSpan.FromSeconds(3)); } Cursor = Cursors.Arrow; }
//Command Line Args private async void Arguments() { string[] args = Environment.GetCommandLineArgs(); if (args.Contains("help")) { Hide(); Help(null, null); Close(); } if (args.Contains("update")) { Hide(); bool updateAvailable = await InstallerHelper.CheckForUpdates(this, true); if (updateAvailable) { Update(null, null); } else { Close(); } } if (args.Contains("troubleshooting")) { //Task.Delay for Open/Close Animations await Task.Delay(400); await ShowOkDialog(str.troubleshooting, str.troubleshootingTips); await Task.Delay(200); Close(); } }
private async void LanguageBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender is ComboBox box) { try { FileIO.Language = (box.SelectedItem as ComboBoxItem).Name; bool result = await ShowAskDialog(str.langChanged); if (result) { InstallerHelper.KillImgurSniper(false); Process.Start(Process.GetCurrentProcess().MainModule.FileName); Application.Current.Shutdown(); } } catch { box.SelectedIndex = 0; } } }
//Constructor public MainWindow() { InitializeComponent(); //Update Loading Indicator ShowProgressIndicator(); SetProgressStatus(str.initializing); //Check for Commandline Arguments Arguments(); //Create Documents\ImgurSniper Path if (!Directory.Exists(DocPath)) { Directory.CreateDirectory(DocPath); } //Initialize Helpers Helper = new InstallerHelper(ErrorToast); }
public MainWindow() { InitializeComponent(); this.Closing += WindowClosing; if (!Directory.Exists(_path)) { Directory.CreateDirectory(_path); } if (!Directory.Exists(_docPath)) { Directory.CreateDirectory(_docPath); } helper = new InstallerHelper(_path, error_toast, success_toast, this); _imgurhelper = new ImgurLoginHelper(error_toast, success_toast); error_toast.Show("Loading...", TimeSpan.FromSeconds(2)); Load(); }
//Constructor public MainWindow() { InitializeComponent(); //Update Loading Indicator loadingDesc.Content = str.initializing; //Check for Commandline Arguments Arguments(); //Create Documents\ImgurSniper Path if (!Directory.Exists(DocPath)) { Directory.CreateDirectory(DocPath); } //Initialize Helpers Helper = new InstallerHelper(Path, DocPath, error_toast, success_toast, this); _imgurhelper = new ImgurLoginHelper(error_toast, success_toast); //Load Config Loaded += delegate { Load(); }; }