# HG changeset patch
# User StephaneLenclud
# Date 1435396962 -7200
# Node ID 878904899ff03f69d67471f235d00a0f19b0bf20
# Parent d1aa17a4d8cfad8a5ecd14cf66d77862b4ebfa14
Fixing field scroll reset issues whenever any field is updated.
Do not update layout when not needed anymore.
diff -r d1aa17a4d8cf -r 878904899ff0 Interface/Interface.cs
--- a/Interface/Interface.cs Sun Jun 21 14:15:11 2015 +0200
+++ b/Interface/Interface.cs Sat Jun 27 11:22:42 2015 +0200
@@ -50,6 +50,50 @@
}
}
+ ///
+ /// Compare two TableLayout object.
+ ///
+ /// Tells whether both layout are identical.
+ public bool IsSameAs(TableLayout aTableLayout)
+ {
+ //Check rows and columns counts
+ if (Columns.Count != aTableLayout.Columns.Count || Rows.Count != aTableLayout.Rows.Count)
+ {
+ return false;
+ }
+
+ //Compare each columns
+ for (int i=0;i Columns { get; set; }
diff -r d1aa17a4d8cf -r 878904899ff0 Server/MainForm.cs
--- a/Server/MainForm.cs Sun Jun 21 14:15:11 2015 +0200
+++ b/Server/MainForm.cs Sat Jun 27 11:22:42 2015 +0200
@@ -1436,10 +1436,14 @@
ClientData client = iClients[aSessionId];
if (client != null)
{
- //Set our client layout then
- client.Layout = aLayout;
- //
- UpdateClientTreeViewNode(client);
+ //Don't change a thing if the layout is the same
+ if (!client.Layout.IsSameAs(aLayout))
+ {
+ //Set our client layout then
+ client.Layout = aLayout;
+ //
+ UpdateClientTreeViewNode(client);
+ }
}
}
}
@@ -1476,19 +1480,21 @@
ClientData client = iClients[aSessionId];
bool layoutChanged = false;
+ bool contentChanged = true;
//Make sure all our fields are in place
while (client.Fields.Count < (aField.Index + 1))
{
- //Add a text field with proper index
+ //Add a data field with proper index
client.Fields.Add(new DataField(client.Fields.Count));
layoutChanged = true;
}
+ //Now that we know hour fields are in place just update that one
+ client.Fields[aField.Index] = aField;
+
if (client.Fields[aField.Index].IsSameLayout(aField))
{
- //Same layout just update our field
- client.Fields[aField.Index] = aField;
//If we are updating a field in our current client we need to update it in our panel
if (aSessionId == iCurrentClientSessionId)
{
@@ -1496,13 +1502,13 @@
{
//Text field control already in place, just change the text
MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aField.Index];
- layoutChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);
+ contentChanged = (label.Text != aField.Text || label.TextAlign != aField.Alignment);
label.Text = aField.Text;
label.TextAlign = aField.Alignment;
}
else if (aField.IsBitmap && aField.Index < tableLayoutPanel.Controls.Count && tableLayoutPanel.Controls[aField.Index] is PictureBox)
{
- layoutChanged = true; //TODO: Bitmap comp or should we leave that to clients?
+ contentChanged = true; //TODO: Bitmap comp or should we leave that to clients?
//Bitmap field control already in place just change the bitmap
PictureBox pictureBox = (PictureBox)tableLayoutPanel.Controls[aField.Index];
pictureBox.Image = aField.Bitmap;
@@ -1514,21 +1520,24 @@
}
}
else
- {
+ {
layoutChanged = true;
- //Different layout, need to rebuild it
- client.Fields[aField.Index] = aField;
}
- //
- if (layoutChanged)
+ //If either content or layout changed we need to update our tree view to reflect the changes
+ if (contentChanged || layoutChanged)
{
UpdateClientTreeViewNode(client);
- //Our layout has changed, if we are already the current client we need to update our panel
- if (aSessionId == iCurrentClientSessionId)
+ //
+ if (layoutChanged)
{
- //Apply layout and set data fields.
- UpdateTableLayoutPanel(iCurrentClientData);
+ Debug.Print("Layout changed");
+ //Our layout has changed, if we are already the current client we need to update our panel
+ if (aSessionId == iCurrentClientSessionId)
+ {
+ //Apply layout and set data fields.
+ UpdateTableLayoutPanel(iCurrentClientData);
+ }
}
}
@@ -1592,6 +1601,8 @@
///
private void UpdateClientTreeViewNode(ClientData aClient)
{
+ Debug.Print("UpdateClientTreeViewNode");
+
if (aClient == null)
{
return;
@@ -1673,6 +1684,8 @@
///
private void UpdateTableLayoutPanel(ClientData aClient)
{
+ Debug.Print("UpdateClientTreeViewNode");
+
if (aClient == null)
{
//Just drop it
diff -r d1aa17a4d8cf -r 878904899ff0 Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Sun Jun 21 14:15:11 2015 +0200
+++ b/Server/SharpDisplayManager.csproj Sat Jun 27 11:22:42 2015 +0200
@@ -32,7 +32,7 @@
true
index.htm
false
- 1
+ 2
0.5.0.%2a
false
true