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