# HG changeset patch # User sl # Date 1412354635 -7200 # Node ID 464486b8163560e51cdd0a2da3d498c2c658e5a4 # Parent ab4ff9d33c73970ff9dbe36f35338e9e0bf463ae Adding current client concept. diff -r ab4ff9d33c73 -r 464486b81635 Client/MainForm.cs --- a/Client/MainForm.cs Mon Sep 22 22:04:39 2014 +0200 +++ b/Client/MainForm.cs Fri Oct 03 18:43:55 2014 +0200 @@ -152,8 +152,11 @@ private void buttonLayoutUpdate_Click(object sender, EventArgs e) { + //Define a 2 by 2 layout TableLayout layout = new TableLayout(2,2); + //Second column only takes up 25% layout.Columns[1].Width = 25F; + //Send layout to server iClient.SetLayout(layout); } } diff -r ab4ff9d33c73 -r 464486b81635 Interface/Interface.cs --- a/Interface/Interface.cs Mon Sep 22 22:04:39 2014 +0200 +++ b/Interface/Interface.cs Fri Oct 03 18:43:55 2014 +0200 @@ -56,7 +56,6 @@ [DataMember] public List Rows { get; set; } - } /// @@ -129,7 +128,6 @@ [OperationContract(IsOneWay = true)] void SetName(string aClientName); - /// /// /// diff -r ab4ff9d33c73 -r 464486b81635 Server/App.config --- a/Server/App.config Mon Sep 22 22:04:39 2014 +0200 +++ b/Server/App.config Fri Oct 03 18:43:55 2014 +0200 @@ -16,6 +16,9 @@ 0 + + False + diff -r ab4ff9d33c73 -r 464486b81635 Server/MainForm.cs --- a/Server/MainForm.cs Mon Sep 22 22:04:39 2014 +0200 +++ b/Server/MainForm.cs Fri Oct 03 18:43:55 2014 +0200 @@ -42,17 +42,24 @@ System.Drawing.Bitmap iBmp; bool iCreateBitmap; //Workaround render to bitmap issues when minimized ServiceHost iServiceHost; - /// - /// Our collection of clients - /// + // Our collection of clients sorted by session id. public Dictionary iClients; + // The name of the client which informations are currently displayed. + public string iCurrentClientSessionId; + ClientData iCurrentClientData; + // public bool iClosing; + //Function pointer for pixel color filtering ColorProcessingDelegate iColorFx; + //Function pointer for pixel X coordinate intercept CoordinateTranslationDelegate iScreenX; + //Function pointer for pixel Y coordinate intercept CoordinateTranslationDelegate iScreenY; public MainForm() { + iCurrentClientSessionId = ""; + iCurrentClientData = null; LastTickTime = DateTime.Now; iDisplay = new Display(); iClients = new Dictionary(); @@ -62,8 +69,6 @@ //We have a bug when drawing minimized and reusing our bitmap iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); iCreateBitmap = false; - // - //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint); } private void MainForm_Load(object sender, EventArgs e) @@ -76,32 +81,28 @@ } } - //Testing that stuff - private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e) + /// + /// Set our current client. + /// This will take care of applying our client layout and set data fields. + /// + /// + void SetCurrentClient(string aSessionId) { - var panel = sender as TableLayoutPanel; - //e.Graphics.SmoothingMode = SmoothingMode.HighQuality; - var rectangle = e.CellBounds; - using (var pen = new Pen(Color.Black, 1)) + if (aSessionId == iCurrentClientSessionId) { - pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center; - pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + //Given client is already the current one. + //Don't bother changing anything then. + return; + } - if (e.Row == (panel.RowCount - 1)) - { - rectangle.Height -= 1; - } - - if (e.Column == (panel.ColumnCount - 1)) - { - rectangle.Width -= 1; - } - - e.Graphics.DrawRectangle(pen, rectangle); - } + //Set current client ID. + iCurrentClientSessionId = aSessionId; + //Fetch and set current client data. + iCurrentClientData = iClients[aSessionId]; + //Apply layout and set data fields. + UpdateTableLayoutPanel(iCurrentClientData); } - private void buttonFont_Click(object sender, EventArgs e) { //fontDialog.ShowColor = true; @@ -430,12 +431,12 @@ { get { - DisplaysSettings settings = Properties.Settings.Default.DisplaySettings; + DisplaysSettings settings = Properties.Settings.Default.DisplaysSettings; if (settings == null) { settings = new DisplaysSettings(); settings.Init(); - Properties.Settings.Default.DisplaySettings = settings; + Properties.Settings.Default.DisplaysSettings = settings; } //Make sure all our settings have been created @@ -776,7 +777,7 @@ if (client != null) { client.Layout = aLayout; - UpdateTableLayoutPanel(client.Layout); + UpdateTableLayoutPanel(client); // UpdateClientTreeViewNode(client); } @@ -788,16 +789,17 @@ /// /// /// - public void SetTextThreadSafe(string aSessionId, TextField aTextField) + public void SetClientTextThreadSafe(string aSessionId, TextField aTextField) { if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe); + SetTextDelegate d = new SetTextDelegate(SetClientTextThreadSafe); this.Invoke(d, new object[] { aSessionId, aTextField }); } else { + SetCurrentClient(aSessionId); ClientData client = iClients[aSessionId]; if (client != null) { @@ -823,16 +825,17 @@ /// /// /// - public void SetTextsThreadSafe(string aSessionId, System.Collections.Generic.IList aTextFields) + public void SetClientTextsThreadSafe(string aSessionId, System.Collections.Generic.IList aTextFields) { if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe); + SetTextsDelegate d = new SetTextsDelegate(SetClientTextsThreadSafe); this.Invoke(d, new object[] { aSessionId, aTextFields }); } else { + SetCurrentClient(aSessionId); //We are in the proper thread ClientData client = iClients[aSessionId]; if (client != null) @@ -851,7 +854,7 @@ } j++; } - //Only support two lines for now + //Put each our text fields in a label control for (int i = 0; i < aTextFields.Count; i++) { MarqueeLabel label = (MarqueeLabel)tableLayoutPanel.Controls[aTextFields[i].Index]; @@ -1069,20 +1072,22 @@ /// Update our display table layout. /// /// - private void UpdateTableLayoutPanel(TableLayout aLayout) + private void UpdateTableLayoutPanel(ClientData aClient) { + TableLayout layout = aClient.Layout; + tableLayoutPanel.Controls.Clear(); tableLayoutPanel.RowStyles.Clear(); tableLayoutPanel.ColumnStyles.Clear(); tableLayoutPanel.RowCount = 0; tableLayoutPanel.ColumnCount = 0; - while (tableLayoutPanel.RowCount < aLayout.Rows.Count) + while (tableLayoutPanel.RowCount < layout.Rows.Count) { tableLayoutPanel.RowCount++; } - while (tableLayoutPanel.ColumnCount < aLayout.Columns.Count) + while (tableLayoutPanel.ColumnCount < layout.Columns.Count) { tableLayoutPanel.ColumnCount++; } @@ -1090,14 +1095,14 @@ for (int i = 0; i < tableLayoutPanel.ColumnCount; i++) { //Create our column styles - this.tableLayoutPanel.ColumnStyles.Add(aLayout.Columns[i]); + this.tableLayoutPanel.ColumnStyles.Add(layout.Columns[i]); for (int j = 0; j < tableLayoutPanel.RowCount; j++) { if (i == 0) { //Create our row styles - this.tableLayoutPanel.RowStyles.Add(aLayout.Rows[j]); + this.tableLayoutPanel.RowStyles.Add(layout.Rows[j]); } MarqueeLabel control = new SharpDisplayManager.MarqueeLabel(); @@ -1107,14 +1112,20 @@ control.Dock = System.Windows.Forms.DockStyle.Fill; control.Location = new System.Drawing.Point(1, 1); control.Margin = new System.Windows.Forms.Padding(0); - control.Name = "marqueeLabelCol" + aLayout.Columns.Count + "Row" + aLayout.Rows.Count; + control.Name = "marqueeLabelCol" + layout.Columns.Count + "Row" + layout.Rows.Count; control.OwnTimer = false; control.PixelsPerSecond = 64; control.Separator = "|"; //control.Size = new System.Drawing.Size(254, 30); //control.TabIndex = 2; control.Font = cds.Font; - control.Text = "ABCDEFGHIJKLMNOPQRST[0123456789]"; + control.Text = ""; + //If we already have a text for that field + if (aClient.Texts.Count > tableLayoutPanel.Controls.Count) + { + control.Text = aClient.Texts[tableLayoutPanel.Controls.Count].Text; + } + control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; control.UseCompatibleTextRendering = true; // diff -r ab4ff9d33c73 -r 464486b81635 Server/Properties/Settings.Designer.cs --- a/Server/Properties/Settings.Designer.cs Mon Sep 22 22:04:39 2014 +0200 +++ b/Server/Properties/Settings.Designer.cs Fri Oct 03 18:43:55 2014 +0200 @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -37,12 +37,12 @@ [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public global::SharpDisplayManager.DisplaysSettings DisplaySettings { + public global::SharpDisplayManager.DisplaysSettings DisplaysSettings { get { - return ((global::SharpDisplayManager.DisplaysSettings)(this["DisplaySettings"])); + return ((global::SharpDisplayManager.DisplaysSettings)(this["DisplaysSettings"])); } set { - this["DisplaySettings"] = value; + this["DisplaysSettings"] = value; } } @@ -57,5 +57,17 @@ this["CurrentDisplayIndex"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CycleClients { + get { + return ((bool)(this["CycleClients"])); + } + set { + this["CycleClients"] = value; + } + } } } diff -r ab4ff9d33c73 -r 464486b81635 Server/Properties/Settings.settings --- a/Server/Properties/Settings.settings Mon Sep 22 22:04:39 2014 +0200 +++ b/Server/Properties/Settings.settings Fri Oct 03 18:43:55 2014 +0200 @@ -5,11 +5,14 @@ False - + 0 + + False + \ No newline at end of file diff -r ab4ff9d33c73 -r 464486b81635 Server/Session.cs --- a/Server/Session.cs Mon Sep 22 22:04:39 2014 +0200 +++ b/Server/Session.cs Fri Oct 03 18:43:55 2014 +0200 @@ -62,13 +62,13 @@ //From IDisplayService public void SetTexts(System.Collections.Generic.IList aTextFields) { - SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields); + SharpDisplayManager.Program.iMainForm.SetClientTextsThreadSafe(SessionId, aTextFields); } // public void SetText(TextField aTextField) { - SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField); + SharpDisplayManager.Program.iMainForm.SetClientTextThreadSafe(SessionId, aTextField); }