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