1.1 --- a/Server/MainForm.cs Mon Oct 13 19:24:30 2014 +0200
1.2 +++ b/Server/MainForm.cs Mon Oct 13 20:05:48 2014 +0200
1.3 @@ -26,6 +26,7 @@
1.4 public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
1.5 public delegate void RemoveClientDelegate(string aSessionId);
1.6 public delegate void SetTextDelegate(string SessionId, TextField aTextField);
1.7 + public delegate void SetBitmapDelegate(string SessionId, BitmapField aTextField);
1.8 public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
1.9 public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
1.10 public delegate void SetClientNameDelegate(string aSessionId, string aName);
1.11 @@ -787,8 +788,8 @@
1.12 /// <summary>
1.13 ///
1.14 /// </summary>
1.15 - /// <param name="aLineIndex"></param>
1.16 - /// <param name="aText"></param>
1.17 + /// <param name="aSessionId"></param>
1.18 + /// <param name="aTextField"></param>
1.19 public void SetClientTextThreadSafe(string aSessionId, TextField aTextField)
1.20 {
1.21 if (this.InvokeRequired)
1.22 @@ -804,12 +805,12 @@
1.23 if (client != null)
1.24 {
1.25 //Make sure all our texts are in place
1.26 - while (client.Texts.Count < (aTextField.Index + 1))
1.27 + while (client.Fields.Count < (aTextField.Index + 1))
1.28 {
1.29 //Add a text field with proper index
1.30 - client.Texts.Add(new TextField(client.Texts.Count));
1.31 + client.Fields.Add(new TextField(client.Fields.Count));
1.32 }
1.33 - client.Texts[aTextField.Index] = aTextField;
1.34 + client.Fields[aTextField.Index] = aTextField;
1.35
1.36 //We are in the proper thread
1.37 MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
1.38 @@ -844,13 +845,13 @@
1.39 int j = 0;
1.40 foreach (TextField textField in aTextFields)
1.41 {
1.42 - if (client.Texts.Count < (j + 1))
1.43 + if (client.Fields.Count < (j + 1))
1.44 {
1.45 - client.Texts.Add(textField);
1.46 + client.Fields.Add(textField);
1.47 }
1.48 else
1.49 {
1.50 - client.Texts[j] = textField;
1.51 + client.Fields[j] = textField;
1.52 }
1.53 j++;
1.54 }
1.55 @@ -868,6 +869,44 @@
1.56 }
1.57 }
1.58
1.59 + /// <summary>
1.60 + ///
1.61 + /// </summary>
1.62 + /// <param name="aSessionId"></param>
1.63 + /// <param name="aTextField"></param>
1.64 + public void SetClientBitmapThreadSafe(string aSessionId, BitmapField aBitmapField)
1.65 + {
1.66 + if (this.InvokeRequired)
1.67 + {
1.68 + //Not in the proper thread, invoke ourselves
1.69 + SetBitmapDelegate d = new SetBitmapDelegate(SetClientBitmapThreadSafe);
1.70 + this.Invoke(d, new object[] { aSessionId, aBitmapField });
1.71 + }
1.72 + else
1.73 + {
1.74 + SetCurrentClient(aSessionId);
1.75 + ClientData client = iClients[aSessionId];
1.76 + if (client != null)
1.77 + {
1.78 + //Make sure all our texts are in place
1.79 + while (client.Fields.Count < (aBitmapField.Index + 1))
1.80 + {
1.81 + //Add a text field with proper index
1.82 + client.Fields.Add(new TextField(client.Fields.Count));
1.83 + }
1.84 +
1.85 + client.Fields[aBitmapField.Index] = aBitmapField;
1.86 +
1.87 + //We are in the proper thread
1.88 + MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aBitmapField.Index];
1.89 + label.Text = "Bitmap";
1.90 + //
1.91 + UpdateClientTreeViewNode(client);
1.92 + }
1.93 + }
1.94 + }
1.95 +
1.96 +
1.97
1.98 /// <summary>
1.99 ///
1.100 @@ -942,15 +981,27 @@
1.101 node.Text = aClient.SessionId;
1.102 }
1.103
1.104 - if (aClient.Texts.Count > 0)
1.105 + if (aClient.Fields.Count > 0)
1.106 {
1.107 //Create root node for our texts
1.108 TreeNode textsRoot = new TreeNode("Text");
1.109 node.Nodes.Add(textsRoot);
1.110 //For each text add a new entry
1.111 - foreach (TextField field in aClient.Texts)
1.112 + foreach (DataField field in aClient.Fields)
1.113 {
1.114 - textsRoot.Nodes.Add(new TreeNode(field.Text));
1.115 + if (field is TextField)
1.116 + {
1.117 + TextField textField = (TextField)field;
1.118 + textsRoot.Nodes.Add(new TreeNode(textField.Text));
1.119 + }
1.120 + else if (field is BitmapField)
1.121 + {
1.122 + textsRoot.Nodes.Add(new TreeNode("[Bitmap Field]"));
1.123 + }
1.124 + else
1.125 + {
1.126 + textsRoot.Nodes.Add(new TreeNode("[Unknown Field Type]"));
1.127 + }
1.128 }
1.129 }
1.130
1.131 @@ -1121,9 +1172,14 @@
1.132 control.Font = cds.Font;
1.133 control.Text = "";
1.134 //If we already have a text for that field
1.135 - if (aClient.Texts.Count > tableLayoutPanel.Controls.Count)
1.136 + if (aClient.Fields.Count > tableLayoutPanel.Controls.Count)
1.137 {
1.138 - control.Text = aClient.Texts[tableLayoutPanel.Controls.Count].Text;
1.139 + DataField field = aClient.Fields[tableLayoutPanel.Controls.Count];
1.140 + if (field is TextField)
1.141 + {
1.142 + TextField textField = (TextField)field;
1.143 + control.Text = textField.Text;
1.144 + }
1.145 }
1.146
1.147 control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
1.148 @@ -1223,14 +1279,14 @@
1.149 {
1.150 SessionId = aSessionId;
1.151 Name = "";
1.152 - Texts = new List<TextField>();
1.153 + Fields = new List<DataField>();
1.154 Layout = new TableLayout(1, 2); //Default to one column and two rows
1.155 Callback = aCallback;
1.156 }
1.157
1.158 public string SessionId { get; set; }
1.159 public string Name { get; set; }
1.160 - public List<TextField> Texts { get; set; }
1.161 + public List<DataField> Fields { get; set; }
1.162 public TableLayout Layout { get; set; }
1.163 public ICallback Callback { get; set; }
1.164 }