private void Window_Loaded(object sender, RoutedEventArgs e) { // Load and assign saved hotkeys var keyBind = new KeyBinding(); string setting; bool gotHotkeyException = false; // Very crappy check for every hotkey // TODO: refactor and add friendly exception handling try { setting = Settings.Default.Hotkey_CaptureArea; if (setting != null && setting != string.Empty) { keyBind.FromString(setting); HotkeyManager.Current.AddOrReplace("CaptureArea", keyBind.Key, keyBind.ModifierKeys, PublishDesktopHotkey); } } catch (NHotkey.HotkeyAlreadyRegisteredException exception) { HotkeyManager.Current.Remove(exception.Name); gotHotkeyException = true; } try { setting = Settings.Default.Hotkey_PublishClip; if (setting != null && setting != string.Empty) { keyBind.FromString(setting); HotkeyManager.Current.AddOrReplace("PublishClip", keyBind.Key, keyBind.ModifierKeys, PublishClipHotkey); } } catch (NHotkey.HotkeyAlreadyRegisteredException exception) { HotkeyManager.Current.Remove(exception.Name); gotHotkeyException = true; } try { setting = Settings.Default.Hotkey_PublishFile; if (setting != null && setting != string.Empty) { keyBind.FromString(setting); HotkeyManager.Current.AddOrReplace("PublishFile", keyBind.Key, keyBind.ModifierKeys, PublishClipHotkey); } } catch (NHotkey.HotkeyAlreadyRegisteredException exception) { HotkeyManager.Current.Remove(exception.Name); gotHotkeyException = true; } // Prompt message box to alert about hotkeys if (gotHotkeyException) { if (MessageBox.Show("Some of the hotkeys are disabled because they are already registered somewhere else. Do you want to change them now? ('Yes' opens Settings window)", "Hotkey already registered.", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes) { new SettingsWindow(); } } // Suggest user to log in if (Settings.Default.Username == string.Empty) { if (MessageBox.Show("To upload something you'll need to log in from installed app (Tray Icon -> Settings). Would you like to do it now?", "Don't forget to log in!", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.Yes) == MessageBoxResult.Yes) { new SettingsWindow(); } } }