From 86c0771c3e2a4cc6482a6066951741c333074aa6 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sat, 5 Feb 2022 10:32:28 +0100 Subject: [PATCH] [Feature] Visual feedback during click (#311), version 1.2.3.6 --- Business/KeyboardInput.cs | 1 + Business/Menus.cs | 18 ++++++- Business/WaitToLoadMenu.cs | 1 + DataClasses/RowData.cs | 11 ++++ Properties/AssemblyInfo.cs | 4 +- UserInterface/SettingsForm.Designer.cs | 72 +++++++++++++------------- UserInterface/SettingsForm.resx | 9 ++++ 7 files changed, 76 insertions(+), 40 deletions(-) diff --git a/Business/KeyboardInput.cs b/Business/KeyboardInput.cs index ad1a4aa..45ad445 100644 --- a/Business/KeyboardInput.cs +++ b/Business/KeyboardInput.cs @@ -585,6 +585,7 @@ namespace SystemTrayMenu.Handler RowData rowData = (RowData)row.Cells[2].Value; rowData.IsSelected = false; row.Selected = false; + rowData.IsClicking = false; } } } diff --git a/Business/Menus.cs b/Business/Menus.cs index d01170c..05a18c0 100644 --- a/Business/Menus.cs +++ b/Business/Menus.cs @@ -64,6 +64,7 @@ namespace SystemTrayMenu.Business { RowData rowDataToClear = (RowData)row[2]; rowDataToClear.IsMenuOpen = false; + rowDataToClear.IsClicking = false; rowDataToClear.IsSelected = false; rowDataToClear.IsContextMenuOpen = false; } @@ -262,8 +263,9 @@ namespace SystemTrayMenu.Business } else if (closedLoadingMenu && menus[0].IsUsable) { - menuData.RowDataParent.IsSelected = false; menuData.RowDataParent.IsMenuOpen = false; + menuData.RowDataParent.IsClicking = false; + menuData.RowDataParent.IsSelected = false; RefreshSelection(menus[menuLoading.Level - 1].GetDataGridView()); } } @@ -1088,6 +1090,7 @@ namespace SystemTrayMenu.Business { RowData rowData = (RowData)dgv.Rows[hitTestInfo.RowIndex].Cells[2].Value; rowData.MouseDown(dgv, e); + dgv.InvalidateRow(hitTestInfo.RowIndex); } if (e.Button == MouseButtons.Left) @@ -1178,6 +1181,7 @@ namespace SystemTrayMenu.Business { RowData trigger = (RowData)dgv.Rows[hitTestInfo.RowIndex].Cells[2].Value; trigger.DoubleClick(e, out bool toCloseByDoubleClick); + dgv.InvalidateRow(hitTestInfo.RowIndex); if (toCloseByDoubleClick) { MenusFadeOut(); @@ -1208,6 +1212,11 @@ namespace SystemTrayMenu.Business row.DefaultCellStyle.SelectionBackColor = Color.White; row.Selected = false; } + else if (rowData.IsClicking) + { + row.DefaultCellStyle.SelectionBackColor = MenuDefines.ColorIcons; + row.Selected = true; + } else if (rowData.IsContextMenuOpen || (rowData.IsMenuOpen && rowData.IsSelected)) { row.Selected = true; @@ -1248,7 +1257,12 @@ namespace SystemTrayMenu.Business int width = dgv.Columns[0].Width + dgv.Columns[1].Width; Rectangle rowBounds = new(0, e.RowBounds.Top, width, e.RowBounds.Height); - if (rowData.IsContextMenuOpen || (rowData.IsMenuOpen && rowData.IsSelected)) + if (rowData.IsClicking) + { + ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorIcons, ButtonBorderStyle.Solid); + row.DefaultCellStyle.SelectionBackColor = MenuDefines.ColorSelectedItem; + } + else if (rowData.IsContextMenuOpen || (rowData.IsMenuOpen && rowData.IsSelected)) { ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid); row.DefaultCellStyle.SelectionBackColor = MenuDefines.ColorSelectedItem; diff --git a/Business/WaitToLoadMenu.cs b/Business/WaitToLoadMenu.cs index 04f7a05..c3c281f 100644 --- a/Business/WaitToLoadMenu.cs +++ b/Business/WaitToLoadMenu.cs @@ -204,6 +204,7 @@ namespace SystemTrayMenu.Handler if (rowData != null) { rowData.IsSelected = false; + rowData.IsClicking = false; dgv.Rows[rowIndex].Selected = false; this.dgv = null; this.rowIndex = 0; diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index 969fa22..624eab0 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -30,6 +30,8 @@ namespace SystemTrayMenu.DataClasses internal bool IsMenuOpen { get; set; } + internal bool IsClicking { get; set; } + internal bool IsSelected { get; set; } internal bool ContainsMenu { get; set; } @@ -142,6 +144,11 @@ namespace SystemTrayMenu.DataClasses internal void MouseDown(DataGridView dgv, MouseEventArgs e) { + if (e.Button == MouseButtons.Left) + { + IsClicking = true; + } + if (e != null && e.Button == MouseButtons.Right && FileInfo != null && @@ -176,6 +183,8 @@ namespace SystemTrayMenu.DataClasses internal void MouseClick(MouseEventArgs e, out bool toCloseByDoubleClick) { + IsClicking = false; + toCloseByDoubleClick = false; if (Properties.Settings.Default.OpenItemWithOneClick) { @@ -195,6 +204,8 @@ namespace SystemTrayMenu.DataClasses internal void DoubleClick(MouseEventArgs e, out bool toCloseByDoubleClick) { + IsClicking = false; + toCloseByDoubleClick = false; if (!Properties.Settings.Default.OpenItemWithOneClick) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 6d7cb2f..3bbe18c 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.2.3.5")] -[assembly: AssemblyFileVersion("1.2.3.5")] +[assembly: AssemblyVersion("1.2.3.6")] +[assembly: AssemblyFileVersion("1.2.3.6")] diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index 1d0eda0..0966d93 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -304,14 +304,14 @@ namespace SystemTrayMenu.UserInterface this.labelSearchField = new System.Windows.Forms.Label(); this.groupBoxAppearance = new System.Windows.Forms.GroupBox(); this.tableLayoutPanelAppearance = new System.Windows.Forms.TableLayoutPanel(); - this.checkBoxRoundCorners = new System.Windows.Forms.CheckBox(); + this.buttonAppearanceDefault = new System.Windows.Forms.Button(); + this.checkBoxUseFading = new System.Windows.Forms.CheckBox(); this.checkBoxDarkModeAlwaysOn = new System.Windows.Forms.CheckBox(); + this.checkBoxRoundCorners = new System.Windows.Forms.CheckBox(); this.tableLayoutPanelBottom = new System.Windows.Forms.TableLayoutPanel(); this.buttonOk = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.colorDialog = new System.Windows.Forms.ColorDialog(); - this.checkBoxUseFading = new System.Windows.Forms.CheckBox(); - this.buttonAppearanceDefault = new System.Windows.Forms.Button(); this.tableLayoutPanelMain.SuspendLayout(); this.tabControl.SuspendLayout(); this.tabPageGeneral.SuspendLayout(); @@ -4315,16 +4315,29 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelAppearance.Size = new System.Drawing.Size(379, 106); this.tableLayoutPanelAppearance.TabIndex = 1; // - // checkBoxRoundCorners + // buttonAppearanceDefault // - this.checkBoxRoundCorners.AutoSize = true; - this.checkBoxRoundCorners.Dock = System.Windows.Forms.DockStyle.Fill; - this.checkBoxRoundCorners.Location = new System.Drawing.Point(3, 3); - this.checkBoxRoundCorners.Name = "checkBoxRoundCorners"; - this.checkBoxRoundCorners.Size = new System.Drawing.Size(373, 19); - this.checkBoxRoundCorners.TabIndex = 4; - this.checkBoxRoundCorners.Text = "checkBoxRoundCorners"; - this.checkBoxRoundCorners.UseVisualStyleBackColor = true; + this.buttonAppearanceDefault.AutoSize = true; + this.buttonAppearanceDefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonAppearanceDefault.Location = new System.Drawing.Point(3, 78); + this.buttonAppearanceDefault.MinimumSize = new System.Drawing.Size(75, 23); + this.buttonAppearanceDefault.Name = "buttonAppearanceDefault"; + this.buttonAppearanceDefault.Size = new System.Drawing.Size(154, 25); + this.buttonAppearanceDefault.TabIndex = 3; + this.buttonAppearanceDefault.Text = "buttonAppearanceDefault"; + this.buttonAppearanceDefault.UseVisualStyleBackColor = true; + this.buttonAppearanceDefault.Click += new System.EventHandler(this.ButtonAppearanceDefault_Click); + // + // checkBoxUseFading + // + this.checkBoxUseFading.AutoSize = true; + this.checkBoxUseFading.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBoxUseFading.Location = new System.Drawing.Point(3, 28); + this.checkBoxUseFading.Name = "checkBoxUseFading"; + this.checkBoxUseFading.Size = new System.Drawing.Size(373, 19); + this.checkBoxUseFading.TabIndex = 5; + this.checkBoxUseFading.Text = "checkBoxUseFading"; + this.checkBoxUseFading.UseVisualStyleBackColor = true; // // checkBoxDarkModeAlwaysOn // @@ -4338,6 +4351,17 @@ namespace SystemTrayMenu.UserInterface this.checkBoxDarkModeAlwaysOn.UseVisualStyleBackColor = true; this.checkBoxDarkModeAlwaysOn.CheckedChanged += new System.EventHandler(this.CheckBoxDarkModeAlwaysOnCheckedChanged); // + // checkBoxRoundCorners + // + this.checkBoxRoundCorners.AutoSize = true; + this.checkBoxRoundCorners.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBoxRoundCorners.Location = new System.Drawing.Point(3, 3); + this.checkBoxRoundCorners.Name = "checkBoxRoundCorners"; + this.checkBoxRoundCorners.Size = new System.Drawing.Size(373, 19); + this.checkBoxRoundCorners.TabIndex = 4; + this.checkBoxRoundCorners.Text = "checkBoxRoundCorners"; + this.checkBoxRoundCorners.UseVisualStyleBackColor = true; + // // tableLayoutPanelBottom // this.tableLayoutPanelBottom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -4386,30 +4410,6 @@ namespace SystemTrayMenu.UserInterface this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // - // checkBoxUseFading - // - this.checkBoxUseFading.AutoSize = true; - this.checkBoxUseFading.Dock = System.Windows.Forms.DockStyle.Fill; - this.checkBoxUseFading.Location = new System.Drawing.Point(3, 28); - this.checkBoxUseFading.Name = "checkBoxUseFading"; - this.checkBoxUseFading.Size = new System.Drawing.Size(373, 19); - this.checkBoxUseFading.TabIndex = 5; - this.checkBoxUseFading.Text = "checkBoxUseFading"; - this.checkBoxUseFading.UseVisualStyleBackColor = true; - // - // buttonAppearanceDefault - // - this.buttonAppearanceDefault.AutoSize = true; - this.buttonAppearanceDefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonAppearanceDefault.Location = new System.Drawing.Point(3, 78); - this.buttonAppearanceDefault.MinimumSize = new System.Drawing.Size(75, 23); - this.buttonAppearanceDefault.Name = "buttonAppearanceDefault"; - this.buttonAppearanceDefault.Size = new System.Drawing.Size(154, 25); - this.buttonAppearanceDefault.TabIndex = 3; - this.buttonAppearanceDefault.Text = "buttonAppearanceDefault"; - this.buttonAppearanceDefault.UseVisualStyleBackColor = true; - this.buttonAppearanceDefault.Click += new System.EventHandler(this.ButtonAppearanceDefault_Click); - // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); diff --git a/UserInterface/SettingsForm.resx b/UserInterface/SettingsForm.resx index 4bd7aa9..ccfb013 100644 --- a/UserInterface/SettingsForm.resx +++ b/UserInterface/SettingsForm.resx @@ -66,6 +66,15 @@ True + + True + + + True + + + True + 17, 17