# HG changeset patch # User sl # Date 1411383627 -7200 # Node ID 4f2a73683adc5ec5b6ef23bd56069ee36a53886a # Parent 9979787100b1173ae056511d76ad7324ee646bf3 Adding and removing row is now working. Can now have any number of text field. diff -r 9979787100b1 -r 4f2a73683adc Client/MainForm.cs --- a/Client/MainForm.cs Mon Sep 22 10:05:45 2014 +0200 +++ b/Client/MainForm.cs Mon Sep 22 13:00:27 2014 +0200 @@ -49,12 +49,12 @@ } - + public delegate void CloseConnectionDelegate(); public delegate void CloseDelegate(); /// - /// + /// /// public void CloseConnectionThreadSafe() { @@ -80,7 +80,7 @@ } /// - /// + /// /// public void CloseThreadSafe() { @@ -133,6 +133,7 @@ { //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft); iTextFieldTop.Text = textBoxTop.Text; + iTextFieldTop.Alignment = Alignment; iClient.SetText(iTextFieldTop); } @@ -143,7 +144,7 @@ //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft); iClient.SetTexts(new TextField[] - { + { new TextField(0, textBoxTop.Text, Alignment), new TextField(1, textBoxBottom.Text, Alignment) }); diff -r 9979787100b1 -r 4f2a73683adc Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Mon Sep 22 10:05:45 2014 +0200 +++ b/Server/MainForm.Designer.cs Mon Sep 22 13:00:27 2014 +0200 @@ -102,24 +102,27 @@ this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanel.BackColor = System.Drawing.SystemColors.ControlLightLight; this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; this.tableLayoutPanel.ColumnCount = 1; this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0); this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1); + this.tableLayoutPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize; this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel.Name = "tableLayoutPanel"; this.tableLayoutPanel.RowCount = 2; - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); this.tableLayoutPanel.TabIndex = 5; // // marqueeLabelTop // this.marqueeLabelTop.AutoEllipsis = true; + this.marqueeLabelTop.AutoSize = true; this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); @@ -137,6 +140,7 @@ // marqueeLabelBottom // this.marqueeLabelBottom.AutoEllipsis = true; + this.marqueeLabelBottom.AutoSize = true; this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32); this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); @@ -637,6 +641,7 @@ this.Resize += new System.EventHandler(this.MainForm_Resize); this.panelDisplay.ResumeLayout(false); this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.tabPageClients.ResumeLayout(false); diff -r 9979787100b1 -r 4f2a73683adc Server/MainForm.cs --- a/Server/MainForm.cs Mon Sep 22 10:05:45 2014 +0200 +++ b/Server/MainForm.cs Mon Sep 22 13:00:27 2014 +0200 @@ -99,7 +99,8 @@ //fontDialog.ShowColor = true; //fontDialog.ShowApply = true; fontDialog.ShowEffects = true; - fontDialog.Font = marqueeLabelTop.Font; + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[0]; + fontDialog.Font = label.Font; fontDialog.FixedPitchOnly = checkBoxFixedPitchFontOnly.Checked; @@ -120,8 +121,10 @@ //MsgBox.Show("MessageBox MsgBox", "MsgBox caption"); //MessageBox.Show("Ok"); - marqueeLabelTop.Font = fontDialog.Font; - marqueeLabelBottom.Font = fontDialog.Font; + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.Font = fontDialog.Font; + } cds.Font = fontDialog.Font; Properties.Settings.Default.Save(); // @@ -148,9 +151,10 @@ } //Now check font height and show a warning if needed. - if (marqueeLabelBottom.Font.Height > marqueeLabelBottom.Height) + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[0]; + if (label.Font.Height > label.Height) { - labelWarning.Text = "WARNING: Selected font is too height by " + (marqueeLabelBottom.Font.Height - marqueeLabelBottom.Height) + " pixels!"; + labelWarning.Text = "WARNING: Selected font is too height by " + (label.Font.Height - label.Height) + " pixels!"; labelWarning.Visible = true; } else @@ -167,7 +171,7 @@ //Bitmap bmpToSave = new Bitmap(bmp); bmp.Save("D:\\capture.png"); - marqueeLabelTop.Text = "Sweet"; + ((MarqueeLabel)tableLayoutPanel.Controls[0]).Text = "Captured"; /* string outputFileName = "d:\\capture.png"; @@ -307,8 +311,12 @@ //Update our animations DateTime NewTickTime = DateTime.Now; - marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime); - marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime); + //Update animation for all our marquees + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.UpdateAnimation(LastTickTime, NewTickTime); + } + //Update our display if (iDisplay.IsOpen()) @@ -464,8 +472,13 @@ //Load settings checkBoxShowBorders.Checked = cds.ShowBorders; tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); - marqueeLabelTop.Font = cds.Font; - marqueeLabelBottom.Font = cds.Font; + + //Set the proper font to each of our labels + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.Font = cds.Font; + } + CheckFontHeight(); checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup; checkBoxReverseScreen.Checked = cds.ReverseScreen; @@ -770,19 +783,10 @@ client.Texts[aTextField.Index] = aTextField; //We are in the proper thread - //Only support two lines for now - if (aTextField.Index == 0) - { - marqueeLabelTop.Text = aTextField.Text; - marqueeLabelTop.TextAlign = aTextField.Alignment; - } - else if (aTextField.Index == 1) - { - marqueeLabelBottom.Text = aTextField.Text; - marqueeLabelBottom.TextAlign = aTextField.Alignment; - } - - + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index]; + label.Text = aTextField.Text; + label.TextAlign = aTextField.Alignment; + // UpdateClientTreeViewNode(client); } } @@ -823,16 +827,9 @@ //Only support two lines for now for (int i = 0; i < aTextFields.Count; i++) { - if (aTextFields[i].Index == 0) - { - marqueeLabelTop.Text = aTextFields[i].Text; - marqueeLabelTop.TextAlign = aTextFields[i].Alignment; - } - else if (aTextFields[i].Index == 1) - { - marqueeLabelBottom.Text = aTextFields[i].Text; - marqueeLabelBottom.TextAlign = aTextFields[i].Alignment; - } + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextFields[i].Index]; + label.Text = aTextFields[i].Text; + label.TextAlign = aTextFields[i].Alignment; } @@ -935,7 +932,7 @@ { if (tableLayoutPanel.RowCount < 6) { - tableLayoutPanel.RowCount++; + CreateMarqueeForCell(0, tableLayoutPanel.RowCount); CheckFontHeight(); } } @@ -944,9 +941,58 @@ { if (tableLayoutPanel.RowCount > 1) { + tableLayoutPanel.RowStyles.RemoveAt(tableLayoutPanel.RowCount-1); + tableLayoutPanel.Controls.RemoveAt(tableLayoutPanel.RowCount-1); tableLayoutPanel.RowCount--; CheckFontHeight(); } + + UpdateTableLayoutRowStyles(); + } + + /// + /// Update our table layout row styles to make sure each rows have similar height + /// + private void UpdateTableLayoutRowStyles() + { + foreach (RowStyle rowStyle in tableLayoutPanel.RowStyles) + { + rowStyle.SizeType = SizeType.Percent; + rowStyle.Height = 100 / tableLayoutPanel.RowCount; + } + } + + /// + /// Create the specified cell in our table layout and add a marquee label to it. + /// + /// + /// + private void CreateMarqueeForCell(int aColumn, int aRow) + { + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize)); + MarqueeLabel control = new SharpDisplayManager.MarqueeLabel(); + control.AutoEllipsis = true; + control.AutoSize = true; + control.BackColor = System.Drawing.Color.Transparent; + control.Dock = System.Windows.Forms.DockStyle.Fill; + control.Location = new System.Drawing.Point(1, 1); + control.Margin = new System.Windows.Forms.Padding(0); + control.Name = "marqueeLabelCol" + aColumn + "Row" + aRow; + control.OwnTimer = false; + control.PixelsPerSecond = 64; + control.Separator = "|"; + //control.Size = new System.Drawing.Size(254, 30); + //control.TabIndex = 2; + control.Font = cds.Font; + control.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; + control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + control.UseCompatibleTextRendering = true; + // + tableLayoutPanel.RowCount++; + tableLayoutPanel.Controls.Add(control, aColumn, aRow); + + UpdateTableLayoutRowStyles(); + } private void buttonAddColumn_Click(object sender, EventArgs e) @@ -969,20 +1015,26 @@ private void buttonAlignLeft_Click(object sender, EventArgs e) { - marqueeLabelTop.TextAlign = ContentAlignment.MiddleLeft; - marqueeLabelBottom.TextAlign = ContentAlignment.MiddleLeft; + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.TextAlign = ContentAlignment.MiddleLeft; + } } private void buttonAlignCenter_Click(object sender, EventArgs e) { - marqueeLabelTop.TextAlign = ContentAlignment.MiddleCenter; - marqueeLabelBottom.TextAlign = ContentAlignment.MiddleCenter; + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.TextAlign = ContentAlignment.MiddleCenter; + } } private void buttonAlignRight_Click(object sender, EventArgs e) { - marqueeLabelTop.TextAlign = ContentAlignment.MiddleRight; - marqueeLabelBottom.TextAlign = ContentAlignment.MiddleRight; + foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls) + { + ctrl.TextAlign = ContentAlignment.MiddleRight; + } } private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e) @@ -1035,7 +1087,6 @@ { iDisplay.HideClock(); } - } ///