# HG changeset patch # User StephaneLenclud # Date 1453659951 -3600 # Node ID 7b6aa551eb6ccb4b6058282906281ce1fa29f2d5 # Parent e9a5dc5092fd6766941c968fc011da2229b502e1 Adding support for client priorities. diff -r e9a5dc5092fd -r 7b6aa551eb6c Client/MainForm.Designer.cs --- a/Client/MainForm.Designer.cs Fri Jan 22 16:08:22 2016 +0100 +++ b/Client/MainForm.Designer.cs Sun Jan 24 19:25:51 2016 +0100 @@ -41,6 +41,9 @@ this.buttonIndicatorsLayout = new System.Windows.Forms.Button(); this.buttonUpdateTexts = new System.Windows.Forms.Button(); this.buttonLayoutOneTextField = new System.Windows.Forms.Button(); + this.numericUpDownPriority = new System.Windows.Forms.NumericUpDown(); + this.labelPriority = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPriority)).BeginInit(); this.SuspendLayout(); // // buttonSetText @@ -167,11 +170,45 @@ this.buttonLayoutOneTextField.UseVisualStyleBackColor = true; this.buttonLayoutOneTextField.Click += new System.EventHandler(this.buttonLayoutOneTextField_Click); // + // numericUpDownPriority + // + this.numericUpDownPriority.Increment = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownPriority.Location = new System.Drawing.Point(57, 83); + this.numericUpDownPriority.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownPriority.Name = "numericUpDownPriority"; + this.numericUpDownPriority.Size = new System.Drawing.Size(60, 20); + this.numericUpDownPriority.TabIndex = 31; + this.numericUpDownPriority.Value = new decimal(new int[] { + 500, + 0, + 0, + 0}); + this.numericUpDownPriority.ValueChanged += new System.EventHandler(this.numericUpDownPriority_ValueChanged); + // + // labelPriority + // + this.labelPriority.AutoSize = true; + this.labelPriority.Location = new System.Drawing.Point(12, 85); + this.labelPriority.Name = "labelPriority"; + this.labelPriority.Size = new System.Drawing.Size(41, 13); + this.labelPriority.TabIndex = 32; + this.labelPriority.Text = "Priority:"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(443, 252); + this.Controls.Add(this.labelPriority); + this.Controls.Add(this.numericUpDownPriority); this.Controls.Add(this.buttonLayoutOneTextField); this.Controls.Add(this.buttonUpdateTexts); this.Controls.Add(this.buttonIndicatorsLayout); @@ -189,6 +226,7 @@ this.Text = "Client"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPriority)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -209,6 +247,8 @@ private System.Windows.Forms.Button buttonIndicatorsLayout; private System.Windows.Forms.Button buttonUpdateTexts; private System.Windows.Forms.Button buttonLayoutOneTextField; + private System.Windows.Forms.NumericUpDown numericUpDownPriority; + private System.Windows.Forms.Label labelPriority; } } diff -r e9a5dc5092fd -r 7b6aa551eb6c Client/MainForm.cs --- a/Client/MainForm.cs Fri Jan 22 16:08:22 2016 +0100 +++ b/Client/MainForm.cs Sun Jan 24 19:25:51 2016 +0100 @@ -395,5 +395,10 @@ new TextField(textBoxTop.Text, Alignment) }); } + + private void numericUpDownPriority_ValueChanged(object sender, EventArgs e) + { + iClient.SetPriority((uint)numericUpDownPriority.Value); + } } } diff -r e9a5dc5092fd -r 7b6aa551eb6c Client/SharpDisplayClient.csproj --- a/Client/SharpDisplayClient.csproj Fri Jan 22 16:08:22 2016 +0100 +++ b/Client/SharpDisplayClient.csproj Sun Jan 24 19:25:51 2016 +0100 @@ -85,7 +85,7 @@ - ..\packages\SharpLibDisplay.0.2.4\lib\net40\SharpLibDisplay.dll + ..\packages\SharpLibDisplay.0.2.5\lib\net40\SharpLibDisplay.dll True diff -r e9a5dc5092fd -r 7b6aa551eb6c Client/packages.config --- a/Client/packages.config Fri Jan 22 16:08:22 2016 +0100 +++ b/Client/packages.config Sun Jan 24 19:25:51 2016 +0100 @@ -1,4 +1,4 @@  - + \ No newline at end of file diff -r e9a5dc5092fd -r 7b6aa551eb6c Server/ClientData.cs --- a/Server/ClientData.cs Fri Jan 22 16:08:22 2016 +0100 +++ b/Server/ClientData.cs Sun Jan 24 19:25:51 2016 +0100 @@ -18,6 +18,7 @@ { SessionId = aSessionId; Name = ""; + Priority = Priorities.Default; Fields = new List(); Layout = new TableLayout(1, 2); //Default to one column and two rows Callback = aCallback; @@ -26,6 +27,7 @@ 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 ICallback Callback { get; set; } diff -r e9a5dc5092fd -r 7b6aa551eb6c Server/MainForm.cs --- a/Server/MainForm.cs Fri Jan 22 16:08:22 2016 +0100 +++ b/Server/MainForm.cs Sun Jan 24 19:25:51 2016 +0100 @@ -58,7 +58,8 @@ 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 PlainUpdateDelegate(); + public delegate void SetClientPriorityDelegate(string aSessionId, uint aPriority); + public delegate void PlainUpdateDelegate(); public delegate void WndProcDelegate(ref Message aMessage); /// @@ -1758,6 +1759,30 @@ } } + /// + public void SetClientPriorityThreadSafe(string aSessionId, uint aPriority) + { + if (this.InvokeRequired) + { + //Not in the proper thread, invoke ourselves + SetClientPriorityDelegate d = new SetClientPriorityDelegate(SetClientPriorityThreadSafe); + this.Invoke(d, new object[] { aSessionId, aPriority }); + } + else + { + //We are in the proper thread + //Get our client + ClientData client = iClients[aSessionId]; + if (client != null) + { + //Set its name + client.Priority = aPriority; + //Update our tree-view + UpdateClientTreeViewNode(client); + } + } + } + /// /// /// @@ -1851,9 +1876,9 @@ if (node != null) { //Change its name - if (aClient.Name != "") + if (!String.IsNullOrEmpty(aClient.Name)) { - //We have a name, us it as text for our root node + //We have a name, use it as text for our root node node.Text = aClient.Name; //Add a child with SessionId node.Nodes.Add(new TreeNode(aClient.SessionId)); @@ -1864,6 +1889,9 @@ node.Text = aClient.SessionId; } + //Display client priority + node.Nodes.Add(new TreeNode("Priority: " + aClient.Priority)); + if (aClient.Fields.Count > 0) { //Create root node for our texts diff -r e9a5dc5092fd -r 7b6aa551eb6c Server/Session.cs --- a/Server/Session.cs Fri Jan 22 16:08:22 2016 +0100 +++ b/Server/Session.cs Sun Jan 24 19:25:51 2016 +0100 @@ -40,6 +40,7 @@ { public string SessionId { get; set; } public string Name { get; set; } + public uint Priority { get; set; } Session() { @@ -73,6 +74,16 @@ //callback.OnConnected(); } + /// + /// + /// + /// + public void SetPriority(uint aPriority) + { + Priority = aPriority; + SharpDisplayManager.Program.iMainForm.SetClientPriorityThreadSafe(SessionId, Priority); + } + public void SetLayout(TableLayout aLayout) { SharpDisplayManager.Program.iMainForm.SetClientLayoutThreadSafe(SessionId, aLayout); diff -r e9a5dc5092fd -r 7b6aa551eb6c Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Fri Jan 22 16:08:22 2016 +0100 +++ b/Server/SharpDisplayManager.csproj Sun Jan 24 19:25:51 2016 +0100 @@ -121,7 +121,7 @@ ..\packages\NAudio.1.7.3\lib\net35\NAudio.dll - ..\packages\SharpLibDisplay.0.2.4\lib\net40\SharpLibDisplay.dll + ..\packages\SharpLibDisplay.0.2.5\lib\net40\SharpLibDisplay.dll True diff -r e9a5dc5092fd -r 7b6aa551eb6c Server/packages.config --- a/Server/packages.config Fri Jan 22 16:08:22 2016 +0100 +++ b/Server/packages.config Sun Jan 24 19:25:51 2016 +0100 @@ -2,7 +2,7 @@ - +