TableLayout now support row and column styles.
authorsl
Mon, 22 Sep 2014 17:23:35 +0200
changeset 63cd9924457275
parent 62 ac698f4e1b36
child 64 ab4ff9d33c73
TableLayout now support row and column styles.
Client/MainForm.cs
Interface/Interface.cs
Interface/SharpDisplayInterface.csproj
Server/MainForm.cs
     1.1 --- a/Client/MainForm.cs	Mon Sep 22 16:04:26 2014 +0200
     1.2 +++ b/Client/MainForm.cs	Mon Sep 22 17:23:35 2014 +0200
     1.3 @@ -153,6 +153,7 @@
     1.4          private void buttonLayoutUpdate_Click(object sender, EventArgs e)
     1.5          {
     1.6              TableLayout layout = new TableLayout(2,2);
     1.7 +            layout.Columns[1].Width = 25F;
     1.8              iClient.SetLayout(layout);
     1.9          }
    1.10      }
     2.1 --- a/Interface/Interface.cs	Mon Sep 22 16:04:26 2014 +0200
     2.2 +++ b/Interface/Interface.cs	Mon Sep 22 17:23:35 2014 +0200
     2.3 @@ -11,10 +11,14 @@
     2.4  using System.Collections;
     2.5  using System.Drawing;
     2.6  using System.Runtime.Serialization;
     2.7 +using System.Windows.Forms;
     2.8  
     2.9  
    2.10  namespace SharpDisplay
    2.11  {
    2.12 +
    2.13 +
    2.14 +
    2.15      /// <summary>
    2.16      /// TextField can be send to our server to be displayed on the screen.
    2.17      /// </summary>
    2.18 @@ -23,25 +27,36 @@
    2.19      {
    2.20          public TableLayout()
    2.21          {
    2.22 -            ColumnCount = 0;
    2.23 -            RowCount = 0;
    2.24 -            //Alignment = ContentAlignment.MiddleLeft;
    2.25 +            Columns = new List<ColumnStyle>();
    2.26 +            Rows = new List<RowStyle>();
    2.27 +            Cells = new List<DataField>();
    2.28          }
    2.29  
    2.30          public TableLayout(int aColumnCount, int aRowCount)
    2.31          {
    2.32 -            ColumnCount = aColumnCount;
    2.33 -            RowCount = aRowCount;
    2.34 +            Columns = new List<ColumnStyle>();
    2.35 +            Rows = new List<RowStyle>();
    2.36 +
    2.37 +            for (int i = 0; i < aColumnCount; i++)
    2.38 +            {
    2.39 +                Columns.Add(new ColumnStyle(SizeType.Percent, 100 / aColumnCount));
    2.40 +            }
    2.41 +
    2.42 +            for (int i = 0; i < aRowCount; i++)
    2.43 +            {
    2.44 +                Rows.Add(new RowStyle(SizeType.Percent, 100 / aRowCount));
    2.45 +            }
    2.46          }
    2.47  
    2.48          [DataMember]
    2.49 -        public int ColumnCount { get; set; }
    2.50 +        public List<DataField> Cells { get; set; }
    2.51  
    2.52          [DataMember]
    2.53 -        public int RowCount { get; set; }
    2.54 +        public List<ColumnStyle> Columns { get; set; }
    2.55  
    2.56          [DataMember]
    2.57 -        public List<DataField> Cells { get; set; }
    2.58 +        public List<RowStyle> Rows { get; set; }
    2.59 +
    2.60      }
    2.61  
    2.62      /// <summary>
     3.1 --- a/Interface/SharpDisplayInterface.csproj	Mon Sep 22 16:04:26 2014 +0200
     3.2 +++ b/Interface/SharpDisplayInterface.csproj	Mon Sep 22 17:23:35 2014 +0200
     3.3 @@ -58,6 +58,7 @@
     3.4      <Reference Include="System.Drawing" />
     3.5      <Reference Include="System.Runtime.Serialization" />
     3.6      <Reference Include="System.ServiceModel" />
     3.7 +    <Reference Include="System.Windows.Forms" />
     3.8      <Reference Include="System.Xml.Linq" />
     3.9      <Reference Include="System.Data.DataSetExtensions" />
    3.10      <Reference Include="Microsoft.CSharp" />
     4.1 --- a/Server/MainForm.cs	Mon Sep 22 16:04:26 2014 +0200
     4.2 +++ b/Server/MainForm.cs	Mon Sep 22 17:23:35 2014 +0200
     4.3 @@ -776,7 +776,7 @@
     4.4                  if (client != null)
     4.5                  {
     4.6                      client.Layout = aLayout;
     4.7 -                    UpdateTableLayoutPanel(client.Layout.ColumnCount, client.Layout.RowCount);
     4.8 +                    UpdateTableLayoutPanel(client.Layout);
     4.9                      //
    4.10                      UpdateClientTreeViewNode(client);
    4.11                  }
    4.12 @@ -1064,6 +1064,68 @@
    4.13              CheckFontHeight();
    4.14          }
    4.15  
    4.16 +
    4.17 +        /// <summary>
    4.18 +        /// Update our display table layout.
    4.19 +        /// </summary>
    4.20 +        /// <param name="aLayout"></param>
    4.21 +        private void UpdateTableLayoutPanel(TableLayout aLayout)
    4.22 +        {
    4.23 +            tableLayoutPanel.Controls.Clear();
    4.24 +            tableLayoutPanel.RowStyles.Clear();
    4.25 +            tableLayoutPanel.ColumnStyles.Clear();
    4.26 +            tableLayoutPanel.RowCount = 0;
    4.27 +            tableLayoutPanel.ColumnCount = 0;
    4.28 +
    4.29 +            while (tableLayoutPanel.RowCount < aLayout.Rows.Count)
    4.30 +            {
    4.31 +                tableLayoutPanel.RowCount++;
    4.32 +            }
    4.33 +
    4.34 +            while (tableLayoutPanel.ColumnCount < aLayout.Columns.Count)
    4.35 +            {
    4.36 +                tableLayoutPanel.ColumnCount++;
    4.37 +            }
    4.38 +
    4.39 +            for (int i = 0; i < tableLayoutPanel.ColumnCount; i++)
    4.40 +            {
    4.41 +                //Create our column styles
    4.42 +                this.tableLayoutPanel.ColumnStyles.Add(aLayout.Columns[i]);
    4.43 +
    4.44 +                for (int j = 0; j < tableLayoutPanel.RowCount; j++)
    4.45 +                {
    4.46 +                    if (i == 0)
    4.47 +                    {
    4.48 +                        //Create our row styles
    4.49 +                        this.tableLayoutPanel.RowStyles.Add(aLayout.Rows[j]);
    4.50 +                    }
    4.51 +
    4.52 +                    MarqueeLabel control = new SharpDisplayManager.MarqueeLabel();
    4.53 +                    control.AutoEllipsis = true;
    4.54 +                    control.AutoSize = true;
    4.55 +                    control.BackColor = System.Drawing.Color.Transparent;
    4.56 +                    control.Dock = System.Windows.Forms.DockStyle.Fill;
    4.57 +                    control.Location = new System.Drawing.Point(1, 1);
    4.58 +                    control.Margin = new System.Windows.Forms.Padding(0);
    4.59 +                    control.Name = "marqueeLabelCol" + aLayout.Columns.Count + "Row" + aLayout.Rows.Count;
    4.60 +                    control.OwnTimer = false;
    4.61 +                    control.PixelsPerSecond = 64;
    4.62 +                    control.Separator = "|";
    4.63 +                    //control.Size = new System.Drawing.Size(254, 30);
    4.64 +                    //control.TabIndex = 2;
    4.65 +                    control.Font = cds.Font;
    4.66 +                    control.Text = "ABCDEFGHIJKLMNOPQRST[0123456789]";
    4.67 +                    control.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    4.68 +                    control.UseCompatibleTextRendering = true;
    4.69 +                    //
    4.70 +                    tableLayoutPanel.Controls.Add(control, i, j);
    4.71 +                }
    4.72 +            }
    4.73 +
    4.74 +            CheckFontHeight();
    4.75 +        }
    4.76 +
    4.77 +
    4.78          private void buttonAlignLeft_Click(object sender, EventArgs e)
    4.79          {
    4.80              foreach (MarqueeLabel ctrl in tableLayoutPanel.Controls)