From dccd13c0195c45fad042446f443855a144a4fc60 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Tue, 11 May 2021 16:08:57 +1200 Subject: [PATCH] [WIP] Partially working flowlayout --- .../UIForms/ShortcutForm.Designer.cs | 32 +++++------- DisplayMagician/UIForms/ShortcutForm.cs | 49 ++++++++++++------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs index 2f08b0f..72a98d4 100644 --- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs +++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs @@ -118,7 +118,7 @@ namespace DisplayMagician.UIForms this.cb_autosuggest = new System.Windows.Forms.CheckBox(); this.btn_hotkey = new System.Windows.Forms.Button(); this.lbl_hotkey_assigned = new System.Windows.Forms.Label(); - this.tlp_start_programs = new System.Windows.Forms.TableLayoutPanel(); + this.flp_start_programs = new System.Windows.Forms.FlowLayoutPanel(); this.tabc_shortcut.SuspendLayout(); this.tabp_display.SuspendLayout(); this.tabp_audio.SuspendLayout(); @@ -616,7 +616,7 @@ namespace DisplayMagician.UIForms // tabp_before // this.tabp_before.BackColor = System.Drawing.Color.Black; - this.tabp_before.Controls.Add(this.tlp_start_programs); + this.tabp_before.Controls.Add(this.flp_start_programs); this.tabp_before.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tabp_before.ForeColor = System.Drawing.Color.White; this.tabp_before.Location = new System.Drawing.Point(4, 32); @@ -1248,23 +1248,17 @@ namespace DisplayMagician.UIForms this.lbl_hotkey_assigned.Visible = false; this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); // - // tlp_start_programs + // flp_start_programs // - this.tlp_start_programs.AutoScroll = true; - this.tlp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0); - this.tlp_start_programs.BackColor = System.Drawing.Color.White; - this.tlp_start_programs.ColumnCount = 1; - this.tlp_start_programs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlp_start_programs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom; - this.tlp_start_programs.Location = new System.Drawing.Point(3, 112); - this.tlp_start_programs.MinimumSize = new System.Drawing.Size(900, 150); - this.tlp_start_programs.Name = "tlp_start_programs"; - this.tlp_start_programs.RowCount = 1; - this.tlp_start_programs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlp_start_programs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlp_start_programs.Size = new System.Drawing.Size(1076, 503); - this.tlp_start_programs.TabIndex = 0; + this.flp_start_programs.AutoScroll = true; + this.flp_start_programs.AutoScrollMargin = new System.Drawing.Size(5, 0); + this.flp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0); + this.flp_start_programs.BackColor = System.Drawing.Color.White; + this.flp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flp_start_programs.Location = new System.Drawing.Point(3, 107); + this.flp_start_programs.Name = "flp_start_programs"; + this.flp_start_programs.Size = new System.Drawing.Size(1076, 508); + this.flp_start_programs.TabIndex = 0; // // ShortcutForm // @@ -1415,6 +1409,6 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.CheckBox cb_wait_alternative_game; private System.Windows.Forms.Button btn_hotkey; private System.Windows.Forms.Label lbl_hotkey_assigned; - private System.Windows.Forms.TableLayoutPanel tlp_start_programs; + private System.Windows.Forms.FlowLayoutPanel flp_start_programs; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 149144e..f7b2602 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -456,7 +456,7 @@ namespace DisplayMagician.UIForms // Scan through the list of List newStartPrograms = new List() { }; - foreach (StartProgramControl myStartProgramControl in tlp_start_programs.Controls) + foreach (StartProgramControl myStartProgramControl in flp_start_programs.Controls) { newStartPrograms.Add(myStartProgramControl.StartProgram); } @@ -1171,20 +1171,20 @@ namespace DisplayMagician.UIForms Padding startProgramMargin = new Padding(10) { }; //Clear out the existing controls, we are generating a new table layout - tlp_start_programs.Controls.Clear(); + //flp_start_programs.Controls.Clear(); //Clear out the existing row and column styles - tlp_start_programs.ColumnStyles.Clear(); - tlp_start_programs.RowStyles.Clear(); + //flp_start_programs.ColumnStyles.Clear(); + //flp_start_programs.RowStyles.Clear(); - int myIndex = 0; + //int myIndex = 0; // Order the inital list in order of priority foreach (StartProgram myStartProgram in _shortcutToEdit.StartPrograms.OrderBy(sp => sp.Priority)) { StartProgramControl startProgramControl = new StartProgramControl(myStartProgram); - //startProgramControl.Dock = DockStyle.None; - //startProgramControl.Margin = startProgramMargin; - startProgramControl.Width = tlp_start_programs.Width - 40; + startProgramControl.Dock = DockStyle.None; + startProgramControl.Margin = startProgramMargin; + startProgramControl.Width = flp_start_programs.Width - 40; //startProgramControl.Height = 170; //startProgramControl.Height = pnl_start_programs.Height; @@ -1192,9 +1192,9 @@ namespace DisplayMagician.UIForms // startProgramControl.BringToFront(); //startProgramControl.Margin = DefaultMargin; //startProgramControl.Width = pnl_start_programs.Width; - tlp_start_programs.RowStyles.Add(new RowStyle(SizeType.Absolute, 170F)); - tlp_start_programs.RowCount = myIndex + 1; - tlp_start_programs.Controls.Add(startProgramControl); + //flp_start_programs.RowStyles.Add(new RowStyle(SizeType.Absolute, 170F)); + //flp_start_programs.RowCount = myIndex + 1; + flp_start_programs.Controls.Add(startProgramControl); // Move the next line down //y += startProgramControl.Height + 5; } @@ -2029,26 +2029,39 @@ namespace DisplayMagician.UIForms public void RemoveStartProgram(StartProgramControl startProgramControlToRemove) { - int rowIndex = 1; + + // If we find the start program then we need to remove it from the list + _shortcutToEdit.StartPrograms.Remove(startProgramControlToRemove.StartProgram); + // And we remove the program control passed in as well + flp_start_programs.SuspendLayout(); + // And we remove the row control passed in as well + flp_start_programs.Controls.Remove(startProgramControlToRemove); + //TableLayoutHelper.RemoveArbitraryRow(tlp_start_programs, rowIndex); + flp_start_programs.ResumeLayout(); + //tlp_start_programs.PerformLayout(); + //break; + + /*int rowIndex = 1; foreach (StartProgram startProgramToTest in _shortcutToEdit.StartPrograms) { if (startProgramControlToRemove.StartProgram.Equals(startProgramToTest)) { // If we find the start program then we need to remove it from the list - //_shortcutToEdit.StartPrograms.Remove(startProgramToTest); + _shortcutToEdit.StartPrograms.Remove(startProgramToTest); // And we remove the program control passed in as well - tlp_start_programs.SuspendLayout(); + flp_start_programs.SuspendLayout(); // And we remove the row control passed in as well - TableLayoutHelper.RemoveArbitraryRow(tlp_start_programs, rowIndex); - tlp_start_programs.ResumeLayout(); + flp_start_programs.Controls.Remove(startProgramControlToRemove); + //TableLayoutHelper.RemoveArbitraryRow(tlp_start_programs, rowIndex); + flp_start_programs.ResumeLayout(); //tlp_start_programs.PerformLayout(); break; } rowIndex++; - } + }*/ // And we redraw the panel again - tlp_start_programs.Refresh(); + //flp_start_programs.Refresh(); } private void btn_hotkey_Click(object sender, EventArgs e)