1.1 --- a/Server/MainForm.cs Mon Sep 22 13:21:00 2014 +0200
1.2 +++ b/Server/MainForm.cs Mon Sep 22 16:04:26 2014 +0200
1.3 @@ -22,6 +22,14 @@
1.4 //Types declarations
1.5 public delegate uint ColorProcessingDelegate(int aX, int aY, uint aPixel);
1.6 public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
1.7 + //Delegates are used for our thread safe method
1.8 + public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
1.9 + public delegate void RemoveClientDelegate(string aSessionId);
1.10 + public delegate void SetTextDelegate(string SessionId, TextField aTextField);
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 SetClientNameDelegate(string aSessionId, string aName);
1.14 +
1.15
1.16 /// <summary>
1.17 /// Our Display manager main form
1.18 @@ -691,13 +699,6 @@
1.19
1.20 }
1.21
1.22 - //Delegates are used for our thread safe method
1.23 - public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
1.24 - public delegate void RemoveClientDelegate(string aSessionId);
1.25 - public delegate void SetTextDelegate(string SessionId, TextField aTextField);
1.26 - public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
1.27 - public delegate void SetClientNameDelegate(string aSessionId, string aName);
1.28 -
1.29
1.30 /// <summary>
1.31 ///
1.32 @@ -759,6 +760,32 @@
1.33 /// <summary>
1.34 ///
1.35 /// </summary>
1.36 + /// <param name="aSessionId"></param>
1.37 + /// <param name="aTextField"></param>
1.38 + public void SetClientLayoutThreadSafe(string aSessionId, TableLayout aLayout)
1.39 + {
1.40 + if (this.InvokeRequired)
1.41 + {
1.42 + //Not in the proper thread, invoke ourselves
1.43 + SetLayoutDelegate d = new SetLayoutDelegate(SetClientLayoutThreadSafe);
1.44 + this.Invoke(d, new object[] { aSessionId, aLayout });
1.45 + }
1.46 + else
1.47 + {
1.48 + ClientData client = iClients[aSessionId];
1.49 + if (client != null)
1.50 + {
1.51 + client.Layout = aLayout;
1.52 + UpdateTableLayoutPanel(client.Layout.ColumnCount, client.Layout.RowCount);
1.53 + //
1.54 + UpdateClientTreeViewNode(client);
1.55 + }
1.56 + }
1.57 + }
1.58 +
1.59 + /// <summary>
1.60 + ///
1.61 + /// </summary>
1.62 /// <param name="aLineIndex"></param>
1.63 /// <param name="aText"></param>
1.64 public void SetTextThreadSafe(string aSessionId, TextField aTextField)
1.65 @@ -932,8 +959,7 @@
1.66 {
1.67 if (tableLayoutPanel.RowCount < 6)
1.68 {
1.69 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount + 1);
1.70 - CheckFontHeight();
1.71 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount + 1);
1.72 }
1.73 }
1.74
1.75 @@ -941,13 +967,29 @@
1.76 {
1.77 if (tableLayoutPanel.RowCount > 1)
1.78 {
1.79 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount - 1);
1.80 - CheckFontHeight();
1.81 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount - 1);
1.82 }
1.83
1.84 UpdateTableLayoutRowStyles();
1.85 }
1.86
1.87 + private void buttonAddColumn_Click(object sender, EventArgs e)
1.88 + {
1.89 + if (tableLayoutPanel.ColumnCount < 8)
1.90 + {
1.91 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount + 1, tableLayoutPanel.RowCount);
1.92 + }
1.93 + }
1.94 +
1.95 + private void buttonRemoveColumn_Click(object sender, EventArgs e)
1.96 + {
1.97 + if (tableLayoutPanel.ColumnCount > 1)
1.98 + {
1.99 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount - 1, tableLayoutPanel.RowCount);
1.100 + }
1.101 + }
1.102 +
1.103 +
1.104 /// <summary>
1.105 /// Update our table layout row styles to make sure each rows have similar height
1.106 /// </summary>
1.107 @@ -966,7 +1008,7 @@
1.108 /// </summary>
1.109 /// <param name="aColumn"></param>
1.110 /// <param name="aRow"></param>
1.111 - private void RecreateTableLayoutPanel(int aColumn, int aRow)
1.112 + private void UpdateTableLayoutPanel(int aColumn, int aRow)
1.113 {
1.114 tableLayoutPanel.Controls.Clear();
1.115 tableLayoutPanel.RowStyles.Clear();
1.116 @@ -1018,24 +1060,8 @@
1.117 tableLayoutPanel.Controls.Add(control, i, j);
1.118 }
1.119 }
1.120 - }
1.121
1.122 - private void buttonAddColumn_Click(object sender, EventArgs e)
1.123 - {
1.124 - if (tableLayoutPanel.ColumnCount < 8)
1.125 - {
1.126 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount + 1, tableLayoutPanel.RowCount);
1.127 - //CheckFontHeight();
1.128 - }
1.129 - }
1.130 -
1.131 - private void buttonRemoveColumn_Click(object sender, EventArgs e)
1.132 - {
1.133 - if (tableLayoutPanel.ColumnCount > 1)
1.134 - {
1.135 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount - 1, tableLayoutPanel.RowCount);
1.136 - //CheckFontHeight();
1.137 - }
1.138 + CheckFontHeight();
1.139 }
1.140
1.141 private void buttonAlignLeft_Click(object sender, EventArgs e)
1.142 @@ -1125,12 +1151,14 @@
1.143 SessionId = aSessionId;
1.144 Name = "";
1.145 Texts = new List<TextField>();
1.146 + Layout = new TableLayout(1, 2); //Default to one column and two rows
1.147 Callback = aCallback;
1.148 }
1.149
1.150 public string SessionId { get; set; }
1.151 public string Name { get; set; }
1.152 public List<TextField> Texts { get; set; }
1.153 + public TableLayout Layout { get; set; }
1.154 public ICallback Callback { get; set; }
1.155 }
1.156 }