Example #1
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);
            } //}}}
        }     //}}}