Exemplo n.º 1
0
        /// <summary>
        /// This method performs a first initialization of default settings for
        /// GlobalHotKeysManager configuration. Called only once during first
        /// application startup (Sessions Form opening).
        /// </summary>
        private void GlobalHotKeysFirstStart()
        {
            // Application first run - set the default GlobalHotKeys (this must be placed to to application startup!!!)
            if (tabPagesForwardGlobalHotKeySettings.key == null && tabPagesbackwardGlobalHotKeySettings.key == null &&
                splitScreenGlobalHotKeySettings.key == null && sftpManagerGlobalHotKeySettings.key == null && kotarakGlobalHotKeySettings.key == null)
            {
                // CTRL + TAB for tabPagesForwardGlobalHotKey
                tabPagesForwardGlobalHotKeySettings.modifier = 2;
                tabPagesForwardGlobalHotKeySettings.key      = "Tab";

                // CTRL + Shift + Tab for tabPagesbackwardGlobalHotKey
                tabPagesbackwardGlobalHotKeySettings.modifier = 6;
                tabPagesbackwardGlobalHotKeySettings.key      = "Tab";

                // CTRL + F1 for splitScreenGlobalHotKey
                splitScreenGlobalHotKeySettings.modifier = 2;
                splitScreenGlobalHotKeySettings.key      = "F1";

                // CTRL + F2 for sftpManagerGlobalHotKey
                sftpManagerGlobalHotKeySettings.modifier = 2;
                sftpManagerGlobalHotKeySettings.key      = "F2";

                // CTRL + F3 for kotarakGlobalHotKey
                kotarakGlobalHotKeySettings.modifier = 2;
                kotarakGlobalHotKeySettings.key      = "F3";

                // Save it!
                tabPagesForwardGlobalHotKeySettings.Save();
                tabPagesbackwardGlobalHotKeySettings.Save();
                splitScreenGlobalHotKeySettings.Save();
                sftpManagerGlobalHotKeySettings.Save();
                kotarakGlobalHotKeySettings.Save();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the new GlobalHotKeys configuration and unregister -> register new hotkeys again!
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            if (!(TabPagesForwardCTRLMOD.Checked || TabPagesForwardALTMOD.Checked || TabPagesForwardSHIFTMOD.Checked ||
                  TabPagesForwardWINMOD.Checked) || TabPagesForwardCombobox.SelectedItem == null)
            {
                MessageBox.Show("GlobalHotKey for TabPagesForward must be set first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!(TabPagesBackwardCTRLMOD.Checked || TabPagesBackwardALTMOD.Checked || TabPagesBackwardSHIFTMOD.Checked ||
                  TabPagesBackwardWINMOD.Checked) || TabPagesBackwardCombobox == null)
            {
                MessageBox.Show("GlobalHotKey for TabPagesBackward must be set first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!(SplitScreenCTRLMOD.Checked || SplitScreenALTMOD.Checked || SplitScreenSHIFTMOD.Checked ||
                  SplitScreenWINMOD.Checked) || SplitScreenCombobox == null)
            {
                MessageBox.Show("GlobalHotKey for SplitScreen must be set first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!(SFTPManagerCTRLMOD.Checked || SFTPManagerALTMOD.Checked || SFTPManagerSHIFTMOD.Checked ||
                  SFTPManagerWINMOD.Checked) || SFTPManagerCombobox == null)
            {
                MessageBox.Show("GlobalHotKey for SFTPManager must be set first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!(KotarakCTRLMOD.Checked || KotarakALTMOD.Checked || KotarakSHIFTMOD.Checked || KotarakWINMOD.Checked) ||
                KotarakCombobox == null)
            {
                MessageBox.Show("GlobalHotKey for Kotarak must be set first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Save to the config first!
            try
            {
                tabPagesForwardGlobalHotKeySettings.modifier = GetGlobalHotKeysSettingsModifier(tabPagesForwardModifiersCheckBoxes);
                tabPagesForwardGlobalHotKeySettings.key      = TabPagesForwardCombobox.Text;

                tabPagesbackwardGlobalHotKeySettings.modifier = GetGlobalHotKeysSettingsModifier(tabPagesbackwardModifiersCheckBoxes);
                tabPagesbackwardGlobalHotKeySettings.key      = TabPagesBackwardCombobox.Text;

                splitScreenGlobalHotKeySettings.modifier = GetGlobalHotKeysSettingsModifier(splitScreenModifiersCheckBoxes);
                splitScreenGlobalHotKeySettings.key      = SplitScreenCombobox.Text;

                sftpManagerGlobalHotKeySettings.modifier = GetGlobalHotKeysSettingsModifier(sftpManagerModifierCheckBoxes);
                sftpManagerGlobalHotKeySettings.key      = SFTPManagerCombobox.Text;

                kotarakGlobalHotKeySettings.modifier = GetGlobalHotKeysSettingsModifier(kotarakModifierCheckBoxes);
                kotarakGlobalHotKeySettings.key      = KotarakCombobox.Text;

                tabPagesForwardGlobalHotKeySettings.Save();
                tabPagesbackwardGlobalHotKeySettings.Save();
                splitScreenGlobalHotKeySettings.Save();
                sftpManagerGlobalHotKeySettings.Save();
                kotarakGlobalHotKeySettings.Save();
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Register new hotkeys!
            try
            {
                Form SessionsForm = Application.OpenForms["Sessions"];

                if (SessionsForm != null && SessionsForm.Handle != IntPtr.Zero)
                {
                    TabPagesForwardGlobalHotKeyWorker.Handle = SessionsForm.Handle;
                    TabPagesForwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)ConvertFromStringToKey(tabPagesForwardGlobalHotKeySettings.key),
                                                                           tabPagesForwardGlobalHotKeySettings.modifier);

                    TabPagesBackwardGlobalHotKeyWorker.Handle = SessionsForm.Handle;
                    TabPagesBackwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)ConvertFromStringToKey(tabPagesbackwardGlobalHotKeySettings.key),
                                                                            tabPagesbackwardGlobalHotKeySettings.modifier);

                    SplitScreenGlobalHotKeyWorker.Handle = SessionsForm.Handle;
                    SplitScreenGlobalHotKeyWorker.RegisterGlobalHotKey((int)ConvertFromStringToKey(splitScreenGlobalHotKeySettings.key),
                                                                       splitScreenGlobalHotKeySettings.modifier);

                    SFTPManagerGlobalHotKeyWorker.Handle = SessionsForm.Handle;
                    SFTPManagerGlobalHotKeyWorker.RegisterGlobalHotKey((int)ConvertFromStringToKey(sftpManagerGlobalHotKeySettings.key),
                                                                       sftpManagerGlobalHotKeySettings.modifier);

                    KotarakGlobalHotKeyWorker.Handle = SessionsForm.Handle;
                    KotarakGlobalHotKeyWorker.RegisterGlobalHotKey((int)ConvertFromStringToKey(kotarakGlobalHotKeySettings.key),
                                                                   kotarakGlobalHotKeySettings.modifier);

                    MessageBox.Show("GlobalHotKeys saved to the config and registered!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("GlobalHotKeys saved to the config but not registered because" +
                                    " SessionsForm has been closed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }