Adding the possibility for clients to define a basic layout.
1.1 --- a/Client/Client.cs Mon Sep 22 13:21:00 2014 +0200
1.2 +++ b/Client/Client.cs Mon Sep 22 16:04:26 2014 +0200
1.3 @@ -70,6 +70,12 @@
1.4 Channel.SetName(aClientName);
1.5 }
1.6
1.7 +
1.8 + public void SetLayout(TableLayout aLayout)
1.9 + {
1.10 + Channel.SetLayout(aLayout);
1.11 + }
1.12 +
1.13 public void SetText(TextField aTextField)
1.14 {
1.15 Channel.SetText(aTextField);
2.1 --- a/Client/MainForm.Designer.cs Mon Sep 22 13:21:00 2014 +0200
2.2 +++ b/Client/MainForm.Designer.cs Mon Sep 22 16:04:26 2014 +0200
2.3 @@ -35,6 +35,7 @@
2.4 this.buttonAlignCenter = new System.Windows.Forms.Button();
2.5 this.buttonAlignLeft = new System.Windows.Forms.Button();
2.6 this.buttonSetTopText = new System.Windows.Forms.Button();
2.7 + this.buttonLayoutUpdate = new System.Windows.Forms.Button();
2.8 this.SuspendLayout();
2.9 //
2.10 // buttonSetText
2.11 @@ -101,11 +102,22 @@
2.12 this.buttonSetTopText.UseVisualStyleBackColor = true;
2.13 this.buttonSetTopText.Click += new System.EventHandler(this.buttonSetTopText_Click);
2.14 //
2.15 + // buttonLayoutUpdate
2.16 + //
2.17 + this.buttonLayoutUpdate.Location = new System.Drawing.Point(176, 131);
2.18 + this.buttonLayoutUpdate.Name = "buttonLayoutUpdate";
2.19 + this.buttonLayoutUpdate.Size = new System.Drawing.Size(75, 23);
2.20 + this.buttonLayoutUpdate.TabIndex = 25;
2.21 + this.buttonLayoutUpdate.Text = "Layout 2x2";
2.22 + this.buttonLayoutUpdate.UseVisualStyleBackColor = true;
2.23 + this.buttonLayoutUpdate.Click += new System.EventHandler(this.buttonLayoutUpdate_Click);
2.24 + //
2.25 // MainForm
2.26 //
2.27 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
2.28 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
2.29 this.ClientSize = new System.Drawing.Size(443, 252);
2.30 + this.Controls.Add(this.buttonLayoutUpdate);
2.31 this.Controls.Add(this.buttonSetTopText);
2.32 this.Controls.Add(this.buttonAlignRight);
2.33 this.Controls.Add(this.buttonAlignCenter);
2.34 @@ -131,6 +143,7 @@
2.35 private System.Windows.Forms.Button buttonAlignCenter;
2.36 private System.Windows.Forms.Button buttonAlignLeft;
2.37 private System.Windows.Forms.Button buttonSetTopText;
2.38 + private System.Windows.Forms.Button buttonLayoutUpdate;
2.39 }
2.40 }
2.41
3.1 --- a/Client/MainForm.cs Mon Sep 22 13:21:00 2014 +0200
3.2 +++ b/Client/MainForm.cs Mon Sep 22 16:04:26 2014 +0200
3.3 @@ -149,5 +149,11 @@
3.4 new TextField(1, textBoxBottom.Text, Alignment)
3.5 });
3.6 }
3.7 +
3.8 + private void buttonLayoutUpdate_Click(object sender, EventArgs e)
3.9 + {
3.10 + TableLayout layout = new TableLayout(2,2);
3.11 + iClient.SetLayout(layout);
3.12 + }
3.13 }
3.14 }
4.1 --- a/Interface/Interface.cs Mon Sep 22 13:21:00 2014 +0200
4.2 +++ b/Interface/Interface.cs Mon Sep 22 16:04:26 2014 +0200
4.3 @@ -19,7 +19,57 @@
4.4 /// TextField can be send to our server to be displayed on the screen.
4.5 /// </summary>
4.6 [DataContract]
4.7 - public class TextField
4.8 + public class TableLayout
4.9 + {
4.10 + public TableLayout()
4.11 + {
4.12 + ColumnCount = 0;
4.13 + RowCount = 0;
4.14 + //Alignment = ContentAlignment.MiddleLeft;
4.15 + }
4.16 +
4.17 + public TableLayout(int aColumnCount, int aRowCount)
4.18 + {
4.19 + ColumnCount = aColumnCount;
4.20 + RowCount = aRowCount;
4.21 + }
4.22 +
4.23 + [DataMember]
4.24 + public int ColumnCount { get; set; }
4.25 +
4.26 + [DataMember]
4.27 + public int RowCount { get; set; }
4.28 +
4.29 + [DataMember]
4.30 + public List<DataField> Cells { get; set; }
4.31 + }
4.32 +
4.33 + /// <summary>
4.34 + ///
4.35 + /// </summary>
4.36 + [DataContract]
4.37 + public class DataField
4.38 + {
4.39 + [DataMember]
4.40 + public int Column { get; set; }
4.41 +
4.42 + [DataMember]
4.43 + public int Row { get; set; }
4.44 +
4.45 + [DataMember]
4.46 + public int ColumnSpan { get; set; }
4.47 +
4.48 + [DataMember]
4.49 + public int RowSpan { get; set; }
4.50 +
4.51 + }
4.52 +
4.53 +
4.54 + /// <summary>
4.55 + /// TextField can be send to our server to be displayed on the screen.
4.56 + /// </summary>
4.57 + [DataContract]
4.58 + public class TextField : DataField
4.59 {
4.60 public TextField()
4.61 {
4.62 @@ -64,6 +114,13 @@
4.63 [OperationContract(IsOneWay = true)]
4.64 void SetName(string aClientName);
4.65
4.66 +
4.67 + /// <summary>
4.68 + /// </summary>
4.69 + /// <param name="aLayout"></param>
4.70 + [OperationContract(IsOneWay = true)]
4.71 + void SetLayout(TableLayout aLayout);
4.72 +
4.73 /// <summary>
4.74 /// Put the given text in the given field on your display.
4.75 /// Fields are often just lines of text.
5.1 --- a/Server/MainForm.cs Mon Sep 22 13:21:00 2014 +0200
5.2 +++ b/Server/MainForm.cs Mon Sep 22 16:04:26 2014 +0200
5.3 @@ -22,6 +22,14 @@
5.4 //Types declarations
5.5 public delegate uint ColorProcessingDelegate(int aX, int aY, uint aPixel);
5.6 public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
5.7 + //Delegates are used for our thread safe method
5.8 + public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
5.9 + public delegate void RemoveClientDelegate(string aSessionId);
5.10 + public delegate void SetTextDelegate(string SessionId, TextField aTextField);
5.11 + public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
5.12 + public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
5.13 + public delegate void SetClientNameDelegate(string aSessionId, string aName);
5.14 +
5.15
5.16 /// <summary>
5.17 /// Our Display manager main form
5.18 @@ -691,13 +699,6 @@
5.19
5.20 }
5.21
5.22 - //Delegates are used for our thread safe method
5.23 - public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
5.24 - public delegate void RemoveClientDelegate(string aSessionId);
5.25 - public delegate void SetTextDelegate(string SessionId, TextField aTextField);
5.26 - public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
5.27 - public delegate void SetClientNameDelegate(string aSessionId, string aName);
5.28 -
5.29
5.30 /// <summary>
5.31 ///
5.32 @@ -759,6 +760,32 @@
5.33 /// <summary>
5.34 ///
5.35 /// </summary>
5.36 + /// <param name="aSessionId"></param>
5.37 + /// <param name="aTextField"></param>
5.38 + public void SetClientLayoutThreadSafe(string aSessionId, TableLayout aLayout)
5.39 + {
5.40 + if (this.InvokeRequired)
5.41 + {
5.42 + //Not in the proper thread, invoke ourselves
5.43 + SetLayoutDelegate d = new SetLayoutDelegate(SetClientLayoutThreadSafe);
5.44 + this.Invoke(d, new object[] { aSessionId, aLayout });
5.45 + }
5.46 + else
5.47 + {
5.48 + ClientData client = iClients[aSessionId];
5.49 + if (client != null)
5.50 + {
5.51 + client.Layout = aLayout;
5.52 + UpdateTableLayoutPanel(client.Layout.ColumnCount, client.Layout.RowCount);
5.53 + //
5.54 + UpdateClientTreeViewNode(client);
5.55 + }
5.56 + }
5.57 + }
5.58 +
5.59 + /// <summary>
5.60 + ///
5.61 + /// </summary>
5.62 /// <param name="aLineIndex"></param>
5.63 /// <param name="aText"></param>
5.64 public void SetTextThreadSafe(string aSessionId, TextField aTextField)
5.65 @@ -932,8 +959,7 @@
5.66 {
5.67 if (tableLayoutPanel.RowCount < 6)
5.68 {
5.69 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount + 1);
5.70 - CheckFontHeight();
5.71 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount + 1);
5.72 }
5.73 }
5.74
5.75 @@ -941,13 +967,29 @@
5.76 {
5.77 if (tableLayoutPanel.RowCount > 1)
5.78 {
5.79 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount - 1);
5.80 - CheckFontHeight();
5.81 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount, tableLayoutPanel.RowCount - 1);
5.82 }
5.83
5.84 UpdateTableLayoutRowStyles();
5.85 }
5.86
5.87 + private void buttonAddColumn_Click(object sender, EventArgs e)
5.88 + {
5.89 + if (tableLayoutPanel.ColumnCount < 8)
5.90 + {
5.91 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount + 1, tableLayoutPanel.RowCount);
5.92 + }
5.93 + }
5.94 +
5.95 + private void buttonRemoveColumn_Click(object sender, EventArgs e)
5.96 + {
5.97 + if (tableLayoutPanel.ColumnCount > 1)
5.98 + {
5.99 + UpdateTableLayoutPanel(tableLayoutPanel.ColumnCount - 1, tableLayoutPanel.RowCount);
5.100 + }
5.101 + }
5.102 +
5.103 +
5.104 /// <summary>
5.105 /// Update our table layout row styles to make sure each rows have similar height
5.106 /// </summary>
5.107 @@ -966,7 +1008,7 @@
5.108 /// </summary>
5.109 /// <param name="aColumn"></param>
5.110 /// <param name="aRow"></param>
5.111 - private void RecreateTableLayoutPanel(int aColumn, int aRow)
5.112 + private void UpdateTableLayoutPanel(int aColumn, int aRow)
5.113 {
5.114 tableLayoutPanel.Controls.Clear();
5.115 tableLayoutPanel.RowStyles.Clear();
5.116 @@ -1018,24 +1060,8 @@
5.117 tableLayoutPanel.Controls.Add(control, i, j);
5.118 }
5.119 }
5.120 - }
5.121
5.122 - private void buttonAddColumn_Click(object sender, EventArgs e)
5.123 - {
5.124 - if (tableLayoutPanel.ColumnCount < 8)
5.125 - {
5.126 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount + 1, tableLayoutPanel.RowCount);
5.127 - //CheckFontHeight();
5.128 - }
5.129 - }
5.130 -
5.131 - private void buttonRemoveColumn_Click(object sender, EventArgs e)
5.132 - {
5.133 - if (tableLayoutPanel.ColumnCount > 1)
5.134 - {
5.135 - RecreateTableLayoutPanel(tableLayoutPanel.ColumnCount - 1, tableLayoutPanel.RowCount);
5.136 - //CheckFontHeight();
5.137 - }
5.138 + CheckFontHeight();
5.139 }
5.140
5.141 private void buttonAlignLeft_Click(object sender, EventArgs e)
5.142 @@ -1125,12 +1151,14 @@
5.143 SessionId = aSessionId;
5.144 Name = "";
5.145 Texts = new List<TextField>();
5.146 + Layout = new TableLayout(1, 2); //Default to one column and two rows
5.147 Callback = aCallback;
5.148 }
5.149
5.150 public string SessionId { get; set; }
5.151 public string Name { get; set; }
5.152 public List<TextField> Texts { get; set; }
5.153 + public TableLayout Layout { get; set; }
5.154 public ICallback Callback { get; set; }
5.155 }
5.156 }
6.1 --- a/Server/Session.cs Mon Sep 22 13:21:00 2014 +0200
6.2 +++ b/Server/Session.cs Mon Sep 22 16:04:26 2014 +0200
6.3 @@ -13,9 +13,9 @@
6.4 /// Implement our display services.
6.5 /// Each client connection has such a session object server side.
6.6 /// </summary>
6.7 - [ServiceBehavior(
6.8 + [ServiceBehavior(
6.9 ConcurrencyMode = ConcurrencyMode.Multiple,
6.10 - InstanceContextMode = InstanceContextMode.PerSession
6.11 + InstanceContextMode = InstanceContextMode.PerSession
6.12 )]
6.13 class Session : IService, IDisposable
6.14 {
6.15 @@ -38,18 +38,6 @@
6.16 Trace.TraceInformation("Server session closing.");
6.17 SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId);
6.18 }
6.19 -
6.20 - //From IDisplayService
6.21 - public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
6.22 - {
6.23 - SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields);
6.24 - }
6.25 -
6.26 - //
6.27 - public void SetText(TextField aTextField)
6.28 - {
6.29 - SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField);
6.30 - }
6.31
6.32 //
6.33 public void SetName(string aClientName)
6.34 @@ -66,13 +54,31 @@
6.35 //callback.OnConnected();
6.36 }
6.37
6.38 + public void SetLayout(TableLayout aLayout)
6.39 + {
6.40 + SharpDisplayManager.Program.iMainForm.SetClientLayoutThreadSafe(SessionId, aLayout);
6.41 + }
6.42 +
6.43 + //From IDisplayService
6.44 + public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
6.45 + {
6.46 + SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields);
6.47 + }
6.48 +
6.49 + //
6.50 + public void SetText(TextField aTextField)
6.51 + {
6.52 + SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField);
6.53 + }
6.54 +
6.55 +
6.56 ///
6.57 public int ClientCount()
6.58 {
6.59 return SharpDisplayManager.Program.iMainForm.iClients.Count;
6.60 }
6.61
6.62 -
6.63 +
6.64
6.65 }
6.66