[Feature] CodeBuity&Refactor #49,[Feature] Better colors handling #37

This commit is contained in:
Markus Hofknecht 2020-03-21 15:46:35 +01:00
parent f53c252121
commit 2f7ba21327
6 changed files with 36 additions and 39 deletions

View file

@ -47,7 +47,7 @@ namespace SystemTrayMenu
// //
this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.labelTitle.AutoSize = true; this.labelTitle.AutoSize = true;
this.labelTitle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.labelTitle.BackColor = MenuDefines.ColorTitleBackground;
this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTitle.ForeColor = System.Drawing.Color.Black; this.labelTitle.ForeColor = System.Drawing.Color.Black;
this.labelTitle.Location = new System.Drawing.Point(0, 0); this.labelTitle.Location = new System.Drawing.Point(0, 0);

View file

@ -54,7 +54,7 @@ namespace SystemTrayMenu
SetDoubleBuffer(dgv, true); SetDoubleBuffer(dgv, true);
DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle(); DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle();
dgvCellStyle.SelectionBackColor = MenuDefines.FileHover; dgvCellStyle.SelectionBackColor = MenuDefines.ColorSelectedItem;
dgvCellStyle.SelectionForeColor = Color.Black; dgvCellStyle.SelectionForeColor = Color.Black;
this.dgv.DefaultCellStyle = dgvCellStyle; this.dgv.DefaultCellStyle = dgvCellStyle;
@ -99,15 +99,15 @@ namespace SystemTrayMenu
break; break;
case Type.Empty: case Type.Empty:
SetTitle(Language.Translate("Folder empty")); SetTitle(Language.Translate("Folder empty"));
labelTitle.BackColor = MenuDefines.Background; labelTitle.BackColor = MenuDefines.ColorTitleWarning;
break; break;
case Type.NoAccess: case Type.NoAccess:
SetTitle(Language.Translate("Folder inaccessible")); SetTitle(Language.Translate("Folder inaccessible"));
labelTitle.BackColor = MenuDefines.Background; labelTitle.BackColor = MenuDefines.ColorTitleWarning;
break; break;
case Type.MaxReached: case Type.MaxReached:
SetTitle($"Max {MenuDefines.MenusMax - 1} Menus"); SetTitle($"Max {MenuDefines.MenusMax - 1} Menus");
labelTitle.BackColor = MenuDefines.Background; labelTitle.BackColor = MenuDefines.ColorTitleWarning;
break; break;
case Type.Main: case Type.Main:
break; break;
@ -300,12 +300,12 @@ namespace SystemTrayMenu
private void LabelTitle_MouseEnter(object sender, EventArgs e) private void LabelTitle_MouseEnter(object sender, EventArgs e)
{ {
this.labelTitle.BackColor = MenuDefines.FileHover; this.labelTitle.BackColor = MenuDefines.ColorTitleSelected;
} }
private void LabelTitle_MouseLeave(object sender, EventArgs e) private void LabelTitle_MouseLeave(object sender, EventArgs e)
{ {
this.labelTitle.BackColor = MenuDefines.Background; this.labelTitle.BackColor = MenuDefines.ColorTitleBackground;
} }
protected override CreateParams CreateParams protected override CreateParams CreateParams

View file

@ -142,7 +142,6 @@ namespace SystemTrayMenu.Handler
{ {
isStillSelected = true; isStillSelected = true;
menuFromSelected = rowData.SubMenu; menuFromSelected = rowData.SubMenu;
#warning CodeBeauty&Refactor #49 refactor datagridviewrow get
textselected = dgv.Rows[iRowKey]. textselected = dgv.Rows[iRowKey].
Cells[1].Value.ToString(); Cells[1].Value.ToString();
} }
@ -351,12 +350,18 @@ namespace SystemTrayMenu.Handler
public void Select(DataGridView dgv, int i) public void Select(DataGridView dgv, int i)
{ {
int newiMenuKey = ((Menu)dgv.TopLevelControl).Level;
if (i != iRowKey || newiMenuKey != iMenuKey)
{
ClearIsSelectedByKey();
}
iRowKey = i; iRowKey = i;
iMenuKey = ((Menu)dgv.TopLevelControl).Level; iMenuKey = newiMenuKey;
DataGridViewRow row = dgv.Rows[i]; DataGridViewRow row = dgv.Rows[i];
RowData rowData = (RowData)row.Tag; RowData rowData = (RowData)row.Tag;
rowData.IsSelectedByKeyboard = true; rowData.IsSelectedByKeyboard = true;
row.Selected = true; row.Selected = false; //event trigger
row.Selected = true; //event trigger
} }
private bool Select(DataGridView dgv, int i, private bool Select(DataGridView dgv, int i,

View file

@ -7,41 +7,38 @@ namespace SystemTrayMenu
{ {
public static readonly List<string> Languages = public static readonly List<string> Languages =
new List<string>() { "en", "de" }; new List<string>() { "en", "de" };
// windows explorer background white
public static Color File = Color.White; public static Color File = Color.White;
public static Color Folder = Color.White; public static Color Folder = Color.White;
public static Color ColorSelectedItem = AppColors.Blue;
// windows explorer selected text public static Color ColorOpenFolder = AppColors.Green;
public static Color FileHover = Color.FromArgb(204, 232, 255); public static Color ColorTitleWarning = AppColors.Red;
public static Color ColorTitleSelected = AppColors.Yellow;
// windows explorer highlighted text public static Color ColorTitleBackground = AppColors.YellowSlightly;
public static Color FolderOpen = Color.FromArgb(229, 243, 255); public static int KeySearchInterval = 1000;
public static Color Background = Color.FromArgb(229, 243, 255);
internal static Color KeyBoardSelection = Color.FromArgb(204, 232, 255);
internal static int KeySearchInterval = 1000;
public const int MenuRowsHeight = 18; public const int MenuRowsHeight = 18;
public const int LengthMax = 37; public const int LengthMax = 37;
public const int ButtonTextPaddingLeft = 18;
public const int ButtonTextPaddingRight = 12;
public const int Scrollspeed = 4; public const int Scrollspeed = 4;
public const int WaitMenuOpen = 200; public const int WaitMenuOpen = 200;
// 60 fps => 1000ms/60fps =~ 16.6ms // 60 fps => 1000ms/60fps =~ 16.6ms
public const int IntervalFade = 16; public const int IntervalFade = 16;
// 60 fps => 1000ms/60fps =~ 16.6ms // 60 fps => 1000ms/60fps =~ 16.6ms
public const int IntervalLoad = 16; public const int IntervalLoad = 16;
public const double OpacityHalfValue = 0.80; public const double OpacityHalfValue = 0.80;
public const double OpacityInStep = 0.20; public const double OpacityInStep = 0.20;
public const double OpacityOutStep = 0.05; public const double OpacityOutStep = 0.05;
public const double OpacityHalfStep = 0.01; public const double OpacityHalfStep = 0.01;
public const int MenusMax = 50; public const int MenusMax = 50;
public static int MaxClicksInQueue = 1; public static int MaxClicksInQueue = 1;
} }
public static class AppColors
{
public static Color Blue = Color.FromArgb(204, 232, 255);
public static Color BlueSelectedInactive = Color.FromArgb(217, 217, 217);
public static Color Green = Color.FromArgb(194, 245, 222);
public static Color GreenBackgroundInactive = Color.FromArgb(217, 217, 217);
public static Color Red = Color.FromArgb(255, 204, 232);
public static Color Yellow = Color.LightYellow;
public static Color YellowSlightly = Color.Azure;
}
} }

View file

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.2.8")] [assembly: AssemblyVersion("0.9.2.9")]
[assembly: AssemblyFileVersion("0.9.2.8")] [assembly: AssemblyFileVersion("0.9.2.9")]

View file

@ -324,9 +324,6 @@ namespace SystemTrayMenu
if (!isAnyMenuActive) if (!isAnyMenuActive)
{ {
menus[0].SetTitleColorDeactive(); menus[0].SetTitleColorDeactive();
CheckMenuOpenerStop(keyboardInput.iMenuKey,
keyboardInput.iRowKey);
keyboardInput.ClearIsSelectedByKey();
} }
else else
{ {
@ -500,9 +497,7 @@ namespace SystemTrayMenu
if (!keyboardInput.InUse) if (!keyboardInput.InUse)
{ {
keyboardInput.ClearIsSelectedByKey();
keyboardInput.Select(dgv, e.RowIndex); keyboardInput.Select(dgv, e.RowIndex);
CheckMenuOpenerStart(dgv, e.RowIndex); CheckMenuOpenerStart(dgv, e.RowIndex);
} }
} }
@ -609,13 +604,13 @@ namespace SystemTrayMenu
if (rowData.IsSelectedByKeyboard) if (rowData.IsSelectedByKeyboard)
{ {
row.DefaultCellStyle.SelectionBackColor = row.DefaultCellStyle.SelectionBackColor =
MenuDefines.KeyBoardSelection; MenuDefines.ColorSelectedItem;
row.Selected = true; row.Selected = true;
} }
else if (rowData.IsSelected) else if (rowData.IsSelected)
{ {
row.DefaultCellStyle.SelectionBackColor = row.DefaultCellStyle.SelectionBackColor =
MenuDefines.FolderOpen; MenuDefines.ColorOpenFolder;
row.Selected = true; row.Selected = true;
} }
else else