private void Execute_Command_Button_Add_Hotkey(object Parameter) { if (m_Command == null || m_Hotkey == null) { return; } if (m_Hotkey.Trim().Length != 0 && m_Hotkey != "BELEGT" && m_Hotkey != "ERROR" && m_Command.Trim().Length != 0) { // Baue Hotkey und Hotkey Display Objekt M_Binding Disp = new M_Binding(); Disp.Bezeichnung = m_Hotkey; Disp.KeyValue = CurrentKeyValue; Disp.KeyValueForms = (int)(System.Windows.Forms.Keys)KeyInterop.VirtualKeyFromKey((Key)CurrentKeyValue); Disp.ModValue = CurrentKeyModValue; Disp.AutoEnter = AutoEnter; Disp.Auflistung_BindingOptions = new List <M_BindingOption>(); // Command aufsplitten, wenn Contains ~ if (m_Command.Contains("~")) { if (!AutoEnter) { // Hinweis Anzeigen, wenn Mehrere Commands da sind, aber AutoEnter False ist if (MessageBoxResult.No == Bindermessage.ShowQuestionYesNo("Sie haben den Hotkey mit mehreren Befehlen belegt und die Auto-Enter Funktion deaktiviert!\nBeachten Sie, dass hierdurch nur der letzte Befehl nicht automatisch abgesendet wird!\n\nMöchten Sie den Hotkey trotzdem hinzufügen?")) { return; } } string[] commands = m_Command.Split('~'); foreach (string command in commands) { M_BindingOption opt = new M_BindingOption(); opt.cmd = command.TrimStart(); Disp.Auflistung_BindingOptions.Add(opt); } } else { M_BindingOption opt = new M_BindingOption(); opt.cmd = m_Command.TrimStart(); Disp.Auflistung_BindingOptions.Add(opt); } m_Auflistung_Keybinds.Add(Disp); OnPropertyChanged("Auflistung_Keybinds"); // RESET FIELDS m_Hotkey = String.Empty; m_Command = String.Empty; OnPropertyChanged("Hotkey"); OnPropertyChanged("Command"); } }
private void Execute_Command_Button_Edit_Save(object Parameter) { // Suche das alte Binding in der Liste for (int i = 0; i < m_Auflistung_Keybinds.Count; i++) { if (m_Altes_Binding.Bezeichnung == m_Auflistung_Keybinds[i].Bezeichnung & m_Altes_Binding.KeyValue == m_Auflistung_Keybinds[i].KeyValue && m_Altes_Binding.ModValue == m_Auflistung_Keybinds[i].ModValue && m_Altes_Binding.Auflistung_BindingOptions[0].cmd == m_Auflistung_Keybinds[i].Auflistung_BindingOptions[0].cmd) { m_Auflistung_Keybinds[i].AutoEnter = AutoEnter_Edit; m_Auflistung_Keybinds[i].Bezeichnung = Hotkey_Edit; m_Auflistung_Keybinds[i].KeyValue = CurrentKeyValue; m_Auflistung_Keybinds[i].KeyValueForms = (int)(System.Windows.Forms.Keys)KeyInterop.VirtualKeyFromKey((Key)CurrentKeyValue); m_Auflistung_Keybinds[i].ModValue = CurrentKeyModValue; //Reset Commands m_Auflistung_Keybinds[i].Auflistung_BindingOptions = new List <M_BindingOption>(); // Command aufsplitten, wenn Contains ~ if (m_Command_Edit.Contains("~")) { if (!AutoEnter_Edit) { // Hinweis Anzeigen, wenn Mehrere Commands da sind, aber AutoEnter False ist if (MessageBoxResult.No == Bindermessage.ShowQuestionYesNo("Sie haben den Hotkey mit mehreren Befehlen belegt und die Auto-Enter Funktion deaktiviert!\nBeachten Sie, dass hierdurch nur der letzte Befehl nicht automatisch abgesendet wird!\n\nMöchten Sie den Hotkey trotzdem hinzufügen?")) { return; } } string[] commands = m_Command_Edit.Split('~'); foreach (string command in commands) { M_BindingOption opt = new M_BindingOption(); opt.cmd = command.TrimStart(); m_Auflistung_Keybinds[i].Auflistung_BindingOptions.Add(opt); } } else { M_BindingOption opt = new M_BindingOption(); opt.cmd = m_Command_Edit.TrimStart(); m_Auflistung_Keybinds[i].Auflistung_BindingOptions.Add(opt); } } } Hotkey_Edit = String.Empty; Command_Edit = String.Empty; isEditMode = false; OnPropertyChanged("Auflistung_Keybinds"); Auflistung_Keybinds = new ObservableCollection <M_Binding>(m_Auflistung_Keybinds); _CONTROLLER.SetzeUC(_CONTROLLER.VCustomKeybinds, _CONTROLLER.VMCustomKeybinds); }