Esempio n. 1
0
        private void EditProfile(string ProfiletoEdit)
        {
            DialogResult PPropAnswer;
            bool bNewProfile = false;
            bool clearProfile = false;
            ProfileSearcher Searcher = new ProfileSearcher();

            //Disable App Change timer, so CurrentProfile doesn't get edited
            appFocusCheckTimer.Enabled = false;

            //Cannot Edit (Global) Profile
            if (ProfiletoEdit == DefGlobalProf)
            {
                MessageBox.Show("Cannot Edit the Global Profile's properties", "", MessageBoxButtons.OK);
                return;
            }

            //Determine if creating a new Profile or editing an existing profile
            ProfileProperties PProp = new ProfileProperties();
            if (ProfiletoEdit == DefCreateProf)
            {
                bNewProfile = true;
                CurrentProfile.ProfName = "New";
                PProp.EditProfile(CurrentProfile);
            }
            else
            {
                //Find the Selected profile and pass its options to the PProp Dialog
                CurrentProfile = Searcher.ProfileSearchByName(ProfileList, V_Profiles.Text);

                PProp.EditProfile(CurrentProfile);
            }

            //Determine return and either creat a new Prifile in the list, or edit the existing
            PPropAnswer = PProp.ShowDialog();
            if (PPropAnswer == DialogResult.OK)
            {
                //Select the recently edited profile
                if (bNewProfile)
                {
                    //Check to ensure profile name doesn't already exist
                    if (Searcher.ProfileSearchByName(ProfileList, PProp.GetProfileNameOnly()) != null)
                    {
                        //Profile already exists, do not create this profile
                        MessageBox.Show("This Profile Name already exists, please edit that profile.  Changes cancelled.", "", MessageBoxButtons.OK);
                        V_Profiles.Text = DefCreateProf;
                    }
                    else
                    {
                        //Create a new Profile of the detail in the PProp dialog
                        V_Profiles.Items.Add(PProp.GetEditedProfile(ref CurrentProfile, ref clearProfile));
                        V_Profiles.Text = CurrentProfile.ProfName;
                        ProfileList.Add(CurrentProfile);
                        if (clearProfile)
                        {
                            //Create all keys as Unassigned
                            InitKeyMap(ref KeyMaps);
                            SaveButtonstoProfile(CurrentProfile.ProfName);
                            ReBuildKeyMap();
                        }
                        else
                        {
                            //Save current keyset to new profile
                            SaveButtonstoProfile(CurrentProfile.ProfName);
                        }
                    }

                }
                else
                {
                    //Update the Profile that was selected already
                    PProp.GetEditedProfile(ref CurrentProfile, ref clearProfile);
                    if (clearProfile)
                    {
                        //Clear all the currently programmed keys on this profile
                        InitKeyMap(ref KeyMaps);
                        SaveButtonstoProfile(CurrentProfile.ProfName);
                    }
                }

            }
            else
            {
                //Cancel was pressed, check to see if we were creating a new profile
                //If so, switch to the Global Profile
                if (bNewProfile) { SelectProfile(DefGlobalProf); }
            }

            //Save Profile List
            SaveProfiles();

            //reenable App Change timer
            appFocusCheckTimer.Enabled = true;
        }
Esempio n. 2
0
        } //}}}

        public void EditProfile(string profileName) // {{{
        {
            // Cannot Edit the Global profile {{{

/*{{{
*       if(profileName == Globals.MENU_GLOBAL_PROFILE)
*       {
*           if( Environment.UserInteractive )
*               MessageBox.Show("Cannot Edit the Global profile's properties", "", MessageBoxButtons.OK);
*
*           return;
*       }
*  }}}*/
            //}}}
            // CHECK PROFILE NAME .. (NEW OR EXISTING) {{{
            ProfileSearcher   Searcher = new ProfileSearcher();
            ProfileProperties PProp    = new ProfileProperties();

            //}}}
            // [PProp DIALOG BOX] .. f(New menu entry) .. f(profile name .. from ui.D_Profiles.Text) {{{
            bool bNewProfile
                = (profileName == Globals.MENU_NEW_PROFILE)
                ;

            CurrentProfileName
                = bNewProfile
            ?  "New"
            :  Searcher.ProfileSearchByName(ProfileList, ui.get_D_Profiles_Text());

            PProp.EditProfile(CurrentProfileName);
            //}}}

            bool         clearProfile = false;
            DialogResult PPropAnswer  = PProp.ShowDialog();

            // DIALOG [CANCEL] {{{
            if (PPropAnswer != DialogResult.OK)
            {
                // if we were creating a new profile switch to the Global profile
                if (bNewProfile)
                {
                    SelectProfile(Globals.MENU_GLOBAL_PROFILE);
                }
            }
            //}}}

            // DIALOG [OK] {{{
            else
            {
                // [bNewProfile] {{{
                if (bNewProfile)
                {
                    // REJECT ALREADY EXISTING PROFILE NAME {{{
                    if (Searcher.ProfileSearchByName(ProfileList, PProp.GetProfileNameOnly()) != null)
                    {
                        if (Environment.UserInteractive)
                        {
                            MessageBox.Show("This profile already exists, you should load it first. Changes cancelled.", "", MessageBoxButtons.OK);
                        }

                        ui.set_D_Profiles_Text(Globals.MENU_NEW_PROFILE);
                    }
                    //}}}
                    else
                    {
                        // CREATE NEW PROFILE {{{
                        ui.set_D_Profiles_Text(CurrentProfileName);

                        PProp.GetEditedProfile(ref CurrentProfileName, ref clearProfile);
                        ui.add_D_Profiles_Item(CurrentProfileName);

                        ProfileList.Add(CurrentProfileName);
                        _Save_ProfileList_to_Dx1Profiles_dat();
                        //}}}
                        // [UNASSIGN ALL KEYS] {{{
                        if (clearProfile)
                        {
                            init_keyMapList();
                            ProfileManager.SaveProfile(CurrentProfileName, keyMapList);
                            SyncUI.sync("EditProfile");
                        }
                        else
                        {
                            ProfileManager.SaveProfile(CurrentProfileName, keyMapList);
                        }
                        //}}}
                    }
                }
                //}}}
                // UPDATE SELECTED PROFILE {{{
                else
                {
                    PProp.GetEditedProfile(ref CurrentProfileName, ref clearProfile);
                    if (clearProfile)
                    {
                        //Clear all the currently programmed keys on this profile
                        init_keyMapList();
                        ProfileManager.SaveProfile(CurrentProfileName, keyMapList);
                    }
                }
                //}}}
                ui.set_B_Delete_Enabled(true);
            } //}}}
        }     //}}}
Esempio n. 3
0
        private void EditProfile(string ProfiletoEdit)
        {
            DialogResult    PPropAnswer;
            bool            bNewProfile  = false;
            bool            clearProfile = false;
            ProfileSearcher Searcher     = new ProfileSearcher();

            //Disable App Change timer, so CurrentProfile doesn't get edited
            appFocusCheckTimer.Enabled = false;

            //Cannot Edit (Global) Profile
            if (ProfiletoEdit == DefGlobalProf)
            {
                MessageBox.Show("Cannot Edit the Global Profile's properties", "", MessageBoxButtons.OK);
                return;
            }

            //Determine if creating a new Profile or editing an existing profile
            ProfileProperties PProp = new ProfileProperties();

            if (ProfiletoEdit == DefCreateProf)
            {
                bNewProfile             = true;
                CurrentProfile.ProfName = "New";
                PProp.EditProfile(CurrentProfile);
            }
            else
            {
                //Find the Selected profile and pass its options to the PProp Dialog
                CurrentProfile = Searcher.ProfileSearchByName(ProfileList, V_Profiles.Text);

                PProp.EditProfile(CurrentProfile);
            }

            //Determine return and either creat a new Prifile in the list, or edit the existing
            PPropAnswer = PProp.ShowDialog();
            if (PPropAnswer == DialogResult.OK)
            {
                //Select the recently edited profile
                if (bNewProfile)
                {
                    //Check to ensure profile name doesn't already exist
                    if (Searcher.ProfileSearchByName(ProfileList, PProp.GetProfileNameOnly()) != null)
                    {
                        //Profile already exists, do not create this profile
                        MessageBox.Show("This Profile Name already exists, please edit that profile.  Changes cancelled.", "", MessageBoxButtons.OK);
                        V_Profiles.Text = DefCreateProf;
                    }
                    else
                    {
                        //Create a new Profile of the detail in the PProp dialog
                        V_Profiles.Items.Add(PProp.GetEditedProfile(ref CurrentProfile, ref clearProfile));
                        V_Profiles.Text = CurrentProfile.ProfName;
                        ProfileList.Add(CurrentProfile);
                        if (clearProfile)
                        {
                            //Create all keys as Unassigned
                            InitKeyMap(ref KeyMaps);
                            SaveButtonstoProfile(CurrentProfile.ProfName);
                            ReBuildKeyMap();
                        }
                        else
                        {
                            //Save current keyset to new profile
                            SaveButtonstoProfile(CurrentProfile.ProfName);
                        }
                    }
                }
                else
                {
                    //Update the Profile that was selected already
                    PProp.GetEditedProfile(ref CurrentProfile, ref clearProfile);
                    if (clearProfile)
                    {
                        //Clear all the currently programmed keys on this profile
                        InitKeyMap(ref KeyMaps);
                        SaveButtonstoProfile(CurrentProfile.ProfName);
                    }
                }
            }
            else
            {
                //Cancel was pressed, check to see if we were creating a new profile
                //If so, switch to the Global Profile
                if (bNewProfile)
                {
                    SelectProfile(DefGlobalProf);
                }
            }


            //Save Profile List
            SaveProfiles();

            //reenable App Change timer
            appFocusCheckTimer.Enabled = true;
        }