# HG changeset patch
# User sl
# Date 1413223548 -7200
# Node ID 6e50baf5a8110e9ee2ab0b33c8d6e4dbf0a8f032
# Parent a02bd242f219a0832355343fb2142aef326f8cc3
Ground work for supporting generic field and bitmap ones.
diff -r a02bd242f219 -r 6e50baf5a811 Client/Client.cs
--- a/Client/Client.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Client/Client.cs Mon Oct 13 20:05:48 2014 +0200
@@ -86,6 +86,11 @@
Channel.SetTexts(aTextFields);
}
+ public void SetBitmap(BitmapField aBitmapField)
+ {
+ Channel.SetBitmap(aBitmapField);
+ }
+
public int ClientCount()
{
return Channel.ClientCount();
diff -r a02bd242f219 -r 6e50baf5a811 Client/MainForm.Designer.cs
--- a/Client/MainForm.Designer.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Client/MainForm.Designer.cs Mon Oct 13 20:05:48 2014 +0200
@@ -36,6 +36,7 @@
this.buttonAlignLeft = new System.Windows.Forms.Button();
this.buttonSetTopText = new System.Windows.Forms.Button();
this.buttonLayoutUpdate = new System.Windows.Forms.Button();
+ this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonSetText
@@ -112,11 +113,22 @@
this.buttonLayoutUpdate.UseVisualStyleBackColor = true;
this.buttonLayoutUpdate.Click += new System.EventHandler(this.buttonLayoutUpdate_Click);
//
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(12, 190);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 26;
+ this.button1.Text = "Set Bitmap";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_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.button1);
this.Controls.Add(this.buttonLayoutUpdate);
this.Controls.Add(this.buttonSetTopText);
this.Controls.Add(this.buttonAlignRight);
@@ -144,6 +156,7 @@
private System.Windows.Forms.Button buttonAlignLeft;
private System.Windows.Forms.Button buttonSetTopText;
private System.Windows.Forms.Button buttonLayoutUpdate;
+ private System.Windows.Forms.Button button1;
}
}
diff -r a02bd242f219 -r 6e50baf5a811 Client/MainForm.cs
--- a/Client/MainForm.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Client/MainForm.cs Mon Oct 13 20:05:48 2014 +0200
@@ -159,5 +159,23 @@
//Send layout to server
iClient.SetLayout(layout);
}
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ Bitmap bitmap = new Bitmap(60,60);
+ Pen blackPen = new Pen(Color.Black, 3);
+
+ int x1 = 0;
+ int y1 = 0;
+ int x2 = 60;
+ int y2 = 60;
+ // Draw line to screen.
+ using (var graphics = Graphics.FromImage(bitmap))
+ {
+ graphics.DrawLine(blackPen, x1, y1, x2, y2);
+ }
+
+ iClient.SetBitmap(new BitmapField(0, bitmap));
+ }
}
}
diff -r a02bd242f219 -r 6e50baf5a811 Interface/Interface.cs
--- a/Interface/Interface.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Interface/Interface.cs Mon Oct 13 20:05:48 2014 +0200
@@ -16,9 +16,6 @@
namespace SharpDisplay
{
-
-
-
///
/// For client to specify a specific layout.
///
@@ -177,6 +174,14 @@
void SetTexts(System.Collections.Generic.IList aTextFields);
///
+ /// Put the given bitmap in the given field on your display.
+ /// Fields are often just lines of text.
+ ///
+ ///
+ [OperationContract(IsOneWay = true)]
+ void SetBitmap(BitmapField aBitmapField);
+
+ ///
/// Provides the number of clients currently connected
///
///
diff -r a02bd242f219 -r 6e50baf5a811 Server/MainForm.Designer.cs
--- a/Server/MainForm.Designer.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Server/MainForm.Designer.cs Mon Oct 13 20:05:48 2014 +0200
@@ -77,6 +77,7 @@
this.buttonAddRow = new System.Windows.Forms.Button();
this.labelFontWidth = new System.Windows.Forms.Label();
this.labelFontHeight = new System.Windows.Forms.Label();
+ this.pictureBoxDemo = new System.Windows.Forms.PictureBox();
this.panelDisplay.SuspendLayout();
this.tableLayoutPanel.SuspendLayout();
this.statusStrip.SuspendLayout();
@@ -85,6 +86,7 @@
((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
this.tabControl.SuspendLayout();
this.tabPageDesign.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxDemo)).BeginInit();
this.SuspendLayout();
//
// panelDisplay
@@ -622,11 +624,20 @@
this.labelFontHeight.TabIndex = 20;
this.labelFontHeight.Text = "Font height";
//
+ // pictureBoxDemo
+ //
+ this.pictureBoxDemo.Location = new System.Drawing.Point(478, 54);
+ this.pictureBoxDemo.Name = "pictureBoxDemo";
+ this.pictureBoxDemo.Size = new System.Drawing.Size(100, 50);
+ this.pictureBoxDemo.TabIndex = 21;
+ this.pictureBoxDemo.TabStop = false;
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(624, 442);
+ this.Controls.Add(this.pictureBoxDemo);
this.Controls.Add(this.labelFontHeight);
this.Controls.Add(this.labelFontWidth);
this.Controls.Add(this.labelWarning);
@@ -651,6 +662,7 @@
this.tabControl.ResumeLayout(false);
this.tabPageDesign.ResumeLayout(false);
this.tabPageDesign.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxDemo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -706,6 +718,7 @@
private System.Windows.Forms.Label labelFontWidth;
private System.Windows.Forms.Label labelFontHeight;
private System.Windows.Forms.CheckBox checkBoxInverseColors;
+ private System.Windows.Forms.PictureBox pictureBoxDemo;
}
}
diff -r a02bd242f219 -r 6e50baf5a811 Server/MainForm.cs
--- a/Server/MainForm.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Server/MainForm.cs Mon Oct 13 20:05:48 2014 +0200
@@ -26,6 +26,7 @@
public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
public delegate void RemoveClientDelegate(string aSessionId);
public delegate void SetTextDelegate(string SessionId, TextField aTextField);
+ public delegate void SetBitmapDelegate(string SessionId, BitmapField aTextField);
public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList aTextFields);
public delegate void SetClientNameDelegate(string aSessionId, string aName);
@@ -787,8 +788,8 @@
///
///
///
- ///
- ///
+ ///
+ ///
public void SetClientTextThreadSafe(string aSessionId, TextField aTextField)
{
if (this.InvokeRequired)
@@ -804,12 +805,12 @@
if (client != null)
{
//Make sure all our texts are in place
- while (client.Texts.Count < (aTextField.Index + 1))
+ while (client.Fields.Count < (aTextField.Index + 1))
{
//Add a text field with proper index
- client.Texts.Add(new TextField(client.Texts.Count));
+ client.Fields.Add(new TextField(client.Fields.Count));
}
- client.Texts[aTextField.Index] = aTextField;
+ client.Fields[aTextField.Index] = aTextField;
//We are in the proper thread
MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
@@ -844,13 +845,13 @@
int j = 0;
foreach (TextField textField in aTextFields)
{
- if (client.Texts.Count < (j + 1))
+ if (client.Fields.Count < (j + 1))
{
- client.Texts.Add(textField);
+ client.Fields.Add(textField);
}
else
{
- client.Texts[j] = textField;
+ client.Fields[j] = textField;
}
j++;
}
@@ -868,6 +869,44 @@
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void SetClientBitmapThreadSafe(string aSessionId, BitmapField aBitmapField)
+ {
+ if (this.InvokeRequired)
+ {
+ //Not in the proper thread, invoke ourselves
+ SetBitmapDelegate d = new SetBitmapDelegate(SetClientBitmapThreadSafe);
+ this.Invoke(d, new object[] { aSessionId, aBitmapField });
+ }
+ else
+ {
+ SetCurrentClient(aSessionId);
+ ClientData client = iClients[aSessionId];
+ if (client != null)
+ {
+ //Make sure all our texts are in place
+ while (client.Fields.Count < (aBitmapField.Index + 1))
+ {
+ //Add a text field with proper index
+ client.Fields.Add(new TextField(client.Fields.Count));
+ }
+
+ client.Fields[aBitmapField.Index] = aBitmapField;
+
+ //We are in the proper thread
+ MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aBitmapField.Index];
+ label.Text = "Bitmap";
+ //
+ UpdateClientTreeViewNode(client);
+ }
+ }
+ }
+
+
///
///
@@ -942,15 +981,27 @@
node.Text = aClient.SessionId;
}
- if (aClient.Texts.Count > 0)
+ if (aClient.Fields.Count > 0)
{
//Create root node for our texts
TreeNode textsRoot = new TreeNode("Text");
node.Nodes.Add(textsRoot);
//For each text add a new entry
- foreach (TextField field in aClient.Texts)
+ foreach (DataField field in aClient.Fields)
{
- textsRoot.Nodes.Add(new TreeNode(field.Text));
+ if (field is TextField)
+ {
+ TextField textField = (TextField)field;
+ textsRoot.Nodes.Add(new TreeNode(textField.Text));
+ }
+ else if (field is BitmapField)
+ {
+ textsRoot.Nodes.Add(new TreeNode("[Bitmap Field]"));
+ }
+ else
+ {
+ textsRoot.Nodes.Add(new TreeNode("[Unknown Field Type]"));
+ }
}
}
@@ -1121,9 +1172,14 @@
control.Font = cds.Font;
control.Text = "";
//If we already have a text for that field
- if (aClient.Texts.Count > tableLayoutPanel.Controls.Count)
+ if (aClient.Fields.Count > tableLayoutPanel.Controls.Count)
{
- control.Text = aClient.Texts[tableLayoutPanel.Controls.Count].Text;
+ DataField field = aClient.Fields[tableLayoutPanel.Controls.Count];
+ if (field is TextField)
+ {
+ TextField textField = (TextField)field;
+ control.Text = textField.Text;
+ }
}
control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1223,14 +1279,14 @@
{
SessionId = aSessionId;
Name = "";
- Texts = new List();
+ Fields = new List();
Layout = new TableLayout(1, 2); //Default to one column and two rows
Callback = aCallback;
}
public string SessionId { get; set; }
public string Name { get; set; }
- public List Texts { get; set; }
+ public List Fields { get; set; }
public TableLayout Layout { get; set; }
public ICallback Callback { get; set; }
}
diff -r a02bd242f219 -r 6e50baf5a811 Server/Session.cs
--- a/Server/Session.cs Mon Oct 13 19:24:30 2014 +0200
+++ b/Server/Session.cs Mon Oct 13 20:05:48 2014 +0200
@@ -71,6 +71,11 @@
SharpDisplayManager.Program.iMainForm.SetClientTextThreadSafe(SessionId, aTextField);
}
+ //
+ public void SetBitmap(BitmapField aBitmapField)
+ {
+ SharpDisplayManager.Program.iMainForm.SetClientBitmapThreadSafe(SessionId, aBitmapField);
+ }
///
public int ClientCount()