author | sl |
Thu, 14 Aug 2014 10:41:44 +0200 | |
changeset 28 | 2aa3974c485f |
parent 22 | cac466b1b6e6 |
child 29 | c4e03315035c |
permissions | -rw-r--r-- |
sl@17 | 1 |
using System; |
sl@17 | 2 |
using System.Windows.Forms; |
sl@19 | 3 |
using System.Collections; |
sl@20 | 4 |
using System.ServiceModel; |
sl@21 | 5 |
using System.Collections.Generic; |
sl@21 | 6 |
using System.Linq; |
sl@22 | 7 |
using SharpDisplayInterface; |
sl@17 | 8 |
|
sl@17 | 9 |
namespace SharpDisplayManager |
sl@17 | 10 |
{ |
sl@17 | 11 |
/// <summary> |
sl@17 | 12 |
/// Implement our display service. |
sl@17 | 13 |
/// This class is instantiated anew whenever a client send a request. |
sl@17 | 14 |
/// </summary> |
sl@20 | 15 |
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)] |
sl@17 | 16 |
class DisplayServer : IDisplayService |
sl@17 | 17 |
{ |
sl@17 | 18 |
//From IDisplayService |
sl@19 | 19 |
public void SetTexts(System.Collections.Generic.IList<string> aTexts) |
sl@19 | 20 |
{ |
sl@19 | 21 |
//Only support two lines for now |
sl@19 | 22 |
for (int i=0; i<aTexts.Count; i++) |
sl@19 | 23 |
{ |
sl@19 | 24 |
if (i == 0) |
sl@19 | 25 |
{ |
sl@19 | 26 |
Program.iMainForm.marqueeLabelTop.Text = aTexts[i]; |
sl@19 | 27 |
} |
sl@19 | 28 |
else if (i == 1) |
sl@19 | 29 |
{ |
sl@19 | 30 |
Program.iMainForm.marqueeLabelBottom.Text = aTexts[i]; |
sl@19 | 31 |
} |
sl@19 | 32 |
} |
sl@19 | 33 |
} |
sl@22 | 34 |
|
sl@19 | 35 |
// |
sl@17 | 36 |
public void SetText(int aLineIndex, string aText) |
sl@17 | 37 |
{ |
sl@19 | 38 |
//Only support two lines for now |
sl@19 | 39 |
if (aLineIndex == 0) |
sl@19 | 40 |
{ |
sl@19 | 41 |
Program.iMainForm.marqueeLabelTop.Text = aText; |
sl@19 | 42 |
} |
sl@19 | 43 |
else if (aLineIndex == 1) |
sl@19 | 44 |
{ |
sl@19 | 45 |
Program.iMainForm.marqueeLabelBottom.Text = aText; |
sl@19 | 46 |
} |
sl@17 | 47 |
} |
sl@17 | 48 |
|
sl@20 | 49 |
// |
sl@20 | 50 |
public void Connect(string aClientName) |
sl@20 | 51 |
{ |
sl@26 | 52 |
Disconnect(aClientName); |
sl@26 | 53 |
|
sl@26 | 54 |
//Register our client and its callback interface |
sl@20 | 55 |
IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>(); |
sl@21 | 56 |
Program.iMainForm.iClients.Add(aClientName, callback); |
sl@22 | 57 |
|
sl@21 | 58 |
//For some reason MP still hangs on that one |
sl@21 | 59 |
//callback.OnConnected(); |
sl@20 | 60 |
} |
sl@20 | 61 |
|
sl@26 | 62 |
/// |
sl@26 | 63 |
public void Disconnect(string aClientName) |
sl@26 | 64 |
{ |
sl@26 | 65 |
//remove the old client if any |
sl@26 | 66 |
if (Program.iMainForm.iClients.Keys.Contains(aClientName)) |
sl@26 | 67 |
{ |
sl@26 | 68 |
Program.iMainForm.iClients.Remove(aClientName); |
sl@26 | 69 |
} |
sl@26 | 70 |
} |
sl@26 | 71 |
|
sl@21 | 72 |
|
sl@17 | 73 |
} |
sl@17 | 74 |
|
sl@17 | 75 |
} |