Interface/Interface.cs
author sl
Sun, 31 Aug 2014 17:44:18 +0200
changeset 51 ae2052cc89ef
parent 32 4c416d2878dd
child 55 b5ed2e29be23
permissions -rw-r--r--
Fixing issue with interval zero exception.
Adding support for GP1212A02 firmware revision display.
Fixing issue that would always auto connect on stratup.
     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 SharpDisplayInterface
    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(IDisplayServiceCallback),
    43                         SessionMode = SessionMode.Required)]
    44     public interface IDisplayService
    45     {
    46         /// <summary>
    47         /// Set the name of this client.
    48         /// Name is a convenient way to recognize your client.
    49         /// Naming you client is not mandatory.
    50         /// In the absence of a name the session ID is often used instead.
    51         /// </summary>
    52         /// <param name="aClientName"></param>
    53         [OperationContract(IsOneWay = true)]
    54         void SetName(string aClientName);
    55 
    56         /// <summary>
    57         /// Put the given text in the given field on your display.
    58         /// Fields are often just lines of text.
    59         /// </summary>
    60         /// <param name="aTextFieldIndex"></param>
    61         [OperationContract(IsOneWay = true)]
    62         void SetText(TextField aTextField);
    63 
    64         /// <summary>
    65         /// Allows a client to set multiple text fields at once.
    66         /// </summary>
    67         /// <param name="aTexts"></param>
    68         [OperationContract(IsOneWay = true)]
    69         void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
    70 
    71         /// <summary>
    72         /// Provides the number of clients currently connected
    73         /// </summary>
    74         /// <returns></returns>
    75         [OperationContract()]
    76         int ClientCount();
    77 
    78     }
    79 
    80 
    81     public interface IDisplayServiceCallback
    82     {
    83         [OperationContract(IsOneWay = true)]
    84         void OnConnected();
    85 
    86         /// <summary>
    87         /// Tell our client to close its connection.
    88         /// Notably sent when the server is shutting down.
    89         /// </summary>
    90         [OperationContract(IsOneWay = true)]
    91         void OnCloseOrder();
    92     }
    93 
    94 
    95 
    96 }