# HG changeset patch # User sl # Date 1418744155 -3600 # Node ID 76564df23849ee9c760ab7e3ac797a80eb0decca # Parent f0dda362f77e2ed7c6215ed5caed7ccad40d2eaf Adding indicators layout demo. diff -r f0dda362f77e -r 76564df23849 Client/MainForm.Designer.cs --- a/Client/MainForm.Designer.cs Tue Dec 16 13:24:12 2014 +0100 +++ b/Client/MainForm.Designer.cs Tue Dec 16 16:35:55 2014 +0100 @@ -38,6 +38,7 @@ this.buttonLayoutUpdate = new System.Windows.Forms.Button(); this.buttonSetBitmap = new System.Windows.Forms.Button(); this.buttonBitmapLayout = new System.Windows.Forms.Button(); + this.buttonIndicatorsLayout = new System.Windows.Forms.Button(); this.SuspendLayout(); // // buttonSetText @@ -134,11 +135,22 @@ this.buttonBitmapLayout.UseVisualStyleBackColor = true; this.buttonBitmapLayout.Click += new System.EventHandler(this.buttonBitmapLayout_Click); // + // buttonIndicatorsLayout + // + this.buttonIndicatorsLayout.Location = new System.Drawing.Point(94, 189); + this.buttonIndicatorsLayout.Name = "buttonIndicatorsLayout"; + this.buttonIndicatorsLayout.Size = new System.Drawing.Size(75, 35); + this.buttonIndicatorsLayout.TabIndex = 28; + this.buttonIndicatorsLayout.Text = "Indicators Layout "; + this.buttonIndicatorsLayout.UseVisualStyleBackColor = true; + this.buttonIndicatorsLayout.Click += new System.EventHandler(this.buttonIndicatorsLayout_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(443, 252); + this.Controls.Add(this.buttonIndicatorsLayout); this.Controls.Add(this.buttonBitmapLayout); this.Controls.Add(this.buttonSetBitmap); this.Controls.Add(this.buttonLayoutUpdate); @@ -170,6 +182,7 @@ private System.Windows.Forms.Button buttonLayoutUpdate; private System.Windows.Forms.Button buttonSetBitmap; private System.Windows.Forms.Button buttonBitmapLayout; + private System.Windows.Forms.Button buttonIndicatorsLayout; } } diff -r f0dda362f77e -r 76564df23849 Client/MainForm.cs --- a/Client/MainForm.cs Tue Dec 16 13:24:12 2014 +0100 +++ b/Client/MainForm.cs Tue Dec 16 16:35:55 2014 +0100 @@ -226,7 +226,6 @@ DataField field = new DataField(0, bitmap); //We want our bitmap field to span across two rows field.RowSpan = 2; - iClient.SetField(field); //Set texts iClient.SetFields(new DataField[] @@ -237,5 +236,62 @@ }); } + + private void buttonIndicatorsLayout_Click(object sender, EventArgs e) + { + //Define a 2 by 4 layout + TableLayout layout = new TableLayout(2, 4); + //First column + layout.Columns[0].Width = 87.5F; + //Second column + layout.Columns[1].Width = 12.5F; + //Send layout to server + iClient.SetLayout(layout); + + //Create a bitmap for our indicators field + int x1 = 0; + int y1 = 0; + int x2 = 32; + int y2 = 16; + + Bitmap bitmap = new Bitmap(x2, y2); + Pen blackPen = new Pen(Color.Black, 3); + + // Draw line to screen. + using (var graphics = Graphics.FromImage(bitmap)) + { + graphics.DrawLine(blackPen, x1, y1, x2, y2); + graphics.DrawLine(blackPen, x1, y2, x2, y1); + } + + //Create a bitmap field from the bitmap we just created + DataField indicator1 = new DataField(2, bitmap); + //Create a bitmap field from the bitmap we just created + DataField indicator2 = new DataField(3, bitmap); + //Create a bitmap field from the bitmap we just created + DataField indicator3 = new DataField(4, bitmap); + //Create a bitmap field from the bitmap we just created + DataField indicator4 = new DataField(5, bitmap); + + // + DataField textFieldTop = new DataField(0, textBoxTop.Text, Alignment); + textFieldTop.RowSpan = 2; + + DataField textFieldBottom = new DataField(1, textBoxBottom.Text, Alignment); + textFieldBottom.RowSpan = 2; + + + //Set texts + iClient.SetFields(new DataField[] + { + textFieldTop, + indicator1, + indicator2, + textFieldBottom, + indicator3, + indicator4 + }); + + } } } diff -r f0dda362f77e -r 76564df23849 Server/MainForm.cs --- a/Server/MainForm.cs Tue Dec 16 13:24:12 2014 +0100 +++ b/Server/MainForm.cs Tue Dec 16 16:35:55 2014 +0100 @@ -25,9 +25,9 @@ //Delegates are used for our thread safe method public delegate void AddClientDelegate(string aSessionId, ICallback aCallback); public delegate void RemoveClientDelegate(string aSessionId); - public delegate void SetTextDelegate(string SessionId, DataField aField); + public delegate void SetFieldDelegate(string SessionId, DataField aField); + public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList aFields); public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout); - public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList aFields); public delegate void SetClientNameDelegate(string aSessionId, string aName); @@ -807,7 +807,7 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetTextDelegate d = new SetTextDelegate(SetClientFieldThreadSafe); + SetFieldDelegate d = new SetFieldDelegate(SetClientFieldThreadSafe); this.Invoke(d, new object[] { aSessionId, aField }); } else @@ -819,12 +819,12 @@ } /// - /// + /// /// /// /// private void SetClientField(string aSessionId, DataField aField) - { + { SetCurrentClient(aSessionId); ClientData client = iClients[aSessionId]; if (client != null) @@ -845,7 +845,7 @@ client.Fields[aField.Index] = aField; // if (aField.IsText && tableLayoutPanel.Controls[aField.Index] is MarqueeLabel) - { + { //Text field control already in place, just change the text MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index]; somethingChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);