Example #1
0
        private void FormHotkeys_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (this.DialogResult == DialogResult.OK)
                {
                    if (txtSelectCategory.Hotkey == txtEditValue.Hotkey && txtSelectCategory.HotkeyModifiers == txtEditValue.HotkeyModifiers)
                    {
                        throw new Exception("Same hotkey defined for more than one action");
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    if (txtSelectCategory.Hotkey == Keys.Return && txtSelectCategory.HotkeyModifiers == Keys.Alt ||
                        txtEditValue.Hotkey == Keys.Return && txtEditValue.HotkeyModifiers == Keys.Alt)
                    {
                        throw new Exception("Combination '" + txtSelectCategory.Text + "' is not supported");
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    _views.SetHotkeyByCode(PaneDocuments.HotkeyCode_SelectCategory, new HotkeyInfo {
                        Hotkey = txtSelectCategory.Hotkey, Modifiers = txtSelectCategory.HotkeyModifiers
                    });
                    _views.SetHotkeyByCode(PaneDocuments.HotkeyCode_EditValue, new HotkeyInfo {
                        Hotkey = txtEditValue.Hotkey, Modifiers = txtEditValue.HotkeyModifiers
                    });

                    ///////////////////////////////////////////////////////////////////////////////

                    _views.SaveHotkeys();
                }
            }
            catch (Exception ex)
            {
                MainForm.ShowExceptionMessage(ex);

                e.Cancel = true;
            }
        }