WIP: tile group controls

This commit is contained in:
Ray 2020-05-03 19:36:06 +01:00
parent 92ee5e8eed
commit be44cff6ff
6 changed files with 271 additions and 9 deletions

View File

@ -43,8 +43,8 @@ namespace AppLauncher.Windows.Forms
[Browsable(false)] [Browsable(false)]
public override AutoValidate AutoValidate { get => base.AutoValidate; set => base.AutoValidate = value; } public override AutoValidate AutoValidate { get => base.AutoValidate; set => base.AutoValidate = value; }
[Browsable(false)] //[Browsable(false)]
public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; } //public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; }
[Browsable(false)] [Browsable(false)]
public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; } public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; }

View File

@ -52,6 +52,7 @@
// //
// panel1 // panel1
// //
this.panel1.AllowDrop = true;
this.panel1.AutoScrollMargin = new System.Drawing.Size(0, 0); this.panel1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0); this.panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.panel1.BackColor = System.Drawing.Color.Transparent; this.panel1.BackColor = System.Drawing.Color.Transparent;
@ -72,7 +73,7 @@
// //
this.addToolStripMenuItem.Name = "addToolStripMenuItem"; this.addToolStripMenuItem.Name = "addToolStripMenuItem";
this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.addToolStripMenuItem.Text = "&Add"; this.addToolStripMenuItem.Text = "&Add Tile";
this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click); this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click);
// //
// TileContainer // TileContainer

View File

@ -76,6 +76,24 @@ namespace AppLauncher.Windows.Forms
} }
} }
public FlowLayoutPanel FlowLayoutPanel
{
get
{
if (this.Parent == null)
{
return null;
}
if (this.Parent.GetType() != typeof(FlowLayoutPanel))
{
return null;
}
return this.Parent as FlowLayoutPanel;
}
}
public async Task Collapse() public async Task Collapse()
{ {
await Task.Run(() => await Task.Run(() =>
@ -181,6 +199,89 @@ namespace AppLauncher.Windows.Forms
} }
} }
public void AddGroup()
{
if (this.FlowLayoutPanel == null)
{
return;
}
this.FlowLayoutPanel.Controls.Add(new TileContainer(new TileGroupModel()
{
Title = "New Group",
GridSize = new Size(8, 1)
}));
}
public void EditGroup()
{
}
public void MoveTop()
{
if (this.FlowLayoutPanel == null)
{
return;
}
this.FlowLayoutPanel.Controls.SetChildIndex(this, 0);
}
public void MoveUp()
{
if (this.FlowLayoutPanel == null)
{
return;
}
int pos = this.FlowLayoutPanel.Controls.GetChildIndex(this);
if (pos <= 0)
{
return;
}
this.FlowLayoutPanel.Controls.SetChildIndex(this, (pos - 1));
}
public void MoveDown()
{
if (this.FlowLayoutPanel == null)
{
return;
}
int pos = this.FlowLayoutPanel.Controls.GetChildIndex(this);
if (pos >= (this.FlowLayoutPanel.Controls.Count - 1))
{
return;
}
this.FlowLayoutPanel.Controls.SetChildIndex(this, (pos + 1));
}
public void MoveBottom()
{
if (this.FlowLayoutPanel == null)
{
return;
}
this.FlowLayoutPanel.Controls.SetChildIndex(this, (this.FlowLayoutPanel.Controls.Count - 1));
}
public void Remove()
{
if (this.FlowLayoutPanel == null)
{
return;
}
this.FlowLayoutPanel.Controls.Remove(this);
}
private void addToolStripMenuItem_Click(object sender, EventArgs e) private void addToolStripMenuItem_Click(object sender, EventArgs e)
{ {
AddTileForm addForm = new AddTileForm(panel1); AddTileForm addForm = new AddTileForm(panel1);

View File

@ -28,8 +28,21 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = 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();
this.upToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.downToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -39,6 +52,7 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ContextMenuStrip = this.contextMenuStrip1;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234)))));
this.label1.Location = new System.Drawing.Point(25, 0); this.label1.Location = new System.Drawing.Point(25, 0);
@ -51,12 +65,95 @@
this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
// //
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2,
this.toolStripMenuItem1,
this.toolStripSeparator2,
this.toolStripMenuItem4,
this.toolStripSeparator1,
this.toolStripMenuItem3});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(133, 104);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(132, 22);
this.toolStripMenuItem2.Text = "&Add Group";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(132, 22);
this.toolStripMenuItem1.Text = "&Edit";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(129, 6);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.topToolStripMenuItem,
this.upToolStripMenuItem,
this.downToolStripMenuItem,
this.bottomToolStripMenuItem});
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(132, 22);
this.toolStripMenuItem4.Text = "&Move";
//
// topToolStripMenuItem
//
this.topToolStripMenuItem.Name = "topToolStripMenuItem";
this.topToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.topToolStripMenuItem.Text = "&Top";
this.topToolStripMenuItem.Click += new System.EventHandler(this.topToolStripMenuItem_Click);
//
// upToolStripMenuItem
//
this.upToolStripMenuItem.Name = "upToolStripMenuItem";
this.upToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.upToolStripMenuItem.Text = "&Up";
this.upToolStripMenuItem.Click += new System.EventHandler(this.upToolStripMenuItem_Click);
//
// downToolStripMenuItem
//
this.downToolStripMenuItem.Name = "downToolStripMenuItem";
this.downToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.downToolStripMenuItem.Text = "&Down";
this.downToolStripMenuItem.Click += new System.EventHandler(this.downToolStripMenuItem_Click);
//
// bottomToolStripMenuItem
//
this.bottomToolStripMenuItem.Name = "bottomToolStripMenuItem";
this.bottomToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.bottomToolStripMenuItem.Text = "&Bottom";
this.bottomToolStripMenuItem.Click += new System.EventHandler(this.bottomToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(129, 6);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(132, 22);
this.toolStripMenuItem3.Text = "&Remove";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
//
// pictureBox1 // pictureBox1
// //
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left))); | System.Windows.Forms.AnchorStyles.Left)));
this.pictureBox1.BackColor = System.Drawing.Color.Transparent; this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.pictureBox1.ContextMenuStrip = this.contextMenuStrip1;
this.pictureBox1.ErrorImage = null; this.pictureBox1.ErrorImage = null;
this.pictureBox1.InitialImage = null; this.pictureBox1.InitialImage = null;
this.pictureBox1.Location = new System.Drawing.Point(0, 0); this.pictureBox1.Location = new System.Drawing.Point(0, 0);
@ -70,16 +167,18 @@
this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
// //
// HeadingPanel // TileGroupLabel
// //
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.ContextMenuStrip = this.contextMenuStrip1;
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.MinimumSize = new System.Drawing.Size(100, 20); this.MinimumSize = new System.Drawing.Size(100, 20);
this.Name = "HeadingPanel"; this.Name = "TileGroupLabel";
this.Size = new System.Drawing.Size(600, 20); this.Size = new System.Drawing.Size(600, 20);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick);
this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -89,5 +188,16 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem topToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem upToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem downToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem bottomToolStripMenuItem;
} }
} }

View File

@ -25,10 +25,7 @@ namespace AppLauncher.Windows.Forms
pictureBox1.BackgroundImage = (value) ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16; pictureBox1.BackgroundImage = (value) ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16;
if (this.TileGroupPanel != null) if (this.TileGroupPanel != null) this.TileGroupPanel.InvalidateContainer();
{
this.TileGroupPanel.InvalidateContainer();
}
} }
} }
@ -45,5 +42,55 @@ namespace AppLauncher.Windows.Forms
this.Checked = !this.Checked; this.Checked = !this.Checked;
} }
private void topToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.MoveTop();
}
private void bottomToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.MoveBottom();
}
private void upToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.MoveUp();
}
private void downToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.MoveDown();
}
/// <summary>
/// Add group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem2_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.AddGroup();
}
/// <summary>
/// Edit group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem1_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.EditGroup();
}
/// <summary>
/// Remove group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem3_Click(object sender, System.EventArgs e)
{
if (this.TileGroupPanel != null) this.TileGroupPanel.Remove();
}
} }
} }

View File

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>