//============ EVENTS ============ #region Events private void OnKeybindChanged(object sender, KeybindChangedEventArgs e) { // Stop cannot be unbound for safety reasons if (sender == keybindReaderStop) { if (keybindReaderStop.Keybind == Keybind.None) { TriggerMessageBox.Show(this, MessageIcon.Warning, "Cannot unassign the stop keybind!", "Can't Unbind"); keybindReaderStop.Keybind = e.Previous; return; } } // Make sure the keybind isn't already in use if (e.New != Keybind.None) { string name = ""; if (e.New == keybindReaderPlay.Keybind && sender != keybindReaderPlay) { name = "Play Midi"; } else if (e.New == keybindReaderPause.Keybind && sender != keybindReaderPause) { name = "Pause Midi"; } else if (e.New == keybindReaderStop.Keybind && sender != keybindReaderStop) { name = "Stop Midi"; } else if (e.New == keybindReaderClose.Keybind && sender != keybindReaderClose) { name = "Close Window"; } else if (e.New == keybindReaderMount.Keybind && sender != keybindReaderMount) { name = "Toggle Mount"; } else { for (int i = 0; i < Config.Midis.Count; i++) { if (e.New == Config.Midis[i].Keybind) { name = Config.Midis[i].ProperName; break; } } } if (name != "") { // Nag the user about making poor life choices TriggerMessageBox.Show(this, MessageIcon.Warning, "Keybind is already in use by the '" + name + "' keybind!", "Keybind in Use"); ((KeybindReader)sender).Keybind = e.Previous; } } }
/**<summary>Shows the message box.</summary>*/ public static MessageBoxResult Show(Window window, MessageIcon icon, string message, string title, MessageBoxButton buttons, string buttonName1 = null, string buttonName2 = null, string buttonName3 = null) { TriggerMessageBox messageBox = new TriggerMessageBox(icon, title, message, buttons, buttonName1, buttonName2, buttonName3); if (window == null || window.Visibility != Visibility.Visible) { messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen; } else { messageBox.Owner = window; } messageBox.ShowDialog(); return(messageBox.result); }