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);
        }
        private void LoadKeybinds()
        {
            string m_appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string m_foldername  = "Bonnyfication";

            string m_FileName_Old     = "Keybinds_Store.xml";
            string m_FileNameExtended = "Keybinds_Store_Extended.xml";

            string m_FullpathOld      = Path.Combine(m_appdatapath, m_foldername, m_FileName_Old);
            string m_FullpathExtended = Path.Combine(m_appdatapath, m_foldername, m_FileNameExtended);

            string m_FullFolderPath = Path.Combine(m_appdatapath, m_foldername);


            // C:\Users\Bonnyfication\AppData\Roaming\Bonnyfication_Keybinds.xml
            //Check Folder exists or Create it
            System.IO.Directory.CreateDirectory(m_FullFolderPath);

            // Wenn die alte Keybinder XML besteht auswerten, Convertieren und Löschen
            if (File.Exists(m_FullpathOld))
            {
                //CONVERT AND DELETE
                ObservableCollection <M_Keybind> m_tmp = new ObservableCollection <M_Keybind>();

                try
                {
                    XmlSerializer seri = new XmlSerializer(typeof(ObservableCollection <M_Keybind>));
                    using (StreamReader read = new StreamReader(m_FullpathOld))
                    {
                        m_tmp = seri.Deserialize(read) as ObservableCollection <M_Keybind>;
                    }
                }
                catch (Exception ex)
                {
                    Bindermessage.ShowError("Fehler beim Laden der Keybinds!\n\nError:\n" + ex);
                }


                if (m_tmp.Count > 0)
                {
                    m_Auflistung_Keybinds = new ObservableCollection <M_Binding>();

                    foreach (M_Keybind item in m_tmp)
                    {
                        M_Binding bin = new M_Binding();
                        bin.Bezeichnung   = item.Bezeichnung;
                        bin.KeyValue      = item.KeyValue;
                        bin.KeyValueForms = item.KeyValueForms;
                        bin.ModValue      = item.ModValue;
                        bin.AutoEnter     = true;

                        M_BindingOption opt = new M_BindingOption();
                        opt.cmd = item.cmd;

                        bin.Auflistung_BindingOptions = new List <M_BindingOption>();
                        bin.Auflistung_BindingOptions.Add(opt);
                        m_Auflistung_Keybinds.Add(bin);
                    }

                    // Speichere die Bindings im neuen Format

                    try
                    {
                        XmlSerializer seri = new XmlSerializer(typeof(ObservableCollection <M_Binding>));
                        using (StreamWriter writ = new StreamWriter(m_FullpathExtended))
                        {
                            seri.Serialize(writ, m_Auflistung_Keybinds);
                        }
                    }
                    catch (Exception ex)
                    {
                        Bindermessage.ShowError("Fehler beim Speichern der konvertierten Keybinds!\n\nError:\n" + ex);
                        Application.Current.Shutdown();
                    }

                    OnPropertyChanged("Auflistung_Keybinds");

                    try
                    {
                        File.Delete(m_FullpathOld);
                    }
                    catch (Exception ex)
                    {
                        Bindermessage.ShowError("Die Datei Keybinder_Store.xml konnte nicht gelöscht werden. Dies ist allerdings erforderlich, damit beim start des Keybinders neue Keybinds nicht überschrieben werden.\nSie können die Datei manuell löschen!\n\nPfad:\n" + m_FullpathOld + "\n\nError:" + ex.Message);
                        Application.Current.Shutdown();
                    }
                }
            }
            else // Existiert die Aktuelle Keybinder_Store_Extended.xml ?
            {
                if (!File.Exists(m_FullpathExtended))
                {
                    return;
                }

                // Auslesen
                Auflistung_Keybinds = new ObservableCollection <M_Binding>();

                try
                {
                    XmlSerializer seri = new XmlSerializer(typeof(ObservableCollection <M_Binding>));
                    using (StreamReader read = new StreamReader(m_FullpathExtended))
                    {
                        m_Auflistung_Keybinds = seri.Deserialize(read) as ObservableCollection <M_Binding>;
                    }
                }
                catch (Exception ex)
                {
                    Bindermessage.ShowError("Fehler beim Laden der Keybinds!\n\nError:\n" + ex);
                }

                OnPropertyChanged("Auflistung_Keybinds");
            }
        }