Onlu update client tree view when needed.
authorsl
Tue, 16 Dec 2014 10:59:10 +0100
changeset 76906d88eb53fb
parent 75 2549a8055bd1
child 77 042c1fa136b9
Onlu update client tree view when needed.
Interface/Interface.cs
Server/MainForm.cs
     1.1 --- a/Interface/Interface.cs	Sun Oct 26 16:16:57 2014 +0100
     1.2 +++ b/Interface/Interface.cs	Tue Dec 16 10:59:10 2014 +0100
     1.3 @@ -201,6 +201,4 @@
     1.4          void OnCloseOrder();
     1.5      }
     1.6  
     1.7 -
     1.8 -
     1.9  }
     2.1 --- a/Server/MainForm.cs	Sun Oct 26 16:16:57 2014 +0100
     2.2 +++ b/Server/MainForm.cs	Tue Dec 16 10:59:10 2014 +0100
     2.3 @@ -829,11 +829,14 @@
     2.4              ClientData client = iClients[aSessionId];
     2.5              if (client != null)
     2.6              {
     2.7 +                bool somethingChanged = false;
     2.8 +
     2.9                  //Make sure all our fields are in place
    2.10                  while (client.Fields.Count < (aField.Index + 1))
    2.11                  {
    2.12                      //Add a text field with proper index
    2.13                      client.Fields.Add(new DataField(client.Fields.Count));
    2.14 +                    somethingChanged = true;
    2.15                  }
    2.16  
    2.17                  if (client.Fields[aField.Index].IsSameLayout(aField))
    2.18 @@ -842,20 +845,23 @@
    2.19                      client.Fields[aField.Index] = aField;
    2.20                      //
    2.21                      if (aField.IsText && tableLayoutPanel.Controls[aField.Index] is MarqueeLabel)
    2.22 -                    {
    2.23 +                    {                        
    2.24                          //Text field control already in place, just change the text
    2.25                          MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index];
    2.26 +                        somethingChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);
    2.27                          label.Text = aField.Text;
    2.28                          label.TextAlign = aField.Alignment;
    2.29                      }
    2.30                      else if (aField.IsBitmap && tableLayoutPanel.Controls[aField.Index] is PictureBox)
    2.31                      {
    2.32 +                        somethingChanged = true; //TODO: Bitmap comp or should we leave that to clients?
    2.33                          //Bitmap field control already in place just change the bitmap
    2.34                          PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aField.Index];
    2.35                          pictureBox.Image = aField.Bitmap;
    2.36                      }
    2.37                      else
    2.38                      {
    2.39 +                        somethingChanged = true;
    2.40                          //The requested control in our layout it not of the correct type
    2.41                          //Wrong control type, re-create them all
    2.42                          UpdateTableLayoutPanel(iCurrentClientData);
    2.43 @@ -863,13 +869,17 @@
    2.44                  }
    2.45                  else
    2.46                  {
    2.47 +                    somethingChanged = true;
    2.48                      //Different layout, need to rebuild it
    2.49                      client.Fields[aField.Index] = aField;
    2.50                      UpdateTableLayoutPanel(iCurrentClientData);
    2.51                  }
    2.52  
    2.53                  //
    2.54 -                UpdateClientTreeViewNode(client);
    2.55 +                if (somethingChanged)
    2.56 +                {
    2.57 +                    UpdateClientTreeViewNode(client);
    2.58 +                }
    2.59              }
    2.60          }
    2.61