1.1 --- a/Server/MainForm.cs Mon Oct 13 21:42:42 2014 +0200
1.2 +++ b/Server/MainForm.cs Tue Oct 14 19:32:09 2014 +0200
1.3 @@ -160,7 +160,7 @@
1.4 labelFontWidth.Text = "Font width: " + charWidth;
1.5 }
1.6
1.7 - MarqueeLabel label = null;
1.8 + MarqueeLabel label = null;
1.9 //Get the first label control we can find
1.10 foreach (Control ctrl in tableLayoutPanel.Controls)
1.11 {
1.12 @@ -863,18 +863,15 @@
1.13 if (client != null)
1.14 {
1.15 //Populate our client with the given text fields
1.16 - int j = 0;
1.17 foreach (TextField textField in aTextFields)
1.18 {
1.19 - if (client.Fields.Count < (j + 1))
1.20 + //Make sure all our texts are in place
1.21 + while (client.Fields.Count < (textField.Index + 1))
1.22 {
1.23 - client.Fields.Add(textField);
1.24 + //Add a text field with proper index
1.25 + client.Fields.Add(new TextField(client.Fields.Count));
1.26 }
1.27 - else
1.28 - {
1.29 - client.Fields[j] = textField;
1.30 - }
1.31 - j++;
1.32 + client.Fields[textField.Index] = textField;
1.33 }
1.34 //Put each our text fields in a label control
1.35 foreach (TextField field in aTextFields)
1.36 @@ -1024,7 +1021,7 @@
1.37 if (aClient.Fields.Count > 0)
1.38 {
1.39 //Create root node for our texts
1.40 - TreeNode textsRoot = new TreeNode("Text");
1.41 + TreeNode textsRoot = new TreeNode("Fields");
1.42 node.Nodes.Add(textsRoot);
1.43 //For each text add a new entry
1.44 foreach (DataField field in aClient.Fields)
1.45 @@ -1032,16 +1029,16 @@
1.46 if (field is TextField)
1.47 {
1.48 TextField textField = (TextField)field;
1.49 - textsRoot.Nodes.Add(new TreeNode(textField.Text));
1.50 + textsRoot.Nodes.Add(new TreeNode("[Text]" + textField.Text));
1.51 }
1.52 else if (field is BitmapField)
1.53 {
1.54 - textsRoot.Nodes.Add(new TreeNode("[Bitmap Field]"));
1.55 + textsRoot.Nodes.Add(new TreeNode("[Bitmap]"));
1.56 }
1.57 else
1.58 {
1.59 - textsRoot.Nodes.Add(new TreeNode("[Unknown Field Type]"));
1.60 - }
1.61 + textsRoot.Nodes.Add(new TreeNode("[Unknown]"));
1.62 + }
1.63 }
1.64 }
1.65
1.66 @@ -1096,6 +1093,7 @@
1.67 }
1.68 }
1.69
1.70 + /// DEPRECATED
1.71 /// <summary>
1.72 /// Empty and recreate our table layout with the given number of columns and rows.
1.73 /// Sizes of rows and columns are uniform.
1.74 @@ -1166,7 +1164,8 @@
1.75 private void UpdateTableLayoutPanel(ClientData aClient)
1.76 {
1.77 TableLayout layout = aClient.Layout;
1.78 -
1.79 + int fieldCount = 0;
1.80 +
1.81 tableLayoutPanel.Controls.Clear();
1.82 tableLayoutPanel.RowStyles.Clear();
1.83 tableLayoutPanel.ColumnStyles.Clear();
1.84 @@ -1196,6 +1195,17 @@
1.85 this.tableLayoutPanel.RowStyles.Add(layout.Rows[j]);
1.86 }
1.87
1.88 + //Check if we already have a control
1.89 + Control existingControl = tableLayoutPanel.GetControlFromPosition(i,j);
1.90 + if (existingControl!=null)
1.91 + {
1.92 + //We already have a control in that cell as a results of row/col spanning
1.93 + //Move on to next cell then
1.94 + continue;
1.95 + }
1.96 +
1.97 + fieldCount++;
1.98 +
1.99 //Check if a client field already exists for that cell
1.100 if (aClient.Fields.Count <= tableLayoutPanel.Controls.Count)
1.101 {
1.102 @@ -1204,17 +1214,30 @@
1.103 }
1.104
1.105 //Create a control corresponding to the field specified for that cell
1.106 - Control control = CreateControlForDataField(aClient.Fields[tableLayoutPanel.Controls.Count]);
1.107 + DataField field = aClient.Fields[tableLayoutPanel.Controls.Count];
1.108 + Control control = CreateControlForDataField(field);
1.109 +
1.110 //Add newly created control to our table layout at the specified row and column
1.111 tableLayoutPanel.Controls.Add(control, i, j);
1.112 + //Make sure we specify row and column span for that new control
1.113 + tableLayoutPanel.SetRowSpan(control,field.RowSpan);
1.114 + tableLayoutPanel.SetColumnSpan(control, field.ColumnSpan);
1.115 }
1.116 }
1.117
1.118 + //
1.119 + while (aClient.Fields.Count > fieldCount)
1.120 + {
1.121 + //We have too much fields for this layout
1.122 + //Just discard them until we get there
1.123 + aClient.Fields.RemoveAt(aClient.Fields.Count-1);
1.124 + }
1.125 +
1.126 CheckFontHeight();
1.127 }
1.128
1.129 /// <summary>
1.130 - /// Not used yet.
1.131 + /// Check our type of data field and create corresponding control
1.132 /// </summary>
1.133 /// <param name="aField"></param>
1.134 private Control CreateControlForDataField(DataField aField)