Fix design problem when title relative long (#85)

This commit is contained in:
Markus Hofknecht 2020-05-24 01:52:42 +02:00
parent 1bacae552d
commit 3c6e2e2dbc
2 changed files with 67 additions and 54 deletions

View file

@ -33,13 +33,13 @@
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.dgv = new System.Windows.Forms.DataGridView();
this.ColumnIcon = new System.Windows.Forms.DataGridViewImageColumn();
this.ColumnText = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.labelTitle = new SystemTrayMenu.UserInterface.LabelNoCopy();
this.tableLayoutPanelSearch = new System.Windows.Forms.TableLayoutPanel();
this.textBoxSearch = new System.Windows.Forms.TextBox();
this.pictureBoxSearch = new System.Windows.Forms.PictureBox();
this.labelTitle = new SystemTrayMenu.UserInterface.LabelNoCopy();
this.ColumnIcon = new System.Windows.Forms.DataGridViewImageColumn();
this.ColumnText = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit();
this.tableLayoutPanel.SuspendLayout();
this.tableLayoutPanelSearch.SuspendLayout();
@ -52,6 +52,7 @@
this.dgv.AllowUserToDeleteRows = false;
this.dgv.AllowUserToResizeColumns = false;
this.dgv.AllowUserToResizeRows = false;
this.dgv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.dgv.BackgroundColor = System.Drawing.Color.White;
this.dgv.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dgv.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
@ -83,6 +84,36 @@
this.dgv.TabIndex = 4;
this.dgv.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.dgv_MouseWheel);
//
// ColumnIcon
//
this.ColumnIcon.DataPropertyName = "ColumnIcon";
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.NullValue = "System.Drawing.Icon";
dataGridViewCellStyle1.Padding = new System.Windows.Forms.Padding(3, 2, 6, 2);
this.ColumnIcon.DefaultCellStyle = dataGridViewCellStyle1;
this.ColumnIcon.Frozen = true;
this.ColumnIcon.HeaderText = "ColumnIcon";
this.ColumnIcon.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom;
this.ColumnIcon.Name = "ColumnIcon";
this.ColumnIcon.ReadOnly = true;
this.ColumnIcon.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.ColumnIcon.Width = 25;
//
// ColumnText
//
this.ColumnText.DataPropertyName = "ColumnText";
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.ColumnText.DefaultCellStyle = dataGridViewCellStyle2;
this.ColumnText.Frozen = true;
this.ColumnText.HeaderText = "ColumnText";
this.ColumnText.MaxInputLength = 40;
this.ColumnText.Name = "ColumnText";
this.ColumnText.ReadOnly = true;
this.ColumnText.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.ColumnText.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic;
this.ColumnText.Width = 50;
//
// tableLayoutPanel
//
this.tableLayoutPanel.AutoScroll = true;
@ -104,6 +135,26 @@
this.tableLayoutPanel.TabIndex = 3;
this.tableLayoutPanel.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.dgv_MouseWheel);
//
// labelTitle
//
this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.labelTitle.AutoSize = true;
this.labelTitle.BackColor = System.Drawing.Color.Azure;
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.Location = new System.Drawing.Point(0, 0);
this.labelTitle.Margin = new System.Windows.Forms.Padding(0);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 1);
this.labelTitle.Size = new System.Drawing.Size(157, 14);
this.labelTitle.TabIndex = 2;
this.labelTitle.Text = "STM";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelTitle.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.LabelTitle_MouseDoubleClick);
this.labelTitle.MouseEnter += new System.EventHandler(this.LabelTitle_MouseEnter);
this.labelTitle.MouseLeave += new System.EventHandler(this.LabelTitle_MouseLeave);
this.labelTitle.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.dgv_MouseWheel);
//
// tableLayoutPanelSearch
//
this.tableLayoutPanelSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@ -147,56 +198,6 @@
this.pictureBoxSearch.TabIndex = 1;
this.pictureBoxSearch.TabStop = false;
//
// labelTitle
//
this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.labelTitle.AutoSize = true;
this.labelTitle.BackColor = System.Drawing.Color.Azure;
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.Location = new System.Drawing.Point(0, 0);
this.labelTitle.Margin = new System.Windows.Forms.Padding(0);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 1);
this.labelTitle.Size = new System.Drawing.Size(157, 14);
this.labelTitle.TabIndex = 2;
this.labelTitle.Text = "STM";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelTitle.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.LabelTitle_MouseDoubleClick);
this.labelTitle.MouseEnter += new System.EventHandler(this.LabelTitle_MouseEnter);
this.labelTitle.MouseLeave += new System.EventHandler(this.LabelTitle_MouseLeave);
this.labelTitle.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.dgv_MouseWheel);
//
// ColumnIcon
//
this.ColumnIcon.DataPropertyName = "ColumnIcon";
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.NullValue = "System.Drawing.Icon";
dataGridViewCellStyle1.Padding = new System.Windows.Forms.Padding(3, 2, 6, 2);
this.ColumnIcon.DefaultCellStyle = dataGridViewCellStyle1;
this.ColumnIcon.Frozen = true;
this.ColumnIcon.HeaderText = "ColumnIcon";
this.ColumnIcon.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom;
this.ColumnIcon.Name = "ColumnIcon";
this.ColumnIcon.ReadOnly = true;
this.ColumnIcon.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.ColumnIcon.Width = 25;
//
// ColumnText
//
this.ColumnText.DataPropertyName = "ColumnText";
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.ColumnText.DefaultCellStyle = dataGridViewCellStyle2;
this.ColumnText.Frozen = true;
this.ColumnText.HeaderText = "ColumnText";
this.ColumnText.MaxInputLength = 40;
this.ColumnText.Name = "ColumnText";
this.ColumnText.ReadOnly = true;
this.ColumnText.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.ColumnText.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic;
this.ColumnText.Width = 50;
//
// Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);

View file

@ -157,14 +157,17 @@ namespace SystemTrayMenu.UserInterface
case MenuType.Empty:
SetTitle(Translator.GetText("Folder empty"));
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
this.tableLayoutPanelSearch.Visible = false;
break;
case MenuType.NoAccess:
SetTitle(Translator.GetText("Folder inaccessible"));
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
this.tableLayoutPanelSearch.Visible = false;
break;
case MenuType.MaxReached:
SetTitle($"Max {MenuDefines.MenusMax - 1} Menus");
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
this.tableLayoutPanelSearch.Visible = false;
break;
case MenuType.Main:
break;
@ -299,7 +302,16 @@ namespace SystemTrayMenu.UserInterface
{
newWidth += SystemInformation.VerticalScrollBarWidth;
}
dgv.Width = newWidth;
if (labelTitle.Width > newWidth)
{
dgv.Width = labelTitle.Width;
dgv.Columns[1].Width = labelTitle.Width - dgv.Columns[0].Width;
}
else
{
dgv.Width = newWidth;
}
//Only scaling correct with Sans Serif for textBoxSearch. Workaround:
textBoxSearch.Font = new Font("Segoe UI", 8.25F * Scaling.Factor,