author | sl |
Mon, 22 Sep 2014 16:04:26 +0200 | |
changeset 62 | ac698f4e1b36 |
parent 56 | e86d84480b32 |
child 63 | cd9924457275 |
permissions | -rw-r--r-- |
sl@56 | 1 |
// |
sl@56 | 2 |
// Define a public API for both SharpDisplay client and server to use. |
sl@56 | 3 |
// |
sl@56 | 4 |
|
sl@56 | 5 |
using System; |
sl@24 | 6 |
using System.Collections.Generic; |
sl@24 | 7 |
using System.Linq; |
sl@24 | 8 |
using System.Text; |
sl@24 | 9 |
using System.Threading.Tasks; |
sl@24 | 10 |
using System.ServiceModel; |
sl@24 | 11 |
using System.Collections; |
sl@43 | 12 |
using System.Drawing; |
sl@43 | 13 |
using System.Runtime.Serialization; |
sl@24 | 14 |
|
sl@24 | 15 |
|
sl@55 | 16 |
namespace SharpDisplay |
sl@24 | 17 |
{ |
sl@56 | 18 |
/// <summary> |
sl@56 | 19 |
/// TextField can be send to our server to be displayed on the screen. |
sl@56 | 20 |
/// </summary> |
sl@43 | 21 |
[DataContract] |
sl@62 | 22 |
public class TableLayout |
sl@62 | 23 |
{ |
sl@62 | 24 |
public TableLayout() |
sl@62 | 25 |
{ |
sl@62 | 26 |
ColumnCount = 0; |
sl@62 | 27 |
RowCount = 0; |
sl@62 | 28 |
//Alignment = ContentAlignment.MiddleLeft; |
sl@62 | 29 |
} |
sl@62 | 30 |
|
sl@62 | 31 |
public TableLayout(int aColumnCount, int aRowCount) |
sl@62 | 32 |
{ |
sl@62 | 33 |
ColumnCount = aColumnCount; |
sl@62 | 34 |
RowCount = aRowCount; |
sl@62 | 35 |
} |
sl@62 | 36 |
|
sl@62 | 37 |
[DataMember] |
sl@62 | 38 |
public int ColumnCount { get; set; } |
sl@62 | 39 |
|
sl@62 | 40 |
[DataMember] |
sl@62 | 41 |
public int RowCount { get; set; } |
sl@62 | 42 |
|
sl@62 | 43 |
[DataMember] |
sl@62 | 44 |
public List<DataField> Cells { get; set; } |
sl@62 | 45 |
} |
sl@62 | 46 |
|
sl@62 | 47 |
/// <summary> |
sl@62 | 48 |
/// |
sl@62 | 49 |
/// </summary> |
sl@62 | 50 |
[DataContract] |
sl@62 | 51 |
public class DataField |
sl@62 | 52 |
{ |
sl@62 | 53 |
[DataMember] |
sl@62 | 54 |
public int Column { get; set; } |
sl@62 | 55 |
|
sl@62 | 56 |
[DataMember] |
sl@62 | 57 |
public int Row { get; set; } |
sl@62 | 58 |
|
sl@62 | 59 |
[DataMember] |
sl@62 | 60 |
public int ColumnSpan { get; set; } |
sl@62 | 61 |
|
sl@62 | 62 |
[DataMember] |
sl@62 | 63 |
public int RowSpan { get; set; } |
sl@62 | 64 |
|
sl@62 | 65 |
} |
sl@62 | 66 |
|
sl@62 | 67 |
|
sl@62 | 68 |
/// <summary> |
sl@62 | 69 |
/// TextField can be send to our server to be displayed on the screen. |
sl@62 | 70 |
/// </summary> |
sl@62 | 71 |
[DataContract] |
sl@62 | 72 |
public class TextField : DataField |
sl@43 | 73 |
{ |
sl@43 | 74 |
public TextField() |
sl@43 | 75 |
{ |
sl@43 | 76 |
Index = 0; |
sl@43 | 77 |
Text = ""; |
sl@43 | 78 |
Alignment = ContentAlignment.MiddleLeft; |
sl@43 | 79 |
} |
sl@43 | 80 |
|
sl@43 | 81 |
public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft) |
sl@43 | 82 |
{ |
sl@43 | 83 |
Index = aIndex; |
sl@43 | 84 |
Text = aText; |
sl@43 | 85 |
Alignment = aAlignment; |
sl@43 | 86 |
} |
sl@43 | 87 |
|
sl@43 | 88 |
[DataMember] |
sl@43 | 89 |
public int Index { get; set; } |
sl@43 | 90 |
|
sl@43 | 91 |
[DataMember] |
sl@43 | 92 |
public string Text { get; set; } |
sl@43 | 93 |
|
sl@43 | 94 |
[DataMember] |
sl@43 | 95 |
public ContentAlignment Alignment { get; set; } |
sl@43 | 96 |
} |
sl@43 | 97 |
|
sl@56 | 98 |
/// <summary> |
sl@56 | 99 |
/// Define our SharpDisplay service. |
sl@56 | 100 |
/// Clients and servers must implement it to communicate with one another. |
sl@56 | 101 |
/// Through this service clients can send requests to a server. |
sl@56 | 102 |
/// Through this service a server session can receive requests from a client. |
sl@56 | 103 |
/// </summary> |
sl@55 | 104 |
[ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)] |
sl@55 | 105 |
public interface IService |
sl@24 | 106 |
{ |
sl@32 | 107 |
/// <summary> |
sl@32 | 108 |
/// Set the name of this client. |
sl@32 | 109 |
/// Name is a convenient way to recognize your client. |
sl@32 | 110 |
/// Naming you client is not mandatory. |
sl@32 | 111 |
/// In the absence of a name the session ID is often used instead. |
sl@32 | 112 |
/// </summary> |
sl@32 | 113 |
/// <param name="aClientName"></param> |
sl@24 | 114 |
[OperationContract(IsOneWay = true)] |
sl@32 | 115 |
void SetName(string aClientName); |
sl@24 | 116 |
|
sl@62 | 117 |
|
sl@62 | 118 |
/// <summary> |
sl@62 | 119 |
/// </summary> |
sl@62 | 120 |
/// <param name="aLayout"></param> |
sl@62 | 121 |
[OperationContract(IsOneWay = true)] |
sl@62 | 122 |
void SetLayout(TableLayout aLayout); |
sl@62 | 123 |
|
sl@32 | 124 |
/// <summary> |
sl@32 | 125 |
/// Put the given text in the given field on your display. |
sl@32 | 126 |
/// Fields are often just lines of text. |
sl@32 | 127 |
/// </summary> |
sl@43 | 128 |
/// <param name="aTextFieldIndex"></param> |
sl@24 | 129 |
[OperationContract(IsOneWay = true)] |
sl@43 | 130 |
void SetText(TextField aTextField); |
sl@26 | 131 |
|
sl@32 | 132 |
/// <summary> |
sl@32 | 133 |
/// Allows a client to set multiple text fields at once. |
sl@32 | 134 |
/// </summary> |
sl@32 | 135 |
/// <param name="aTexts"></param> |
sl@24 | 136 |
[OperationContract(IsOneWay = true)] |
sl@43 | 137 |
void SetTexts(System.Collections.Generic.IList<TextField> aTextFields); |
sl@32 | 138 |
|
sl@32 | 139 |
/// <summary> |
sl@32 | 140 |
/// Provides the number of clients currently connected |
sl@32 | 141 |
/// </summary> |
sl@32 | 142 |
/// <returns></returns> |
sl@32 | 143 |
[OperationContract()] |
sl@32 | 144 |
int ClientCount(); |
sl@32 | 145 |
|
sl@24 | 146 |
} |
sl@24 | 147 |
|
sl@56 | 148 |
/// <summary> |
sl@56 | 149 |
/// SharDisplay callback provides a means for a server to notify its clients. |
sl@56 | 150 |
/// </summary> |
sl@55 | 151 |
public interface ICallback |
sl@24 | 152 |
{ |
sl@24 | 153 |
[OperationContract(IsOneWay = true)] |
sl@24 | 154 |
void OnConnected(); |
sl@24 | 155 |
|
sl@32 | 156 |
/// <summary> |
sl@32 | 157 |
/// Tell our client to close its connection. |
sl@32 | 158 |
/// Notably sent when the server is shutting down. |
sl@32 | 159 |
/// </summary> |
sl@24 | 160 |
[OperationContract(IsOneWay = true)] |
sl@32 | 161 |
void OnCloseOrder(); |
sl@24 | 162 |
} |
sl@24 | 163 |
|
sl@24 | 164 |
|
sl@24 | 165 |
|
sl@24 | 166 |
} |