Server/MainForm.cs
changeset 148 878904899ff0
parent 142 45afadb954ba
child 152 03a1757a38df
     1.1 --- a/Server/MainForm.cs	Sun Jun 21 14:15:11 2015 +0200
     1.2 +++ b/Server/MainForm.cs	Sat Jun 27 11:22:42 2015 +0200
     1.3 @@ -1436,10 +1436,14 @@
     1.4                  ClientData client = iClients[aSessionId];
     1.5                  if (client != null)
     1.6                  {
     1.7 -                    //Set our client layout then
     1.8 -                    client.Layout = aLayout;
     1.9 -                    //
    1.10 -                    UpdateClientTreeViewNode(client);
    1.11 +                    //Don't change a thing if the layout is the same
    1.12 +                    if (!client.Layout.IsSameAs(aLayout))
    1.13 +                    {
    1.14 +                        //Set our client layout then
    1.15 +                        client.Layout = aLayout;
    1.16 +                        //
    1.17 +                        UpdateClientTreeViewNode(client);
    1.18 +                    }
    1.19                  }
    1.20              }
    1.21          }
    1.22 @@ -1476,19 +1480,21 @@
    1.23  
    1.24              ClientData client = iClients[aSessionId];
    1.25              bool layoutChanged = false;
    1.26 +            bool contentChanged = true;
    1.27  
    1.28              //Make sure all our fields are in place
    1.29              while (client.Fields.Count < (aField.Index + 1))
    1.30              {
    1.31 -                //Add a text field with proper index
    1.32 +                //Add a data field with proper index
    1.33                  client.Fields.Add(new DataField(client.Fields.Count));
    1.34                  layoutChanged = true;
    1.35              }
    1.36  
    1.37 +            //Now that we know hour fields are in place just update that one
    1.38 +            client.Fields[aField.Index] = aField;
    1.39 +
    1.40              if (client.Fields[aField.Index].IsSameLayout(aField))
    1.41              {
    1.42 -                //Same layout just update our field
    1.43 -                client.Fields[aField.Index] = aField;
    1.44                  //If we are updating a field in our current client we need to update it in our panel
    1.45                  if (aSessionId == iCurrentClientSessionId)
    1.46                  {
    1.47 @@ -1496,13 +1502,13 @@
    1.48                      {
    1.49                          //Text field control already in place, just change the text
    1.50                          MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index];
    1.51 -                        layoutChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);
    1.52 +                        contentChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);
    1.53                          label.Text = aField.Text;
    1.54                          label.TextAlign = aField.Alignment;
    1.55                      }
    1.56                      else if (aField.IsBitmap && aField.Index < tableLayoutPanel.Controls.Count && tableLayoutPanel.Controls[aField.Index] is PictureBox)
    1.57                      {
    1.58 -                        layoutChanged = true; //TODO: Bitmap comp or should we leave that to clients?
    1.59 +                        contentChanged = true; //TODO: Bitmap comp or should we leave that to clients?
    1.60                          //Bitmap field control already in place just change the bitmap
    1.61                          PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aField.Index];
    1.62                          pictureBox.Image = aField.Bitmap;
    1.63 @@ -1514,21 +1520,24 @@
    1.64                  }
    1.65              }
    1.66              else
    1.67 -            {
    1.68 +            {                
    1.69                  layoutChanged = true;
    1.70 -                //Different layout, need to rebuild it
    1.71 -                client.Fields[aField.Index] = aField;
    1.72              }
    1.73  
    1.74 -            //
    1.75 -            if (layoutChanged)
    1.76 +            //If either content or layout changed we need to update our tree view to reflect the changes
    1.77 +            if (contentChanged || layoutChanged)
    1.78              {
    1.79                  UpdateClientTreeViewNode(client);
    1.80 -                //Our layout has changed, if we are already the current client we need to update our panel
    1.81 -                if (aSessionId == iCurrentClientSessionId)
    1.82 +                //
    1.83 +                if (layoutChanged)
    1.84                  {
    1.85 -                    //Apply layout and set data fields.
    1.86 -                    UpdateTableLayoutPanel(iCurrentClientData);
    1.87 +                    Debug.Print("Layout changed");
    1.88 +                    //Our layout has changed, if we are already the current client we need to update our panel
    1.89 +                    if (aSessionId == iCurrentClientSessionId)
    1.90 +                    {
    1.91 +                        //Apply layout and set data fields.
    1.92 +                        UpdateTableLayoutPanel(iCurrentClientData);
    1.93 +                    }
    1.94                  }
    1.95              }
    1.96  
    1.97 @@ -1592,6 +1601,8 @@
    1.98          /// <param name="aClient"></param>
    1.99          private void UpdateClientTreeViewNode(ClientData aClient)
   1.100          {
   1.101 +            Debug.Print("UpdateClientTreeViewNode");
   1.102 +
   1.103              if (aClient == null)
   1.104              {
   1.105                  return;
   1.106 @@ -1673,6 +1684,8 @@
   1.107          /// <param name="aLayout"></param>
   1.108          private void UpdateTableLayoutPanel(ClientData aClient)
   1.109          {
   1.110 +            Debug.Print("UpdateClientTreeViewNode");
   1.111 +
   1.112  			if (aClient == null)
   1.113  			{
   1.114  				//Just drop it