Exemplo n.º 1
0
        /*
         * Main constructor for the keyboard shortcut form. Takes a
         * reference to the ButtonSetting instance for the button that
         * is to be modified.
         */
        public FrmKeyboardShortcut(ButtonSetting buttonSetting)
        {
            InitializeComponent();

            this.shortcut      = new string[4];
            this.buttonSetting = buttonSetting;
        }
Exemplo n.º 2
0
        /*
         * Sets the settings for one of the device buttons between
         * 1-6 and takes the button number and ButtonSetting instance
         * as arguments.
         */
        public void SetButtonSetting(int buttonNumber, ButtonSetting settings)
        {
            if (buttonNumber > 6 || buttonNumber < 1 || settings == null)
            {
                return;
            }

            buttonSettings[buttonNumber - 1] = settings;
        }
Exemplo n.º 3
0
        /*
         * Loads the values from the ButtonSettings instance passed as an argument
         * into the UI.
         */
        private void LoadButtonSettingsIntoLayout(ButtonSetting settings)
        {
            if (isJoystickView) // don't do anything if we're not in button view
            {
                return;
            }

            switch (currentButtonSetting.Setting)
            {
            case ButtonSetting.ButtonSettingMode.None:
                radLeftClick.Checked  = false;
                radRightClick.Checked = false;
                radOSK.Checked        = false;
                radSentence.Checked   = false;
                radProgram.Checked    = false;
                radWebsite.Checked    = false;
                radShortcut.Checked   = false;
                break;

            case ButtonSetting.ButtonSettingMode.LeftClick:
                radLeftClick.Select();
                break;

            case ButtonSetting.ButtonSettingMode.RightClick:
                radRightClick.Select();
                break;

            case ButtonSetting.ButtonSettingMode.OnScreenKeyboard:
                radOSK.Select();
                break;

            case ButtonSetting.ButtonSettingMode.TypePhrase:
                radSentence.Select();
                break;

            case ButtonSetting.ButtonSettingMode.OpenProgram:
                radProgram.Select();
                break;

            case ButtonSetting.ButtonSettingMode.OpenWebsite:
                radWebsite.Select();
                break;

            case ButtonSetting.ButtonSettingMode.KeyboardShortcut:
                radShortcut.Select();
                break;
            }

            txtPhrase.Text  = currentButtonSetting.Phrase;
            txtWebsite.Text = currentButtonSetting.WebsiteURL;

            UpdateAssignedProgram();
            UpdateKeyboardShortcut();
        }
Exemplo n.º 4
0
        /*
         * Loads button view and button 6 settings into UI when Button 6
         * button is clicked.
         */
        private void btnButton6_Click(object sender, EventArgs e)
        {
            btnButton6.BackColor = Color.FromArgb(230, 0, 0);
            SetDefaultButtonColour((Button)sender);

            if (isJoystickView)
            {
                SetToButtonLayout();
            }

            currentButtonSetting = buttonSettings[5];
            currentButton        = 6;

            LoadButtonSettingsIntoLayout(currentButtonSetting);
        }
Exemplo n.º 5
0
        /*
         * Executes the appropriate action from the passed ButtonSetting
         * instance.
         */
        private void PerformButtonAction(ButtonSetting button)
        {
            switch (button.Setting)
            {
            case ButtonSetting.ButtonSettingMode.LeftClick:
                OSController.SimulateLeftClick();
                break;

            case ButtonSetting.ButtonSettingMode.RightClick:
                OSController.SimulateRightClick();
                break;

            case ButtonSetting.ButtonSettingMode.OnScreenKeyboard:
                OSController.OpenOnScreenKeyboard();
                break;

            case ButtonSetting.ButtonSettingMode.TypePhrase:
                if (!String.IsNullOrEmpty(button.Phrase))
                {
                    OSController.TypePhrase(button.Phrase);
                }
                break;

            case ButtonSetting.ButtonSettingMode.OpenProgram:
                if (button.ProgramInfo != null && !String.IsNullOrEmpty(button.ProgramInfo.Path))
                {
                    OSController.OpenExecutable(button.ProgramInfo.Path);
                }
                break;

            case ButtonSetting.ButtonSettingMode.OpenWebsite:
                if (!String.IsNullOrEmpty(button.WebsiteURL))
                {
                    OSController.OpenWebsite(button.WebsiteURL);
                }
                break;

            case ButtonSetting.ButtonSettingMode.KeyboardShortcut:
                if (button.KeyCombination != null)
                {
                    OSController.PerformKeyboardShortcut(button.KeyCombination);
                }
                break;
            }
        }
Exemplo n.º 6
0
        /*
         * Initializes form values upon load and loads previous settings
         * into UI, if available. If not, settings are initialized to
         * defaults.
         */
        private void FrmMain_Load(object sender, EventArgs e)
        {
            // get UI button references
            uiButtons = new Button[7];

            uiButtons[0] = btnJoystick;
            uiButtons[1] = btnButton1;
            uiButtons[2] = btnButton2;
            uiButtons[3] = btnButton3;
            uiButtons[4] = btnButton4;
            uiButtons[5] = btnButton5;
            uiButtons[6] = btnButton6;

            // scroll wheel event handlers so the scroll wheel cannot control the trackbars in joystick view
            trkJoystick.MouseWheel += new MouseEventHandler(trackBar_MouseWheel);
            trkCursor.MouseWheel   += new MouseEventHandler(trackBar_MouseWheel);

            // load settings
            settings       = DeviceSettings.Instance;
            buttonSettings = new ButtonSetting[6];

            // if previous settings were loaded, update the UI to reflect them
            if (settings.LoadedPreviousSession)
            {
                buttonSettings[0] = settings.GetButtonSetting(1);
                buttonSettings[1] = settings.GetButtonSetting(2);
                buttonSettings[2] = settings.GetButtonSetting(3);
                buttonSettings[3] = settings.GetButtonSetting(4);
                buttonSettings[4] = settings.GetButtonSetting(5);
                buttonSettings[5] = settings.GetButtonSetting(6);

                currentJoystickSetting = settings.JoystickSetting;
                currentJoystickSetting.AssignedButton = uiButtons[0];

                for (int i = 0; i < 6; i++)
                {
                    buttonSettings[i].AssignedButton = uiButtons[i + 1];
                }

                mnuStartWithWindows.Checked = settings.RunAtStartup;
                trayNotifShown = true;
            }
            else // set default values if not
            {
                currentJoystickSetting   = new JoystickSetting(uiButtons[0]);
                settings.JoystickSetting = currentJoystickSetting;
                for (int i = 0; i < 6; i++)
                {
                    buttonSettings[i] = new ButtonSetting(uiButtons[i + 1]);
                    settings.SetButtonSetting(i + 1, buttonSettings[i]);
                }

                trayNotifShown = false;

                // since we don't know if the application is to run at startup
                // from device settings since a previous session was not loaded,
                // check if the task exists and update device settings accordingly
                using (TaskService scheduler = new TaskService())
                {
                    if (scheduler.GetTask("Custom Mouse Controller") == null)
                    {
                        settings.RunAtStartup       = false;
                        mnuStartWithWindows.Checked = false;
                    }
                    else
                    {
                        settings.RunAtStartup       = true;
                        mnuStartWithWindows.Checked = true;
                    }
                }
            }

            //show warning if programs assigned last session have not been found
            if (settings.NotAllProgramsLoaded)
            {
                MessageBox.Show(this, "One or more programs that were assigned to the buttons have been uninstalled or moved since " +
                                "last run. Their assignments have been removed.", "Custom Mouse Controller - Missing Programs", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (Visible)
                {
                    Focus();
                }
            }

            // start out on joystick view since it is the first button
            btnJoystick.PerformClick();
            isJoystickView = true;
        }
Exemplo n.º 7
0
 /*
  * Main constructor for the Select a Program form. Takes a
  * reference to the ButtonSetting instance for the button that
  * is to be modified.
  */
 public FrmSelectProgram(ButtonSetting buttonSetting)
 {
     InitializeComponent();
     this.buttonSetting = buttonSetting;
 }