Adding indicators layout demo.
1.1 --- a/Client/MainForm.Designer.cs Tue Dec 16 13:24:12 2014 +0100
1.2 +++ b/Client/MainForm.Designer.cs Tue Dec 16 16:35:55 2014 +0100
1.3 @@ -38,6 +38,7 @@
1.4 this.buttonLayoutUpdate = new System.Windows.Forms.Button();
1.5 this.buttonSetBitmap = new System.Windows.Forms.Button();
1.6 this.buttonBitmapLayout = new System.Windows.Forms.Button();
1.7 + this.buttonIndicatorsLayout = new System.Windows.Forms.Button();
1.8 this.SuspendLayout();
1.9 //
1.10 // buttonSetText
1.11 @@ -134,11 +135,22 @@
1.12 this.buttonBitmapLayout.UseVisualStyleBackColor = true;
1.13 this.buttonBitmapLayout.Click += new System.EventHandler(this.buttonBitmapLayout_Click);
1.14 //
1.15 + // buttonIndicatorsLayout
1.16 + //
1.17 + this.buttonIndicatorsLayout.Location = new System.Drawing.Point(94, 189);
1.18 + this.buttonIndicatorsLayout.Name = "buttonIndicatorsLayout";
1.19 + this.buttonIndicatorsLayout.Size = new System.Drawing.Size(75, 35);
1.20 + this.buttonIndicatorsLayout.TabIndex = 28;
1.21 + this.buttonIndicatorsLayout.Text = "Indicators Layout ";
1.22 + this.buttonIndicatorsLayout.UseVisualStyleBackColor = true;
1.23 + this.buttonIndicatorsLayout.Click += new System.EventHandler(this.buttonIndicatorsLayout_Click);
1.24 + //
1.25 // MainForm
1.26 //
1.27 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
1.28 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
1.29 this.ClientSize = new System.Drawing.Size(443, 252);
1.30 + this.Controls.Add(this.buttonIndicatorsLayout);
1.31 this.Controls.Add(this.buttonBitmapLayout);
1.32 this.Controls.Add(this.buttonSetBitmap);
1.33 this.Controls.Add(this.buttonLayoutUpdate);
1.34 @@ -170,6 +182,7 @@
1.35 private System.Windows.Forms.Button buttonLayoutUpdate;
1.36 private System.Windows.Forms.Button buttonSetBitmap;
1.37 private System.Windows.Forms.Button buttonBitmapLayout;
1.38 + private System.Windows.Forms.Button buttonIndicatorsLayout;
1.39 }
1.40 }
1.41
2.1 --- a/Client/MainForm.cs Tue Dec 16 13:24:12 2014 +0100
2.2 +++ b/Client/MainForm.cs Tue Dec 16 16:35:55 2014 +0100
2.3 @@ -226,7 +226,6 @@
2.4 DataField field = new DataField(0, bitmap);
2.5 //We want our bitmap field to span across two rows
2.6 field.RowSpan = 2;
2.7 - iClient.SetField(field);
2.8
2.9 //Set texts
2.10 iClient.SetFields(new DataField[]
2.11 @@ -237,5 +236,62 @@
2.12 });
2.13
2.14 }
2.15 +
2.16 + private void buttonIndicatorsLayout_Click(object sender, EventArgs e)
2.17 + {
2.18 + //Define a 2 by 4 layout
2.19 + TableLayout layout = new TableLayout(2, 4);
2.20 + //First column
2.21 + layout.Columns[0].Width = 87.5F;
2.22 + //Second column
2.23 + layout.Columns[1].Width = 12.5F;
2.24 + //Send layout to server
2.25 + iClient.SetLayout(layout);
2.26 +
2.27 + //Create a bitmap for our indicators field
2.28 + int x1 = 0;
2.29 + int y1 = 0;
2.30 + int x2 = 32;
2.31 + int y2 = 16;
2.32 +
2.33 + Bitmap bitmap = new Bitmap(x2, y2);
2.34 + Pen blackPen = new Pen(Color.Black, 3);
2.35 +
2.36 + // Draw line to screen.
2.37 + using (var graphics = Graphics.FromImage(bitmap))
2.38 + {
2.39 + graphics.DrawLine(blackPen, x1, y1, x2, y2);
2.40 + graphics.DrawLine(blackPen, x1, y2, x2, y1);
2.41 + }
2.42 +
2.43 + //Create a bitmap field from the bitmap we just created
2.44 + DataField indicator1 = new DataField(2, bitmap);
2.45 + //Create a bitmap field from the bitmap we just created
2.46 + DataField indicator2 = new DataField(3, bitmap);
2.47 + //Create a bitmap field from the bitmap we just created
2.48 + DataField indicator3 = new DataField(4, bitmap);
2.49 + //Create a bitmap field from the bitmap we just created
2.50 + DataField indicator4 = new DataField(5, bitmap);
2.51 +
2.52 + //
2.53 + DataField textFieldTop = new DataField(0, textBoxTop.Text, Alignment);
2.54 + textFieldTop.RowSpan = 2;
2.55 +
2.56 + DataField textFieldBottom = new DataField(1, textBoxBottom.Text, Alignment);
2.57 + textFieldBottom.RowSpan = 2;
2.58 +
2.59 +
2.60 + //Set texts
2.61 + iClient.SetFields(new DataField[]
2.62 + {
2.63 + textFieldTop,
2.64 + indicator1,
2.65 + indicator2,
2.66 + textFieldBottom,
2.67 + indicator3,
2.68 + indicator4
2.69 + });
2.70 +
2.71 + }
2.72 }
2.73 }
3.1 --- a/Server/MainForm.cs Tue Dec 16 13:24:12 2014 +0100
3.2 +++ b/Server/MainForm.cs Tue Dec 16 16:35:55 2014 +0100
3.3 @@ -25,9 +25,9 @@
3.4 //Delegates are used for our thread safe method
3.5 public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
3.6 public delegate void RemoveClientDelegate(string aSessionId);
3.7 - public delegate void SetTextDelegate(string SessionId, DataField aField);
3.8 + public delegate void SetFieldDelegate(string SessionId, DataField aField);
3.9 + public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList<DataField> aFields);
3.10 public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
3.11 - public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList<DataField> aFields);
3.12 public delegate void SetClientNameDelegate(string aSessionId, string aName);
3.13
3.14
3.15 @@ -807,7 +807,7 @@
3.16 if (this.InvokeRequired)
3.17 {
3.18 //Not in the proper thread, invoke ourselves
3.19 - SetTextDelegate d = new SetTextDelegate(SetClientFieldThreadSafe);
3.20 + SetFieldDelegate d = new SetFieldDelegate(SetClientFieldThreadSafe);
3.21 this.Invoke(d, new object[] { aSessionId, aField });
3.22 }
3.23 else
3.24 @@ -819,12 +819,12 @@
3.25 }
3.26
3.27 /// <summary>
3.28 - ///
3.29 + ///
3.30 /// </summary>
3.31 /// <param name="aSessionId"></param>
3.32 /// <param name="aField"></param>
3.33 private void SetClientField(string aSessionId, DataField aField)
3.34 - {
3.35 + {
3.36 SetCurrentClient(aSessionId);
3.37 ClientData client = iClients[aSessionId];
3.38 if (client != null)
3.39 @@ -845,7 +845,7 @@
3.40 client.Fields[aField.Index] = aField;
3.41 //
3.42 if (aField.IsText && tableLayoutPanel.Controls[aField.Index] is MarqueeLabel)
3.43 - {
3.44 + {
3.45 //Text field control already in place, just change the text
3.46 MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index];
3.47 somethingChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);