# HG changeset patch # User StephaneLenclud # Date 1484502546 -3600 # Node ID 10f0de70b69bf4ea58b9fadd3b3249be4e779d72 # Parent 2481c46d1f933a0af7b665d780fdcd73a79e1603 Ground work for display layout support. diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Idle/SharpDisplayClientIdle.csproj --- a/Clients/Idle/SharpDisplayClientIdle.csproj Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Idle/SharpDisplayClientIdle.csproj Sun Jan 15 18:49:06 2017 +0100 @@ -66,8 +66,8 @@ true - - ..\..\packages\SharpLibDisplay.0.2.8\lib\net40\SharpLibDisplay.dll + + ..\..\packages\SharpLibDisplay.0.3.3\lib\net40\SharpLibDisplay.dll True diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Idle/packages.config --- a/Clients/Idle/packages.config Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Idle/packages.config Sun Jan 15 18:49:06 2017 +0100 @@ -1,4 +1,4 @@  - + \ No newline at end of file diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Message/SharpDisplayClientMessage.csproj --- a/Clients/Message/SharpDisplayClientMessage.csproj Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Message/SharpDisplayClientMessage.csproj Sun Jan 15 18:49:06 2017 +0100 @@ -65,8 +65,8 @@ true - - ..\..\packages\SharpLibDisplay.0.2.8\lib\net40\SharpLibDisplay.dll + + ..\..\packages\SharpLibDisplay.0.3.3\lib\net40\SharpLibDisplay.dll True diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Message/packages.config --- a/Clients/Message/packages.config Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Message/packages.config Sun Jan 15 18:49:06 2017 +0100 @@ -1,4 +1,4 @@  - + \ No newline at end of file diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Test/SharpDisplayClientTest.csproj --- a/Clients/Test/SharpDisplayClientTest.csproj Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Test/SharpDisplayClientTest.csproj Sun Jan 15 18:49:06 2017 +0100 @@ -84,8 +84,8 @@ true - - ..\..\packages\SharpLibDisplay.0.2.8\lib\net40\SharpLibDisplay.dll + + ..\..\packages\SharpLibDisplay.0.3.3\lib\net40\SharpLibDisplay.dll True diff -r 2481c46d1f93 -r 10f0de70b69b Clients/Test/packages.config --- a/Clients/Test/packages.config Sun Jan 08 12:19:35 2017 +0100 +++ b/Clients/Test/packages.config Sun Jan 15 18:49:06 2017 +0100 @@ -1,4 +1,4 @@  - + \ No newline at end of file diff -r 2481c46d1f93 -r 10f0de70b69b Server/ClientData.cs --- a/Server/ClientData.cs Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/ClientData.cs Sun Jan 15 18:49:06 2017 +0100 @@ -19,62 +19,24 @@ SessionId = aSessionId; Name = ""; Priority = Priorities.Default; - Fields = new List(); - Layout = new TableLayout(1, 2); //Default to one column and two rows Callback = aCallback; - HasNewLayout = true; + HasNewLayout = true; + View = new View(); } public string SessionId { get; set; } public string Name { get; set; } public uint Priority { get; set; } - public List Fields { get; set; } - public TableLayout Layout { get; set; } + public Target Target { get; set; } + public View View { get; set; } public ICallback Callback { get; set; } + public bool HasNewLayout { get; set; } //Client management public DateTime LastSwitchTime { get; set; } - /// - /// Look up the corresponding field in our field collection. - /// - /// - /// - public DataField FindSameFieldAs(DataField aField) - { - foreach (DataField field in Fields) - { - if (field.IsSameAs(aField)) - { - return field; - } - } - - return null; - } - - - /// - /// Look up the corresponding field in our field collection. - /// - /// - /// - public int FindSameFieldIndex(DataField aField) - { - int i = 0; - foreach (DataField field in Fields) - { - if (field.IsSameAs(aField)) - { - return i; - } - i++; - } - - return -1; - } } diff -r 2481c46d1f93 -r 10f0de70b69b Server/FormMain.Designer.cs --- a/Server/FormMain.Designer.cs Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/FormMain.Designer.cs Sun Jan 15 18:49:06 2017 +0100 @@ -39,8 +39,10 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); - this.panelDisplay = new System.Windows.Forms.Panel(); - this.iTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.iPanelDisplay = new System.Windows.Forms.Panel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.iTableLayoutPanelDisplay = new System.Windows.Forms.TableLayoutPanel(); + this.iTableLayoutPanelCurrentClient = new System.Windows.Forms.TableLayoutPanel(); this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.fontDialog = new System.Windows.Forms.FontDialog(); @@ -133,8 +135,10 @@ this.labelFontHeight = new System.Windows.Forms.Label(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.panelDisplay.SuspendLayout(); - this.iTableLayoutPanel.SuspendLayout(); + this.iPanelDisplay.SuspendLayout(); + this.panel1.SuspendLayout(); + this.iTableLayoutPanelDisplay.SuspendLayout(); + this.iTableLayoutPanelCurrentClient.SuspendLayout(); this.statusStrip.SuspendLayout(); this.tabPageClients.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); @@ -153,36 +157,69 @@ // // panelDisplay // - this.panelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelDisplay.Controls.Add(this.iTableLayoutPanel); - this.panelDisplay.Location = new System.Drawing.Point(173, 40); - this.panelDisplay.Margin = new System.Windows.Forms.Padding(0); - this.panelDisplay.Name = "panelDisplay"; - this.panelDisplay.Size = new System.Drawing.Size(258, 66); - this.panelDisplay.TabIndex = 12; + this.iPanelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.iPanelDisplay.Controls.Add(this.panel1); + this.iPanelDisplay.Location = new System.Drawing.Point(173, 40); + this.iPanelDisplay.Margin = new System.Windows.Forms.Padding(0); + this.iPanelDisplay.Name = "panelDisplay"; + this.iPanelDisplay.Size = new System.Drawing.Size(258, 66); + this.iPanelDisplay.TabIndex = 12; // - // iTableLayoutPanel + // panel1 // - this.iTableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.Add(this.iTableLayoutPanelDisplay); + this.panel1.Location = new System.Drawing.Point(-1, -1); + this.panel1.Margin = new System.Windows.Forms.Padding(0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(258, 66); + this.panel1.TabIndex = 22; + // + // iTableLayoutPanelDisplay + // + this.iTableLayoutPanelDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.iTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.iTableLayoutPanel.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.iTableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; - this.iTableLayoutPanel.ColumnCount = 1; - this.iTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.iTableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0); - this.iTableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1); - this.iTableLayoutPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize; - this.iTableLayoutPanel.Location = new System.Drawing.Point(0, 0); - this.iTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); - this.iTableLayoutPanel.Name = "iTableLayoutPanel"; - this.iTableLayoutPanel.RowCount = 2; - this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.iTableLayoutPanel.Size = new System.Drawing.Size(256, 64); - this.iTableLayoutPanel.TabIndex = 5; - this.iTableLayoutPanel.SizeChanged += new System.EventHandler(this.tableLayoutPanel_SizeChanged); + this.iTableLayoutPanelDisplay.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.iTableLayoutPanelDisplay.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.iTableLayoutPanelDisplay.ColumnCount = 2; + this.iTableLayoutPanelDisplay.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 88.88889F)); + this.iTableLayoutPanelDisplay.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); + this.iTableLayoutPanelDisplay.Controls.Add(this.iTableLayoutPanelCurrentClient, 0, 0); + this.iTableLayoutPanelDisplay.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize; + this.iTableLayoutPanelDisplay.Location = new System.Drawing.Point(0, 0); + this.iTableLayoutPanelDisplay.Margin = new System.Windows.Forms.Padding(0); + this.iTableLayoutPanelDisplay.Name = "iTableLayoutPanelDisplay"; + this.iTableLayoutPanelDisplay.RowCount = 4; + this.iTableLayoutPanelDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.iTableLayoutPanelDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.iTableLayoutPanelDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.iTableLayoutPanelDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.iTableLayoutPanelDisplay.Size = new System.Drawing.Size(256, 64); + this.iTableLayoutPanelDisplay.TabIndex = 5; + // + // iTableLayoutPanelCurrentClient + // + this.iTableLayoutPanelCurrentClient.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.iTableLayoutPanelCurrentClient.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.iTableLayoutPanelCurrentClient.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.iTableLayoutPanelCurrentClient.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.iTableLayoutPanelCurrentClient.ColumnCount = 1; + this.iTableLayoutPanelCurrentClient.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.iTableLayoutPanelCurrentClient.Controls.Add(this.marqueeLabelTop, 0, 0); + this.iTableLayoutPanelCurrentClient.Controls.Add(this.marqueeLabelBottom, 0, 1); + this.iTableLayoutPanelCurrentClient.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize; + this.iTableLayoutPanelCurrentClient.Location = new System.Drawing.Point(0, 0); + this.iTableLayoutPanelCurrentClient.Margin = new System.Windows.Forms.Padding(0); + this.iTableLayoutPanelCurrentClient.Name = "iTableLayoutPanelCurrentClient"; + this.iTableLayoutPanelCurrentClient.RowCount = 2; + this.iTableLayoutPanelDisplay.SetRowSpan(this.iTableLayoutPanelCurrentClient, 4); + this.iTableLayoutPanelCurrentClient.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.iTableLayoutPanelCurrentClient.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.iTableLayoutPanelCurrentClient.Size = new System.Drawing.Size(227, 64); + this.iTableLayoutPanelCurrentClient.TabIndex = 6; // // marqueeLabelTop // @@ -198,7 +235,7 @@ this.marqueeLabelTop.PixelsPerSecond = 64; this.marqueeLabelTop.ScaleToFit = true; this.marqueeLabelTop.Separator = "|"; - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30); + this.marqueeLabelTop.Size = new System.Drawing.Size(225, 30); this.marqueeLabelTop.TabIndex = 2; this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -217,7 +254,7 @@ this.marqueeLabelBottom.PixelsPerSecond = 64; this.marqueeLabelBottom.ScaleToFit = true; this.marqueeLabelBottom.Separator = "|"; - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31); + this.marqueeLabelBottom.Size = new System.Drawing.Size(225, 31); this.marqueeLabelBottom.TabIndex = 3; this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -1261,7 +1298,7 @@ this.Controls.Add(this.labelWarning); this.Controls.Add(this.statusStrip); this.Controls.Add(this.tabControl); - this.Controls.Add(this.panelDisplay); + this.Controls.Add(this.iPanelDisplay); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(800, 600); this.Name = "FormMain"; @@ -1270,9 +1307,11 @@ this.Load += new System.EventHandler(this.MainForm_Load); this.SizeChanged += new System.EventHandler(this.MainForm_SizeChanged); this.Resize += new System.EventHandler(this.MainForm_Resize); - this.panelDisplay.ResumeLayout(false); - this.iTableLayoutPanel.ResumeLayout(false); - this.iTableLayoutPanel.PerformLayout(); + this.iPanelDisplay.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.iTableLayoutPanelDisplay.ResumeLayout(false); + this.iTableLayoutPanelCurrentClient.ResumeLayout(false); + this.iTableLayoutPanelCurrentClient.PerformLayout(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.tabPageClients.ResumeLayout(false); @@ -1310,10 +1349,7 @@ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower; - private System.Windows.Forms.Panel panelDisplay; - private System.Windows.Forms.TableLayoutPanel iTableLayoutPanel; - private MarqueeLabel marqueeLabelTop; - private MarqueeLabel marqueeLabelBottom; + private System.Windows.Forms.Panel iPanelDisplay; private System.Windows.Forms.TabPage tabPageClients; private System.Windows.Forms.TreeView iTreeViewClients; private System.Windows.Forms.TabPage tabPageDisplay; @@ -1397,6 +1433,11 @@ private System.Windows.Forms.TextBox iTextBoxHarmonyHubAddress; private System.Windows.Forms.CheckBox iCheckBoxHarmonyEnabled; private System.Windows.Forms.Button iButtonHarmonyConnect; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TableLayoutPanel iTableLayoutPanelDisplay; + private System.Windows.Forms.TableLayoutPanel iTableLayoutPanelCurrentClient; + private MarqueeLabel marqueeLabelTop; + private MarqueeLabel marqueeLabelBottom; } } diff -r 2481c46d1f93 -r 10f0de70b69b Server/FormMain.cs --- a/Server/FormMain.cs Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/FormMain.cs Sun Jan 15 18:49:06 2017 +0100 @@ -69,16 +69,6 @@ public delegate void RemoveClientDelegate(string aSessionId); - public delegate void SetFieldDelegate(string SessionId, DataField aField); - - public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList aFields); - - public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout); - - public delegate void SetClientNameDelegate(string aSessionId, string aName); - - public delegate void SetClientPriorityDelegate(string aSessionId, uint aPriority); - public delegate void WndProcDelegate(ref Message aMessage); /// @@ -99,6 +89,13 @@ // The name of the client which informations are currently displayed. public string iCurrentClientSessionId; ClientData iCurrentClientData; + /// + /// Define our display view including layout and fields. + /// Display view should include one ClientField that will show on client View. + /// + SharpLib.Display.View iDisplayView; + + bool iHasNewDisplayLayout; // public bool iClosing; // @@ -175,6 +172,10 @@ iStartupManager = new StartupManager(); iNotifyIcon = new SharpLib.Notification.Control(); iRecordingNotification = new SharpLib.Notification.Control(); + iDisplayView = new SharpLib.Display.View(); + // Default to a single field showing our client + iDisplayView.Layout = new TableLayout(1, 1); + iDisplayView.Fields.Add(new ClientField()); //Have our designer initialize its controls InitializeComponent(); @@ -191,7 +192,7 @@ //We have a bug when drawing minimized and reusing our bitmap //Though I could not reproduce it on Windows 10 - iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height, + iBmp = new System.Drawing.Bitmap(iTableLayoutPanelDisplay.Width, iTableLayoutPanelDisplay.Height, PixelFormat.Format32bppArgb); iCreateBitmap = false; @@ -255,7 +256,7 @@ #if !DEBUG //When not debugging we want the screen to be empty until a client takes over - ClearLayout(); + ClearLayout(iTableLayoutPanelCurrentClient); iCurrentClientData = null; #else //When developing we want at least one client for testing @@ -344,7 +345,7 @@ //panelDisplay needs an extra 2 pixels for borders on each sides //tableLayoutPanel will eventually be the exact size of our display Size size = new Size(iDisplay.WidthInPixels() + 2, iDisplay.HeightInPixels() + 2); - panelDisplay.Size = size; + iPanelDisplay.Size = size; //Our display was just opened, update our UI UpdateStatus(); @@ -665,12 +666,12 @@ // Check if our current client has an Audio Visualizer field // and render them as needed - foreach (DataField f in iCurrentClientData.Fields) + foreach (DataField f in iCurrentClientData.View.Fields) { if (f is AudioVisualizerField) { AudioVisualizerField avf = (AudioVisualizerField)f; - Control ctrl = iTableLayoutPanel.GetControlFromPosition(avf.Column, avf.Row); + Control ctrl = iTableLayoutPanelCurrentClient.GetControlFromPosition(avf.Column, avf.Row); if (ctrl is PictureBox) { @@ -853,7 +854,7 @@ //Fetch and set current client data. iCurrentClientData = requestedClientData; //Apply layout and set data fields. - UpdateTableLayoutPanel(iCurrentClientData); + UpdateTableLayoutPanel(iCurrentClientData.View, iTableLayoutPanelCurrentClient); } private void buttonFont_Click(object sender, EventArgs e) @@ -878,25 +879,19 @@ //if (fontDialog.ShowDialog(this) != DialogResult.Cancel) if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel) { - //Set the fonts to all our labels in our layout - foreach (Control ctrl in iTableLayoutPanel.Controls) - { - if (ctrl is MarqueeLabel) - { - ((MarqueeLabel) ctrl).Font = fontDialog.Font; - } - } - //Save font settings cds.Font = fontDialog.Font; Properties.Settings.Default.Save(); // + //Set the fonts to all our labels in our layout + UpdateFonts(iTableLayoutPanelDisplay); + // CheckFontHeight(); } } /// - /// + /// TODO: review this in respect to our logical font feature when we get there. /// void CheckFontHeight() { @@ -915,7 +910,7 @@ MarqueeLabel label = null; //Get the first label control we can find - foreach (Control ctrl in iTableLayoutPanel.Controls) + foreach (Control ctrl in iTableLayoutPanelCurrentClient.Controls) { if (ctrl is MarqueeLabel) { @@ -940,13 +935,11 @@ private void buttonCapture_Click(object sender, EventArgs e) { - System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height); - iTableLayoutPanel.DrawToBitmap(bmp, iTableLayoutPanel.ClientRectangle); + System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(iTableLayoutPanelDisplay.Width, iTableLayoutPanelDisplay.Height); + iTableLayoutPanelDisplay.DrawToBitmap(bmp, iTableLayoutPanelDisplay.ClientRectangle); //Bitmap bmpToSave = new Bitmap(bmp); bmp.Save("D:\\capture.png"); - ((MarqueeLabel) iTableLayoutPanel.Controls[0]).Text = "Captured"; - /* string outputFileName = "d:\\capture.png"; using (MemoryStream memory = new MemoryStream()) @@ -1092,15 +1085,10 @@ UpdateNetworkSignal(LastTickTime, NewTickTime); - //Update animation for all our marquees - foreach (Control ctrl in iTableLayoutPanel.Controls) - { - if (ctrl is MarqueeLabel) - { - ((MarqueeLabel) ctrl).UpdateAnimation(LastTickTime, NewTickTime); - } - } - + // Update animation for all our marquees + UpdateMarqueesAnimations(iTableLayoutPanelDisplay, LastTickTime, NewTickTime); + + // Update audio visualization UpdateAudioVisualization(); //Update our display @@ -1115,11 +1103,11 @@ //Draw to bitmap if (iCreateBitmap) { - iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height, + iBmp = new System.Drawing.Bitmap(iTableLayoutPanelDisplay.Width, iTableLayoutPanelDisplay.Height, PixelFormat.Format32bppArgb); iCreateBitmap = false; } - iTableLayoutPanel.DrawToBitmap(iBmp, iTableLayoutPanel.ClientRectangle); + iTableLayoutPanelDisplay.DrawToBitmap(iBmp, iTableLayoutPanelDisplay.ClientRectangle); //iBmp.Save("D:\\capture.png"); //Send it to our display @@ -1155,6 +1143,25 @@ } /// + /// Update marquee animation children of the given control. + /// + static private void UpdateMarqueesAnimations(Control aControl, DateTime aLastTickTime, DateTime aNewTickTime) + { + // For each our children + foreach (Control ctrl in aControl.Controls) + { + // Update animation if it is a marquee control + if (ctrl is MarqueeLabel) + { + ((MarqueeLabel)ctrl).UpdateAnimation(aLastTickTime, aNewTickTime); + } + + // Go one level deeper by recursion + UpdateMarqueesAnimations(ctrl, aLastTickTime, aNewTickTime); + } + } + + /// /// Attempt to establish connection with our display hardware. /// private void OpenDisplayConnection() @@ -1273,21 +1280,56 @@ } /// + /// Update fonts in our control tree. + /// + /// + private void UpdateFonts(Control aControl) + { + foreach (Control ctrl in aControl.Controls) + { + if (ctrl is MarqueeLabel) + { + MarqueeLabel marquee = (MarqueeLabel)ctrl; + marquee.Font = cds.Font; + } + + // Recurse + UpdateFonts(ctrl); + } + } + + /// + /// Update marquees separator in our control tree. + /// + /// + private void UpdateMarqueesSeparator(Control aControl) + { + foreach (Control ctrl in aControl.Controls) + { + if (ctrl is MarqueeLabel) + { + MarqueeLabel marquee = (MarqueeLabel)ctrl; + marquee.Separator = cds.Separator; + } + + // Recurse + UpdateMarqueesSeparator(ctrl); + } + } + + /// /// Synchronize UI with settings /// private void UpdateStatus() { //Load settings checkBoxShowBorders.Checked = cds.ShowBorders; - iTableLayoutPanel.CellBorderStyle = (cds.ShowBorders + iTableLayoutPanelCurrentClient.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); //Set the proper font to each of our labels - foreach (MarqueeLabel ctrl in iTableLayoutPanel.Controls) - { - ctrl.Font = cds.Font; - } + UpdateFonts(iTableLayoutPanelDisplay); CheckFontHeight(); //Check if "run on Windows startup" is enabled @@ -1318,8 +1360,9 @@ //Reflect that in our UI StartTimer(); - iTableLayoutPanel.Enabled = true; - panelDisplay.Enabled = true; + iTableLayoutPanelDisplay.Enabled = true; + iTableLayoutPanelCurrentClient.Enabled = true; + iPanelDisplay.Enabled = true; //Only setup brightness if display is open trackBarBrightness.Minimum = iDisplay.MinBrightness(); @@ -1397,8 +1440,9 @@ StopTimer(); #endif checkBoxShowVolumeLabel.Enabled = false; - iTableLayoutPanel.Enabled = false; - panelDisplay.Enabled = false; + iTableLayoutPanelDisplay.Enabled = false; + iTableLayoutPanelCurrentClient.Enabled = false; + iPanelDisplay.Enabled = false; buttonFill.Enabled = false; buttonClear.Enabled = false; buttonOpen.Enabled = true; @@ -1430,7 +1474,7 @@ private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e) { //Save our show borders setting - iTableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked + iTableLayoutPanelCurrentClient.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); cds.ShowBorders = checkBoxShowBorders.Checked; @@ -1527,6 +1571,9 @@ } } + /// + /// + /// public void BroadcastCloseEvent() { Trace.TraceInformation("BroadcastCloseEvent - start"); @@ -1560,7 +1607,7 @@ if (iClients.Count == 0) { - ClearLayout(); + ClearLayout(iTableLayoutPanelCurrentClient); iCurrentClientData = null; } } @@ -1568,24 +1615,24 @@ /// /// Just remove all our fields. /// - private void ClearLayout() + static private void ClearLayout(TableLayoutPanel aPanel) { // For each loop did not work as calling Dispose on a control removes it from the collection. // We make sure every control are disposed of notably to turn off visualizer when no more needed. // That's the only way we found to make sure Control.Disposed is called in a timely fashion. // Though that loop is admetitly dangerous as if one of the control does not removes itself from the list we end up with infinite loop. // That's what happened with our MarqueeLabel until we fixed it's Dispose override. - while (iTableLayoutPanel.Controls.Count>0) + while (aPanel.Controls.Count>0) { // Dispose our last item - iTableLayoutPanel.Controls[iTableLayoutPanel.Controls.Count-1].Dispose(); + aPanel.Controls[aPanel.Controls.Count-1].Dispose(); } - iTableLayoutPanel.Controls.Clear(); - iTableLayoutPanel.RowStyles.Clear(); - iTableLayoutPanel.ColumnStyles.Clear(); - iTableLayoutPanel.RowCount = 0; - iTableLayoutPanel.ColumnCount = 0; + aPanel.Controls.Clear(); + aPanel.RowStyles.Clear(); + aPanel.ColumnStyles.Clear(); + aPanel.RowCount = 0; + aPanel.ColumnCount = 0; } /// @@ -1764,7 +1811,7 @@ if (iClients.Count == 0) { //Clear our screen when last client disconnects - ClearLayout(); + ClearLayout(iTableLayoutPanelCurrentClient); iCurrentClientData = null; if (iClosing) @@ -1789,32 +1836,43 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetLayoutDelegate d = new SetLayoutDelegate(SetClientLayoutThreadSafe); - this.Invoke(d, new object[] {aSessionId, aLayout}); + Invoke(new Action((sender) => { SetClientLayoutThreadSafe(aSessionId, aLayout); }), this); + return; } - else + + ClientData client = iClients[aSessionId]; + if (client == null) { - ClientData client = iClients[aSessionId]; - if (client != null) + //TODO: logs + return; + } + + // If we have a matching client and we want to change the client layout + if (client.Target == Target.Client) + { + //Don't change a thing if the layout is the same + if (!client.View.Layout.IsSameAs(aLayout)) { - //Don't change a thing if the layout is the same - if (!client.Layout.IsSameAs(aLayout)) - { - Debug.Print("SetClientLayoutThreadSafe: Layout updated."); - //Set our client layout then - client.Layout = aLayout; - //So that next time we update all our fields at ones - client.HasNewLayout = true; - //Layout has changed clear our fields then - client.Fields.Clear(); - // - UpdateClientTreeViewNode(client); - } - else - { - Debug.Print("SetClientLayoutThreadSafe: Layout has not changed."); - } + Debug.Print("SetClientLayoutThreadSafe: Layout updated."); + //Set our client layout then + client.View.Layout = aLayout; + //So that next time we update all our fields at ones + client.HasNewLayout = true; + //Layout has changed clear our fields then + client.View.Fields.Clear(); + // + UpdateClientTreeViewNode(client); } + else + { + Debug.Print("SetClientLayoutThreadSafe: Layout has not changed."); + } + } + else if (client.Target == Target.Display) + { + // Mark our display layout has updated and wait for the fields. + // Is display layout a property from our client? + //iTableLayoutPanelDisplay. = aLayout; } } @@ -1828,8 +1886,7 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetFieldDelegate d = new SetFieldDelegate(SetClientFieldThreadSafe); - this.Invoke(d, new object[] {aSessionId, aField}); + Invoke(new Action((sender) => { SetClientFieldThreadSafe(aSessionId, aField); }), this); } else { @@ -1856,7 +1913,7 @@ bool contentChanged = true; //Fetch our field index - int fieldIndex = client.FindSameFieldIndex(aField); + int fieldIndex = client.View.FindSameFieldIndex(aField); if (fieldIndex < 0) { @@ -1865,9 +1922,9 @@ } //Keep our previous field in there - DataField previousField = client.Fields[fieldIndex]; + DataField previousField = client.View.Fields[fieldIndex]; //Just update that field then - client.Fields[fieldIndex] = aField; + client.View.Fields[fieldIndex] = aField; if (!aField.IsTableField) { @@ -1882,7 +1939,7 @@ //If we are updating a field in our current client we need to update it in our panel if (aSessionId == iCurrentClientSessionId) { - Control ctrl = iTableLayoutPanel.GetControlFromPosition(tableField.Column, tableField.Row); + Control ctrl = iTableLayoutPanelCurrentClient.GetControlFromPosition(tableField.Column, tableField.Row); if (aField.IsTextField && ctrl is MarqueeLabel) { TextField textField = (TextField)aField; @@ -1927,7 +1984,7 @@ if (aSessionId == iCurrentClientSessionId) { //Apply layout and set data fields. - UpdateTableLayoutPanel(iCurrentClientData); + UpdateTableLayoutPanel(iCurrentClientData.View, iTableLayoutPanelCurrentClient); } } else @@ -1953,8 +2010,7 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetFieldsDelegate d = new SetFieldsDelegate(SetClientFieldsThreadSafe); - this.Invoke(d, new object[] {aSessionId, aFields}); + Invoke(new Action((sender) => { SetClientFieldsThreadSafe(aSessionId, aFields); }), this); } else { @@ -1967,7 +2023,7 @@ //Do some special handling to avoid re-creating our panel N times, once for each fields client.HasNewLayout = false; //Just set all our fields then - client.Fields.AddRange(aFields); + client.View.Fields.AddRange(aFields); //Try switch to that client SetCurrentClient(aSessionId); @@ -1975,7 +2031,7 @@ if (aSessionId == iCurrentClientSessionId) { //Apply layout and set data fields. - UpdateTableLayoutPanel(iCurrentClientData); + UpdateTableLayoutPanel(iCurrentClientData.View, iTableLayoutPanelCurrentClient); } UpdateClientTreeViewNode(client); @@ -2001,8 +2057,7 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetClientNameDelegate d = new SetClientNameDelegate(SetClientNameThreadSafe); - this.Invoke(d, new object[] {aSessionId, aName}); + Invoke(new Action((sender) => { SetClientNameThreadSafe(aSessionId, aName); }), this); } else { @@ -2025,8 +2080,7 @@ if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves - SetClientPriorityDelegate d = new SetClientPriorityDelegate(SetClientPriorityThreadSafe); - this.Invoke(d, new object[] {aSessionId, aPriority}); + Invoke(new Action((sender) => { SetClientPriorityThreadSafe(aSessionId, aPriority); }), this); } else { @@ -2035,7 +2089,7 @@ ClientData client = iClients[aSessionId]; if (client != null) { - //Set its name + //Set its priority client.Priority = aPriority; //Update our tree-view UpdateClientTreeViewNode(client); @@ -2052,6 +2106,33 @@ /// /// /// + /// + /// + public void SetClientTargetThreadSafe(string aSessionId, Target aTarget) + { + if (this.InvokeRequired) + { + //Not in the proper thread, invoke ourselves + Invoke(new Action((sender) => { SetClientTargetThreadSafe(aSessionId, aTarget); }), this); + } + else + { + //We are in the proper thread + //Get our client + ClientData client = iClients[aSessionId]; + if (client != null) + { + //Set its priority + client.Target = aTarget; + //Update our tree-view + //UpdateClientTreeViewNode(client); + } + } + } + + /// + /// + /// /// /// /// @@ -2071,7 +2152,7 @@ RecordingField recField = new RecordingField(); foreach (var client in iClients) { - RecordingField rec = (RecordingField) client.Value.FindSameFieldAs(recField); + RecordingField rec = (RecordingField) client.Value.View.FindSameFieldAs(recField); if (rec != null && rec.IsActive) { activeRecording = true; @@ -2158,13 +2239,13 @@ //Display client priority node.Nodes.Add(new TreeNode("Priority: " + aClient.Priority)); - if (aClient.Fields.Count > 0) + if (aClient.View.Fields.Count > 0) { //Create root node for our texts TreeNode textsRoot = new TreeNode("Fields"); node.Nodes.Add(textsRoot); //For each text add a new entry - foreach (DataField field in aClient.Fields) + foreach (DataField field in aClient.View.Fields) { if (field.IsTextField) { @@ -2192,64 +2273,52 @@ } /// - /// Update our table layout row styles to make sure each rows have similar height - /// - private void UpdateTableLayoutRowStyles() - { - foreach (RowStyle rowStyle in iTableLayoutPanel.RowStyles) - { - rowStyle.SizeType = SizeType.Percent; - rowStyle.Height = 100/iTableLayoutPanel.RowCount; - } - } - - /// /// Update our display table layout. /// Will instanciated every field control as defined by our client. /// Fields must be specified by rows from the left. /// /// - private void UpdateTableLayoutPanel(ClientData aClient) + private void UpdateTableLayoutPanel(SharpLib.Display.View aView, TableLayoutPanel aPanel) { Debug.Print("UpdateTableLayoutPanel"); - if (aClient == null) + if (aView == null) { //Just drop it return; } - TableLayout layout = aClient.Layout; + TableLayout layout = aView.Layout; //First clean our current panel - ClearLayout(); + ClearLayout(aPanel); //Then recreate our rows... - while (iTableLayoutPanel.RowCount < layout.Rows.Count) + while (aPanel.RowCount < layout.Rows.Count) { - iTableLayoutPanel.RowCount++; + aPanel.RowCount++; } // ...and columns - while (iTableLayoutPanel.ColumnCount < layout.Columns.Count) + while (aPanel.ColumnCount < layout.Columns.Count) { - iTableLayoutPanel.ColumnCount++; + aPanel.ColumnCount++; } //For each column - for (int i = 0; i < iTableLayoutPanel.ColumnCount; i++) + for (int i = 0; i < aPanel.ColumnCount; i++) { //Create our column styles - this.iTableLayoutPanel.ColumnStyles.Add(layout.Columns[i]); + aPanel.ColumnStyles.Add(layout.Columns[i]); //For each rows - for (int j = 0; j < iTableLayoutPanel.RowCount; j++) + for (int j = 0; j < aPanel.RowCount; j++) { if (i == 0) { //Create our row styles - this.iTableLayoutPanel.RowStyles.Add(layout.Rows[j]); + aPanel.RowStyles.Add(layout.Rows[j]); } else { @@ -2259,7 +2328,7 @@ } //For each field - foreach (DataField field in aClient.Fields) + foreach (DataField field in aView.Fields) { if (!field.IsTableField) { @@ -2273,10 +2342,10 @@ Control control = CreateControlForDataField(tableField); //Add newly created control to our table layout at the specified row and column - iTableLayoutPanel.Controls.Add(control, tableField.Column, tableField.Row); + aPanel.Controls.Add(control, tableField.Column, tableField.Row); //Make sure we specify column and row span for that new control - iTableLayoutPanel.SetColumnSpan(control, tableField.ColumnSpan); - iTableLayoutPanel.SetRowSpan(control, tableField.RowSpan); + aPanel.SetColumnSpan(control, tableField.ColumnSpan); + aPanel.SetRowSpan(control, tableField.RowSpan); } @@ -2428,7 +2497,10 @@ cds.MinFontSize = minFontSize; Properties.Settings.Default.Save(); //We need to recreate our layout for that change to take effect - UpdateTableLayoutPanel(iCurrentClientData); + if (iCurrentClientData != null) + { + UpdateTableLayoutPanel(iCurrentClientData.View, iTableLayoutPanelCurrentClient); + } } } } @@ -2445,22 +2517,26 @@ cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed; Properties.Settings.Default.Save(); //We need to recreate our layout for that change to take effect - UpdateTableLayoutPanel(iCurrentClientData); + if (iCurrentClientData != null) + { + UpdateTableLayoutPanel(iCurrentClientData.View, iTableLayoutPanelCurrentClient); + } } } } + /// + /// + /// + /// + /// private void textBoxScrollLoopSeparator_TextChanged(object sender, EventArgs e) { cds.Separator = textBoxScrollLoopSeparator.Text; Properties.Settings.Default.Save(); //Update our text fields - foreach (MarqueeLabel ctrl in iTableLayoutPanel.Controls) - { - ctrl.Separator = cds.Separator; - } - + UpdateMarqueesSeparator(iTableLayoutPanelDisplay); } private void buttonPowerOn_Click(object sender, EventArgs e) diff -r 2481c46d1f93 -r 10f0de70b69b Server/Session.cs --- a/Server/Session.cs Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/Session.cs Sun Jan 15 18:49:06 2017 +0100 @@ -41,6 +41,7 @@ public string SessionId { get; set; } public string Name { get; set; } public uint Priority { get; set; } + public Target Target { get; set; } Session() { @@ -84,6 +85,13 @@ SharpDisplayManager.Program.iFormMain.SetClientPriorityThreadSafe(SessionId, Priority); } + public void SetTarget(Target aTarget) + { + Target = aTarget; + SharpDisplayManager.Program.iFormMain.SetClientTargetThreadSafe(SessionId, Target); + } + + public void SetLayout(TableLayout aLayout) { SharpDisplayManager.Program.iFormMain.SetClientLayoutThreadSafe(SessionId, aLayout); diff -r 2481c46d1f93 -r 10f0de70b69b Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/SharpDisplayManager.csproj Sun Jan 15 18:49:06 2017 +0100 @@ -128,8 +128,8 @@ ..\packages\LibMiniDisplay.1.1.8\lib\net20\MiniDisplayInterop.dll True - - ..\packages\SharpLibDisplay.0.2.8\lib\net40\SharpLibDisplay.dll + + ..\packages\SharpLibDisplay.0.3.3\lib\net40\SharpLibDisplay.dll True diff -r 2481c46d1f93 -r 10f0de70b69b Server/packages.config --- a/Server/packages.config Sun Jan 08 12:19:35 2017 +0100 +++ b/Server/packages.config Sun Jan 15 18:49:06 2017 +0100 @@ -3,7 +3,7 @@ - +