From 6a2adbbf655227eb459c820f5b9296a35770759b Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 19 Jan 2020 14:50:46 +0200 Subject: [PATCH] Added able to disable all shortcut keys --- Crypto Notepad/App.config | 3 + Crypto Notepad/Forms/MainForm.cs | 67 +++++++++++++++++++ Crypto Notepad/Forms/SettingsForm.Designer.cs | 14 ++++ Crypto Notepad/Forms/SettingsForm.cs | 7 ++ .../Properties/Settings.Designer.cs | 12 ++++ Crypto Notepad/Properties/Settings.settings | 3 + 6 files changed, 106 insertions(+) diff --git a/Crypto Notepad/App.config b/Crypto Notepad/App.config index 1bc50b5..6e5d422 100644 --- a/Crypto Notepad/App.config +++ b/Crypto Notepad/App.config @@ -186,6 +186,9 @@ False + + True + diff --git a/Crypto Notepad/Forms/MainForm.cs b/Crypto Notepad/Forms/MainForm.cs index 989e0a9..5226c30 100644 --- a/Crypto Notepad/Forms/MainForm.cs +++ b/Crypto Notepad/Forms/MainForm.cs @@ -638,6 +638,72 @@ public void MenuIcons(bool menuIcons) dropDownItem.Image = null; } } + } + } + + protected internal void ShortcutKeys(bool shortcutKeys) + { + if (shortcutKeys) + { + newMainMenu.ShortcutKeys = Keys.Control | Keys.N; + openMainMenu.ShortcutKeys = Keys.Control | Keys.O; + saveMainMenu.ShortcutKeys = Keys.Control | Keys.S; + saveAsMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.S; + saveCloseFileMainMenu.ShortcutKeys = Keys.Alt | Keys.Shift | Keys.S; + openFileLocationMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.O; + deleteFileMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.D; + exitMainMenu.ShortcutKeys = Keys.Control | Keys.Q; + undoMainMenu.ShortcutKeys = Keys.Control | Keys.Z; + redoMainMenu.ShortcutKeys = Keys.Control | Keys.Y; + cutMainMenu.ShortcutKeys = Keys.Control | Keys.X; + copyMainMenu.ShortcutKeys = Keys.Control | Keys.C; + pasteMainMenu.ShortcutKeys = Keys.Control | Keys.V; + deleteMainMenu.ShortcutKeys = Keys.Delete; + findMainMenu.ShortcutKeys = Keys.Control | Keys.F; + selectAllMainMenu.ShortcutKeys = Keys.Control | Keys.A; + clearClipboardMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.C; + wordWrapMainMenu.ShortcutKeys = Keys.Control | Keys.W; + readOnlyMainMenu.ShortcutKeys = Keys.Control | Keys.R; + clearMainMenu.ShortcutKeys = Keys.Control | Keys.Delete; + alwaysOnTopMainMenu.ShortcutKeys = Keys.Control | Keys.T; + passwordGeneratorMainMenu.ShortcutKeys = Keys.Control | Keys.P; + changePasswordMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.P; + lockMainMenu.ShortcutKeys = Keys.Control | Keys.L; + settingsMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.T; + documentationMainMenu.ShortcutKeys = Keys.Control | Keys.F1; + checkForUpdatesMainMenu.ShortcutKeys = Keys.Control | Keys.U; + aboutMainMenu.ShortcutKeys = Keys.Control | Keys.Shift | Keys.A; + } + else + { + newMainMenu.ShortcutKeys = Keys.None; + openMainMenu.ShortcutKeys = Keys.None; + saveMainMenu.ShortcutKeys = Keys.None; + saveAsMainMenu.ShortcutKeys = Keys.None; + saveCloseFileMainMenu.ShortcutKeys = Keys.None; + openFileLocationMainMenu.ShortcutKeys = Keys.None; + deleteFileMainMenu.ShortcutKeys = Keys.None; + exitMainMenu.ShortcutKeys = Keys.None; + undoMainMenu.ShortcutKeys = Keys.None; + redoMainMenu.ShortcutKeys = Keys.None; + cutMainMenu.ShortcutKeys = Keys.None; + copyMainMenu.ShortcutKeys = Keys.None; + pasteMainMenu.ShortcutKeys = Keys.None; + deleteMainMenu.ShortcutKeys = Keys.None; + findMainMenu.ShortcutKeys = Keys.None; + selectAllMainMenu.ShortcutKeys = Keys.None; + clearClipboardMainMenu.ShortcutKeys = Keys.None; + wordWrapMainMenu.ShortcutKeys = Keys.None; + readOnlyMainMenu.ShortcutKeys = Keys.None; + clearMainMenu.ShortcutKeys = Keys.None; + alwaysOnTopMainMenu.ShortcutKeys = Keys.None; + passwordGeneratorMainMenu.ShortcutKeys = Keys.None; + changePasswordMainMenu.ShortcutKeys = Keys.None; + lockMainMenu.ShortcutKeys = Keys.None; + settingsMainMenu.ShortcutKeys = Keys.None; + documentationMainMenu.ShortcutKeys = Keys.None; + checkForUpdatesMainMenu.ShortcutKeys = Keys.None; + aboutMainMenu.ShortcutKeys = Keys.None; } } @@ -879,6 +945,7 @@ private async void MainWindow_Load(object sender, EventArgs e) Methods.DeleteUpdateFiles(); MenuIcons(settings.menuIcons); ToolbarIcons(settings.oldToolbarIcons); + ShortcutKeys(settings.shortcutKeys); statusPanelReadonlyLabel.Text = "Readonly: " + readOnlyMainMenu.Checked.ToString(); statusPanelWordwrapLabel.Text = "Word Wrap: " + wordWrapMainMenu.Checked.ToString(); if (args.Length == 2) /*drag & drop to executable*/ diff --git a/Crypto Notepad/Forms/SettingsForm.Designer.cs b/Crypto Notepad/Forms/SettingsForm.Designer.cs index eb17673..798d6fe 100644 --- a/Crypto Notepad/Forms/SettingsForm.Designer.cs +++ b/Crypto Notepad/Forms/SettingsForm.Designer.cs @@ -107,6 +107,7 @@ private void InitializeComponent() this.settingsNavigation = new System.Windows.Forms.ListBox(); this.fontDialog = new System.Windows.Forms.FontDialog(); this.settingsToolTip = new System.Windows.Forms.ToolTip(this.components); + this.shortcutKeysCheckBox = new System.Windows.Forms.CheckBox(); this.settingsTabControl.SuspendLayout(); this.generalTabPage.SuspendLayout(); this.integrationGroupBox.SuspendLayout(); @@ -499,6 +500,7 @@ private void InitializeComponent() // // mainMenuGroupBox // + this.mainMenuGroupBox.Controls.Add(this.shortcutKeysCheckBox); this.mainMenuGroupBox.Controls.Add(this.mainMenuCheckBox); this.mainMenuGroupBox.Controls.Add(this.menuIconsCheckBox); this.mainMenuGroupBox.Location = new System.Drawing.Point(6, 6); @@ -1002,6 +1004,17 @@ private void InitializeComponent() this.fontDialog.ShowEffects = false; this.fontDialog.Apply += new System.EventHandler(this.FontDialog_Apply); // + // shortcutKeysCheckBox + // + this.shortcutKeysCheckBox.AutoSize = true; + this.shortcutKeysCheckBox.Location = new System.Drawing.Point(166, 22); + this.shortcutKeysCheckBox.Name = "shortcutKeysCheckBox"; + this.shortcutKeysCheckBox.Size = new System.Drawing.Size(97, 19); + this.shortcutKeysCheckBox.TabIndex = 3; + this.shortcutKeysCheckBox.Text = "Shortcut keys"; + this.shortcutKeysCheckBox.UseVisualStyleBackColor = true; + this.shortcutKeysCheckBox.Click += new System.EventHandler(this.ShortcutKeysCheckBox_Click); + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1125,5 +1138,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox clearClipboardTextBox; private System.Windows.Forms.Label clearClipboardLabel; private System.Windows.Forms.CheckBox statusPanelClipboardCheckBox; + private System.Windows.Forms.CheckBox shortcutKeysCheckBox; } } \ No newline at end of file diff --git a/Crypto Notepad/Forms/SettingsForm.cs b/Crypto Notepad/Forms/SettingsForm.cs index 8e4cd73..9b8c92c 100644 --- a/Crypto Notepad/Forms/SettingsForm.cs +++ b/Crypto Notepad/Forms/SettingsForm.cs @@ -35,6 +35,7 @@ private void LoadSettings() autoCheckUpdatesCheckBox.Checked = settings.autoCheckUpdate; mainMenuCheckBox.Checked = settings.mainMenuVisible; menuIconsCheckBox.Checked = settings.menuIcons; + shortcutKeysCheckBox.Checked = settings.shortcutKeys; minimizeToTrayCheckBox.Checked = settings.minimizeToTray; closeToTrayCheckBox.Checked = settings.closeToTray; singleInstanceCheckBox.Checked = settings.singleInstance; @@ -608,5 +609,11 @@ private void ClearClipboardTextBox_TextChanged(object sender, EventArgs e) } + private void ShortcutKeysCheckBox_Click(object sender, EventArgs e) + { + MainForm main = Owner as MainForm; + settings.shortcutKeys = shortcutKeysCheckBox.Checked; + main.ShortcutKeys(settings.shortcutKeys); + } } } \ No newline at end of file diff --git a/Crypto Notepad/Properties/Settings.Designer.cs b/Crypto Notepad/Properties/Settings.Designer.cs index 1905de8..490758a 100644 --- a/Crypto Notepad/Properties/Settings.Designer.cs +++ b/Crypto Notepad/Properties/Settings.Designer.cs @@ -777,5 +777,17 @@ public bool statusPanelClipboard { this["statusPanelClipboard"] = value; } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool shortcutKeys { + get { + return ((bool)(this["shortcutKeys"])); + } + set { + this["shortcutKeys"] = value; + } + } } } diff --git a/Crypto Notepad/Properties/Settings.settings b/Crypto Notepad/Properties/Settings.settings index 9fde883..11b94a4 100644 --- a/Crypto Notepad/Properties/Settings.settings +++ b/Crypto Notepad/Properties/Settings.settings @@ -176,5 +176,8 @@ False + + True + \ No newline at end of file