Changed: better stability on animation

This commit is contained in:
Ray 2020-11-09 00:58:27 +00:00
parent 0c3a756252
commit 17ac0a4355
2 changed files with 129 additions and 57 deletions

View File

@ -36,6 +36,7 @@
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = 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.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.topToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.topToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -44,7 +45,7 @@
this.bottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.bottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); 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.contextMenuStrip1.SuspendLayout();
this.contextMenuStrip2.SuspendLayout(); this.contextMenuStrip2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -55,20 +56,20 @@
this.addToolStripMenuItem, this.addToolStripMenuItem,
this.addListToolStripMenuItem}); this.addListToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(139, 48); this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70);
// //
// addToolStripMenuItem // addToolStripMenuItem
// //
this.addToolStripMenuItem.Name = "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.Text = "&Add Tile";
this.addToolStripMenuItem.Click += new System.EventHandler(this.addTileMenuItem_Click); this.addToolStripMenuItem.Click += new System.EventHandler(this.addTileMenuItem_Click);
// //
// addListToolStripMenuItem // addListToolStripMenuItem
// //
this.addListToolStripMenuItem.Name = "addListToolStripMenuItem"; this.addListToolStripMenuItem.Name = "addListToolStripMenuItem";
this.addListToolStripMenuItem.Size = new System.Drawing.Size(138, 22); this.addListToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.addListToolStripMenuItem.Text = "Add &List Tile"; this.addListToolStripMenuItem.Text = "Add &Folder";
this.addListToolStripMenuItem.Click += new System.EventHandler(this.addListTileMenuItem_Click); this.addListToolStripMenuItem.Click += new System.EventHandler(this.addListTileMenuItem_Click);
// //
// contextMenuStrip2 // contextMenuStrip2
@ -83,33 +84,40 @@
this.toolStripSeparator1, this.toolStripSeparator1,
this.toolStripMenuItem3}); this.toolStripMenuItem3});
this.contextMenuStrip2.Name = "contextMenuStrip1"; this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(181, 170); this.contextMenuStrip2.Size = new System.Drawing.Size(144, 148);
// //
// toolStripMenuItem2 // toolStripMenuItem2
// //
this.toolStripMenuItem2.Name = "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.Text = "&Add Group";
this.toolStripMenuItem2.Click += new System.EventHandler(this.addGroupMenuItem_Click); this.toolStripMenuItem2.Click += new System.EventHandler(this.addGroupMenuItem_Click);
// //
// toolStripMenuItem5 // toolStripMenuItem5
// //
this.toolStripMenuItem5.Name = "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.Text = "Add &Row";
this.toolStripMenuItem5.Click += new System.EventHandler(this.addRowMenuItem_Click); this.toolStripMenuItem5.Click += new System.EventHandler(this.addRowMenuItem_Click);
// //
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.Name = "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.Text = "&Edit";
this.toolStripMenuItem1.Click += new System.EventHandler(this.editGroupMenuItem_Click); 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 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(140, 6);
// //
// toolStripMenuItem4 // toolStripMenuItem4
// //
@ -119,66 +127,76 @@
this.downToolStripMenuItem, this.downToolStripMenuItem,
this.bottomToolStripMenuItem}); this.bottomToolStripMenuItem});
this.toolStripMenuItem4.Name = "toolStripMenuItem4"; 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"; this.toolStripMenuItem4.Text = "&Move";
// //
// topToolStripMenuItem // topToolStripMenuItem
// //
this.topToolStripMenuItem.Name = "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.Text = "&Top";
this.topToolStripMenuItem.Click += new System.EventHandler(this.moveTopMenuItem_Click); this.topToolStripMenuItem.Click += new System.EventHandler(this.moveTopMenuItem_Click);
// //
// upToolStripMenuItem // upToolStripMenuItem
// //
this.upToolStripMenuItem.Name = "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.Text = "&Up";
this.upToolStripMenuItem.Click += new System.EventHandler(this.moveUpMenuItem_Click); this.upToolStripMenuItem.Click += new System.EventHandler(this.moveUpMenuItem_Click);
// //
// downToolStripMenuItem // downToolStripMenuItem
// //
this.downToolStripMenuItem.Name = "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.Text = "&Down";
this.downToolStripMenuItem.Click += new System.EventHandler(this.moveDownMenuItem_Click); this.downToolStripMenuItem.Click += new System.EventHandler(this.moveDownMenuItem_Click);
// //
// bottomToolStripMenuItem // bottomToolStripMenuItem
// //
this.bottomToolStripMenuItem.Name = "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.Text = "&Bottom";
this.bottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomMenuItem_Click); this.bottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(140, 6);
// //
// toolStripMenuItem3 // toolStripMenuItem3
// //
this.toolStripMenuItem3.Name = "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.Text = "&Remove";
this.toolStripMenuItem3.Click += new System.EventHandler(this.removeGroupMenuItem3_Click); this.toolStripMenuItem3.Click += new System.EventHandler(this.removeGroupMenuItem3_Click);
// //
// removeRowToolStripMenuItem // label1
// //
this.removeRowToolStripMenuItem.Name = "removeRowToolStripMenuItem"; this.label1.AutoSize = true;
this.removeRowToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(105)))), ((int)(((byte)(119)))));
this.removeRowToolStripMenuItem.Text = "Remo&ve Row"; this.label1.Image = global::AppLauncher.Properties.Resources.toggle_left_ea_16;
this.removeRowToolStripMenuItem.Click += new System.EventHandler(this.removeRowToolStripMenuItem_Click); 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 // TTilePanelLayout
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent; this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.label1);
this.Name = "TTilePanelLayout"; this.Name = "TTilePanelLayout";
this.Size = new System.Drawing.Size(370, 150); this.Size = new System.Drawing.Size(370, 150);
this.contextMenuStrip1.ResumeLayout(false); this.contextMenuStrip1.ResumeLayout(false);
this.contextMenuStrip2.ResumeLayout(false); this.contextMenuStrip2.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -199,5 +217,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem removeRowToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeRowToolStripMenuItem;
private System.Windows.Forms.Label label1;
} }
} }

View File

@ -46,6 +46,10 @@ namespace AppLauncher.Windows.Forms
this.BackColor = Color.Transparent; this.BackColor = Color.Transparent;
this.LoadModel(model); 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) protected override void OnDragDrop(DragEventArgs e)
@ -124,16 +128,16 @@ namespace AppLauncher.Windows.Forms
//this.Size = new Size(panel1.Width, this.ExpandedHeight); //this.Size = new Size(panel1.Width, this.ExpandedHeight);
} }
protected override void OnPaint(PaintEventArgs e) //protected override void OnPaint(PaintEventArgs e)
{ //{
base.OnPaint(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) protected override async void OnResize(EventArgs e)
{ {
@ -152,38 +156,38 @@ namespace AppLauncher.Windows.Forms
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
if (isLabel) //if (isLabel)
{ //{
isChecked = !isChecked; // isChecked = !isChecked;
this.Invalidate(); // this.Invalidate();
await this.InvalidateContainer(); // await this.InvalidateContainer();
// exclusivity // // exclusivity
if (isChecked) // if (isChecked)
{ // {
if (this.Model.IsExclusive) // if (this.Model.IsExclusive)
{ // {
if (this.FlowLayoutPanel != null) // if (this.FlowLayoutPanel != null)
{ // {
foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType<TTilePanelLayout>()) // foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType<TTilePanelLayout>())
{ // {
if (item.Equals(this)) // if (item.Equals(this))
{ // {
continue; // continue;
} // }
await item.Collapse(); // await item.Collapse();
} // }
} // }
} // }
} // }
} //}
else //else
{ //{
// do nothing // // do nothing
} //}
} }
else if (e.Button == MouseButtons.Right) else if (e.Button == MouseButtons.Right)
{ {
@ -417,6 +421,9 @@ namespace AppLauncher.Windows.Forms
isChecked = groupModel.IsExpanded; 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.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height);
this.LoadTiles(model.Items); this.LoadTiles(model.Items);
this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height); this.SetGridSize(groupModel.GridSize.Width, groupModel.GridSize.Height);
@ -429,6 +436,8 @@ namespace AppLauncher.Windows.Forms
groupModel = model; groupModel = model;
isChecked = groupModel.IsExpanded; isChecked = groupModel.IsExpanded;
label1.Text = " " + groupModel?.Title;
this.Invalidate(); 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<TTilePanelLayout>())
{
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);
}
}
} }
} }