diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 698ab8d..a32b3c4 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -34,25 +34,21 @@ this.headingPanel1 = new AppLauncher.Windows.Forms.HeadingPanel(); this.panel6 = new System.Windows.Forms.Panel(); this.panel7 = new System.Windows.Forms.Panel(); - this.panel8 = new System.Windows.Forms.Panel(); - this.panel9 = new System.Windows.Forms.Panel(); - this.panel10 = new System.Windows.Forms.Panel(); - this.panel11 = new System.Windows.Forms.Panel(); - this.panel12 = new System.Windows.Forms.Panel(); - this.panel13 = new System.Windows.Forms.Panel(); - this.panel14 = new System.Windows.Forms.Panel(); - this.panel15 = new System.Windows.Forms.Panel(); this.button2 = new System.Windows.Forms.Button(); this.tilePanel2 = new AppLauncher.Windows.Forms.TilePanel(); this.tilePanel1 = new AppLauncher.Windows.Forms.TilePanel(); this.panel4 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel(); this.tilePanelContainer1 = new AppLauncher.Windows.Forms.TilePanelContainer(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.headingPanel2 = new AppLauncher.Windows.Forms.HeadingPanel(); + this.headingPanel3 = new AppLauncher.Windows.Forms.HeadingPanel(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(12, 359); + this.button1.Location = new System.Drawing.Point(710, 243); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(78, 40); this.button1.TabIndex = 0; @@ -62,7 +58,7 @@ // // richTextBox1 // - this.richTextBox1.Location = new System.Drawing.Point(573, 340); + this.richTextBox1.Location = new System.Drawing.Point(412, 69); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(215, 88); this.richTextBox1.TabIndex = 2; @@ -87,8 +83,9 @@ this.headingPanel1.Location = new System.Drawing.Point(12, 64); this.headingPanel1.MinimumSize = new System.Drawing.Size(100, 20); this.headingPanel1.Name = "headingPanel1"; - this.headingPanel1.Size = new System.Drawing.Size(600, 20); + this.headingPanel1.Size = new System.Drawing.Size(291, 20); this.headingPanel1.TabIndex = 9; + this.headingPanel1.TilePanelContainer = null; this.headingPanel1.TitleText = "Featured"; // // panel6 @@ -111,89 +108,9 @@ this.panel7.Size = new System.Drawing.Size(70, 70); this.panel7.TabIndex = 11; // - // panel8 - // - this.panel8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel8.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel8.Location = new System.Drawing.Point(233, 163); - this.panel8.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel8.Name = "panel8"; - this.panel8.Size = new System.Drawing.Size(70, 70); - this.panel8.TabIndex = 16; - // - // panel9 - // - this.panel9.BackColor = System.Drawing.Color.White; - this.panel9.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel9.Location = new System.Drawing.Point(160, 163); - this.panel9.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel9.Name = "panel9"; - this.panel9.Size = new System.Drawing.Size(70, 70); - this.panel9.TabIndex = 15; - // - // panel10 - // - this.panel10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel10.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel10.Location = new System.Drawing.Point(87, 163); - this.panel10.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel10.Name = "panel10"; - this.panel10.Size = new System.Drawing.Size(70, 70); - this.panel10.TabIndex = 14; - // - // panel11 - // - this.panel11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel11.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel11.Location = new System.Drawing.Point(14, 163); - this.panel11.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel11.Name = "panel11"; - this.panel11.Size = new System.Drawing.Size(70, 70); - this.panel11.TabIndex = 13; - // - // panel12 - // - this.panel12.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel12.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel12.Location = new System.Drawing.Point(233, 236); - this.panel12.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel12.Name = "panel12"; - this.panel12.Size = new System.Drawing.Size(70, 70); - this.panel12.TabIndex = 20; - // - // panel13 - // - this.panel13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel13.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel13.Location = new System.Drawing.Point(160, 236); - this.panel13.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel13.Name = "panel13"; - this.panel13.Size = new System.Drawing.Size(70, 70); - this.panel13.TabIndex = 19; - // - // panel14 - // - this.panel14.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel14.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel14.Location = new System.Drawing.Point(87, 236); - this.panel14.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel14.Name = "panel14"; - this.panel14.Size = new System.Drawing.Size(70, 70); - this.panel14.TabIndex = 18; - // - // panel15 - // - this.panel15.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); - this.panel15.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.panel15.Location = new System.Drawing.Point(14, 236); - this.panel15.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); - this.panel15.Name = "panel15"; - this.panel15.Size = new System.Drawing.Size(70, 70); - this.panel15.TabIndex = 17; - // // button2 // - this.button2.Location = new System.Drawing.Point(160, 340); + this.button2.Location = new System.Drawing.Point(710, 289); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(78, 40); this.button2.TabIndex = 21; @@ -208,7 +125,7 @@ this.tilePanel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); this.tilePanel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); this.tilePanel2.IconImage = global::AppLauncher.Properties.Resources.folder_ea_32; - this.tilePanel2.Location = new System.Drawing.Point(394, 236); + this.tilePanel2.Location = new System.Drawing.Point(726, 46); this.tilePanel2.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); this.tilePanel2.MaximumSize = new System.Drawing.Size(70, 70); this.tilePanel2.MinimumSize = new System.Drawing.Size(70, 70); @@ -228,7 +145,7 @@ this.tilePanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68))))); this.tilePanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(234)))), ((int)(((byte)(234))))); this.tilePanel1.IconImage = global::AppLauncher.Properties.Resources.mail_ea_32; - this.tilePanel1.Location = new System.Drawing.Point(321, 236); + this.tilePanel1.Location = new System.Drawing.Point(653, 46); this.tilePanel1.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0); this.tilePanel1.MaximumSize = new System.Drawing.Size(70, 70); this.tilePanel1.MinimumSize = new System.Drawing.Size(70, 70); @@ -268,11 +185,51 @@ this.tilePanelContainer1.AutoScrollMargin = new System.Drawing.Size(0, 0); this.tilePanelContainer1.AutoScrollMinSize = new System.Drawing.Size(0, 0); this.tilePanelContainer1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); - this.tilePanelContainer1.Location = new System.Drawing.Point(509, 109); + this.tilePanelContainer1.Location = new System.Drawing.Point(2, 23); + this.tilePanelContainer1.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0); this.tilePanelContainer1.Name = "tilePanelContainer1"; - this.tilePanelContainer1.Size = new System.Drawing.Size(278, 220); + this.tilePanelContainer1.Size = new System.Drawing.Size(584, 146); this.tilePanelContainer1.TabIndex = 26; // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.headingPanel2); + this.flowLayoutPanel1.Controls.Add(this.tilePanelContainer1); + this.flowLayoutPanel1.Controls.Add(this.headingPanel3); + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 163); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(615, 265); + this.flowLayoutPanel1.TabIndex = 27; + // + // headingPanel2 + // + this.headingPanel2.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.headingPanel2.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.headingPanel2.Checked = false; + this.headingPanel2.Location = new System.Drawing.Point(0, 0); + this.headingPanel2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); + this.headingPanel2.MinimumSize = new System.Drawing.Size(100, 20); + this.headingPanel2.Name = "headingPanel2"; + this.headingPanel2.Size = new System.Drawing.Size(223, 20); + this.headingPanel2.TabIndex = 10; + this.headingPanel2.TilePanelContainer = this.tilePanelContainer1; + this.headingPanel2.TitleText = "Featured"; + // + // headingPanel3 + // + this.headingPanel3.AutoScrollMargin = new System.Drawing.Size(0, 0); + this.headingPanel3.AutoScrollMinSize = new System.Drawing.Size(0, 0); + this.headingPanel3.Checked = false; + this.headingPanel3.Location = new System.Drawing.Point(0, 169); + this.headingPanel3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); + this.headingPanel3.MinimumSize = new System.Drawing.Size(100, 20); + this.headingPanel3.Name = "headingPanel3"; + this.headingPanel3.Size = new System.Drawing.Size(223, 20); + this.headingPanel3.TabIndex = 27; + this.headingPanel3.TilePanelContainer = null; + this.headingPanel3.TitleText = "Featured"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -280,18 +237,10 @@ this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(83)))), ((int)(((byte)(93))))); this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(800, 440); - this.Controls.Add(this.tilePanelContainer1); + this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.tilePanel2); this.Controls.Add(this.tilePanel1); this.Controls.Add(this.button2); - this.Controls.Add(this.panel12); - this.Controls.Add(this.panel13); - this.Controls.Add(this.panel14); - this.Controls.Add(this.panel15); - this.Controls.Add(this.panel8); - this.Controls.Add(this.panel9); - this.Controls.Add(this.panel10); - this.Controls.Add(this.panel11); this.Controls.Add(this.panel6); this.Controls.Add(this.panel7); this.Controls.Add(this.panel4); @@ -302,6 +251,7 @@ this.Controls.Add(this.button1); this.Name = "MainForm"; this.Text = "Form1"; + this.flowLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); } @@ -316,18 +266,13 @@ private System.Windows.Forms.Panel panel4; private System.Windows.Forms.Panel panel6; private System.Windows.Forms.Panel panel7; - private System.Windows.Forms.Panel panel8; - private System.Windows.Forms.Panel panel9; - private System.Windows.Forms.Panel panel10; - private System.Windows.Forms.Panel panel11; - private System.Windows.Forms.Panel panel12; - private System.Windows.Forms.Panel panel13; - private System.Windows.Forms.Panel panel14; - private System.Windows.Forms.Panel panel15; private System.Windows.Forms.Button button2; private Windows.Forms.TilePanel tilePanel1; private Windows.Forms.TilePanel tilePanel2; private Windows.Forms.TilePanelContainer tilePanelContainer1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private Windows.Forms.HeadingPanel headingPanel2; + private Windows.Forms.HeadingPanel headingPanel3; } } diff --git a/Windows/Forms/HeadingPanel.Designer.cs b/Windows/Forms/HeadingPanel.Designer.cs index 3cc838b..324a61b 100644 --- a/Windows/Forms/HeadingPanel.Designer.cs +++ b/Windows/Forms/HeadingPanel.Designer.cs @@ -48,6 +48,8 @@ this.label1.Size = new System.Drawing.Size(575, 20); this.label1.TabIndex = 8; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick); + this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick); // // pictureBox1 // @@ -65,6 +67,8 @@ this.pictureBox1.Size = new System.Drawing.Size(20, 20); this.pictureBox1.TabIndex = 7; this.pictureBox1.TabStop = false; + this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick); + this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick); // // HeadingPanel // @@ -75,6 +79,7 @@ this.MinimumSize = new System.Drawing.Size(100, 20); this.Name = "HeadingPanel"; this.Size = new System.Drawing.Size(600, 20); + this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HeadingPanel_MouseClick); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); diff --git a/Windows/Forms/HeadingPanel.cs b/Windows/Forms/HeadingPanel.cs index 405f268..c2d1021 100644 --- a/Windows/Forms/HeadingPanel.cs +++ b/Windows/Forms/HeadingPanel.cs @@ -1,4 +1,7 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; +using System.Threading.Tasks; +using System.Windows.Forms; namespace AppLauncher.Windows.Forms { @@ -11,6 +14,7 @@ namespace AppLauncher.Windows.Forms InitializeComponent(); this.Checked = false; + } [Category("Appearance"), Browsable(true)] @@ -28,5 +32,46 @@ namespace AppLauncher.Windows.Forms } } + public TilePanelContainer TilePanelContainer { get; set; } = null; + + protected async override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + if (this.TilePanelContainer != null) + { + if (this.Checked) + { + await this.TilePanelContainer.Expand(120); + } + else + { + await this.TilePanelContainer.Collapse(0); + } + } + } + + private async void HeadingPanel_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button != MouseButtons.Left) + { + return; + } + + this.Checked = !this.Checked; + + if (this.TilePanelContainer != null) + { + if (this.Checked) + { + await this.TilePanelContainer.Expand(120); + } + else + { + await this.TilePanelContainer.Collapse(0); + } + } + } + } } diff --git a/Windows/Forms/TilePanelContainer.cs b/Windows/Forms/TilePanelContainer.cs index 37027a2..1ae9df4 100644 --- a/Windows/Forms/TilePanelContainer.cs +++ b/Windows/Forms/TilePanelContainer.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -26,27 +27,72 @@ namespace AppLauncher.Windows.Forms OnResize(e); } - - protected override void OnResize(EventArgs e) + public Point GridSize { - base.OnResize(e); + get + { + int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize)); + int h = (int)Math.Floor(decimal.Divide(this.Height, this.TileSize)); - int tileWidth = (tileSize + margin); - int w = (int)Math.Floor(decimal.Divide(this.Width, tileWidth)); - int h = (int)Math.Floor(decimal.Divide(this.Height, tileWidth)); - - this.GridSize = new Point(w, h); + return new Point(w, h); + } } - public Point GridSize { get; protected set; } + public int TileSize => (tileSize + margin); + + + public async Task Collapse(int height, int increment = 6) + { + await Task.Run(() => + { + while (this.Height > height) + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + this.Height -= increment; + })); + } + else + { + this.Height -= increment; + } + + Thread.Sleep(10); + } + }); + } + + public async Task Expand(int height, int increment = 8) + { + await Task.Run(() => + { + while (this.Height < height) + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + this.Height += increment; + this.Invalidate(); + })); + } + else + { + this.Height += increment; + this.Invalidate(); + } + + Thread.Sleep(10); + } + }); + } public Point GetTileCoord(Point location) => this.GetTileCoord(location.X, location.Y); public Point GetTileCoord(int posX, int posY) { - int w = (tileSize + margin); - int x = (int)Math.Round(decimal.Divide(posX, w)); - int y = (int)Math.Round(decimal.Divide(posY, w)); + int x = (int)Math.Round(decimal.Divide(posX, this.TileSize)); + int y = (int)Math.Round(decimal.Divide(posY, this.TileSize)); if (x < 0) x = 0; if (y < 0) y = 0; @@ -58,15 +104,18 @@ namespace AppLauncher.Windows.Forms public Point GetTilePosition(int posX, int posY) { - int w = (tileSize + margin); - int x = (int)Math.Round(decimal.Divide(posX, w)); - int y = (int)Math.Round(decimal.Divide(posY, w)); + int x = (int)Math.Round(decimal.Divide(posX, this.TileSize)); + int y = (int)Math.Round(decimal.Divide(posY, this.TileSize)); if (x < 0) x = 0; if (y < 0) y = 0; - return new Point((x * w), (y * w)); + return new Point((x * this.TileSize), (y * this.TileSize)); } + public void SetGridSize(int width, int height) + { + this.Size = new Size((this.TileSize * width), (this.TileSize * height)); + } } -} +} \ No newline at end of file