From 17ac0a435590449327e48d743b5c9144cc5d33d5 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 9 Nov 2020 00:58:27 +0000 Subject: [PATCH] Changed: better stability on animation --- .../Forms/Tile/TTilePanelLayout.Designer.cs | 63 +++++---- Windows/Forms/Tile/TTilePanelLayout.cs | 123 +++++++++++++----- 2 files changed, 129 insertions(+), 57 deletions(-) diff --git a/Windows/Forms/Tile/TTilePanelLayout.Designer.cs b/Windows/Forms/Tile/TTilePanelLayout.Designer.cs index 93e43a8..7f5696d 100644 --- a/Windows/Forms/Tile/TTilePanelLayout.Designer.cs +++ b/Windows/Forms/Tile/TTilePanelLayout.Designer.cs @@ -36,6 +36,7 @@ this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.removeRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); this.topToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -44,7 +45,7 @@ this.bottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); - this.removeRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label1 = new System.Windows.Forms.Label(); this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip2.SuspendLayout(); this.SuspendLayout(); @@ -55,20 +56,20 @@ this.addToolStripMenuItem, this.addListToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(139, 48); + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); // // addToolStripMenuItem // this.addToolStripMenuItem.Name = "addToolStripMenuItem"; - this.addToolStripMenuItem.Size = new System.Drawing.Size(138, 22); + this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.addToolStripMenuItem.Text = "&Add Tile"; this.addToolStripMenuItem.Click += new System.EventHandler(this.addTileMenuItem_Click); // // addListToolStripMenuItem // this.addListToolStripMenuItem.Name = "addListToolStripMenuItem"; - this.addListToolStripMenuItem.Size = new System.Drawing.Size(138, 22); - this.addListToolStripMenuItem.Text = "Add &List Tile"; + this.addListToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.addListToolStripMenuItem.Text = "Add &Folder"; this.addListToolStripMenuItem.Click += new System.EventHandler(this.addListTileMenuItem_Click); // // contextMenuStrip2 @@ -83,33 +84,40 @@ this.toolStripSeparator1, this.toolStripMenuItem3}); this.contextMenuStrip2.Name = "contextMenuStrip1"; - this.contextMenuStrip2.Size = new System.Drawing.Size(181, 170); + this.contextMenuStrip2.Size = new System.Drawing.Size(144, 148); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem2.Size = new System.Drawing.Size(143, 22); this.toolStripMenuItem2.Text = "&Add Group"; this.toolStripMenuItem2.Click += new System.EventHandler(this.addGroupMenuItem_Click); // // toolStripMenuItem5 // this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem5.Size = new System.Drawing.Size(143, 22); this.toolStripMenuItem5.Text = "Add &Row"; this.toolStripMenuItem5.Click += new System.EventHandler(this.addRowMenuItem_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem1.Size = new System.Drawing.Size(143, 22); this.toolStripMenuItem1.Text = "&Edit"; this.toolStripMenuItem1.Click += new System.EventHandler(this.editGroupMenuItem_Click); // + // removeRowToolStripMenuItem + // + this.removeRowToolStripMenuItem.Name = "removeRowToolStripMenuItem"; + this.removeRowToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.removeRowToolStripMenuItem.Text = "Remo&ve Row"; + this.removeRowToolStripMenuItem.Click += new System.EventHandler(this.removeRowToolStripMenuItem_Click); + // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(140, 6); // // toolStripMenuItem4 // @@ -119,66 +127,76 @@ this.downToolStripMenuItem, this.bottomToolStripMenuItem}); this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem4.Size = new System.Drawing.Size(143, 22); this.toolStripMenuItem4.Text = "&Move"; // // topToolStripMenuItem // this.topToolStripMenuItem.Name = "topToolStripMenuItem"; - this.topToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.topToolStripMenuItem.Size = new System.Drawing.Size(114, 22); this.topToolStripMenuItem.Text = "&Top"; this.topToolStripMenuItem.Click += new System.EventHandler(this.moveTopMenuItem_Click); // // upToolStripMenuItem // this.upToolStripMenuItem.Name = "upToolStripMenuItem"; - this.upToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.upToolStripMenuItem.Size = new System.Drawing.Size(114, 22); this.upToolStripMenuItem.Text = "&Up"; this.upToolStripMenuItem.Click += new System.EventHandler(this.moveUpMenuItem_Click); // // downToolStripMenuItem // this.downToolStripMenuItem.Name = "downToolStripMenuItem"; - this.downToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.downToolStripMenuItem.Size = new System.Drawing.Size(114, 22); this.downToolStripMenuItem.Text = "&Down"; this.downToolStripMenuItem.Click += new System.EventHandler(this.moveDownMenuItem_Click); // // bottomToolStripMenuItem // this.bottomToolStripMenuItem.Name = "bottomToolStripMenuItem"; - this.bottomToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.bottomToolStripMenuItem.Size = new System.Drawing.Size(114, 22); this.bottomToolStripMenuItem.Text = "&Bottom"; this.bottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(140, 6); // // toolStripMenuItem3 // this.toolStripMenuItem3.Name = "toolStripMenuItem3"; - this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem3.Size = new System.Drawing.Size(143, 22); this.toolStripMenuItem3.Text = "&Remove"; this.toolStripMenuItem3.Click += new System.EventHandler(this.removeGroupMenuItem3_Click); // - // removeRowToolStripMenuItem + // label1 // - this.removeRowToolStripMenuItem.Name = "removeRowToolStripMenuItem"; - this.removeRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.removeRowToolStripMenuItem.Text = "Remo&ve Row"; - this.removeRowToolStripMenuItem.Click += new System.EventHandler(this.removeRowToolStripMenuItem_Click); + this.label1.AutoSize = true; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(105)))), ((int)(((byte)(119))))); + this.label1.Image = global::AppLauncher.Properties.Resources.toggle_left_ea_16; + this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label1.Location = new System.Drawing.Point(227, 72); + this.label1.Margin = new System.Windows.Forms.Padding(0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(0, 13); + this.label1.TabIndex = 2; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.label1_MouseClick); + this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.label1_MouseClick); // // TTilePanelLayout // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Transparent; + this.Controls.Add(this.label1); this.Name = "TTilePanelLayout"; this.Size = new System.Drawing.Size(370, 150); this.contextMenuStrip1.ResumeLayout(false); this.contextMenuStrip2.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -199,5 +217,6 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; private System.Windows.Forms.ToolStripMenuItem removeRowToolStripMenuItem; + private System.Windows.Forms.Label label1; } } diff --git a/Windows/Forms/Tile/TTilePanelLayout.cs b/Windows/Forms/Tile/TTilePanelLayout.cs index 7e0bc29..2e99b6c 100644 --- a/Windows/Forms/Tile/TTilePanelLayout.cs +++ b/Windows/Forms/Tile/TTilePanelLayout.cs @@ -46,6 +46,10 @@ namespace AppLauncher.Windows.Forms this.BackColor = Color.Transparent; this.LoadModel(model); + + label1.Location = new Point(0, 4); + label1.Margin = new Padding(0); + label1.Padding = new Padding(0); } protected override void OnDragDrop(DragEventArgs e) @@ -124,16 +128,16 @@ namespace AppLauncher.Windows.Forms //this.Size = new Size(panel1.Width, this.ExpandedHeight); } - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); + //protected override void OnPaint(PaintEventArgs e) + //{ + // base.OnPaint(e); - Graphics g = e.Graphics; + // Graphics g = e.Graphics; - g.DrawImageUnscaled((isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16), 2, 2); + //g.DrawImageUnscaled((isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16), 2, 2); - TextRenderer.DrawText(g, groupModel?.Title, new Font(this.Font.FontFamily, 8.25F), new Point(25, 4), Color.FromArgb(99, 105, 119)); - } + //TextRenderer.DrawText(g, groupModel?.Title, new Font(this.Font.FontFamily, 8.25F), new Point(25, 4), Color.FromArgb(99, 105, 119)); + //} protected override async void OnResize(EventArgs e) { @@ -152,38 +156,38 @@ namespace AppLauncher.Windows.Forms if (e.Button == MouseButtons.Left) { - if (isLabel) - { - isChecked = !isChecked; + //if (isLabel) + //{ + // isChecked = !isChecked; - this.Invalidate(); + // this.Invalidate(); - await this.InvalidateContainer(); + // await this.InvalidateContainer(); - // exclusivity - if (isChecked) - { - if (this.Model.IsExclusive) - { - if (this.FlowLayoutPanel != null) - { - foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType()) - { - if (item.Equals(this)) - { - continue; - } + // // exclusivity + // if (isChecked) + // { + // if (this.Model.IsExclusive) + // { + // if (this.FlowLayoutPanel != null) + // { + // foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType()) + // { + // if (item.Equals(this)) + // { + // continue; + // } - await item.Collapse(); - } - } - } - } - } - else - { - // do nothing - } + // await item.Collapse(); + // } + // } + // } + // } + //} + //else + //{ + // // do nothing + //} } else if (e.Button == MouseButtons.Right) { @@ -417,6 +421,9 @@ namespace AppLauncher.Windows.Forms isChecked = groupModel.IsExpanded; + label1.Text = " " + groupModel?.Title; + label1.Image = (isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16); + this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height); this.LoadTiles(model.Items); this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height); @@ -429,6 +436,8 @@ namespace AppLauncher.Windows.Forms groupModel = model; isChecked = groupModel.IsExpanded; + label1.Text = " " + groupModel?.Title; + this.Invalidate(); } @@ -793,5 +802,49 @@ namespace AppLauncher.Windows.Forms } } + private async void label1_MouseClick(object sender, MouseEventArgs e) + { + if (isAnimating) return; + + if (e.Button == MouseButtons.Left) + { + isChecked = !isChecked; + + label1.Image = (isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16); + + this.Invalidate(); + + await this.InvalidateContainer(); + + // exclusivity + if (isChecked) + { + if (this.Model.IsExclusive) + { + if (this.FlowLayoutPanel != null) + { + foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType()) + { + if (item.Equals(this)) + { + continue; + } + + await item.Collapse(); + } + } + } + } + + label1.Image = (isChecked ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16); + } + else if (e.Button == MouseButtons.Right) + { + contextMenuStrip2.Show(this, e.Location); + } + } + + + } }