1.1 --- a/Server/MainForm.cs Mon Jan 25 21:26:30 2016 +0100
1.2 +++ b/Server/MainForm.cs Mon Jan 25 23:16:35 2016 +0100
1.3 @@ -1494,6 +1494,25 @@
1.4 }
1.5 }
1.6
1.7 +
1.8 + /// <summary>
1.9 + /// Find the client with the highest priority if any.
1.10 + /// </summary>
1.11 + /// <returns>Our highest priority client or null if not a single client is connected.</returns>
1.12 + public ClientData FindHighestPriorityClient()
1.13 + {
1.14 + ClientData highestPriorityClient = null;
1.15 + foreach (var client in iClients)
1.16 + {
1.17 + if (highestPriorityClient == null || client.Value.Priority > highestPriorityClient.Priority)
1.18 + {
1.19 + highestPriorityClient = client.Value;
1.20 + }
1.21 + }
1.22 +
1.23 + return highestPriorityClient;
1.24 + }
1.25 +
1.26 /// <summary>
1.27 ///
1.28 /// </summary>
1.29 @@ -1516,7 +1535,19 @@
1.30 Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
1.31 }
1.32
1.33 - if (iClients.Count == 0)
1.34 + if (iCurrentClientSessionId == aSessionId)
1.35 + {
1.36 + //The current client is closing
1.37 + iCurrentClientData = null;
1.38 + //Find the client with the highest priority and set it as current
1.39 + ClientData newCurrentClient = FindHighestPriorityClient();
1.40 + if (newCurrentClient!=null)
1.41 + {
1.42 + SetCurrentClient(newCurrentClient.SessionId, true);
1.43 + }
1.44 + }
1.45 +
1.46 + if (iClients.Count == 0)
1.47 {
1.48 //Clear our screen when last client disconnects
1.49 ClearLayout();
1.50 @@ -1789,6 +1820,12 @@
1.51 client.Priority = aPriority;
1.52 //Update our tree-view
1.53 UpdateClientTreeViewNode(client);
1.54 + //Change our current client as per new priority
1.55 + ClientData newCurrentClient = FindHighestPriorityClient();
1.56 + if (newCurrentClient!=null)
1.57 + {
1.58 + SetCurrentClient(newCurrentClient.SessionId);
1.59 + }
1.60 }
1.61 }
1.62 }
2.1 --- a/Server/SharpDisplayManager.csproj Mon Jan 25 21:26:30 2016 +0100
2.2 +++ b/Server/SharpDisplayManager.csproj Mon Jan 25 23:16:35 2016 +0100
2.3 @@ -34,7 +34,7 @@
2.4 <WebPage>index.htm</WebPage>
2.5 <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
2.6 <ApplicationRevision>0</ApplicationRevision>
2.7 - <ApplicationVersion>0.8.4.0</ApplicationVersion>
2.8 + <ApplicationVersion>0.8.5.0</ApplicationVersion>
2.9 <UseApplicationTrust>false</UseApplicationTrust>
2.10 <CreateDesktopShortcut>true</CreateDesktopShortcut>
2.11 <PublishWizardCompleted>true</PublishWizardCompleted>