Adding texts fields to our test client.
authorsl
Sat, 16 Aug 2014 11:15:42 +0200
changeset 331363bda20171
parent 32 4c416d2878dd
child 34 59bfa4ebcbbb
Adding texts fields to our test client.
Trying to fix bugs and optimize our marquee control.
Creating a proper ClientData class to use in our UI thread client dictionary.
Centralising tree-view update.
Client/MainForm.Designer.cs
Client/MainForm.cs
Server/MainForm.Designer.cs
Server/MainForm.cs
Server/MarqueeLabel.cs
     1.1 --- a/Client/MainForm.Designer.cs	Fri Aug 15 13:26:38 2014 +0200
     1.2 +++ b/Client/MainForm.Designer.cs	Sat Aug 16 11:15:42 2014 +0200
     1.3 @@ -29,11 +29,13 @@
     1.4          private void InitializeComponent()
     1.5          {
     1.6              this.buttonSetText = new System.Windows.Forms.Button();
     1.7 +            this.textBoxTop = new System.Windows.Forms.TextBox();
     1.8 +            this.textBoxBottom = new System.Windows.Forms.TextBox();
     1.9              this.SuspendLayout();
    1.10              // 
    1.11              // buttonSetText
    1.12              // 
    1.13 -            this.buttonSetText.Location = new System.Drawing.Point(170, 104);
    1.14 +            this.buttonSetText.Location = new System.Drawing.Point(12, 132);
    1.15              this.buttonSetText.Name = "buttonSetText";
    1.16              this.buttonSetText.Size = new System.Drawing.Size(75, 23);
    1.17              this.buttonSetText.TabIndex = 0;
    1.18 @@ -41,23 +43,42 @@
    1.19              this.buttonSetText.UseVisualStyleBackColor = true;
    1.20              this.buttonSetText.Click += new System.EventHandler(this.buttonSetText_Click);
    1.21              // 
    1.22 +            // textBoxTop
    1.23 +            // 
    1.24 +            this.textBoxTop.Location = new System.Drawing.Point(12, 31);
    1.25 +            this.textBoxTop.Name = "textBoxTop";
    1.26 +            this.textBoxTop.Size = new System.Drawing.Size(419, 20);
    1.27 +            this.textBoxTop.TabIndex = 1;
    1.28 +            // 
    1.29 +            // textBoxBottom
    1.30 +            // 
    1.31 +            this.textBoxBottom.Location = new System.Drawing.Point(12, 57);
    1.32 +            this.textBoxBottom.Name = "textBoxBottom";
    1.33 +            this.textBoxBottom.Size = new System.Drawing.Size(419, 20);
    1.34 +            this.textBoxBottom.TabIndex = 2;
    1.35 +            // 
    1.36              // MainForm
    1.37              // 
    1.38              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    1.39              this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    1.40              this.ClientSize = new System.Drawing.Size(443, 252);
    1.41 +            this.Controls.Add(this.textBoxBottom);
    1.42 +            this.Controls.Add(this.textBoxTop);
    1.43              this.Controls.Add(this.buttonSetText);
    1.44              this.Name = "MainForm";
    1.45              this.Text = "Client";
    1.46              this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
    1.47              this.Load += new System.EventHandler(this.MainForm_Load);
    1.48              this.ResumeLayout(false);
    1.49 +            this.PerformLayout();
    1.50  
    1.51          }
    1.52  
    1.53          #endregion
    1.54  
    1.55          private System.Windows.Forms.Button buttonSetText;
    1.56 +        private System.Windows.Forms.TextBox textBoxTop;
    1.57 +        private System.Windows.Forms.TextBox textBoxBottom;
    1.58      }
    1.59  }
    1.60  
     2.1 --- a/Client/MainForm.cs	Fri Aug 15 13:26:38 2014 +0200
     2.2 +++ b/Client/MainForm.cs	Sat Aug 16 11:15:42 2014 +0200
     2.3 @@ -28,7 +28,7 @@
     2.4          {
     2.5              //iClient.SetText(0,"Top");
     2.6              //iClient.SetText(1, "Bottom");
     2.7 -            iClient.SetTexts(new string[] { iClient.Name, iClient.SessionId });
     2.8 +            iClient.SetTexts(new string[] { textBoxTop.Text, textBoxBottom.Text });
     2.9          }
    2.10  
    2.11          private void MainForm_Load(object sender, EventArgs e)
    2.12 @@ -45,6 +45,10 @@
    2.13              //Text = Text + ": " + name;
    2.14              Text = "[[" + name + "]]  " + iClient.SessionId;
    2.15  
    2.16 +            //
    2.17 +            textBoxTop.Text = iClient.Name;
    2.18 +            textBoxBottom.Text = iClient.SessionId;
    2.19 +
    2.20          }
    2.21  
    2.22  
     3.1 --- a/Server/MainForm.Designer.cs	Fri Aug 15 13:26:38 2014 +0200
     3.2 +++ b/Server/MainForm.Designer.cs	Sat Aug 16 11:15:42 2014 +0200
     3.3 @@ -39,6 +39,8 @@
     3.4              this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
     3.5              this.panelDisplay = new System.Windows.Forms.Panel();
     3.6              this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     3.7 +            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
     3.8 +            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
     3.9              this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
    3.10              this.trackBarBrightness = new System.Windows.Forms.TrackBar();
    3.11              this.buttonFill = new System.Windows.Forms.Button();
    3.12 @@ -48,6 +50,8 @@
    3.13              this.buttonCapture = new System.Windows.Forms.Button();
    3.14              this.buttonFont = new System.Windows.Forms.Button();
    3.15              this.tabPageTests = new System.Windows.Forms.TabPage();
    3.16 +            this.tabPageClients = new System.Windows.Forms.TabPage();
    3.17 +            this.treeViewClients = new System.Windows.Forms.TreeView();
    3.18              this.fontDialog = new System.Windows.Forms.FontDialog();
    3.19              this.timer = new System.Windows.Forms.Timer(this.components);
    3.20              this.statusStrip = new System.Windows.Forms.StatusStrip();
    3.21 @@ -55,17 +59,13 @@
    3.22              this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
    3.23              this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
    3.24              this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
    3.25 -            this.tabPageClients = new System.Windows.Forms.TabPage();
    3.26 -            this.treeViewClients = new System.Windows.Forms.TreeView();
    3.27 -            this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    3.28 -            this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    3.29              this.tabControl.SuspendLayout();
    3.30              this.tabPageDisplay.SuspendLayout();
    3.31              this.panelDisplay.SuspendLayout();
    3.32              this.tableLayoutPanel.SuspendLayout();
    3.33              ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
    3.34 +            this.tabPageClients.SuspendLayout();
    3.35              this.statusStrip.SuspendLayout();
    3.36 -            this.tabPageClients.SuspendLayout();
    3.37              this.SuspendLayout();
    3.38              // 
    3.39              // tabControl
    3.40 @@ -254,6 +254,39 @@
    3.41              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
    3.42              this.tableLayoutPanel.TabIndex = 5;
    3.43              // 
    3.44 +            // marqueeLabelTop
    3.45 +            // 
    3.46 +            this.marqueeLabelTop.AutoEllipsis = true;
    3.47 +            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
    3.48 +            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
    3.49 +            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
    3.50 +            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
    3.51 +            this.marqueeLabelTop.Name = "marqueeLabelTop";
    3.52 +            this.marqueeLabelTop.OwnTimer = false;
    3.53 +            this.marqueeLabelTop.PixelsPerSecond = 64;
    3.54 +            this.marqueeLabelTop.Separator = "|";
    3.55 +            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30);
    3.56 +            this.marqueeLabelTop.TabIndex = 2;
    3.57 +            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
    3.58 +            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    3.59 +            this.marqueeLabelTop.UseCompatibleTextRendering = true;
    3.60 +            // 
    3.61 +            // marqueeLabelBottom
    3.62 +            // 
    3.63 +            this.marqueeLabelBottom.AutoEllipsis = true;
    3.64 +            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
    3.65 +            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
    3.66 +            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
    3.67 +            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
    3.68 +            this.marqueeLabelBottom.OwnTimer = false;
    3.69 +            this.marqueeLabelBottom.PixelsPerSecond = 64;
    3.70 +            this.marqueeLabelBottom.Separator = "|";
    3.71 +            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31);
    3.72 +            this.marqueeLabelBottom.TabIndex = 3;
    3.73 +            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
    3.74 +            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    3.75 +            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
    3.76 +            // 
    3.77              // checkBoxShowBorders
    3.78              // 
    3.79              this.checkBoxShowBorders.AutoSize = true;
    3.80 @@ -350,6 +383,25 @@
    3.81              this.tabPageTests.Text = "Test";
    3.82              this.tabPageTests.UseVisualStyleBackColor = true;
    3.83              // 
    3.84 +            // tabPageClients
    3.85 +            // 
    3.86 +            this.tabPageClients.Controls.Add(this.treeViewClients);
    3.87 +            this.tabPageClients.Location = new System.Drawing.Point(4, 22);
    3.88 +            this.tabPageClients.Name = "tabPageClients";
    3.89 +            this.tabPageClients.Padding = new System.Windows.Forms.Padding(3);
    3.90 +            this.tabPageClients.Size = new System.Drawing.Size(592, 369);
    3.91 +            this.tabPageClients.TabIndex = 2;
    3.92 +            this.tabPageClients.Text = "Clients";
    3.93 +            this.tabPageClients.UseVisualStyleBackColor = true;
    3.94 +            // 
    3.95 +            // treeViewClients
    3.96 +            // 
    3.97 +            this.treeViewClients.Location = new System.Drawing.Point(6, 6);
    3.98 +            this.treeViewClients.Name = "treeViewClients";
    3.99 +            this.treeViewClients.Size = new System.Drawing.Size(439, 357);
   3.100 +            this.treeViewClients.TabIndex = 0;
   3.101 +            this.treeViewClients.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewClients_AfterSelect);
   3.102 +            // 
   3.103              // timer
   3.104              // 
   3.105              this.timer.Enabled = true;
   3.106 @@ -394,58 +446,6 @@
   3.107              this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
   3.108              this.toolStripStatusLabelFps.Text = "FPS";
   3.109              // 
   3.110 -            // tabPageClients
   3.111 -            // 
   3.112 -            this.tabPageClients.Controls.Add(this.treeViewClients);
   3.113 -            this.tabPageClients.Location = new System.Drawing.Point(4, 22);
   3.114 -            this.tabPageClients.Name = "tabPageClients";
   3.115 -            this.tabPageClients.Padding = new System.Windows.Forms.Padding(3);
   3.116 -            this.tabPageClients.Size = new System.Drawing.Size(592, 369);
   3.117 -            this.tabPageClients.TabIndex = 2;
   3.118 -            this.tabPageClients.Text = "Clients";
   3.119 -            this.tabPageClients.UseVisualStyleBackColor = true;
   3.120 -            // 
   3.121 -            // treeViewClients
   3.122 -            // 
   3.123 -            this.treeViewClients.Location = new System.Drawing.Point(6, 6);
   3.124 -            this.treeViewClients.Name = "treeViewClients";
   3.125 -            this.treeViewClients.Size = new System.Drawing.Size(439, 357);
   3.126 -            this.treeViewClients.TabIndex = 0;
   3.127 -            this.treeViewClients.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewClients_AfterSelect);
   3.128 -            // 
   3.129 -            // marqueeLabelTop
   3.130 -            // 
   3.131 -            this.marqueeLabelTop.AutoEllipsis = true;
   3.132 -            this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
   3.133 -            this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
   3.134 -            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
   3.135 -            this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
   3.136 -            this.marqueeLabelTop.Name = "marqueeLabelTop";
   3.137 -            this.marqueeLabelTop.OwnTimer = false;
   3.138 -            this.marqueeLabelTop.PixelsPerSecond = 64;
   3.139 -            this.marqueeLabelTop.Separator = "|";
   3.140 -            this.marqueeLabelTop.Size = new System.Drawing.Size(254, 9);
   3.141 -            this.marqueeLabelTop.TabIndex = 2;
   3.142 -            this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
   3.143 -            this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   3.144 -            this.marqueeLabelTop.UseCompatibleTextRendering = true;
   3.145 -            // 
   3.146 -            // marqueeLabelBottom
   3.147 -            // 
   3.148 -            this.marqueeLabelBottom.AutoEllipsis = true;
   3.149 -            this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   3.150 -            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 21);
   3.151 -            this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   3.152 -            this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   3.153 -            this.marqueeLabelBottom.OwnTimer = false;
   3.154 -            this.marqueeLabelBottom.PixelsPerSecond = 64;
   3.155 -            this.marqueeLabelBottom.Separator = null;
   3.156 -            this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
   3.157 -            this.marqueeLabelBottom.TabIndex = 3;
   3.158 -            this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
   3.159 -            this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   3.160 -            this.marqueeLabelBottom.UseCompatibleTextRendering = true;
   3.161 -            // 
   3.162              // MainForm
   3.163              // 
   3.164              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   3.165 @@ -465,9 +465,9 @@
   3.166              this.panelDisplay.ResumeLayout(false);
   3.167              this.tableLayoutPanel.ResumeLayout(false);
   3.168              ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
   3.169 +            this.tabPageClients.ResumeLayout(false);
   3.170              this.statusStrip.ResumeLayout(false);
   3.171              this.statusStrip.PerformLayout();
   3.172 -            this.tabPageClients.ResumeLayout(false);
   3.173              this.ResumeLayout(false);
   3.174              this.PerformLayout();
   3.175  
     4.1 --- a/Server/MainForm.cs	Fri Aug 15 13:26:38 2014 +0200
     4.2 +++ b/Server/MainForm.cs	Sat Aug 16 11:15:42 2014 +0200
     4.3 @@ -20,6 +20,27 @@
     4.4  
     4.5  namespace SharpDisplayManager
     4.6  {
     4.7 +    /// <summary>
     4.8 +    /// A UI thread copy of a client relevant data.
     4.9 +    /// Keeping this copy in the UI thread helps us deal with threading issues.
    4.10 +    /// </summary>
    4.11 +    public class ClientData
    4.12 +    {
    4.13 +        public ClientData(string aSessionId, IDisplayServiceCallback aCallback)
    4.14 +        {
    4.15 +            SessionId = aSessionId;
    4.16 +            Name = "";
    4.17 +            Texts = new List<string>();
    4.18 +            Callback = aCallback;
    4.19 +        }
    4.20 +
    4.21 +        public string SessionId { get; set;}
    4.22 +        public string Name { get; set;}
    4.23 +        public List<string> Texts { get; set;}
    4.24 +        public IDisplayServiceCallback Callback { get; set;}
    4.25 +    }
    4.26 +
    4.27 +
    4.28      public partial class MainForm : Form
    4.29      {
    4.30          DateTime LastTickTime;
    4.31 @@ -30,14 +51,14 @@
    4.32          /// <summary>
    4.33          /// Our collection of clients
    4.34          /// </summary>
    4.35 -        public Dictionary<string, IDisplayServiceCallback> iClients;
    4.36 +        public Dictionary<string, ClientData> iClients;
    4.37          public bool iClosing;
    4.38  
    4.39          public MainForm()
    4.40          {
    4.41              LastTickTime = DateTime.Now;
    4.42              iDisplay = new Display();
    4.43 -            iClients = new Dictionary<string, IDisplayServiceCallback>();
    4.44 +            iClients = new Dictionary<string, ClientData>();
    4.45  
    4.46              InitializeComponent();
    4.47              UpdateStatus();
    4.48 @@ -406,7 +427,7 @@
    4.49                      try
    4.50                      {
    4.51                          Trace.TraceInformation("BroadcastCloseEvent - " + client.Key);
    4.52 -                        client.Value.OnCloseOrder(/*eventData*/);
    4.53 +                        client.Value.Callback.OnCloseOrder(/*eventData*/);
    4.54                      }
    4.55                      catch (Exception ex)
    4.56                      {
    4.57 @@ -454,6 +475,7 @@
    4.58  
    4.59          }
    4.60  
    4.61 +        //Delegates are used for our thread safe method 
    4.62          public delegate void AddClientDelegate(string aSessionId, IDisplayServiceCallback aCallback);
    4.63          public delegate void RemoveClientDelegate(string aSessionId);
    4.64          public delegate void SetTextDelegate(int aLineIndex, string aText);
    4.65 @@ -468,7 +490,7 @@
    4.66          /// <param name="aCallback"></param>
    4.67          public void AddClientThreadSafe(string aSessionId, IDisplayServiceCallback aCallback)
    4.68          {
    4.69 -            if (this.treeViewClients.InvokeRequired)
    4.70 +            if (this.InvokeRequired)
    4.71              {
    4.72                  //Not in the proper thread, invoke ourselves
    4.73                  AddClientDelegate d = new AddClientDelegate(AddClientThreadSafe);
    4.74 @@ -478,9 +500,10 @@
    4.75              {
    4.76                  //We are in the proper thread
    4.77                  //Add this session to our collection of clients
    4.78 -                Program.iMainForm.iClients.Add(aSessionId, aCallback);
    4.79 +                ClientData newClient = new ClientData(aSessionId, aCallback);
    4.80 +                Program.iMainForm.iClients.Add(aSessionId, newClient);
    4.81                  //Add this session to our UI
    4.82 -                Program.iMainForm.treeViewClients.Nodes.Add(aSessionId, aSessionId);
    4.83 +                UpdateClientTreeViewNode(newClient);
    4.84              }
    4.85          }
    4.86  
    4.87 @@ -490,7 +513,7 @@
    4.88          /// <param name="aSessionId"></param>
    4.89          public void RemoveClientThreadSafe(string aSessionId)
    4.90          {
    4.91 -            if (this.treeViewClients.InvokeRequired)
    4.92 +            if (this.InvokeRequired)
    4.93              {
    4.94                  //Not in the proper thread, invoke ourselves
    4.95                  RemoveClientDelegate d = new RemoveClientDelegate(RemoveClientThreadSafe);
    4.96 @@ -499,7 +522,7 @@
    4.97              else
    4.98              {
    4.99                  //We are in the proper thread
   4.100 -                            //Remove this session from both client collection and UI tree view
   4.101 +                //Remove this session from both client collection and UI tree view
   4.102                  if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
   4.103                  {
   4.104                      Program.iMainForm.iClients.Remove(aSessionId);
   4.105 @@ -524,7 +547,7 @@
   4.106          /// <param name="aText"></param>
   4.107          public void SetTextThreadSafe(int aLineIndex, string aText)
   4.108          {
   4.109 -            if (this.treeViewClients.InvokeRequired)
   4.110 +            if (this.InvokeRequired)
   4.111              {
   4.112                  //Not in the proper thread, invoke ourselves
   4.113                  SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe);
   4.114 @@ -536,11 +559,11 @@
   4.115                  //Only support two lines for now
   4.116                  if (aLineIndex == 0)
   4.117                  {
   4.118 -                    Program.iMainForm.marqueeLabelTop.Text = aText;
   4.119 +                    marqueeLabelTop.Text = aText;
   4.120                  }
   4.121                  else if (aLineIndex == 1)
   4.122                  {
   4.123 -                    Program.iMainForm.marqueeLabelBottom.Text = aText;
   4.124 +                    marqueeLabelBottom.Text = aText;
   4.125                  }
   4.126              }
   4.127          }
   4.128 @@ -551,7 +574,7 @@
   4.129          /// <param name="aTexts"></param>
   4.130          public void SetTextsThreadSafe(System.Collections.Generic.IList<string> aTexts)
   4.131          {
   4.132 -            if (this.treeViewClients.InvokeRequired)
   4.133 +            if (this.InvokeRequired)
   4.134              {
   4.135                  //Not in the proper thread, invoke ourselves
   4.136                  SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe);
   4.137 @@ -565,11 +588,11 @@
   4.138                  {
   4.139                      if (i == 0)
   4.140                      {
   4.141 -                        Program.iMainForm.marqueeLabelTop.Text = aTexts[i];
   4.142 +                        marqueeLabelTop.Text = aTexts[i];
   4.143                      }
   4.144                      else if (i == 1)
   4.145                      {
   4.146 -                        Program.iMainForm.marqueeLabelBottom.Text = aTexts[i];
   4.147 +                        marqueeLabelBottom.Text = aTexts[i];
   4.148                      }
   4.149                  }
   4.150              }
   4.151 @@ -592,17 +615,73 @@
   4.152              else
   4.153              {
   4.154                  //We are in the proper thread
   4.155 -                //Remove this session from both client collection and UI tree view
   4.156 -                if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
   4.157 +                //Get our client
   4.158 +                ClientData client = iClients[aSessionId];
   4.159 +                if (client != null)
   4.160                  {
   4.161 -                    //Change our session node text 
   4.162 -                    TreeNode node = Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0];
   4.163 -                    node.Text = aName;
   4.164 +                    //Set its name
   4.165 +                    client.Name = aName;
   4.166 +                    //Update our tree-view
   4.167 +                    UpdateClientTreeViewNode(client);
   4.168 +                }
   4.169 +            }
   4.170 +        }
   4.171 +
   4.172 +        /// <summary>
   4.173 +        /// 
   4.174 +        /// </summary>
   4.175 +        /// <param name="aClient"></param>
   4.176 +        private void UpdateClientTreeViewNode(ClientData aClient)
   4.177 +        {
   4.178 +            if (aClient == null)
   4.179 +            {
   4.180 +                return;
   4.181 +            }
   4.182 +
   4.183 +            TreeNode node = null;
   4.184 +            //Check that our client node already exists
   4.185 +            //Get our client root node using its key which is our session ID
   4.186 +            TreeNode[] nodes = treeViewClients.Nodes.Find(aClient.SessionId, false);
   4.187 +            if (nodes.Count()>0)
   4.188 +            {
   4.189 +                //We already have a node for that client
   4.190 +                node = nodes[0];
   4.191 +                //Clear children as we are going to recreate them below
   4.192 +                node.Nodes.Clear();
   4.193 +            }
   4.194 +            else
   4.195 +            {
   4.196 +                //Client node does not exists create a new one
   4.197 +                treeViewClients.Nodes.Add(aClient.SessionId, aClient.SessionId);
   4.198 +                node = treeViewClients.Nodes.Find(aClient.SessionId, false)[0];
   4.199 +            }
   4.200 +
   4.201 +            if (node != null)
   4.202 +            {
   4.203 +                //Change its name
   4.204 +                if (aClient.Name != "")
   4.205 +                {
   4.206 +                    //We have a name, us it as text for our root node
   4.207 +                    node.Text = aClient.Name;
   4.208                      //Add a child with SessionId
   4.209 -                    node.Nodes.Add(new TreeNode(aSessionId));
   4.210 -
   4.211 -                    //Program.iMainForm.iClients.Remove(aSessionId);
   4.212 -                    //Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
   4.213 +                    node.Nodes.Add(new TreeNode(aClient.SessionId));
   4.214 +                }
   4.215 +                else
   4.216 +                {
   4.217 +                    //No name, use session ID instead
   4.218 +                    node.Text = aClient.SessionId;
   4.219 +                }
   4.220 +        
   4.221 +                if (aClient.Texts.Count > 0)
   4.222 +                {
   4.223 +                    //Create root node for our texts
   4.224 +                    TreeNode textsRoot = new TreeNode("Text");
   4.225 +                    node.Nodes.Add(textsRoot);
   4.226 +                    //For each text add a new entry
   4.227 +                    foreach (string text in aClient.Texts)
   4.228 +                    {
   4.229 +                        textsRoot.Nodes.Add(new TreeNode(text));
   4.230 +                    }
   4.231                  }
   4.232              }
   4.233          }
     5.1 --- a/Server/MarqueeLabel.cs	Fri Aug 15 13:26:38 2014 +0200
     5.2 +++ b/Server/MarqueeLabel.cs	Sat Aug 16 11:15:42 2014 +0200
     5.3 @@ -80,6 +80,7 @@
     5.4              //PixelsPerSecond = 32;
     5.5              LastTickTime = DateTime.Now;
     5.6              PixelsLeft = 0;
     5.7 +            CurrentPosition = 0;
     5.8              iBrush = new SolidBrush(ForeColor);
     5.9          }
    5.10  
    5.11 @@ -203,7 +204,11 @@
    5.12  
    5.13          private void HandleTextSizeChange()
    5.14          {
    5.15 +            //Reset our timer whenever our text changes
    5.16              CurrentPosition = 0;
    5.17 +            LastTickTime = DateTime.Now;
    5.18 +            PixelsLeft = 0;
    5.19 +
    5.20              //For all string measurements and drawing issues refer to the following article:
    5.21              // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
    5.22              //Update text size according to text and font
    5.23 @@ -248,15 +253,18 @@
    5.24              e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
    5.25              if (NeedToScroll())
    5.26              {
    5.27 +                //Draw it all in a single call
    5.28 +                e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
    5.29 +                e.Graphics.DrawString(Text + Separator + Text, Font, iBrush, ClientRectangle, iStringFormat);
    5.30                  //Draw the first one
    5.31 -                e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
    5.32 -                e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    5.33 +                //e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
    5.34 +                //e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    5.35                  //Draw separator
    5.36 -                e.Graphics.TranslateTransform(iTextSize.Width, 0);
    5.37 -                e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
    5.38 +                //e.Graphics.TranslateTransform(iTextSize.Width, 0);
    5.39 +                //e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
    5.40                  //Draw the last one
    5.41 -                e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
    5.42 -                e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    5.43 +                //e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
    5.44 +                //e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    5.45              }
    5.46              else
    5.47              {