コード例 #1
0
 public string GetEditedProfile(ref Profiles CurrentProfile, ref bool clearProfile)
 {
     CurrentProfile.ProfName  = T_ProfileName.Text;
     CurrentProfile.ProfPath = T_ProfilePath.Text.ToLower();
     CurrentProfile.ProfEnabled = C_Enabled.Checked;
     CurrentProfile.QuickMenu = C_QuickMenu.Checked;
     clearProfile = C_Blank.Checked;
     return T_ProfileName.Text;
 }
コード例 #2
0
 public void EditProfile(Profiles CurrentProfile)
 {
     T_ProfileName.Text = CurrentProfile.ProfName;
     T_ProfilePath.Text = CurrentProfile.ProfPath;
     C_Enabled.Checked = CurrentProfile.ProfEnabled;
     C_QuickMenu.Checked = CurrentProfile.QuickMenu;
     if (CurrentProfile.ProfName != "New")
     {
         //This is Not a new profile, don't allow editing of the Profile name
         T_ProfileName.Enabled = false;
         //Change
         C_Blank.Text = "Clear all programmed keys";
     }
 }
コード例 #3
0
        private List<Profiles> LoadProfiles(string fileName)
        {
            //Load the Profile List from the Dx1Profiles.dat
            if (System.IO.File.Exists(fileName))
            {
                System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
                System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
                long TotalBytes = new System.IO.FileInfo(fileName).Length;
                byte[] ba = br.ReadBytes((Int32)TotalBytes);
                fs.Close();
                br.Close();

                System.IO.MemoryStream ms = new System.IO.MemoryStream(ba);
                IFormatter formatter = new BinaryFormatter();
                ms.Position = 0;

                List<Profiles> programSet = (List<Profiles>)formatter.Deserialize(ms);

                ms.Close();

                return programSet;
            }
            else
            {
                //File doesn't exist, create a new Profile List
                List<Profiles> programset = new List<Profiles>();

                //Add Default Global Profile
                InitKeyMap(ref KeyMaps);
                CurrentProfile = new Profiles();
                CurrentProfile.ProfName = DefGlobalProf;
                SaveButtonstoProfile(CurrentProfile.ProfName);

                programset.Add(CurrentProfile);
                return programset;
            }
        }
コード例 #4
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;
        }
コード例 #5
0
        public Form1()
        {
            mKeyProgrammer = new KeyProgrammer(ref KeyMaps);
            SpecialKeyPlayer.InitPlayer();

            notifyIcon1 = new System.Windows.Forms.NotifyIcon();
            notifyIcon1.Icon = this.Icon;
            notifyIcon1.Text = "DX1 Utility";
            notifyIcon1.MouseDoubleClick += new MouseEventHandler(notifyIcon1_MouseDoubleClick);
            notifyIcon1.Visible = true;

            InitializeComponent();

            mDX1Hardware = new HardwareInterface();
            mDevHandle = mDX1Hardware.OpenDevice(true);

            mDX1Hardware.RegisterWindowForEvents(mDevHandle, Handle);

            macroTimer.AutoReset = false;
            macroTimer.Elapsed += new System.Timers.ElapsedEventHandler(macroTimer_Elapsed);

            RebuildMacroList();
            ControlBox = true;

            //Add the (Create new Profile) option to the Profile Combobox
            V_Profiles.Items.Add(DefCreateProf);

            //Create the Quick-Menu for Right-Click on NotifyIcon
            ContextMenu ContextMenu1 = new ContextMenu();
            MenuItem ProfileMenu = new MenuItem();

            ProfileMenu.Text = "Profiles";
            ProfileMenu.RadioCheck = true;
            MenuItem ProfileSub;

            //Check for DX1Profiles folder if it doesn't exist, create it
            if (!System.IO.Directory.Exists(Globals.ProfileSavePath))
                System.IO.Directory.CreateDirectory(Globals.ProfileSavePath);

            //Load Profile List
            ProfileList = (List<Profiles>)LoadProfiles(Globals.ProfileSavePath + "Dx1Profiles.dat");

            //Add list of profiles to V_Profiles Combo Box and Context Menu
            foreach (Profiles Profile in ProfileList)
            {
                V_Profiles.Items.Add(Profile.ProfName);

                ProfileSub = new MenuItem();
                if (Profile.QuickMenu & Profile.ProfEnabled)
                {
                    ProfileSub.Text = Profile.ProfName;
                    ProfileSub.RadioCheck = true;
                    ProfileSub.Click += new EventHandler(ProfileSelected);
                    ProfileMenu.MenuItems.Add(ProfileSub);
                }
            }
            V_Profiles.Sorted = true;

            //AutoSelect Global Profile
            //If one doesn't exist create it (For users that have run 1.1 or earlier)
            if (!V_Profiles.Items.Contains(DefGlobalProf))
            {
                //No Global Profile, Create it
                InitKeyMap(ref KeyMaps);
                CurrentProfile = new Profiles();
                CurrentProfile.ProfName = DefGlobalProf;
                ProfileList.Add(CurrentProfile);
                SaveButtonstoProfile(CurrentProfile.ProfName);
                SaveProfiles();
            }
            SelectGlobalProfile();

            //Initialize the DataGrid and KeyMap List
            G_KeyMap.AutoGenerateColumns = false;
            G_KeyMap.DataSource = KeyMaps;
            G_KeyMap.AllowUserToResizeRows = false;
            G_KeyMap.AllowUserToResizeColumns = false;
            //G_KeyMap.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            //G_KeyMap.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;

            //Add Dx1Key Column
            DataGridViewTextBoxColumn DxColumn = new DataGridViewTextBoxColumn();
            DxColumn.Width = 30;
            DxColumn.DataPropertyName = "Dx1Key";
            DxColumn.HeaderText = "Key";
            DxColumn.ReadOnly = true;
            DxColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            G_KeyMap.Columns.Add(DxColumn);

            //Add Description Column
            DataGridViewTextBoxColumn DescColumn = new DataGridViewTextBoxColumn();
            DescColumn.Width = 120;
            DescColumn.DataPropertyName = "Description";
            DescColumn.HeaderText = "Description";
            DescColumn.ReadOnly = true;
            G_KeyMap.Columns.Add(DescColumn);

            //Finialize Quick-Menu Options for the Notify Icon
            ProfileMenu.Popup += new EventHandler(QuickMenuPopup);
            ContextMenu1.MenuItems.Add(ProfileMenu);
            ContextMenu1.MenuItems.Add("-");
            ContextMenu1.MenuItems.Add("O&pen", new EventHandler(notifyIcon1_MouseDoubleClick));
            ContextMenu1.MenuItems.Add("E&xit", new EventHandler(CloseApp));

            notifyIcon1.ContextMenu = ContextMenu1;

            appFocusCheckTimer.AutoReset = true;
            appFocusCheckTimer.Interval = 1000;
            appFocusCheckTimer.Elapsed += new System.Timers.ElapsedEventHandler(appFocusCheckTimer_Elapsed);
            appFocusCheckTimer.Start();
        }
コード例 #6
0
        private void V_Profiles_SelectionChangeCommitted(object sender, EventArgs e)
        {
            StopQuickProgram();
            //ProfileSearcher Searcher = new ProfileSearcher();
            if (V_Profiles.SelectedItem.ToString() != DefCreateProf)
            {
                SelectProfile(V_Profiles.SelectedItem.ToString());
                G_KeyMap.Invalidate();
            }
            else
            {
                //Set Current Profile to Blank
                CurrentProfile = new Profiles();
                EditProfile(V_Profiles.SelectedItem.ToString());
            }
            ProfileManuallySelected = true;

            //Set Focus to Grid
            G_KeyMap.Focus();
        }
コード例 #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 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;
        }
コード例 #9
0
        private void SelectGlobalProfile()
        {
            //Function to specifically select the Global Profile
            ProfileSearcher Searcher = new ProfileSearcher();

            CurrentProfile = Searcher.ProfileSearchByName(ProfileList, DefGlobalProf);
            LoadButtonsfromProfile(CurrentProfile.ProfName);
        }
コード例 #10
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();
                    }
                }
            }
        }
コード例 #11
0
        public Form1()
        {
            mKeyProgrammer = new KeyProgrammer(ref KeyMaps);
            SpecialKeyPlayer.InitPlayer();

            notifyIcon1                   = new System.Windows.Forms.NotifyIcon();
            notifyIcon1.Icon              = this.Icon;
            notifyIcon1.Text              = "DX1 Utility";
            notifyIcon1.MouseDoubleClick += new MouseEventHandler(notifyIcon1_MouseDoubleClick);
            notifyIcon1.Visible           = true;

            InitializeComponent();

            mDX1Hardware = new HardwareInterface();
            mDevHandle   = mDX1Hardware.OpenDevice(true);

            mDX1Hardware.RegisterWindowForEvents(mDevHandle, Handle);

            macroTimer.AutoReset = false;
            macroTimer.Elapsed  += new System.Timers.ElapsedEventHandler(macroTimer_Elapsed);

            RebuildMacroList();
            ControlBox = true;

            //Add the (Create new Profile) option to the Profile Combobox
            V_Profiles.Items.Add(DefCreateProf);

            //Create the Quick-Menu for Right-Click on NotifyIcon
            ContextMenu ContextMenu1 = new ContextMenu();
            MenuItem    ProfileMenu  = new MenuItem();

            ProfileMenu.Text       = "Profiles";
            ProfileMenu.RadioCheck = true;
            MenuItem ProfileSub;

            //Check for DX1Profiles folder if it doesn't exist, create it
            if (!System.IO.Directory.Exists(Globals.ProfileSavePath))
            {
                System.IO.Directory.CreateDirectory(Globals.ProfileSavePath);
            }

            //Load Profile List
            ProfileList = (List <Profiles>)LoadProfiles(Globals.ProfileSavePath + "Dx1Profiles.dat");

            //Add list of profiles to V_Profiles Combo Box and Context Menu
            foreach (Profiles Profile in ProfileList)
            {
                V_Profiles.Items.Add(Profile.ProfName);

                ProfileSub = new MenuItem();
                if (Profile.QuickMenu & Profile.ProfEnabled)
                {
                    ProfileSub.Text       = Profile.ProfName;
                    ProfileSub.RadioCheck = true;
                    ProfileSub.Click     += new EventHandler(ProfileSelected);
                    ProfileMenu.MenuItems.Add(ProfileSub);
                }
            }
            V_Profiles.Sorted = true;

            //AutoSelect Global Profile
            //If one doesn't exist create it (For users that have run 1.1 or earlier)
            if (!V_Profiles.Items.Contains(DefGlobalProf))
            {
                //No Global Profile, Create it
                InitKeyMap(ref KeyMaps);
                CurrentProfile          = new Profiles();
                CurrentProfile.ProfName = DefGlobalProf;
                ProfileList.Add(CurrentProfile);
                SaveButtonstoProfile(CurrentProfile.ProfName);
                SaveProfiles();
            }
            SelectGlobalProfile();


            //Initialize the DataGrid and KeyMap List
            G_KeyMap.AutoGenerateColumns      = false;
            G_KeyMap.DataSource               = KeyMaps;
            G_KeyMap.AllowUserToResizeRows    = false;
            G_KeyMap.AllowUserToResizeColumns = false;
            //G_KeyMap.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            //G_KeyMap.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;


            //Add Dx1Key Column
            DataGridViewTextBoxColumn DxColumn = new DataGridViewTextBoxColumn();

            DxColumn.Width                      = 30;
            DxColumn.DataPropertyName           = "Dx1Key";
            DxColumn.HeaderText                 = "Key";
            DxColumn.ReadOnly                   = true;
            DxColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            G_KeyMap.Columns.Add(DxColumn);

            //Add Description Column
            DataGridViewTextBoxColumn DescColumn = new DataGridViewTextBoxColumn();

            DescColumn.Width            = 120;
            DescColumn.DataPropertyName = "Description";
            DescColumn.HeaderText       = "Description";
            DescColumn.ReadOnly         = true;
            G_KeyMap.Columns.Add(DescColumn);


            //Finialize Quick-Menu Options for the Notify Icon
            ProfileMenu.Popup += new EventHandler(QuickMenuPopup);
            ContextMenu1.MenuItems.Add(ProfileMenu);
            ContextMenu1.MenuItems.Add("-");
            ContextMenu1.MenuItems.Add("O&pen", new EventHandler(notifyIcon1_MouseDoubleClick));
            ContextMenu1.MenuItems.Add("E&xit", new EventHandler(CloseApp));

            notifyIcon1.ContextMenu = ContextMenu1;

            appFocusCheckTimer.AutoReset = true;
            appFocusCheckTimer.Interval  = 1000;
            appFocusCheckTimer.Elapsed  += new System.Timers.ElapsedEventHandler(appFocusCheckTimer_Elapsed);
            appFocusCheckTimer.Start();
        }
コード例 #12
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;
        }