Adding current client concept.
1.1 --- a/Client/MainForm.cs Mon Sep 22 22:04:39 2014 +0200
1.2 +++ b/Client/MainForm.cs Fri Oct 03 18:43:55 2014 +0200
1.3 @@ -152,8 +152,11 @@
1.4
1.5 private void buttonLayoutUpdate_Click(object sender, EventArgs e)
1.6 {
1.7 + //Define a 2 by 2 layout
1.8 TableLayout layout = new TableLayout(2,2);
1.9 + //Second column only takes up 25%
1.10 layout.Columns[1].Width = 25F;
1.11 + //Send layout to server
1.12 iClient.SetLayout(layout);
1.13 }
1.14 }
2.1 --- a/Interface/Interface.cs Mon Sep 22 22:04:39 2014 +0200
2.2 +++ b/Interface/Interface.cs Fri Oct 03 18:43:55 2014 +0200
2.3 @@ -56,7 +56,6 @@
2.4
2.5 [DataMember]
2.6 public List<RowStyle> Rows { get; set; }
2.7 -
2.8 }
2.9
2.10 /// <summary>
2.11 @@ -129,7 +128,6 @@
2.12 [OperationContract(IsOneWay = true)]
2.13 void SetName(string aClientName);
2.14
2.15 -
2.16 /// <summary>
2.17 /// </summary>
2.18 /// <param name="aLayout"></param>
3.1 --- a/Server/App.config Mon Sep 22 22:04:39 2014 +0200
3.2 +++ b/Server/App.config Fri Oct 03 18:43:55 2014 +0200
3.3 @@ -16,6 +16,9 @@
3.4 <setting name="CurrentDisplayIndex" serializeAs="String">
3.5 <value>0</value>
3.6 </setting>
3.7 + <setting name="CycleClients" serializeAs="String">
3.8 + <value>False</value>
3.9 + </setting>
3.10 </SharpDisplayManager.Properties.Settings>
3.11 </userSettings>
3.12 </configuration>
4.1 --- a/Server/MainForm.cs Mon Sep 22 22:04:39 2014 +0200
4.2 +++ b/Server/MainForm.cs Fri Oct 03 18:43:55 2014 +0200
4.3 @@ -42,17 +42,24 @@
4.4 System.Drawing.Bitmap iBmp;
4.5 bool iCreateBitmap; //Workaround render to bitmap issues when minimized
4.6 ServiceHost iServiceHost;
4.7 - /// <summary>
4.8 - /// Our collection of clients
4.9 - /// </summary>
4.10 + // Our collection of clients sorted by session id.
4.11 public Dictionary<string, ClientData> iClients;
4.12 + // The name of the client which informations are currently displayed.
4.13 + public string iCurrentClientSessionId;
4.14 + ClientData iCurrentClientData;
4.15 + //
4.16 public bool iClosing;
4.17 + //Function pointer for pixel color filtering
4.18 ColorProcessingDelegate iColorFx;
4.19 + //Function pointer for pixel X coordinate intercept
4.20 CoordinateTranslationDelegate iScreenX;
4.21 + //Function pointer for pixel Y coordinate intercept
4.22 CoordinateTranslationDelegate iScreenY;
4.23
4.24 public MainForm()
4.25 {
4.26 + iCurrentClientSessionId = "";
4.27 + iCurrentClientData = null;
4.28 LastTickTime = DateTime.Now;
4.29 iDisplay = new Display();
4.30 iClients = new Dictionary<string, ClientData>();
4.31 @@ -62,8 +69,6 @@
4.32 //We have a bug when drawing minimized and reusing our bitmap
4.33 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
4.34 iCreateBitmap = false;
4.35 - //
4.36 - //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint);
4.37 }
4.38
4.39 private void MainForm_Load(object sender, EventArgs e)
4.40 @@ -76,32 +81,28 @@
4.41 }
4.42 }
4.43
4.44 - //Testing that stuff
4.45 - private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
4.46 + /// <summary>
4.47 + /// Set our current client.
4.48 + /// This will take care of applying our client layout and set data fields.
4.49 + /// </summary>
4.50 + /// <param name="aSessionId"></param>
4.51 + void SetCurrentClient(string aSessionId)
4.52 {
4.53 - var panel = sender as TableLayoutPanel;
4.54 - //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
4.55 - var rectangle = e.CellBounds;
4.56 - using (var pen = new Pen(Color.Black, 1))
4.57 + if (aSessionId == iCurrentClientSessionId)
4.58 {
4.59 - pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
4.60 - pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
4.61 + //Given client is already the current one.
4.62 + //Don't bother changing anything then.
4.63 + return;
4.64 + }
4.65
4.66 - if (e.Row == (panel.RowCount - 1))
4.67 - {
4.68 - rectangle.Height -= 1;
4.69 - }
4.70 -
4.71 - if (e.Column == (panel.ColumnCount - 1))
4.72 - {
4.73 - rectangle.Width -= 1;
4.74 - }
4.75 -
4.76 - e.Graphics.DrawRectangle(pen, rectangle);
4.77 - }
4.78 + //Set current client ID.
4.79 + iCurrentClientSessionId = aSessionId;
4.80 + //Fetch and set current client data.
4.81 + iCurrentClientData = iClients[aSessionId];
4.82 + //Apply layout and set data fields.
4.83 + UpdateTableLayoutPanel(iCurrentClientData);
4.84 }
4.85
4.86 -
4.87 private void buttonFont_Click(object sender, EventArgs e)
4.88 {
4.89 //fontDialog.ShowColor = true;
4.90 @@ -430,12 +431,12 @@
4.91 {
4.92 get
4.93 {
4.94 - DisplaysSettings settings = Properties.Settings.Default.DisplaySettings;
4.95 + DisplaysSettings settings = Properties.Settings.Default.DisplaysSettings;
4.96 if (settings == null)
4.97 {
4.98 settings = new DisplaysSettings();
4.99 settings.Init();
4.100 - Properties.Settings.Default.DisplaySettings = settings;
4.101 + Properties.Settings.Default.DisplaysSettings = settings;
4.102 }
4.103
4.104 //Make sure all our settings have been created
4.105 @@ -776,7 +777,7 @@
4.106 if (client != null)
4.107 {
4.108 client.Layout = aLayout;
4.109 - UpdateTableLayoutPanel(client.Layout);
4.110 + UpdateTableLayoutPanel(client);
4.111 //
4.112 UpdateClientTreeViewNode(client);
4.113 }
4.114 @@ -788,16 +789,17 @@
4.115 /// </summary>
4.116 /// <param name="aLineIndex"></param>
4.117 /// <param name="aText"></param>
4.118 - public void SetTextThreadSafe(string aSessionId, TextField aTextField)
4.119 + public void SetClientTextThreadSafe(string aSessionId, TextField aTextField)
4.120 {
4.121 if (this.InvokeRequired)
4.122 {
4.123 //Not in the proper thread, invoke ourselves
4.124 - SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe);
4.125 + SetTextDelegate d = new SetTextDelegate(SetClientTextThreadSafe);
4.126 this.Invoke(d, new object[] { aSessionId, aTextField });
4.127 }
4.128 else
4.129 {
4.130 + SetCurrentClient(aSessionId);
4.131 ClientData client = iClients[aSessionId];
4.132 if (client != null)
4.133 {
4.134 @@ -823,16 +825,17 @@
4.135 ///
4.136 /// </summary>
4.137 /// <param name="aTexts"></param>
4.138 - public void SetTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<TextField> aTextFields)
4.139 + public void SetClientTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<TextField> aTextFields)
4.140 {
4.141 if (this.InvokeRequired)
4.142 {
4.143 //Not in the proper thread, invoke ourselves
4.144 - SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe);
4.145 + SetTextsDelegate d = new SetTextsDelegate(SetClientTextsThreadSafe);
4.146 this.Invoke(d, new object[] { aSessionId, aTextFields });
4.147 }
4.148 else
4.149 {
4.150 + SetCurrentClient(aSessionId);
4.151 //We are in the proper thread
4.152 ClientData client = iClients[aSessionId];
4.153 if (client != null)
4.154 @@ -851,7 +854,7 @@
4.155 }
4.156 j++;
4.157 }
4.158 - //Only support two lines for now
4.159 + //Put each our text fields in a label control
4.160 for (int i = 0; i < aTextFields.Count; i++)
4.161 {
4.162 MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextFields[i].Index];
4.163 @@ -1069,20 +1072,22 @@
4.164 /// Update our display table layout.
4.165 /// </summary>
4.166 /// <param name="aLayout"></param>
4.167 - private void UpdateTableLayoutPanel(TableLayout aLayout)
4.168 + private void UpdateTableLayoutPanel(ClientData aClient)
4.169 {
4.170 + TableLayout layout = aClient.Layout;
4.171 +
4.172 tableLayoutPanel.Controls.Clear();
4.173 tableLayoutPanel.RowStyles.Clear();
4.174 tableLayoutPanel.ColumnStyles.Clear();
4.175 tableLayoutPanel.RowCount = 0;
4.176 tableLayoutPanel.ColumnCount = 0;
4.177
4.178 - while (tableLayoutPanel.RowCount < aLayout.Rows.Count)
4.179 + while (tableLayoutPanel.RowCount < layout.Rows.Count)
4.180 {
4.181 tableLayoutPanel.RowCount++;
4.182 }
4.183
4.184 - while (tableLayoutPanel.ColumnCount < aLayout.Columns.Count)
4.185 + while (tableLayoutPanel.ColumnCount < layout.Columns.Count)
4.186 {
4.187 tableLayoutPanel.ColumnCount++;
4.188 }
4.189 @@ -1090,14 +1095,14 @@
4.190 for (int i = 0; i < tableLayoutPanel.ColumnCount; i++)
4.191 {
4.192 //Create our column styles
4.193 - this.tableLayoutPanel.ColumnStyles.Add(aLayout.Columns[i]);
4.194 + this.tableLayoutPanel.ColumnStyles.Add(layout.Columns[i]);
4.195
4.196 for (int j = 0; j < tableLayoutPanel.RowCount; j++)
4.197 {
4.198 if (i == 0)
4.199 {
4.200 //Create our row styles
4.201 - this.tableLayoutPanel.RowStyles.Add(aLayout.Rows[j]);
4.202 + this.tableLayoutPanel.RowStyles.Add(layout.Rows[j]);
4.203 }
4.204
4.205 MarqueeLabel control = new SharpDisplayManager.MarqueeLabel();
4.206 @@ -1107,14 +1112,20 @@
4.207 control.Dock = System.Windows.Forms.DockStyle.Fill;
4.208 control.Location = new System.Drawing.Point(1, 1);
4.209 control.Margin = new System.Windows.Forms.Padding(0);
4.210 - control.Name = "marqueeLabelCol" + aLayout.Columns.Count + "Row" + aLayout.Rows.Count;
4.211 + control.Name = "marqueeLabelCol" + layout.Columns.Count + "Row" + layout.Rows.Count;
4.212 control.OwnTimer = false;
4.213 control.PixelsPerSecond = 64;
4.214 control.Separator = "|";
4.215 //control.Size = new System.Drawing.Size(254, 30);
4.216 //control.TabIndex = 2;
4.217 control.Font = cds.Font;
4.218 - control.Text = "ABCDEFGHIJKLMNOPQRST[0123456789]";
4.219 + control.Text = "";
4.220 + //If we already have a text for that field
4.221 + if (aClient.Texts.Count > tableLayoutPanel.Controls.Count)
4.222 + {
4.223 + control.Text = aClient.Texts[tableLayoutPanel.Controls.Count].Text;
4.224 + }
4.225 +
4.226 control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
4.227 control.UseCompatibleTextRendering = true;
4.228 //
5.1 --- a/Server/Properties/Settings.Designer.cs Mon Sep 22 22:04:39 2014 +0200
5.2 +++ b/Server/Properties/Settings.Designer.cs Fri Oct 03 18:43:55 2014 +0200
5.3 @@ -1,7 +1,7 @@
5.4 //------------------------------------------------------------------------------
5.5 // <auto-generated>
5.6 // This code was generated by a tool.
5.7 -// Runtime Version:4.0.30319.18444
5.8 +// Runtime Version:4.0.30319.34014
5.9 //
5.10 // Changes to this file may cause incorrect behavior and will be lost if
5.11 // the code is regenerated.
5.12 @@ -37,12 +37,12 @@
5.13
5.14 [global::System.Configuration.UserScopedSettingAttribute()]
5.15 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
5.16 - public global::SharpDisplayManager.DisplaysSettings DisplaySettings {
5.17 + public global::SharpDisplayManager.DisplaysSettings DisplaysSettings {
5.18 get {
5.19 - return ((global::SharpDisplayManager.DisplaysSettings)(this["DisplaySettings"]));
5.20 + return ((global::SharpDisplayManager.DisplaysSettings)(this["DisplaysSettings"]));
5.21 }
5.22 set {
5.23 - this["DisplaySettings"] = value;
5.24 + this["DisplaysSettings"] = value;
5.25 }
5.26 }
5.27
5.28 @@ -57,5 +57,17 @@
5.29 this["CurrentDisplayIndex"] = value;
5.30 }
5.31 }
5.32 +
5.33 + [global::System.Configuration.UserScopedSettingAttribute()]
5.34 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
5.35 + [global::System.Configuration.DefaultSettingValueAttribute("False")]
5.36 + public bool CycleClients {
5.37 + get {
5.38 + return ((bool)(this["CycleClients"]));
5.39 + }
5.40 + set {
5.41 + this["CycleClients"] = value;
5.42 + }
5.43 + }
5.44 }
5.45 }
6.1 --- a/Server/Properties/Settings.settings Mon Sep 22 22:04:39 2014 +0200
6.2 +++ b/Server/Properties/Settings.settings Fri Oct 03 18:43:55 2014 +0200
6.3 @@ -5,11 +5,14 @@
6.4 <Setting Name="DisplayConnectOnStartup" Type="System.Boolean" Scope="User">
6.5 <Value Profile="(Default)">False</Value>
6.6 </Setting>
6.7 - <Setting Name="DisplaySettings" Type="SharpDisplayManager.DisplaySettings" Scope="User">
6.8 + <Setting Name="DisplaysSettings" Type="SharpDisplayManager.DisplaysSettings" Scope="User">
6.9 <Value Profile="(Default)" />
6.10 </Setting>
6.11 <Setting Name="CurrentDisplayIndex" Type="System.Int32" Scope="User">
6.12 <Value Profile="(Default)">0</Value>
6.13 </Setting>
6.14 + <Setting Name="CycleClients" Type="System.Boolean" Scope="User">
6.15 + <Value Profile="(Default)">False</Value>
6.16 + </Setting>
6.17 </Settings>
6.18 </SettingsFile>
6.19 \ No newline at end of file
7.1 --- a/Server/Session.cs Mon Sep 22 22:04:39 2014 +0200
7.2 +++ b/Server/Session.cs Fri Oct 03 18:43:55 2014 +0200
7.3 @@ -62,13 +62,13 @@
7.4 //From IDisplayService
7.5 public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
7.6 {
7.7 - SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields);
7.8 + SharpDisplayManager.Program.iMainForm.SetClientTextsThreadSafe(SessionId, aTextFields);
7.9 }
7.10
7.11 //
7.12 public void SetText(TextField aTextField)
7.13 {
7.14 - SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField);
7.15 + SharpDisplayManager.Program.iMainForm.SetClientTextThreadSafe(SessionId, aTextField);
7.16 }
7.17
7.18