private void addTimerRow(ref TableLayoutPanel TLP, string boxText, bool relayout) { if (TLP.RowCount - StaticUtility.visualNonTimerRows >= StaticUtility.maximumRows) //don't let rows add past limit. Minus 1 is for zero index. { DialogResult result = MessageBox.Show( "Maximum number of timers have been added. Modify the application config file and restart the application to change the maximum rows." , "" , MessageBoxButtons.OK , MessageBoxIcon.Information , MessageBoxDefaultButton.Button1); return; } TLP.SuspendLayout(); addRow(TLP); int cntIx = TLP.RowCount - 1; StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStartBackColor, theme.defStartForeColor, 1, starts_Click, true, true, 0, cntIx); tempLabel.Text = "u"; StaticUtility.addTextBox(ref TLP, ref tempTextBox, theme.defTxtBxBackColor, theme.defTxtBxForeColor, 0, false, false, 2, cntIx); tempTextBox.Text = boxText; StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStartBackColor, theme.defStartForeColor, 0, null, true, false, 3, cntIx); tempLabel.Text = "00:00:00"; TLP.ResumeLayout(false); if (relayout) { TLP.PerformLayout(); } }
private void initializeTLP(ref TableLayoutPanel TLP) { FormClosing += new FormClosingEventHandler(workWinder_FormClosing); //unrelated but I need to do this somewhere TLP = new TableLayoutPanel(); TLP.SuspendLayout(); SuspendLayout(); //Set Window Properties BackColor = theme.defWindowColor; Text = StaticUtility.returnTitleName(); AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; MinimumSize = new Size(Properties.Settings.Default.MainFormWindowWidth, 50); MaximizeBox = false; //Define Column Settings TLP.ColumnCount = 4; TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F)); TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F)); TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80F)); //Add Rows addRow(TLP); addRow(TLP); //Set TableLayoutPanel Settings TLP.Dock = DockStyle.Fill; TLP.Location = new Point(0, 0); TLP.Margin = new Padding(0); TLP.Padding = new Padding(2); TLP.AutoSize = true; Controls.Add(TLP); //Stop Button StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStopBackColor, theme.defStopForeColor, 2, stop_Click, true, true, 0, 0); tempLabel.Text = "Stop"; //Total label StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defTotalBackColor, theme.defTotalForeColor, 0, null, true, true, 2, 0); tempLabel.Text = "Total: 00:00:00"; //Up button StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 1, up_Click, true, false, 0, 1); tempLabel.Text = "p"; //Down button StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 1, down_Click, true, false, 1, 1); tempLabel.Text = "q"; //Open Report StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 2, config_Click, true, true, 2, 1); tempLabel.Text = "Report && Configuration"; //Setup the default name settings string[] nameLiDefault = Properties.Settings.Default.NameList.Split(new char[] { ',' }); for (int i = 0; i < nameLiDefault.Length; i++) { textBoxNamesArray[i] = nameLiDefault[i]; addTimerRow(ref TLP, textBoxNamesArray[i], false); } TLP.ResumeLayout(false); TLP.PerformLayout(); ResumeLayout(false); PerformLayout(); }