private void ProfileProperties_FormClosing(object sender, FormClosingEventArgs e)
        {
            ProfileSearcher Searcher = new ProfileSearcher();

            //Check to ensure name is not "New"
            if (T_ProfileName.Text == "New" && this.DialogResult != DialogResult.Cancel)
            {
                MessageBox.Show("Profile Name cannot be 'New'","",MessageBoxButtons.OK);
                e.Cancel = true;
            }
        }
Пример #2
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;
        }
Пример #3
0
        private void ProfileSelected(object sender, EventArgs e)
        {
            //Runs when a new Profile is selected in the Context menu
            MenuItem QuickSelected = ((MenuItem)sender);
            string SelectedItem = QuickSelected.Text;
            ProfileSearcher Searcher = new ProfileSearcher();

            //Set the Menu Item Checked.
            QuickSelected.Checked = true;

            //Find the selected Profile and load its Keymap
            SelectProfile(SelectedItem);
            //Moved code to a central function for 1.4
            //CurrentProfile = Searcher.ProfileSearchByName(ProfileList, SelectedItem);
            //LoadButtonsfromProfile(CurrentProfile.ProfName);
            //ProfileManuallySelected = true;
            //ApplyKeySet();
        }
Пример #4
0
        void appFocusCheckTimer_Elapsed(Object sender, System.Timers.ElapsedEventArgs e)
        {
            IntPtr handle = GetForegroundWindow();

            //Do not run excesive code if App has not changed from last tick, or App is DX1Utility
            if (handle != lastHandle && handle != SelfHandle)
            {
                DebugLog.Instance.writeLog("New Active App detected: ", true);
                lastHandle = handle;
                String processName = "";
                String exeName = "";
                ProfileSearcher Searcher = new ProfileSearcher();

                DebugLog.Instance.writeLog("   Handle: " + handle.ToString(), true);

                System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();

                foreach (System.Diagnostics.Process process in processes)
                {
                    if (process.MainWindowHandle == handle)
                    {
                        try
                        {
                            //This works on some apps not others
                            exeName = process.MainModule.FileName;
                            DebugLog.Instance.writeLog("   FileName: " + exeName.ToLower());
                        }
                        catch (Exception)
                        {
                            DebugLog.Instance.writeLog("   FileName could not be found");
                        }
                        finally
                        {
                            //Get ProcessName, although currently not used for anything.
                            processName = process.ProcessName;
                            DebugLog.Instance.writeLog("   processName: " + processName.ToLower());
                            if (processName.ToLower().Contains("dx1utility"))
                            {
                                SelfHandle = handle;
                            }
                        }
                        break;
                    }
                }

                String newExeName = "";
                if (exeName != "")
                {
                    newExeName = exeName.ToLower();
                }

                //Search the Profile List for any profile with this Path
                if (Searcher.ProfileSearchByPath(ProfileList, newExeName) != null)
                {
                    //Profile was found, load that profile and apply Keymap
                    CurrentProfile = Searcher.ProfileSearchByPath(ProfileList, newExeName);
                    DebugLog.Instance.writeLog("   Profile Found: " + CurrentProfile.ProfName);
                    LoadButtonsfromProfile(CurrentProfile.ProfName);
                    ApplyKeySet();
                }
                else
                {
                    //Profile Path not found, Select the Global Profile if current Profile wasn't manually selected
                    if (!ProfileManuallySelected)
                    {
                        DebugLog.Instance.writeLog("   No Profile Found Loading " + DefGlobalProf + " Prfoile");
                        SelectGlobalProfile();
                    }
                }

            }
        }
Пример #5
0
        private bool SelectProfile(string profileName)
        {
            //Find the specified Profile and load its Keymap
            ProfileSearcher Searcher = new ProfileSearcher();

            CurrentProfile = Searcher.ProfileSearchByName(ProfileList, profileName);
            LoadButtonsfromProfile(CurrentProfile.ProfName);
            ProfileManuallySelected = true;
            ReBuildKeyMap();
            if (DX1UtilityActive)
            { V_Profiles.Text = CurrentProfile.ProfName; }
            else
            { ApplyKeySet(); }
            return true;
        }
Пример #6
0
        private void SelectGlobalProfile()
        {
            //Function to specifically select the Global Profile
            ProfileSearcher Searcher = new ProfileSearcher();

            CurrentProfile = Searcher.ProfileSearchByName(ProfileList, DefGlobalProf);
            LoadButtonsfromProfile(CurrentProfile.ProfName);
        }
Пример #7
0
        void appFocusCheckTimer_Elapsed(Object sender, System.Timers.ElapsedEventArgs e)
        {
            IntPtr handle = GetForegroundWindow();

            //Do not run excesive code if App has not changed from last tick, or App is DX1Utility
            if (handle != lastHandle && handle != SelfHandle)
            {
                DebugLog.Instance.writeLog("New Active App detected: ", true);
                lastHandle = handle;
                String          processName = "";
                String          exeName     = "";
                ProfileSearcher Searcher    = new ProfileSearcher();

                DebugLog.Instance.writeLog("   Handle: " + handle.ToString(), true);

                System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();


                foreach (System.Diagnostics.Process process in processes)
                {
                    if (process.MainWindowHandle == handle)
                    {
                        try
                        {
                            //This works on some apps not others
                            exeName = process.MainModule.FileName;
                            DebugLog.Instance.writeLog("   FileName: " + exeName.ToLower());
                        }
                        catch (Exception)
                        {
                            DebugLog.Instance.writeLog("   FileName could not be found");
                        }
                        finally
                        {
                            //Get ProcessName, although currently not used for anything.
                            processName = process.ProcessName;
                            DebugLog.Instance.writeLog("   processName: " + processName.ToLower());
                            if (processName.ToLower().Contains("dx1utility"))
                            {
                                SelfHandle = handle;
                            }
                        }
                        break;
                    }
                }


                String newExeName = "";
                if (exeName != "")
                {
                    newExeName = exeName.ToLower();
                }

                //Search the Profile List for any profile with this Path
                if (Searcher.ProfileSearchByPath(ProfileList, newExeName) != null)
                {
                    //Profile was found, load that profile and apply Keymap
                    CurrentProfile = Searcher.ProfileSearchByPath(ProfileList, newExeName);
                    DebugLog.Instance.writeLog("   Profile Found: " + CurrentProfile.ProfName);
                    LoadButtonsfromProfile(CurrentProfile.ProfName);
                    ApplyKeySet();
                }
                else
                {
                    //Profile Path not found, Select the Global Profile if current Profile wasn't manually selected
                    if (!ProfileManuallySelected)
                    {
                        DebugLog.Instance.writeLog("   No Profile Found Loading " + DefGlobalProf + " Prfoile");
                        SelectGlobalProfile();
                    }
                }
            }
        }
Пример #8
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;
        }