[WIP] Partially working flowlayout

This commit is contained in:
Terry MacDonald 2021-05-11 16:08:57 +12:00
parent 6131833b25
commit dccd13c019
2 changed files with 44 additions and 37 deletions

View File

@ -118,7 +118,7 @@ namespace DisplayMagician.UIForms
this.cb_autosuggest = new System.Windows.Forms.CheckBox(); this.cb_autosuggest = new System.Windows.Forms.CheckBox();
this.btn_hotkey = new System.Windows.Forms.Button(); this.btn_hotkey = new System.Windows.Forms.Button();
this.lbl_hotkey_assigned = new System.Windows.Forms.Label(); 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.tabc_shortcut.SuspendLayout();
this.tabp_display.SuspendLayout(); this.tabp_display.SuspendLayout();
this.tabp_audio.SuspendLayout(); this.tabp_audio.SuspendLayout();
@ -616,7 +616,7 @@ namespace DisplayMagician.UIForms
// tabp_before // tabp_before
// //
this.tabp_before.BackColor = System.Drawing.Color.Black; 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.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.ForeColor = System.Drawing.Color.White;
this.tabp_before.Location = new System.Drawing.Point(4, 32); 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.Visible = false;
this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); 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.flp_start_programs.AutoScroll = true;
this.tlp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0); this.flp_start_programs.AutoScrollMargin = new System.Drawing.Size(5, 0);
this.tlp_start_programs.BackColor = System.Drawing.Color.White; this.flp_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 0);
this.tlp_start_programs.ColumnCount = 1; this.flp_start_programs.BackColor = System.Drawing.Color.White;
this.tlp_start_programs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.flp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tlp_start_programs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.flp_start_programs.Location = new System.Drawing.Point(3, 107);
this.tlp_start_programs.Dock = System.Windows.Forms.DockStyle.Bottom; this.flp_start_programs.Name = "flp_start_programs";
this.tlp_start_programs.Location = new System.Drawing.Point(3, 112); this.flp_start_programs.Size = new System.Drawing.Size(1076, 508);
this.tlp_start_programs.MinimumSize = new System.Drawing.Size(900, 150); this.flp_start_programs.TabIndex = 0;
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;
// //
// ShortcutForm // ShortcutForm
// //
@ -1415,6 +1409,6 @@ namespace DisplayMagician.UIForms
private System.Windows.Forms.CheckBox cb_wait_alternative_game; private System.Windows.Forms.CheckBox cb_wait_alternative_game;
private System.Windows.Forms.Button btn_hotkey; private System.Windows.Forms.Button btn_hotkey;
private System.Windows.Forms.Label lbl_hotkey_assigned; private System.Windows.Forms.Label lbl_hotkey_assigned;
private System.Windows.Forms.TableLayoutPanel tlp_start_programs; private System.Windows.Forms.FlowLayoutPanel flp_start_programs;
} }
} }

View File

@ -456,7 +456,7 @@ namespace DisplayMagician.UIForms
// Scan through the list of // Scan through the list of
List<StartProgram> newStartPrograms = new List<StartProgram>() { }; List<StartProgram> newStartPrograms = new List<StartProgram>() { };
foreach (StartProgramControl myStartProgramControl in tlp_start_programs.Controls) foreach (StartProgramControl myStartProgramControl in flp_start_programs.Controls)
{ {
newStartPrograms.Add(myStartProgramControl.StartProgram); newStartPrograms.Add(myStartProgramControl.StartProgram);
} }
@ -1171,20 +1171,20 @@ namespace DisplayMagician.UIForms
Padding startProgramMargin = new Padding(10) { }; Padding startProgramMargin = new Padding(10) { };
//Clear out the existing controls, we are generating a new table layout //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 //Clear out the existing row and column styles
tlp_start_programs.ColumnStyles.Clear(); //flp_start_programs.ColumnStyles.Clear();
tlp_start_programs.RowStyles.Clear(); //flp_start_programs.RowStyles.Clear();
int myIndex = 0; //int myIndex = 0;
// Order the inital list in order of priority // Order the inital list in order of priority
foreach (StartProgram myStartProgram in _shortcutToEdit.StartPrograms.OrderBy(sp => sp.Priority)) foreach (StartProgram myStartProgram in _shortcutToEdit.StartPrograms.OrderBy(sp => sp.Priority))
{ {
StartProgramControl startProgramControl = new StartProgramControl(myStartProgram); StartProgramControl startProgramControl = new StartProgramControl(myStartProgram);
//startProgramControl.Dock = DockStyle.None; startProgramControl.Dock = DockStyle.None;
//startProgramControl.Margin = startProgramMargin; startProgramControl.Margin = startProgramMargin;
startProgramControl.Width = tlp_start_programs.Width - 40; startProgramControl.Width = flp_start_programs.Width - 40;
//startProgramControl.Height = 170; //startProgramControl.Height = 170;
//startProgramControl.Height = pnl_start_programs.Height; //startProgramControl.Height = pnl_start_programs.Height;
@ -1192,9 +1192,9 @@ namespace DisplayMagician.UIForms
// startProgramControl.BringToFront(); // startProgramControl.BringToFront();
//startProgramControl.Margin = DefaultMargin; //startProgramControl.Margin = DefaultMargin;
//startProgramControl.Width = pnl_start_programs.Width; //startProgramControl.Width = pnl_start_programs.Width;
tlp_start_programs.RowStyles.Add(new RowStyle(SizeType.Absolute, 170F)); //flp_start_programs.RowStyles.Add(new RowStyle(SizeType.Absolute, 170F));
tlp_start_programs.RowCount = myIndex + 1; //flp_start_programs.RowCount = myIndex + 1;
tlp_start_programs.Controls.Add(startProgramControl); flp_start_programs.Controls.Add(startProgramControl);
// Move the next line down // Move the next line down
//y += startProgramControl.Height + 5; //y += startProgramControl.Height + 5;
} }
@ -2029,26 +2029,39 @@ namespace DisplayMagician.UIForms
public void RemoveStartProgram(StartProgramControl startProgramControlToRemove) 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) foreach (StartProgram startProgramToTest in _shortcutToEdit.StartPrograms)
{ {
if (startProgramControlToRemove.StartProgram.Equals(startProgramToTest)) if (startProgramControlToRemove.StartProgram.Equals(startProgramToTest))
{ {
// If we find the start program then we need to remove it from the list // 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 // 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 // And we remove the row control passed in as well
TableLayoutHelper.RemoveArbitraryRow(tlp_start_programs, rowIndex); flp_start_programs.Controls.Remove(startProgramControlToRemove);
tlp_start_programs.ResumeLayout(); //TableLayoutHelper.RemoveArbitraryRow(tlp_start_programs, rowIndex);
flp_start_programs.ResumeLayout();
//tlp_start_programs.PerformLayout(); //tlp_start_programs.PerformLayout();
break; break;
} }
rowIndex++; rowIndex++;
} }*/
// And we redraw the panel again // And we redraw the panel again
tlp_start_programs.Refresh(); //flp_start_programs.Refresh();
} }
private void btn_hotkey_Click(object sender, EventArgs e) private void btn_hotkey_Click(object sender, EventArgs e)