# HG changeset patch # User sl # Date 1411399415 -7200 # Node ID cd9924457275dddb0857cfe2f363fba7d1c1dd46 # Parent ac698f4e1b360d29258fad7eae1d58238d163a86 TableLayout now support row and column styles. diff -r ac698f4e1b36 -r cd9924457275 Client/MainForm.cs --- a/Client/MainForm.cs Mon Sep 22 16:04:26 2014 +0200 +++ b/Client/MainForm.cs Mon Sep 22 17:23:35 2014 +0200 @@ -153,6 +153,7 @@ private void buttonLayoutUpdate_Click(object sender, EventArgs e) { TableLayout layout = new TableLayout(2,2); + layout.Columns[1].Width = 25F; iClient.SetLayout(layout); } } diff -r ac698f4e1b36 -r cd9924457275 Interface/Interface.cs --- a/Interface/Interface.cs Mon Sep 22 16:04:26 2014 +0200 +++ b/Interface/Interface.cs Mon Sep 22 17:23:35 2014 +0200 @@ -11,10 +11,14 @@ using System.Collections; using System.Drawing; using System.Runtime.Serialization; +using System.Windows.Forms; namespace SharpDisplay { + + + /// /// TextField can be send to our server to be displayed on the screen. /// @@ -23,25 +27,36 @@ { public TableLayout() { - ColumnCount = 0; - RowCount = 0; - //Alignment = ContentAlignment.MiddleLeft; + Columns = new List(); + Rows = new List(); + Cells = new List(); } public TableLayout(int aColumnCount, int aRowCount) { - ColumnCount = aColumnCount; - RowCount = aRowCount; + Columns = new List(); + Rows = new List(); + + for (int i = 0; i < aColumnCount; i++) + { + Columns.Add(new ColumnStyle(SizeType.Percent, 100 / aColumnCount)); + } + + for (int i = 0; i < aRowCount; i++) + { + Rows.Add(new RowStyle(SizeType.Percent, 100 / aRowCount)); + } } [DataMember] - public int ColumnCount { get; set; } + public List Cells { get; set; } [DataMember] - public int RowCount { get; set; } + public List Columns { get; set; } [DataMember] - public List Cells { get; set; } + public List Rows { get; set; } + } /// diff -r ac698f4e1b36 -r cd9924457275 Interface/SharpDisplayInterface.csproj --- a/Interface/SharpDisplayInterface.csproj Mon Sep 22 16:04:26 2014 +0200 +++ b/Interface/SharpDisplayInterface.csproj Mon Sep 22 17:23:35 2014 +0200 @@ -58,6 +58,7 @@ + diff -r ac698f4e1b36 -r cd9924457275 Server/MainForm.cs --- a/Server/MainForm.cs Mon Sep 22 16:04:26 2014 +0200 +++ b/Server/MainForm.cs Mon Sep 22 17:23:35 2014 +0200 @@ -776,7 +776,7 @@ if (client != null) { client.Layout = aLayout; - UpdateTableLayoutPanel(client.Layout.ColumnCount, client.Layout.RowCount); + UpdateTableLayoutPanel(client.Layout); // UpdateClientTreeViewNode(client); } @@ -1064,6 +1064,68 @@ CheckFontHeight(); } + + /// + /// Update our display table layout. + /// + /// + private void UpdateTableLayoutPanel(TableLayout aLayout) + { + tableLayoutPanel.Controls.Clear(); + tableLayoutPanel.RowStyles.Clear(); + tableLayoutPanel.ColumnStyles.Clear(); + tableLayoutPanel.RowCount = 0; + tableLayoutPanel.ColumnCount = 0; + + while (tableLayoutPanel.RowCount < aLayout.Rows.Count) + { + tableLayoutPanel.RowCount++; + } + + while (tableLayoutPanel.ColumnCount < aLayout.Columns.Count) + { + tableLayoutPanel.ColumnCount++; + } + + for (int i = 0; i < tableLayoutPanel.ColumnCount; i++) + { + //Create our column styles + this.tableLayoutPanel.ColumnStyles.Add(aLayout.Columns[i]); + + for (int j = 0; j < tableLayoutPanel.RowCount; j++) + { + if (i == 0) + { + //Create our row styles + this.tableLayoutPanel.RowStyles.Add(aLayout.Rows[j]); + } + + MarqueeLabel control = new SharpDisplayManager.MarqueeLabel(); + control.AutoEllipsis = true; + control.AutoSize = true; + control.BackColor = System.Drawing.Color.Transparent; + 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.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.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + control.UseCompatibleTextRendering = true; + // + tableLayoutPanel.Controls.Add(control, i, j); + } + } + + CheckFontHeight(); + } + + private void buttonAlignLeft_Click(object sender, EventArgs e) { foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)