From be44cff6ff73554b2abde65b8217ec6f7b223949 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 May 2020 19:36:06 +0100 Subject: [PATCH] WIP: tile group controls --- Windows/Forms/AUserControl.cs | 4 +- Windows/Forms/Tile/TileContainer.Designer.cs | 3 +- Windows/Forms/Tile/TileContainer.cs | 101 ++++++++++++++++ Windows/Forms/Tile/TileGroupLabel.Designer.cs | 114 +++++++++++++++++- Windows/Forms/Tile/TileGroupLabel.cs | 55 ++++++++- Windows/Forms/Tile/TileGroupLabel.resx | 3 + 6 files changed, 271 insertions(+), 9 deletions(-) diff --git a/Windows/Forms/AUserControl.cs b/Windows/Forms/AUserControl.cs index d48b1d6..fef5b7a 100644 --- a/Windows/Forms/AUserControl.cs +++ b/Windows/Forms/AUserControl.cs @@ -43,8 +43,8 @@ namespace AppLauncher.Windows.Forms [Browsable(false)] public override AutoValidate AutoValidate { get => base.AutoValidate; set => base.AutoValidate = value; } - [Browsable(false)] - public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; } + //[Browsable(false)] + //public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; } [Browsable(false)] public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; } diff --git a/Windows/Forms/Tile/TileContainer.Designer.cs b/Windows/Forms/Tile/TileContainer.Designer.cs index 23b6118..9ae6583 100644 --- a/Windows/Forms/Tile/TileContainer.Designer.cs +++ b/Windows/Forms/Tile/TileContainer.Designer.cs @@ -52,6 +52,7 @@ // // panel1 // + this.panel1.AllowDrop = true; this.panel1.AutoScrollMargin = new System.Drawing.Size(0, 0); this.panel1.AutoScrollMinSize = new System.Drawing.Size(0, 0); this.panel1.BackColor = System.Drawing.Color.Transparent; @@ -72,7 +73,7 @@ // this.addToolStripMenuItem.Name = "addToolStripMenuItem"; 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); // // TileContainer diff --git a/Windows/Forms/Tile/TileContainer.cs b/Windows/Forms/Tile/TileContainer.cs index 99b8aee..2347f62 100644 --- a/Windows/Forms/Tile/TileContainer.cs +++ b/Windows/Forms/Tile/TileContainer.cs @@ -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() { 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) { AddTileForm addForm = new AddTileForm(panel1); diff --git a/Windows/Forms/Tile/TileGroupLabel.Designer.cs b/Windows/Forms/Tile/TileGroupLabel.Designer.cs index 461bd35..498aff0 100644 --- a/Windows/Forms/Tile/TileGroupLabel.Designer.cs +++ b/Windows/Forms/Tile/TileGroupLabel.Designer.cs @@ -28,8 +28,21 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); 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.contextMenuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -39,6 +52,7 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); 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.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); 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.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 // this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.pictureBox1.BackColor = System.Drawing.Color.Transparent; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + this.pictureBox1.ContextMenuStrip = this.contextMenuStrip1; this.pictureBox1.ErrorImage = null; this.pictureBox1.InitialImage = null; 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.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); // - // HeadingPanel + // TileGroupLabel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ContextMenuStrip = this.contextMenuStrip1; this.Controls.Add(this.label1); this.Controls.Add(this.pictureBox1); this.MinimumSize = new System.Drawing.Size(100, 20); - this.Name = "HeadingPanel"; + this.Name = "TileGroupLabel"; this.Size = new System.Drawing.Size(600, 20); this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseClick); + this.contextMenuStrip1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); @@ -89,5 +188,16 @@ private System.Windows.Forms.Label label1; 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; } } diff --git a/Windows/Forms/Tile/TileGroupLabel.cs b/Windows/Forms/Tile/TileGroupLabel.cs index 9c60aea..b0575d1 100644 --- a/Windows/Forms/Tile/TileGroupLabel.cs +++ b/Windows/Forms/Tile/TileGroupLabel.cs @@ -25,10 +25,7 @@ namespace AppLauncher.Windows.Forms pictureBox1.BackgroundImage = (value) ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16; - if (this.TileGroupPanel != null) - { - this.TileGroupPanel.InvalidateContainer(); - } + if (this.TileGroupPanel != null) this.TileGroupPanel.InvalidateContainer(); } } @@ -45,5 +42,55 @@ namespace AppLauncher.Windows.Forms 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(); + } + + /// + /// Add group + /// + /// + /// + private void toolStripMenuItem2_Click(object sender, System.EventArgs e) + { + if (this.TileGroupPanel != null) this.TileGroupPanel.AddGroup(); + } + + /// + /// Edit group + /// + /// + /// + private void toolStripMenuItem1_Click(object sender, System.EventArgs e) + { + if (this.TileGroupPanel != null) this.TileGroupPanel.EditGroup(); + } + + /// + /// Remove group + /// + /// + /// + private void toolStripMenuItem3_Click(object sender, System.EventArgs e) + { + if (this.TileGroupPanel != null) this.TileGroupPanel.Remove(); + } + } } \ No newline at end of file diff --git a/Windows/Forms/Tile/TileGroupLabel.resx b/Windows/Forms/Tile/TileGroupLabel.resx index 1af7de1..ad53752 100644 --- a/Windows/Forms/Tile/TileGroupLabel.resx +++ b/Windows/Forms/Tile/TileGroupLabel.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file