Adding and removing row is now working.
authorsl
Mon, 22 Sep 2014 13:00:27 +0200
changeset 604f2a73683adc
parent 59 9979787100b1
child 61 5a24e79384be
Adding and removing row is now working.
Can now have any number of text field.
Client/MainForm.cs
Server/MainForm.Designer.cs
Server/MainForm.cs
     1.1 --- a/Client/MainForm.cs	Mon Sep 22 10:05:45 2014 +0200
     1.2 +++ b/Client/MainForm.cs	Mon Sep 22 13:00:27 2014 +0200
     1.3 @@ -49,12 +49,12 @@
     1.4          }
     1.5  
     1.6  
     1.7 -       
     1.8 +
     1.9          public delegate void CloseConnectionDelegate();
    1.10          public delegate void CloseDelegate();
    1.11  
    1.12          /// <summary>
    1.13 -        /// 
    1.14 +        ///
    1.15          /// </summary>
    1.16          public void CloseConnectionThreadSafe()
    1.17          {
    1.18 @@ -80,7 +80,7 @@
    1.19          }
    1.20  
    1.21          /// <summary>
    1.22 -        /// 
    1.23 +        ///
    1.24          /// </summary>
    1.25          public void CloseThreadSafe()
    1.26          {
    1.27 @@ -133,6 +133,7 @@
    1.28          {
    1.29              //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
    1.30              iTextFieldTop.Text = textBoxTop.Text;
    1.31 +            iTextFieldTop.Alignment = Alignment;
    1.32              iClient.SetText(iTextFieldTop);
    1.33          }
    1.34  
    1.35 @@ -143,7 +144,7 @@
    1.36              //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
    1.37  
    1.38              iClient.SetTexts(new TextField[]
    1.39 -            { 
    1.40 +            {
    1.41                  new TextField(0, textBoxTop.Text, Alignment),
    1.42                  new TextField(1, textBoxBottom.Text, Alignment)
    1.43              });
     2.1 --- a/Server/MainForm.Designer.cs	Mon Sep 22 10:05:45 2014 +0200
     2.2 +++ b/Server/MainForm.Designer.cs	Mon Sep 22 13:00:27 2014 +0200
     2.3 @@ -102,24 +102,27 @@
     2.4              this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     2.5              | System.Windows.Forms.AnchorStyles.Left) 
     2.6              | System.Windows.Forms.AnchorStyles.Right)));
     2.7 +            this.tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     2.8              this.tableLayoutPanel.BackColor = System.Drawing.SystemColors.ControlLightLight;
     2.9              this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
    2.10              this.tableLayoutPanel.ColumnCount = 1;
    2.11              this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
    2.12              this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0);
    2.13              this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1);
    2.14 +            this.tableLayoutPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
    2.15              this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
    2.16              this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
    2.17              this.tableLayoutPanel.Name = "tableLayoutPanel";
    2.18              this.tableLayoutPanel.RowCount = 2;
    2.19 -            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
    2.20 -            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
    2.21 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
    2.22 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
    2.23              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
    2.24              this.tableLayoutPanel.TabIndex = 5;
    2.25              // 
    2.26              // marqueeLabelTop
    2.27              // 
    2.28              this.marqueeLabelTop.AutoEllipsis = true;
    2.29 +            this.marqueeLabelTop.AutoSize = true;
    2.30              this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
    2.31              this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
    2.32              this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
    2.33 @@ -137,6 +140,7 @@
    2.34              // marqueeLabelBottom
    2.35              // 
    2.36              this.marqueeLabelBottom.AutoEllipsis = true;
    2.37 +            this.marqueeLabelBottom.AutoSize = true;
    2.38              this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
    2.39              this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
    2.40              this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
    2.41 @@ -637,6 +641,7 @@
    2.42              this.Resize += new System.EventHandler(this.MainForm_Resize);
    2.43              this.panelDisplay.ResumeLayout(false);
    2.44              this.tableLayoutPanel.ResumeLayout(false);
    2.45 +            this.tableLayoutPanel.PerformLayout();
    2.46              this.statusStrip.ResumeLayout(false);
    2.47              this.statusStrip.PerformLayout();
    2.48              this.tabPageClients.ResumeLayout(false);
     3.1 --- a/Server/MainForm.cs	Mon Sep 22 10:05:45 2014 +0200
     3.2 +++ b/Server/MainForm.cs	Mon Sep 22 13:00:27 2014 +0200
     3.3 @@ -99,7 +99,8 @@
     3.4              //fontDialog.ShowColor = true;
     3.5              //fontDialog.ShowApply = true;
     3.6              fontDialog.ShowEffects = true;
     3.7 -            fontDialog.Font = marqueeLabelTop.Font;
     3.8 +            MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[0];
     3.9 +            fontDialog.Font = label.Font;
    3.10  
    3.11              fontDialog.FixedPitchOnly = checkBoxFixedPitchFontOnly.Checked;
    3.12  
    3.13 @@ -120,8 +121,10 @@
    3.14                  //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
    3.15  
    3.16                  //MessageBox.Show("Ok");
    3.17 -                marqueeLabelTop.Font = fontDialog.Font;
    3.18 -                marqueeLabelBottom.Font = fontDialog.Font;
    3.19 +                foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
    3.20 +                {
    3.21 +                    ctrl.Font = fontDialog.Font;
    3.22 +                }
    3.23                  cds.Font = fontDialog.Font;
    3.24                  Properties.Settings.Default.Save();
    3.25                  //
    3.26 @@ -148,9 +151,10 @@
    3.27              }
    3.28  
    3.29              //Now check font height and show a warning if needed.
    3.30 -            if (marqueeLabelBottom.Font.Height > marqueeLabelBottom.Height)
    3.31 +            MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[0];
    3.32 +            if (label.Font.Height > label.Height)
    3.33              {
    3.34 -                labelWarning.Text = "WARNING: Selected font is too height by " + (marqueeLabelBottom.Font.Height - marqueeLabelBottom.Height) + " pixels!";
    3.35 +                labelWarning.Text = "WARNING: Selected font is too height by " + (label.Font.Height - label.Height) + " pixels!";
    3.36                  labelWarning.Visible = true;
    3.37              }
    3.38              else
    3.39 @@ -167,7 +171,7 @@
    3.40              //Bitmap bmpToSave = new Bitmap(bmp);
    3.41              bmp.Save("D:\\capture.png");
    3.42  
    3.43 -            marqueeLabelTop.Text = "Sweet";
    3.44 +            ((MarqueeLabel)tableLayoutPanel.Controls[0]).Text = "Captured";
    3.45  
    3.46              /*
    3.47              string outputFileName = "d:\\capture.png";
    3.48 @@ -307,8 +311,12 @@
    3.49              //Update our animations
    3.50              DateTime NewTickTime = DateTime.Now;
    3.51  
    3.52 -            marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
    3.53 -            marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
    3.54 +            //Update animation for all our marquees
    3.55 +            foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
    3.56 +            {
    3.57 +                ctrl.UpdateAnimation(LastTickTime, NewTickTime);
    3.58 +            }
    3.59 +
    3.60  
    3.61              //Update our display
    3.62              if (iDisplay.IsOpen())
    3.63 @@ -464,8 +472,13 @@
    3.64              //Load settings
    3.65              checkBoxShowBorders.Checked = cds.ShowBorders;
    3.66              tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
    3.67 -            marqueeLabelTop.Font = cds.Font;
    3.68 -            marqueeLabelBottom.Font = cds.Font;
    3.69 +
    3.70 +            //Set the proper font to each of our labels
    3.71 +            foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
    3.72 +            {
    3.73 +                ctrl.Font = cds.Font;
    3.74 +            }
    3.75 +
    3.76              CheckFontHeight();
    3.77              checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
    3.78              checkBoxReverseScreen.Checked = cds.ReverseScreen;
    3.79 @@ -770,19 +783,10 @@
    3.80                      client.Texts[aTextField.Index] = aTextField;
    3.81  
    3.82                      //We are in the proper thread
    3.83 -                    //Only support two lines for now
    3.84 -                    if (aTextField.Index == 0)
    3.85 -                    {
    3.86 -                        marqueeLabelTop.Text = aTextField.Text;
    3.87 -                        marqueeLabelTop.TextAlign = aTextField.Alignment;
    3.88 -                    }
    3.89 -                    else if (aTextField.Index == 1)
    3.90 -                    {
    3.91 -                        marqueeLabelBottom.Text = aTextField.Text;
    3.92 -                        marqueeLabelBottom.TextAlign = aTextField.Alignment;
    3.93 -                    }
    3.94 -
    3.95 -
    3.96 +                    MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
    3.97 +                    label.Text = aTextField.Text;
    3.98 +                    label.TextAlign = aTextField.Alignment;
    3.99 +                    //
   3.100                      UpdateClientTreeViewNode(client);
   3.101                  }
   3.102              }
   3.103 @@ -823,16 +827,9 @@
   3.104                      //Only support two lines for now
   3.105                      for (int i = 0; i < aTextFields.Count; i++)
   3.106                      {
   3.107 -                        if (aTextFields[i].Index == 0)
   3.108 -                        {
   3.109 -                            marqueeLabelTop.Text = aTextFields[i].Text;
   3.110 -                            marqueeLabelTop.TextAlign = aTextFields[i].Alignment;
   3.111 -                        }
   3.112 -                        else if (aTextFields[i].Index == 1)
   3.113 -                        {
   3.114 -                            marqueeLabelBottom.Text = aTextFields[i].Text;
   3.115 -                            marqueeLabelBottom.TextAlign = aTextFields[i].Alignment;
   3.116 -                        }
   3.117 +                        MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextFields[i].Index];
   3.118 +                        label.Text = aTextFields[i].Text;
   3.119 +                        label.TextAlign = aTextFields[i].Alignment;
   3.120                      }
   3.121  
   3.122  
   3.123 @@ -935,7 +932,7 @@
   3.124          {
   3.125              if (tableLayoutPanel.RowCount < 6)
   3.126              {
   3.127 -                tableLayoutPanel.RowCount++;
   3.128 +                CreateMarqueeForCell(0, tableLayoutPanel.RowCount);
   3.129                  CheckFontHeight();
   3.130              }
   3.131          }
   3.132 @@ -944,9 +941,58 @@
   3.133          {
   3.134              if (tableLayoutPanel.RowCount > 1)
   3.135              {
   3.136 +                tableLayoutPanel.RowStyles.RemoveAt(tableLayoutPanel.RowCount-1);
   3.137 +                tableLayoutPanel.Controls.RemoveAt(tableLayoutPanel.RowCount-1);
   3.138                  tableLayoutPanel.RowCount--;
   3.139                  CheckFontHeight();
   3.140              }
   3.141 +
   3.142 +            UpdateTableLayoutRowStyles();
   3.143 +        }
   3.144 +
   3.145 +        /// <summary>
   3.146 +        /// Update our table layout row styles to make sure each rows have similar height
   3.147 +        /// </summary>
   3.148 +        private void UpdateTableLayoutRowStyles()
   3.149 +        {
   3.150 +            foreach (RowStyle rowStyle in tableLayoutPanel.RowStyles)
   3.151 +            {
   3.152 +                rowStyle.SizeType = SizeType.Percent;
   3.153 +                rowStyle.Height = 100 / tableLayoutPanel.RowCount;
   3.154 +            }
   3.155 +        }
   3.156 +
   3.157 +        /// <summary>
   3.158 +        /// Create the specified cell in our table layout and add a marquee label to it.
   3.159 +        /// </summary>
   3.160 +        /// <param name="aColumn"></param>
   3.161 +        /// <param name="aRow"></param>
   3.162 +        private void CreateMarqueeForCell(int aColumn, int aRow)
   3.163 +        {
   3.164 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
   3.165 +            MarqueeLabel control = new SharpDisplayManager.MarqueeLabel();
   3.166 +            control.AutoEllipsis = true;
   3.167 +            control.AutoSize = true;
   3.168 +            control.BackColor = System.Drawing.Color.Transparent;
   3.169 +            control.Dock = System.Windows.Forms.DockStyle.Fill;
   3.170 +            control.Location = new System.Drawing.Point(1, 1);
   3.171 +            control.Margin = new System.Windows.Forms.Padding(0);
   3.172 +            control.Name = "marqueeLabelCol" + aColumn + "Row" + aRow;
   3.173 +            control.OwnTimer = false;
   3.174 +            control.PixelsPerSecond = 64;
   3.175 +            control.Separator = "|";
   3.176 +            //control.Size = new System.Drawing.Size(254, 30);
   3.177 +            //control.TabIndex = 2;
   3.178 +            control.Font = cds.Font;
   3.179 +            control.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
   3.180 +            control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   3.181 +            control.UseCompatibleTextRendering = true;
   3.182 +            //
   3.183 +            tableLayoutPanel.RowCount++;
   3.184 +            tableLayoutPanel.Controls.Add(control, aColumn, aRow);
   3.185 +
   3.186 +            UpdateTableLayoutRowStyles();
   3.187 +
   3.188          }
   3.189  
   3.190          private void buttonAddColumn_Click(object sender, EventArgs e)
   3.191 @@ -969,20 +1015,26 @@
   3.192  
   3.193          private void buttonAlignLeft_Click(object sender, EventArgs e)
   3.194          {
   3.195 -            marqueeLabelTop.TextAlign = ContentAlignment.MiddleLeft;
   3.196 -            marqueeLabelBottom.TextAlign = ContentAlignment.MiddleLeft;
   3.197 +            foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
   3.198 +            {
   3.199 +                ctrl.TextAlign = ContentAlignment.MiddleLeft;
   3.200 +            }
   3.201          }
   3.202  
   3.203          private void buttonAlignCenter_Click(object sender, EventArgs e)
   3.204          {
   3.205 -            marqueeLabelTop.TextAlign = ContentAlignment.MiddleCenter;
   3.206 -            marqueeLabelBottom.TextAlign = ContentAlignment.MiddleCenter;
   3.207 +            foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
   3.208 +            {
   3.209 +                ctrl.TextAlign = ContentAlignment.MiddleCenter;
   3.210 +            }
   3.211          }
   3.212  
   3.213          private void buttonAlignRight_Click(object sender, EventArgs e)
   3.214          {
   3.215 -            marqueeLabelTop.TextAlign = ContentAlignment.MiddleRight;
   3.216 -            marqueeLabelBottom.TextAlign = ContentAlignment.MiddleRight;
   3.217 +            foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
   3.218 +            {
   3.219 +                ctrl.TextAlign = ContentAlignment.MiddleRight;
   3.220 +            }
   3.221          }
   3.222  
   3.223          private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e)
   3.224 @@ -1035,7 +1087,6 @@
   3.225          {
   3.226              iDisplay.HideClock();
   3.227          }
   3.228 -
   3.229      }
   3.230  
   3.231      /// <summary>