From fed20a59d7b7c323529ec85e226f1e6f97bbb3b6 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Wed, 5 Aug 2020 15:33:45 +0200 Subject: [PATCH] [Feature] Option to remove taskbar icon (#123), version 1.0.14.1 --- Business/App.cs | 42 +++++---- Properties/AssemblyInfo.cs | 4 +- Properties/CustomSettingsProvider.cs | 2 +- Properties/Settings.Designer.cs | 24 +++++ Properties/Settings.settings | 6 ++ Resources/lang.Designer.cs | 27 ++++++ Resources/lang.de-DE.resx | 9 ++ Resources/lang.resx | 9 ++ UserInterface/SettingsForm.Designer.cs | 122 ++++++++++++++++++++++--- UserInterface/SettingsForm.cs | 28 +++++- 10 files changed, 239 insertions(+), 34 deletions(-) diff --git a/Business/App.cs b/Business/App.cs index 699db34..05e8771 100644 --- a/Business/App.cs +++ b/Business/App.cs @@ -17,7 +17,7 @@ namespace SystemTrayMenu { private readonly AppNotifyIcon menuNotifyIcon = new AppNotifyIcon(); private readonly Menus menus = new Menus(); - private readonly TaskbarForm taskbarForm = new TaskbarForm(); + private readonly TaskbarForm taskbarForm = null; public App() { @@ -35,26 +35,30 @@ namespace SystemTrayMenu menuNotifyIcon.OpenLog += Log.OpenLogFile; menus.MainPreload(); - taskbarForm.Activated += TasbkarItemActivated; - void TasbkarItemActivated(object sender, EventArgs e) + if (!Properties.Settings.Default.HideTaskbarForm) { - SetStateNormal(); - taskbarForm.Activate(); - taskbarForm.Focus(); - menus.SwitchOpenCloseByTaskbarItem(); - } + taskbarForm = new TaskbarForm(); + taskbarForm.Activated += TasbkarItemActivated; + void TasbkarItemActivated(object sender, EventArgs e) + { + SetStateNormal(); + taskbarForm.Activate(); + taskbarForm.Focus(); + menus.SwitchOpenCloseByTaskbarItem(); + } - taskbarForm.Resize += TaskbarForm_Resize; - taskbarForm.FormClosed += TaskbarForm_FormClosed; - static void TaskbarForm_FormClosed(object sender, FormClosedEventArgs e) - { - Application.Exit(); - } + taskbarForm.Resize += TaskbarForm_Resize; + taskbarForm.FormClosed += TaskbarForm_FormClosed; + static void TaskbarForm_FormClosed(object sender, FormClosedEventArgs e) + { + Application.Exit(); + } - taskbarForm.Deactivate += TaskbarForm_Deactivate; - void TaskbarForm_Resize(object sender, EventArgs e) - { - SetStateNormal(); + taskbarForm.Deactivate += TaskbarForm_Deactivate; + void TaskbarForm_Resize(object sender, EventArgs e) + { + SetStateNormal(); + } } DllImports.NativeMethods.User32ShowInactiveTopmost(taskbarForm); @@ -62,7 +66,7 @@ namespace SystemTrayMenu public void Dispose() { - taskbarForm.Dispose(); + taskbarForm?.Dispose(); menus.Dispose(); menuNotifyIcon.Dispose(); } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index ffe547f..1475605 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.14.0")] -[assembly: AssemblyFileVersion("1.0.14.0")] +[assembly: AssemblyVersion("1.0.14.1")] +[assembly: AssemblyFileVersion("1.0.14.1")] diff --git a/Properties/CustomSettingsProvider.cs b/Properties/CustomSettingsProvider.cs index 4f78b27..1abcf40 100644 --- a/Properties/CustomSettingsProvider.cs +++ b/Properties/CustomSettingsProvider.cs @@ -51,7 +51,7 @@ namespace SystemTrayMenu.Properties /// Gets the setting key this is returning must set before the settings are used. /// e.g. Properties.Settings.Default.SettingsKey = @"C:\temp\user.config";. /// - private string UserConfigPath + private static string UserConfigPath { get { diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 12b87dc..d4ceec9 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -87,5 +87,29 @@ namespace SystemTrayMenu.Properties { this["IsUpgraded"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool HideTaskbarForm { + get { + return ((bool)(this["HideTaskbarForm"])); + } + set { + this["HideTaskbarForm"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool OpenItemWithOneClick { + get { + return ((bool)(this["OpenItemWithOneClick"])); + } + set { + this["OpenItemWithOneClick"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 5bef7ae..0ccc7c1 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -17,5 +17,11 @@ False + + False + + + False + \ No newline at end of file diff --git a/Resources/lang.Designer.cs b/Resources/lang.Designer.cs index a18195f..f3703f5 100644 --- a/Resources/lang.Designer.cs +++ b/Resources/lang.Designer.cs @@ -132,6 +132,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Expert. + /// + internal static string Expert { + get { + return ResourceManager.GetString("Expert", resourceCulture); + } + } + /// /// Looks up a localized string similar to Folder. /// @@ -186,6 +195,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Hide Taskbar Icon. + /// + internal static string Hide_Taskbar_Icon { + get { + return ResourceManager.GetString("Hide Taskbar Icon", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hotkey. /// @@ -267,6 +285,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Single click to start item. + /// + internal static string Single_click_to_start_item { + get { + return ResourceManager.GetString("Single click to start item", resourceCulture); + } + } + /// /// Looks up a localized string similar to SystemTrayMenu. /// diff --git a/Resources/lang.de-DE.resx b/Resources/lang.de-DE.resx index e58fe87..e47b609 100644 --- a/Resources/lang.de-DE.resx +++ b/Resources/lang.de-DE.resx @@ -195,4 +195,13 @@ Du hast keine Rechte für den Hauptordner. Gewähre die Rechte oder ändere den Hauptordner. + + Experte + + + Taskbar Icon verstecken + + + Einzelner Klick, um Item zu starten + \ No newline at end of file diff --git a/Resources/lang.resx b/Resources/lang.resx index 8e37817..539b861 100644 --- a/Resources/lang.resx +++ b/Resources/lang.resx @@ -195,4 +195,13 @@ You have no access to the root folder for the SystemTrayMenu. Grant access to the folder or change the root folder. + + Expert + + + Hide Taskbar Icon + + + Single click to start item + \ No newline at end of file diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index b73c9df..dd1bf1a 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -32,7 +32,7 @@ namespace SystemTrayMenu.UserInterface { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm)); this.tableLayoutPanelMain = new System.Windows.Forms.TableLayoutPanel(); - this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabControlExpert = new System.Windows.Forms.TabControl(); this.tabPageGeneral = new System.Windows.Forms.TabPage(); this.tableLayoutPanelGeneral = new System.Windows.Forms.TableLayoutPanel(); this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); @@ -52,13 +52,21 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelBottom = new System.Windows.Forms.TableLayoutPanel(); this.buttonOk = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); + this.tabPageExpert = new System.Windows.Forms.TabPage(); + this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); + this.labelHideTaskbarForm = new System.Windows.Forms.Label(); + this.labelOpenItemWithOneClick = new System.Windows.Forms.Label(); + this.checkBoxOpenItemWithOneClick = new System.Windows.Forms.CheckBox(); + this.checkBoxHideTaskbarForm = new System.Windows.Forms.CheckBox(); this.tableLayoutPanelMain.SuspendLayout(); - this.tabControl1.SuspendLayout(); + this.tabControlExpert.SuspendLayout(); this.tabPageGeneral.SuspendLayout(); this.tableLayoutPanelGeneral.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel5.SuspendLayout(); this.tableLayoutPanelBottom.SuspendLayout(); + this.tabPageExpert.SuspendLayout(); + this.tableLayoutPanel6.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanelMain @@ -67,7 +75,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanelMain.ColumnCount = 1; this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanelMain.Controls.Add(this.tabControl1, 0, 0); + this.tableLayoutPanelMain.Controls.Add(this.tabControlExpert, 0, 0); this.tableLayoutPanelMain.Controls.Add(this.tableLayoutPanelBottom, 0, 1); this.tableLayoutPanelMain.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanelMain.Name = "tableLayoutPanelMain"; @@ -79,12 +87,13 @@ namespace SystemTrayMenu.UserInterface // // tabControl1 // - this.tabControl1.Controls.Add(this.tabPageGeneral); - this.tabControl1.Location = new System.Drawing.Point(3, 3); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(395, 240); - this.tabControl1.TabIndex = 0; + this.tabControlExpert.Controls.Add(this.tabPageGeneral); + this.tabControlExpert.Controls.Add(this.tabPageExpert); + this.tabControlExpert.Location = new System.Drawing.Point(3, 3); + this.tabControlExpert.Name = "tabControl1"; + this.tabControlExpert.SelectedIndex = 0; + this.tabControlExpert.Size = new System.Drawing.Size(395, 240); + this.tabControlExpert.TabIndex = 0; // // tabPageGeneral // @@ -122,6 +131,8 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanelGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanelGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanelGeneral.Size = new System.Drawing.Size(313, 145); this.tableLayoutPanelGeneral.TabIndex = 0; // @@ -365,6 +376,85 @@ namespace SystemTrayMenu.UserInterface this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // + // tabPageExpert + // + this.tabPageExpert.Controls.Add(this.tableLayoutPanel6); + this.tabPageExpert.Location = new System.Drawing.Point(4, 22); + this.tabPageExpert.Name = "tabPageExpert"; + this.tabPageExpert.Size = new System.Drawing.Size(387, 214); + this.tabPageExpert.TabIndex = 1; + this.tabPageExpert.Text = "tabPageExpert"; + this.tabPageExpert.UseVisualStyleBackColor = true; + // + // tableLayoutPanel6 + // + this.tableLayoutPanel6.AutoSize = true; + this.tableLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel6.ColumnCount = 3; + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 12F)); + this.tableLayoutPanel6.Controls.Add(this.labelHideTaskbarForm, 0, 0); + this.tableLayoutPanel6.Controls.Add(this.labelOpenItemWithOneClick, 0, 1); + this.tableLayoutPanel6.Controls.Add(this.checkBoxOpenItemWithOneClick, 1, 1); + this.tableLayoutPanel6.Controls.Add(this.checkBoxHideTaskbarForm, 1, 0); + this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3); + this.tableLayoutPanel6.Name = "tableLayoutPanel6"; + this.tableLayoutPanel6.RowCount = 3; + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel6.Size = new System.Drawing.Size(361, 88); + this.tableLayoutPanel6.TabIndex = 1; + // + // labelShowTaskbarForm + // + this.labelHideTaskbarForm.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.labelHideTaskbarForm.AutoSize = true; + this.labelHideTaskbarForm.Location = new System.Drawing.Point(3, 5); + this.labelHideTaskbarForm.Name = "labelShowTaskbarForm"; + this.labelHideTaskbarForm.Size = new System.Drawing.Size(118, 13); + this.labelHideTaskbarForm.TabIndex = 104; + this.labelHideTaskbarForm.Text = "labelShowTaskbarForm"; + // + // labelOpenItemWithOneClick + // + this.labelOpenItemWithOneClick.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.labelOpenItemWithOneClick.AutoSize = true; + this.labelOpenItemWithOneClick.Location = new System.Drawing.Point(3, 29); + this.labelOpenItemWithOneClick.Name = "labelOpenItemWithOneClick"; + this.labelOpenItemWithOneClick.Size = new System.Drawing.Size(140, 13); + this.labelOpenItemWithOneClick.TabIndex = 105; + this.labelOpenItemWithOneClick.Text = "labelOpenItemWithOneClick"; + // + // checkBoxOpenItemWithOneClick + // + this.checkBoxOpenItemWithOneClick.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxOpenItemWithOneClick.AutoSize = true; + this.checkBoxOpenItemWithOneClick.Location = new System.Drawing.Point(155, 31); + this.checkBoxOpenItemWithOneClick.Margin = new System.Windows.Forms.Padding(9, 7, 9, 0); + this.checkBoxOpenItemWithOneClick.Name = "checkBoxOpenItemWithOneClick"; + this.checkBoxOpenItemWithOneClick.Size = new System.Drawing.Size(185, 17); + this.checkBoxOpenItemWithOneClick.TabIndex = 106; + this.checkBoxOpenItemWithOneClick.Text = "checkBoxOpenItemWithOneClick"; + this.checkBoxOpenItemWithOneClick.UseVisualStyleBackColor = true; + // + // checkBoxShowTaskbarForm + // + this.checkBoxHideTaskbarForm.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxHideTaskbarForm.AutoSize = true; + this.checkBoxHideTaskbarForm.Location = new System.Drawing.Point(155, 7); + this.checkBoxHideTaskbarForm.Margin = new System.Windows.Forms.Padding(9, 7, 9, 0); + this.checkBoxHideTaskbarForm.Name = "checkBoxShowTaskbarForm"; + this.checkBoxHideTaskbarForm.Size = new System.Drawing.Size(185, 17); + this.checkBoxHideTaskbarForm.TabIndex = 107; + this.checkBoxHideTaskbarForm.Text = "checkBoxShowTaskbarForm"; + this.checkBoxHideTaskbarForm.UseVisualStyleBackColor = true; + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -383,7 +473,7 @@ namespace SystemTrayMenu.UserInterface this.Load += new System.EventHandler(this.SettingsForm_Load); this.tableLayoutPanelMain.ResumeLayout(false); this.tableLayoutPanelMain.PerformLayout(); - this.tabControl1.ResumeLayout(false); + this.tabControlExpert.ResumeLayout(false); this.tabPageGeneral.ResumeLayout(false); this.tabPageGeneral.PerformLayout(); this.tableLayoutPanelGeneral.ResumeLayout(false); @@ -394,6 +484,10 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanel5.PerformLayout(); this.tableLayoutPanelBottom.ResumeLayout(false); this.tableLayoutPanelBottom.PerformLayout(); + this.tabPageExpert.ResumeLayout(false); + this.tabPageExpert.PerformLayout(); + this.tableLayoutPanel6.ResumeLayout(false); + this.tableLayoutPanel6.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -404,7 +498,7 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.TableLayoutPanel tableLayoutPanelMain; private System.Windows.Forms.Button buttonOk; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelBottom; - private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabControl tabControlExpert; private System.Windows.Forms.TabPage tabPageGeneral; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.ComboBox comboBoxLanguage; @@ -423,5 +517,11 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.Label labelAutostart; private System.Windows.Forms.Label labelHotkey; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelGeneral; + private System.Windows.Forms.TabPage tabPageExpert; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; + private System.Windows.Forms.Label labelHideTaskbarForm; + private System.Windows.Forms.Label labelOpenItemWithOneClick; + private System.Windows.Forms.CheckBox checkBoxOpenItemWithOneClick; + private System.Windows.Forms.CheckBox checkBoxHideTaskbarForm; } } \ No newline at end of file diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index 7f25302..29f6591 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -29,11 +29,16 @@ namespace SystemTrayMenu.UserInterface { Text = Translator.GetText("Settings"); tabPageGeneral.Text = Translator.GetText("General"); + tabPageExpert.Text = Translator.GetText("Expert"); labelFolder.Text = Translator.GetText("Folder"); labelAutostart.Text = Translator.GetText("Autostart"); checkBoxAutostart.Text = Translator.GetText("Launch on startup"); labelHotkey.Text = Translator.GetText("Hotkey"); labelLanguage.Text = Translator.GetText("Language"); + labelHideTaskbarForm.Text = string.Empty; + checkBoxHideTaskbarForm.Text = Translator.GetText("Hide Taskbar Icon"); + labelOpenItemWithOneClick.Text = string.Empty; + checkBoxOpenItemWithOneClick.Text = Translator.GetText("Single click to start item"); buttonOk.Text = Translator.GetText("buttonOk"); buttonCancel.Text = Translator.GetText("buttonCancel"); } @@ -75,6 +80,20 @@ namespace SystemTrayMenu.UserInterface comboBoxLanguage.SelectedValue = "en"; } } + + InitializeHideTaskbarForm(); + void InitializeHideTaskbarForm() + { + checkBoxHideTaskbarForm.Checked = + Properties.Settings.Default.HideTaskbarForm; + } + + InitializeOpenItemWithOneClick(); + void InitializeOpenItemWithOneClick() + { + checkBoxOpenItemWithOneClick.Checked = + Properties.Settings.Default.OpenItemWithOneClick; + } } public string NewHotKey => newHotKey; @@ -237,7 +256,7 @@ namespace SystemTrayMenu.UserInterface private void SettingsForm_Load(object sender, EventArgs e) { - tabControl1.Size = new Size( + tabControlExpert.Size = new Size( tableLayoutPanelGeneral.Size.Width, tableLayoutPanelGeneral.Size.Height); } @@ -247,6 +266,7 @@ namespace SystemTrayMenu.UserInterface SetAutostart(); SetHotkey(); SetLanguage(); + SetExpertOptions(); Properties.Settings.Default.Save(); DialogResult = DialogResult.OK; Close(); @@ -285,6 +305,12 @@ namespace SystemTrayMenu.UserInterface comboBoxLanguage.SelectedValue.ToString(); } + private void SetExpertOptions() + { + Properties.Settings.Default.HideTaskbarForm = checkBoxHideTaskbarForm.Checked; + Properties.Settings.Default.OpenItemWithOneClick = checkBoxOpenItemWithOneClick.Checked; + } + private void ButtonCancel_Click(object sender, EventArgs e) { Properties.Settings.Default.Reload();