Server/MainForm.cs
changeset 72 fd0bb39a7818
parent 70 dcd2bbb90d42
child 75 2549a8055bd1
     1.1 --- a/Server/MainForm.cs	Wed Oct 22 12:17:52 2014 +0200
     1.2 +++ b/Server/MainForm.cs	Sat Oct 25 13:35:11 2014 +0200
     1.3 @@ -25,10 +25,10 @@
     1.4      //Delegates are used for our thread safe method
     1.5      public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
     1.6      public delegate void RemoveClientDelegate(string aSessionId);
     1.7 -    public delegate void SetTextDelegate(string SessionId, TextField aTextField);
     1.8 -    public delegate void SetBitmapDelegate(string SessionId, BitmapField aTextField);
     1.9 +    public delegate void SetTextDelegate(string SessionId, DataField aField);
    1.10 +    public delegate void SetBitmapDelegate(string SessionId, DataField aField);
    1.11      public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
    1.12 -    public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
    1.13 +    public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<DataField> aFields);
    1.14      public delegate void SetClientNameDelegate(string aSessionId, string aName);
    1.15  
    1.16  
    1.17 @@ -776,7 +776,7 @@
    1.18          ///
    1.19          /// </summary>
    1.20          /// <param name="aSessionId"></param>
    1.21 -        /// <param name="aTextField"></param>
    1.22 +        /// <param name="aLayout"></param>
    1.23          public void SetClientLayoutThreadSafe(string aSessionId, TableLayout aLayout)
    1.24          {
    1.25              if (this.InvokeRequired)
    1.26 @@ -802,14 +802,14 @@
    1.27          ///
    1.28          /// </summary>
    1.29          /// <param name="aSessionId"></param>
    1.30 -        /// <param name="aTextField"></param>
    1.31 -        public void SetClientTextThreadSafe(string aSessionId, TextField aTextField)
    1.32 +        /// <param name="aField"></param>
    1.33 +        public void SetClientTextThreadSafe(string aSessionId, DataField aField)
    1.34          {
    1.35              if (this.InvokeRequired)
    1.36              {
    1.37                  //Not in the proper thread, invoke ourselves
    1.38                  SetTextDelegate d = new SetTextDelegate(SetClientTextThreadSafe);
    1.39 -                this.Invoke(d, new object[] { aSessionId, aTextField });
    1.40 +                this.Invoke(d, new object[] { aSessionId, aField });
    1.41              }
    1.42              else
    1.43              {
    1.44 @@ -818,19 +818,19 @@
    1.45                  if (client != null)
    1.46                  {
    1.47                      //Make sure all our texts are in place
    1.48 -                    while (client.Fields.Count < (aTextField.Index + 1))
    1.49 +                    while (client.Fields.Count < (aField.Index + 1))
    1.50                      {
    1.51                          //Add a text field with proper index
    1.52 -                        client.Fields.Add(new TextField(client.Fields.Count));
    1.53 +                        client.Fields.Add(new DataField(client.Fields.Count));
    1.54                      }
    1.55 -                    client.Fields[aTextField.Index] = aTextField;
    1.56 +                    client.Fields[aField.Index] = aField;
    1.57  
    1.58                      //We are in the proper thread
    1.59 -                    if (tableLayoutPanel.Controls[aTextField.Index] is MarqueeLabel)
    1.60 +                    if (tableLayoutPanel.Controls[aField.Index] is MarqueeLabel)
    1.61                      {
    1.62 -                        MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextField.Index];
    1.63 -                        label.Text = aTextField.Text;
    1.64 -                        label.TextAlign = aTextField.Alignment;
    1.65 +                        MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index];
    1.66 +                        label.Text = aField.Text;
    1.67 +                        label.TextAlign = aField.Alignment;
    1.68                      }
    1.69                      else
    1.70                      {
    1.71 @@ -847,13 +847,13 @@
    1.72          ///
    1.73          /// </summary>
    1.74          /// <param name="aTexts"></param>
    1.75 -        public void SetClientTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<TextField> aTextFields)
    1.76 +        public void SetClientTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<DataField> aFields)
    1.77          {
    1.78              if (this.InvokeRequired)
    1.79              {
    1.80                  //Not in the proper thread, invoke ourselves
    1.81                  SetTextsDelegate d = new SetTextsDelegate(SetClientTextsThreadSafe);
    1.82 -                this.Invoke(d, new object[] { aSessionId, aTextFields });
    1.83 +                this.Invoke(d, new object[] { aSessionId, aFields });
    1.84              }
    1.85              else
    1.86              {
    1.87 @@ -863,18 +863,18 @@
    1.88                  if (client != null)
    1.89                  {
    1.90                      //Populate our client with the given text fields
    1.91 -                    foreach (TextField textField in aTextFields)
    1.92 +                    foreach (DataField field in aFields)
    1.93                      {
    1.94                          //Make sure all our texts are in place
    1.95 -                        while (client.Fields.Count < (textField.Index + 1))
    1.96 +                        while (client.Fields.Count < (field.Index + 1))
    1.97                          {
    1.98                              //Add a text field with proper index
    1.99 -                            client.Fields.Add(new TextField(client.Fields.Count));
   1.100 +                            client.Fields.Add(new DataField(client.Fields.Count));
   1.101                          }
   1.102 -                        client.Fields[textField.Index] = textField;
   1.103 +                        client.Fields[field.Index] = field;
   1.104                      }
   1.105                      //Put each our text fields in a label control
   1.106 -                    foreach (TextField field in aTextFields)
   1.107 +                    foreach (DataField field in aFields)
   1.108                      {
   1.109                          if (tableLayoutPanel.Controls[field.Index] is MarqueeLabel)
   1.110                          {
   1.111 @@ -892,7 +892,6 @@
   1.112                          }
   1.113                      }
   1.114  
   1.115 -
   1.116                      UpdateClientTreeViewNode(client);
   1.117                  }
   1.118              }
   1.119 @@ -903,13 +902,13 @@
   1.120          /// </summary>
   1.121          /// <param name="aSessionId"></param>
   1.122          /// <param name="aTextField"></param>
   1.123 -        public void SetClientBitmapThreadSafe(string aSessionId, BitmapField aBitmapField)
   1.124 +        public void SetClientBitmapThreadSafe(string aSessionId, DataField aField)
   1.125          {
   1.126              if (this.InvokeRequired)
   1.127              {
   1.128                  //Not in the proper thread, invoke ourselves
   1.129                  SetBitmapDelegate d = new SetBitmapDelegate(SetClientBitmapThreadSafe);
   1.130 -                this.Invoke(d, new object[] { aSessionId, aBitmapField });
   1.131 +                this.Invoke(d, new object[] { aSessionId, aField });
   1.132              }
   1.133              else
   1.134              {
   1.135 @@ -918,19 +917,19 @@
   1.136                  if (client != null)
   1.137                  {
   1.138                      //Make sure all our texts are in place
   1.139 -                    while (client.Fields.Count < (aBitmapField.Index + 1))
   1.140 +                    while (client.Fields.Count < (aField.Index + 1))
   1.141                      {
   1.142                          //Add a text field with proper index
   1.143 -                        client.Fields.Add(new TextField(client.Fields.Count));
   1.144 +                        client.Fields.Add(new DataField(client.Fields.Count));
   1.145                      }
   1.146  
   1.147 -                    client.Fields[aBitmapField.Index] = aBitmapField;
   1.148 +                    client.Fields[aField.Index] = aField;
   1.149  
   1.150                      //We are in the proper thread
   1.151 -                    if (tableLayoutPanel.Controls[aBitmapField.Index] is PictureBox)
   1.152 +                    if (tableLayoutPanel.Controls[aField.Index] is PictureBox)
   1.153                      {
   1.154 -                        PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aBitmapField.Index];
   1.155 -                        pictureBox.Image = aBitmapField.Bitmap;
   1.156 +                        PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aField.Index];
   1.157 +                        pictureBox.Image = aField.Bitmap;
   1.158                      }
   1.159                      else
   1.160                      {
   1.161 @@ -1026,18 +1025,14 @@
   1.162                      //For each text add a new entry
   1.163                      foreach (DataField field in aClient.Fields)
   1.164                      {
   1.165 -                        if (field is TextField)
   1.166 +                        if (!field.HasBitmap)
   1.167                          {
   1.168 -                            TextField textField = (TextField)field;
   1.169 +                            DataField textField = (DataField)field;
   1.170                              textsRoot.Nodes.Add(new TreeNode("[Text]" + textField.Text));
   1.171                          }
   1.172 -                        else if (field is BitmapField)
   1.173 -                        {
   1.174 -                            textsRoot.Nodes.Add(new TreeNode("[Bitmap]"));
   1.175 -                        }
   1.176                          else
   1.177                          {
   1.178 -                            textsRoot.Nodes.Add(new TreeNode("[Unknown]"));
   1.179 +                            textsRoot.Nodes.Add(new TreeNode("[Bitmap]"));
   1.180                          }
   1.181                      }
   1.182                  }
   1.183 @@ -1210,7 +1205,7 @@
   1.184                      if (aClient.Fields.Count <= tableLayoutPanel.Controls.Count)
   1.185                      {
   1.186                          //No client field specified, create a text field by default
   1.187 -                        aClient.Fields.Add(new TextField(aClient.Fields.Count));
   1.188 +                        aClient.Fields.Add(new DataField(aClient.Fields.Count));
   1.189                      }
   1.190  
   1.191                      //Create a control corresponding to the field specified for that cell
   1.192 @@ -1243,7 +1238,7 @@
   1.193          private Control CreateControlForDataField(DataField aField)
   1.194          {
   1.195              Control control=null;
   1.196 -            if (aField is TextField)
   1.197 +            if (!aField.HasBitmap)
   1.198              {
   1.199                  MarqueeLabel label = new SharpDisplayManager.MarqueeLabel();
   1.200                  label.AutoEllipsis = true;
   1.201 @@ -1262,12 +1257,11 @@
   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 +                label.Text = aField.Text;
   1.208                  //
   1.209                  control = label;
   1.210              }
   1.211 -            else if (aField is BitmapField)
   1.212 +            else
   1.213              {
   1.214                  //Create picture box
   1.215                  PictureBox picture = new PictureBox();
   1.216 @@ -1278,8 +1272,7 @@
   1.217                  picture.Margin = new System.Windows.Forms.Padding(0);
   1.218                  picture.Name = "pictureBox" + aField;
   1.219                  //Set our image
   1.220 -                BitmapField bitmapField = (BitmapField)aField;
   1.221 -                picture.Image = bitmapField.Bitmap;
   1.222 +                picture.Image = aField.Bitmap;
   1.223                  //
   1.224                  control = picture;
   1.225              }