From 3b16677a7b3f0a5711522db3ac7fa72f4f960db2 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 6 Jul 2024 00:30:02 +0100 Subject: [PATCH] Added duplicate tile group --- MainForm.Designer.cs | 31 ++++++++----- MainForm.cs | 104 ++++++++++++++++++++++++------------------- build.bat | 4 +- 3 files changed, 82 insertions(+), 57 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index fb2c82f..5566272 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -77,6 +77,7 @@ namespace FizzyLauncher removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); panel1 = new System.Windows.Forms.Panel(); + toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); contextMenuStrip2.SuspendLayout(); menuStrip1.SuspendLayout(); tileContainerMenu1.SuspendLayout(); @@ -274,41 +275,41 @@ namespace FizzyLauncher // // tileContainerMenu1 // - tileContainerMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addGroupToolStripMenuItem1, toolStripMenuItem4, editToolStripMenuItem, toolStripSeparator1, toolStripMenuItem2, toolStripSeparator2, toolStripMenuItem3, toolStripSeparator3, removeToolStripMenuItem }); + tileContainerMenu1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addGroupToolStripMenuItem1, toolStripMenuItem4, editToolStripMenuItem, toolStripMenuItem5, toolStripSeparator1, toolStripMenuItem2, toolStripSeparator2, toolStripMenuItem3, toolStripSeparator3, removeToolStripMenuItem }); tileContainerMenu1.Name = "tileContainerMenu1"; - tileContainerMenu1.Size = new System.Drawing.Size(133, 154); + tileContainerMenu1.Size = new System.Drawing.Size(181, 198); // // addGroupToolStripMenuItem1 // addGroupToolStripMenuItem1.Name = "addGroupToolStripMenuItem1"; - addGroupToolStripMenuItem1.Size = new System.Drawing.Size(132, 22); + addGroupToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); addGroupToolStripMenuItem1.Text = "&Add Tile"; addGroupToolStripMenuItem1.Click += addGroupToolStripMenuItem1_Click; // // toolStripMenuItem4 // toolStripMenuItem4.Name = "toolStripMenuItem4"; - toolStripMenuItem4.Size = new System.Drawing.Size(132, 22); + toolStripMenuItem4.Size = new System.Drawing.Size(180, 22); toolStripMenuItem4.Text = "Add &Group"; toolStripMenuItem4.Click += toolStripMenuItem4_Click; // // editToolStripMenuItem // editToolStripMenuItem.Name = "editToolStripMenuItem"; - editToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); editToolStripMenuItem.Text = "&Edit"; editToolStripMenuItem.Click += editToolStripMenuItem_Click; // // toolStripSeparator1 // toolStripSeparator1.Name = "toolStripSeparator1"; - toolStripSeparator1.Size = new System.Drawing.Size(129, 6); + toolStripSeparator1.Size = new System.Drawing.Size(177, 6); // // toolStripMenuItem2 // toolStripMenuItem2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { addRowToolStripMenuItem, removeRowToolStripMenuItem }); toolStripMenuItem2.Name = "toolStripMenuItem2"; - toolStripMenuItem2.Size = new System.Drawing.Size(132, 22); + toolStripMenuItem2.Size = new System.Drawing.Size(180, 22); toolStripMenuItem2.Text = "Ro&w"; // // addRowToolStripMenuItem @@ -328,13 +329,13 @@ namespace FizzyLauncher // toolStripSeparator2 // toolStripSeparator2.Name = "toolStripSeparator2"; - toolStripSeparator2.Size = new System.Drawing.Size(129, 6); + toolStripSeparator2.Size = new System.Drawing.Size(177, 6); // // toolStripMenuItem3 // toolStripMenuItem3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { topToolStripMenuItem, upToolStripMenuItem, downToolStripMenuItem, bottomToolStripMenuItem }); toolStripMenuItem3.Name = "toolStripMenuItem3"; - toolStripMenuItem3.Size = new System.Drawing.Size(132, 22); + toolStripMenuItem3.Size = new System.Drawing.Size(180, 22); toolStripMenuItem3.Text = "&Move"; // // topToolStripMenuItem @@ -368,12 +369,12 @@ namespace FizzyLauncher // toolStripSeparator3 // toolStripSeparator3.Name = "toolStripSeparator3"; - toolStripSeparator3.Size = new System.Drawing.Size(129, 6); + toolStripSeparator3.Size = new System.Drawing.Size(177, 6); // // removeToolStripMenuItem // removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + removeToolStripMenuItem.Size = new System.Drawing.Size(180, 22); removeToolStripMenuItem.Text = "&Remove"; removeToolStripMenuItem.Click += removeToolStripMenuItem_Click; // @@ -402,6 +403,13 @@ namespace FizzyLauncher panel1.Size = new System.Drawing.Size(404, 417); panel1.TabIndex = 9; // + // toolStripMenuItem5 + // + toolStripMenuItem5.Name = "toolStripMenuItem5"; + toolStripMenuItem5.Size = new System.Drawing.Size(180, 22); + toolStripMenuItem5.Text = "&Duplicate"; + toolStripMenuItem5.Click += toolStripMenuItem5_Click; + // // MainForm // AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -474,6 +482,7 @@ namespace FizzyLauncher private System.Windows.Forms.ToolStripMenuItem downToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem bottomToolStripMenuItem; private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; } } diff --git a/MainForm.cs b/MainForm.cs index d4e5272..f738c57 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -256,9 +255,9 @@ namespace FizzyLauncher /// /// /// - private void addGroupToolStripMenuItem_Click(object sender, EventArgs e) + private async void addGroupToolStripMenuItem_Click(object sender, EventArgs e) { - AddNewTileGroup(); + await AddNewTileGroup(); } @@ -358,7 +357,7 @@ namespace FizzyLauncher private async Task fileSessionManager_OnNewSession(FileSessionManager sender) { - return await Task.Run(() => + return await Task.Run(async () => { var form = new NewForm(); if (form.ShowDialog() == DialogResult.OK) @@ -371,7 +370,7 @@ namespace FizzyLauncher for (var i = 0; i < result.GroupCount; i++) { - AddNewTileGroup(); + await AddNewTileGroup(); } } @@ -601,6 +600,28 @@ namespace FizzyLauncher }; } + /// + /// Duplicate + /// + /// + /// + private async void toolStripMenuItem5_Click(object sender, EventArgs e) + { + var container = UIControl.GetOwner((ToolStripMenuItem)sender); + if (container == null) + { + return; + } + + var model = UIControl.GetTag(container); + model.IsExpanded = true; + + await AddTileGroups(model); + + _fileSessionManager.HasChanged = true; + } + + /// /// Row - Add Row /// @@ -730,28 +751,44 @@ namespace FizzyLauncher #endregion - private void AddNewTileGroup() + private async Task AddNewTileGroup() { var group = new TileGroupModel(); group.Title = "New Group"; group.IsExpanded = true; group.GridSize = new System.Drawing.Size(this.CurrentSession.TilesPerRow, 1); - var container = new RyzStudio.Windows.TileForms.TileContainer(); - container.Title = group.Title; - container.IsOpen = group.IsExpanded; - container.TitleContextMenuStrip = tileContainerMenu1; - container.AutoSizeHeight = true; - container.Tag = group; - container.BackColor = Color.Orange; - - UIControl.Add(flowLayoutPanel1, container); - - container.AutoSize(group.GridSize.Width, group.GridSize.Height); + await AddTileGroups(group); _fileSessionManager.HasChanged = true; } + private async Task AddTileGroups(TileGroupModel model) + { + await Task.Run(() => + { + var panel = new RyzStudio.Windows.TileForms.TileContainer(); + panel.Title = model.Title; + panel.IsOpen = model.IsExpanded; + panel.TitleContextMenuStrip = tileContainerMenu1; + panel.AutoSizeHeight = true; + panel.Tag = model; + + panel.AutoSize(model.GridSize.Width, model.GridSize.Height); + + UIControl.Add(flowLayoutPanel1, panel); + + // Load tiles + foreach (var item2 in model.Items ?? new List()) + { + var tile = new FizzyLauncher.Windows.Forms.TilePanel(); + tile.LoadInfo(item2); + + panel.Add(tile, item2.Position.X, item2.Position.Y); + } + }); + } + private void AutoResize() { if (flowLayoutPanel1.Controls.Count <= 0) @@ -770,35 +807,12 @@ namespace FizzyLauncher private async Task LoadTileGroups(List groupList) { - await Task.Run(() => + UIControl.Clear(flowLayoutPanel1); + + foreach (var item in groupList ?? new List()) { - UIControl.Clear(flowLayoutPanel1); - - // Load groups - foreach (var item in groupList ?? new List()) - { - var panel = new RyzStudio.Windows.TileForms.TileContainer(); - panel.Title = item.Title; - panel.IsOpen = item.IsExpanded; - panel.TitleContextMenuStrip = tileContainerMenu1; - panel.AutoSizeHeight = true; - panel.Tag = item; - - panel.AutoSize(item.GridSize.Width, item.GridSize.Height); - - UIControl.Add(flowLayoutPanel1, panel); - - // Load tiles - foreach (var item2 in item.Items ?? new List()) - { - var tile = new FizzyLauncher.Windows.Forms.TilePanel(); - tile.LoadInfo(item2); - - panel.Add(tile, item2.Position.X, item2.Position.Y); - } - - } - }); + await AddTileGroups(item); + } } } diff --git a/build.bat b/build.bat index 71bd782..2996b4a 100644 --- a/build.bat +++ b/build.bat @@ -8,4 +8,6 @@ dotnet publish skye.sln -r win-x64 -c Release /p:PublishSingleFile=true /p:SelfC "C:\B\Portable Files (dev)\Inno Setup\v6.0.4-2\app\ISCC.exe" "build-installer.iss" cd "bin\Release\64\" -"C:\B\Portable Files\PeaZip (Portable)\v6.5.1\App\PeaZip\res\7z\7z.exe" a -t7z "..\fizzy-launcher.7z" "*" -mx9 \ No newline at end of file +"C:\B\Portable Files\PeaZip (Portable)\v6.5.1\App\PeaZip\res\7z\7z.exe" a -t7z "..\fizzy-launcher.7z" "*" -mx9 + +PAUSE \ No newline at end of file