Interface/Interface.cs
author sl
Sun, 21 Sep 2014 13:15:52 +0200
changeset 55 b5ed2e29be23
parent 43 86aad774b532
child 56 e86d84480b32
permissions -rw-r--r--
Renaming stuff.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 using System.ServiceModel;
     7 using System.Collections;
     8 using System.Drawing;
     9 using System.Runtime.Serialization;
    10 
    11 
    12 namespace SharpDisplay
    13 {
    14     [DataContract]
    15     public class TextField
    16     {
    17         public TextField()
    18         {
    19             Index = 0;
    20             Text = "";
    21             Alignment = ContentAlignment.MiddleLeft;
    22         }
    23 
    24         public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
    25         {
    26             Index = aIndex;
    27             Text = aText;
    28             Alignment = aAlignment;
    29         }
    30 
    31         [DataMember]
    32         public int Index { get; set; }
    33 
    34         [DataMember]
    35         public string Text { get; set; }
    36 
    37         [DataMember]
    38         public ContentAlignment Alignment { get; set; }
    39     }
    40 
    41 
    42     [ServiceContract(   CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
    43     public interface IService
    44     {
    45         /// <summary>
    46         /// Set the name of this client.
    47         /// Name is a convenient way to recognize your client.
    48         /// Naming you client is not mandatory.
    49         /// In the absence of a name the session ID is often used instead.
    50         /// </summary>
    51         /// <param name="aClientName"></param>
    52         [OperationContract(IsOneWay = true)]
    53         void SetName(string aClientName);
    54 
    55         /// <summary>
    56         /// Put the given text in the given field on your display.
    57         /// Fields are often just lines of text.
    58         /// </summary>
    59         /// <param name="aTextFieldIndex"></param>
    60         [OperationContract(IsOneWay = true)]
    61         void SetText(TextField aTextField);
    62 
    63         /// <summary>
    64         /// Allows a client to set multiple text fields at once.
    65         /// </summary>
    66         /// <param name="aTexts"></param>
    67         [OperationContract(IsOneWay = true)]
    68         void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
    69 
    70         /// <summary>
    71         /// Provides the number of clients currently connected
    72         /// </summary>
    73         /// <returns></returns>
    74         [OperationContract()]
    75         int ClientCount();
    76 
    77     }
    78 
    79 
    80     public interface ICallback
    81     {
    82         [OperationContract(IsOneWay = true)]
    83         void OnConnected();
    84 
    85         /// <summary>
    86         /// Tell our client to close its connection.
    87         /// Notably sent when the server is shutting down.
    88         /// </summary>
    89         [OperationContract(IsOneWay = true)]
    90         void OnCloseOrder();
    91     }
    92 
    93 
    94 
    95 }