예제 #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);
            } //}}}
        }     //}}}
예제 #2
0
        //}}}
        private void ApplyKeySet_handler() //{{{
        {
            // CANCELED BEFORE COUNTDOWN {{{
            if (ApplyKeySet_thread == null)
            {
                Log("UPDATES .. CANCELED BEFORE COUNTDOWN");

                return;
            }
            //}}}
            // [something_to_commit] {{{
            bool something_to_commit
                = (profile.keyProgrammer.Profile_changeToCommit != "") ||
                  (profile.keyProgrammer.KeyMap_changeToCommit != "")
                ;

            if (!something_to_commit)
            {
                if (DX1Utility.Debug)
                {
                    Log("UPDATES .. NONE");
                }

                return;
            }
            else
            {
                L_STANDBY.Text = ""; // CLEAR PROGRESS BAR
            }
            //}}}
            // SHUTDOWN .. OR FOCUS LOST DELAY {{{
            if (!ShutDown_Requested)
            {
                int delay_sec
                    = (cmdLine_apply_delay_sec > 0)
                    ?  cmdLine_apply_delay_sec
                    :  FOCUS_LOST_APPLY_DELAY_SEC;

                cmdLine_apply_delay_sec = -1; /* consume single usage command-line argument */

                if (Environment.UserInteractive)
                {
                    Log("UPDATES .. TO BE APPLIED IN " + delay_sec + "s");
                }

                ApplyKeySet_countDown(delay_sec);
            }
            //}}}
            // CANCELED DURING COUNTDOWN {{{
            if (ApplyKeySet_thread == null)
            {
                Log(Globals.SYMBOL_ARROW_L + Globals.SYMBOL_ARROW_L + " UPDATES .. CANCELED BY USER DURING COUNTDOWN");

                return;
            }
            else
            {
                // USE PENDING COLOR FOR STANDBY CHECKMARK
                L_STANDBY.ForeColor = L_WRITING.ForeColor;

                Log("UPDATES .. APPLYING");
            }
            //}}}
            //{{{ [apply_cause]
            string apply_cause
                = (!DX1UtilityHasFocus ? "FOCUS LOST" : "")
                  + " " + (ShutDown_Requested ? "SHUTDOWN"   : "")
                ;

            apply_cause = apply_cause.Trim();
            //}}}
            // COMMIT PROFILE UPDATE {{{
            if (profile.keyProgrammer.Profile_changeToCommit != "")
            {
                if (DX1Utility.Debug)
                {
                    Log("===");
                }

                Log("UPDATING PROFILE: " + profile.CurrentProfileName + "");

                if (DX1Utility.Debug)
                {
                    Log(".. commited by [" + profile.keyProgrammer.Profile_changeToCommit + " ON " + apply_cause + "]");
                }

                ProfileManager.SaveProfile(profile.CurrentProfileName, profile.keyMapList);

                Log(Globals.SYMBOL_ARROW_L + Globals.SYMBOL_ARROW_L + " PROFILE UPDATE .. DONE");

                if (DX1Utility.Debug)
                {
                    Log("===");
                }
            }
            else
            {
                if (DX1Utility.Debug)
                {
                    Log("===");
                }
                if (DX1Utility.Debug)
                {
                    Log("PROFILE UNCHANGED: [" + profile.CurrentProfileName + "]");
                }
                if (DX1Utility.Debug)
                {
                    Log("===");
                }
            }
            //}}}
            // COMMIT KEY MAPPINGS {{{
            if (profile.keyProgrammer.KeyMap_changeToCommit != "")
            {
                if (DX1Utility.Debug)
                {
                    Log("===");
                }

                Log("SENDING KEYMAP: [" + profile.CurrentProfileName + "]");

                if (DX1Utility.Debug)
                {
                    Log(".. commited by [" + profile.keyProgrammer.KeyMap_changeToCommit + " ON " + apply_cause + "]");
                }

                update_notifyIcon(profile.CurrentProfileName + " profile\n.. SENDING KEYMAP");

                dx1Device.sendProgramPacket(profile.keyProgrammer.get_keyMapList_num_type_code_byteArray(profile.keyMapList));

                Log(Globals.SYMBOL_ARROW_L + Globals.SYMBOL_ARROW_L + " KEYSET  UPDATE .. DONE");

                if (DX1Utility.Debug)
                {
                    Log("===");
                }
            }
            else
            {
                if (DX1Utility.Debug)
                {
                    Log("===");
                }
                if (DX1Utility.Debug)
                {
                    Log("KEYMAP UNCHANGED: [" + profile.CurrentProfileName + "]");
                }
                if (DX1Utility.Debug)
                {
                    Log("===");
                }
            }
            //}}}
            /* 1/2 - EXIT FROM UNATTENDED SERVICE MODE {{{*/
            ApplyKeySet_thread = null;
            if (!Environment.UserInteractive)
            {
                ShutDown_Requested = true;
                exitApp_Handler();
            }
            /*}}}*/
            // 2/2 - OR CLEAR UI COMMIT TRIGGERS {{{
            if (something_to_commit)
            {
                L_STANDBY.Text = Globals.SYMBOL_CHECK; // CHECK PROGRESS BAR
            }
            //                                         profile.keyProgrammer.notify_all_commit_done();
            this.Invoke((MethodInvoker) delegate() { profile.keyProgrammer.notify_all_commit_done(); });

            if (C2_KeyMap_commit.Checked)
            {
                set_C2_KeyMap_commit_Checked(false);
            }
            if (C1_Profile_commit.Checked)
            {
                set_C1_Profile_commit_Checked(false);
            }

            SyncUI.sync("ApplyKeySet_handler");
            //}}}
        } //}}}
예제 #3
0
        } //}}}

        private bool _LoadProfile(string newProfileName) // {{{
        {
            string caller = "_LoadProfile";

            // LOAD PROFILE .. OUT [keyMapList] [keyProgrammer]
            // .. OUT   .. [keyMapList] [keyProgrammer]
            if (DX1Utility.Debug)
            {
                log("_LoadProfile(" + newProfileName + ")");
            }
            // LOAD SELECTED PROFILE {{{
            keyMapList = ProfileManager.LoadProfile(newProfileName);
            if (keyMapList.Count > 0)
            {
                ui.MapMacroKeys(caller);

                log("");
                if (newProfileName == CurrentProfileName)
                {
                    // CLEAR PENDING KEYMAP AND PROFILE COMMIT REQUIREMENTS
                    log("[" + CurrentProfileName + "] RELOADING CURRENT PROFILE");

                    keyProgrammer.notify_keyMap_commit_done();
                    keyProgrammer.notify_profile_commit_done();

                    if (ui.C2_KeyMap_commit.Checked)
                    {
                        ui.set_C2_KeyMap_commit_Checked(false);
                    }
                    if (ui.C1_Profile_commit.Checked)
                    {
                        ui.set_C1_Profile_commit_Checked(false);
                    }
                }
                else
                {
                    // SET PENDING PROFILE COMMIT REQUIREMENTS
                    log("NEW PROFILE LOADED [" + newProfileName + "]");

                    keyProgrammer.notify_keyMap_PROFILE_LOADED();
                    if (ui.C2_KeyMap_commit.Checked)
                    {
                        ui.set_C2_KeyMap_commit_Checked(true);
                    }
                }
                return(true);
            }
            //}}}
            // LOAD THE DEFAULT MAPPING INTO NEW PROFILE {{{
            if (ui.is_FormWindowState_Minimized())
            {
                log("loading Default mappings");
            }
            else
            if (Environment.UserInteractive)
            {
                MessageBox.Show("Error loading profile " + newProfileName + "\n.. loading Defaults.", "", MessageBoxButtons.OK);
            }

            if (newProfileName != Globals.MENU_GLOBAL_PROFILE)
            {
                ProfileManager.SaveProfile(newProfileName, keyMapList);
            }

            return(false);
            //}}}
        } //}}}