1.1 --- a/Server/MainForm.cs Mon Oct 13 20:05:48 2014 +0200
1.2 +++ b/Server/MainForm.cs Mon Oct 13 21:21:53 2014 +0200
1.3 @@ -160,9 +160,19 @@
1.4 labelFontWidth.Text = "Font width: " + charWidth;
1.5 }
1.6
1.7 + MarqueeLabel label = null;
1.8 + //Get the first label control we can find
1.9 + foreach (Control ctrl in tableLayoutPanel.Controls)
1.10 + {
1.11 + if (ctrl is MarqueeLabel)
1.12 + {
1.13 + label = (MarqueeLabel)ctrl;
1.14 + break;
1.15 + }
1.16 + }
1.17 +
1.18 //Now check font height and show a warning if needed.
1.19 - MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[0];
1.20 - if (label.Font.Height > label.Height)
1.21 + if (label != null && label.Font.Height > label.Height)
1.22 {
1.23 labelWarning.Text = "WARNING: Selected font is too height by " + (label.Font.Height - label.Height) + " pixels!";
1.24 labelWarning.Visible = true;
1.25 @@ -322,9 +332,12 @@
1.26 DateTime NewTickTime = DateTime.Now;
1.27
1.28 //Update animation for all our marquees
1.29 - foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)
1.30 + foreach (Control ctrl in tableLayoutPanel.Controls)
1.31 {
1.32 - ctrl.UpdateAnimation(LastTickTime, NewTickTime);
1.33 + if (ctrl is MarqueeLabel)
1.34 + {
1.35 + ((MarqueeLabel)ctrl).UpdateAnimation(LastTickTime, NewTickTime);
1.36 + }
1.37 }
1.38
1.39
1.40 @@ -813,9 +826,17 @@
1.41 client.Fields[aTextField.Index] = aTextField;
1.42
1.43 //We are in the proper thread
1.44 - MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
1.45 - label.Text = aTextField.Text;
1.46 - label.TextAlign = aTextField.Alignment;
1.47 + if (tableLayoutPanel.Controls[aTextField.Index] is MarqueeLabel)
1.48 + {
1.49 + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
1.50 + label.Text = aTextField.Text;
1.51 + label.TextAlign = aTextField.Alignment;
1.52 + }
1.53 + else
1.54 + {
1.55 + //Wrong control type, re-create them all
1.56 + UpdateTableLayoutPanel(iCurrentClientData);
1.57 + }
1.58 //
1.59 UpdateClientTreeViewNode(client);
1.60 }
1.61 @@ -856,11 +877,22 @@
1.62 j++;
1.63 }
1.64 //Put each our text fields in a label control
1.65 - for (int i = 0; i < aTextFields.Count; i++)
1.66 + foreach (TextField field in aTextFields)
1.67 {
1.68 - MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextFields[i].Index];
1.69 - label.Text = aTextFields[i].Text;
1.70 - label.TextAlign = aTextFields[i].Alignment;
1.71 + if (tableLayoutPanel.Controls[field.Index] is MarqueeLabel)
1.72 + {
1.73 + //Proper control type just update the text
1.74 + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[field.Index];
1.75 + label.Text = field.Text;
1.76 + label.TextAlign = field.Alignment;
1.77 + }
1.78 + else
1.79 + {
1.80 + //Wrong control for the given field
1.81 + //Update our layout thus re-creating our controls
1.82 + UpdateTableLayoutPanel(iCurrentClientData);
1.83 + break; //No need to keep on looping layout update will take care of everything
1.84 + }
1.85 }
1.86
1.87
1.88 @@ -898,8 +930,16 @@
1.89 client.Fields[aBitmapField.Index] = aBitmapField;
1.90
1.91 //We are in the proper thread
1.92 - MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aBitmapField.Index];
1.93 - label.Text = "Bitmap";
1.94 + if (tableLayoutPanel.Controls[aBitmapField.Index] is PictureBox)
1.95 + {
1.96 + PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aBitmapField.Index];
1.97 + pictureBox.Image = aBitmapField.Bitmap;
1.98 + }
1.99 + else
1.100 + {
1.101 + //Wrong control type re-create them all
1.102 + UpdateTableLayoutPanel(iCurrentClientData);
1.103 + }
1.104 //
1.105 UpdateClientTreeViewNode(client);
1.106 }
1.107 @@ -1156,21 +1196,26 @@
1.108 this.tableLayoutPanel.RowStyles.Add(layout.Rows[j]);
1.109 }
1.110
1.111 - MarqueeLabel control = new SharpDisplayManager.MarqueeLabel();
1.112 - control.AutoEllipsis = true;
1.113 - control.AutoSize = true;
1.114 - control.BackColor = System.Drawing.Color.Transparent;
1.115 - control.Dock = System.Windows.Forms.DockStyle.Fill;
1.116 - control.Location = new System.Drawing.Point(1, 1);
1.117 - control.Margin = new System.Windows.Forms.Padding(0);
1.118 - control.Name = "marqueeLabelCol" + layout.Columns.Count + "Row" + layout.Rows.Count;
1.119 - control.OwnTimer = false;
1.120 - control.PixelsPerSecond = 64;
1.121 - control.Separator = "|";
1.122 +
1.123 + MarqueeLabel label = new SharpDisplayManager.MarqueeLabel();
1.124 + label.AutoEllipsis = true;
1.125 + label.AutoSize = true;
1.126 + label.BackColor = System.Drawing.Color.Transparent;
1.127 + label.Dock = System.Windows.Forms.DockStyle.Fill;
1.128 + label.Location = new System.Drawing.Point(1, 1);
1.129 + label.Margin = new System.Windows.Forms.Padding(0);
1.130 + label.Name = "marqueeLabelCol" + layout.Columns.Count + "Row" + layout.Rows.Count;
1.131 + label.OwnTimer = false;
1.132 + label.PixelsPerSecond = 64;
1.133 + label.Separator = "|";
1.134 //control.Size = new System.Drawing.Size(254, 30);
1.135 //control.TabIndex = 2;
1.136 - control.Font = cds.Font;
1.137 - control.Text = "";
1.138 + label.Font = cds.Font;
1.139 + label.Text = "";
1.140 + label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
1.141 + label.UseCompatibleTextRendering = true;
1.142 +
1.143 + Control control = label;
1.144 //If we already have a text for that field
1.145 if (aClient.Fields.Count > tableLayoutPanel.Controls.Count)
1.146 {
1.147 @@ -1180,10 +1225,24 @@
1.148 TextField textField = (TextField)field;
1.149 control.Text = textField.Text;
1.150 }
1.151 + else if (field is BitmapField)
1.152 + {
1.153 + //Create picture box
1.154 + PictureBox pictue = new PictureBox();
1.155 + pictue.AutoSize = true;
1.156 + pictue.BackColor = System.Drawing.Color.Transparent;
1.157 + pictue.Dock = System.Windows.Forms.DockStyle.Fill;
1.158 + pictue.Location = new System.Drawing.Point(1, 1);
1.159 + pictue.Margin = new System.Windows.Forms.Padding(0);
1.160 + pictue.Name = "pictureBox" + layout.Columns.Count + "Row" + layout.Rows.Count;
1.161 + //Set our image
1.162 + BitmapField bitmapField = (BitmapField)field;
1.163 + pictue.Image = bitmapField.Bitmap;
1.164 + //
1.165 + control = pictue;
1.166 + }
1.167 }
1.168 -
1.169 - control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
1.170 - control.UseCompatibleTextRendering = true;
1.171 +
1.172 //
1.173 tableLayoutPanel.Controls.Add(control, i, j);
1.174 }
1.175 @@ -1192,6 +1251,56 @@
1.176 CheckFontHeight();
1.177 }
1.178
1.179 + /// <summary>
1.180 + /// Not used yet.
1.181 + /// </summary>
1.182 + /// <param name="aField"></param>
1.183 + private void CreateControlForDataField(DataField aField)
1.184 + {
1.185 + Control control=null;
1.186 + if (aField is TextField)
1.187 + {
1.188 + MarqueeLabel label = new SharpDisplayManager.MarqueeLabel();
1.189 + label.AutoEllipsis = true;
1.190 + label.AutoSize = true;
1.191 + label.BackColor = System.Drawing.Color.Transparent;
1.192 + label.Dock = System.Windows.Forms.DockStyle.Fill;
1.193 + label.Location = new System.Drawing.Point(1, 1);
1.194 + label.Margin = new System.Windows.Forms.Padding(0);
1.195 + label.Name = "marqueeLabel" + aField.Index;
1.196 + label.OwnTimer = false;
1.197 + label.PixelsPerSecond = 64;
1.198 + label.Separator = "|";
1.199 + //control.Size = new System.Drawing.Size(254, 30);
1.200 + //control.TabIndex = 2;
1.201 + label.Font = cds.Font;
1.202 +
1.203 + label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
1.204 + label.UseCompatibleTextRendering = true;
1.205 + TextField textField = (TextField)aField;
1.206 + label.Text = textField.Text;
1.207 + //
1.208 + control = label;
1.209 + }
1.210 + else if (aField is BitmapField)
1.211 + {
1.212 + //Create picture box
1.213 + PictureBox picture = new PictureBox();
1.214 + picture.AutoSize = true;
1.215 + picture.BackColor = System.Drawing.Color.Transparent;
1.216 + picture.Dock = System.Windows.Forms.DockStyle.Fill;
1.217 + picture.Location = new System.Drawing.Point(1, 1);
1.218 + picture.Margin = new System.Windows.Forms.Padding(0);
1.219 + picture.Name = "pictureBox" + aField;
1.220 + //Set our image
1.221 + BitmapField bitmapField = (BitmapField)aField;
1.222 + picture.Image = bitmapField.Bitmap;
1.223 + //
1.224 + control = picture;
1.225 + }
1.226 +
1.227 + }
1.228 +
1.229
1.230 private void buttonAlignLeft_Click(object sender, EventArgs e)
1.231 {