Adding the possibility for clients to define a basic layout.
2 // Define a public API for both SharpDisplay client and server to use.
6 using System.Collections.Generic;
9 using System.Threading.Tasks;
10 using System.ServiceModel;
11 using System.Collections;
13 using System.Runtime.Serialization;
16 namespace SharpDisplay
19 /// TextField can be send to our server to be displayed on the screen.
22 public class TableLayout
28 //Alignment = ContentAlignment.MiddleLeft;
31 public TableLayout(int aColumnCount, int aRowCount)
33 ColumnCount = aColumnCount;
38 public int ColumnCount { get; set; }
41 public int RowCount { get; set; }
44 public List<DataField> Cells { get; set; }
51 public class DataField
54 public int Column { get; set; }
57 public int Row { get; set; }
60 public int ColumnSpan { get; set; }
63 public int RowSpan { get; set; }
69 /// TextField can be send to our server to be displayed on the screen.
72 public class TextField : DataField
78 Alignment = ContentAlignment.MiddleLeft;
81 public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
85 Alignment = aAlignment;
89 public int Index { get; set; }
92 public string Text { get; set; }
95 public ContentAlignment Alignment { get; set; }
99 /// Define our SharpDisplay service.
100 /// Clients and servers must implement it to communicate with one another.
101 /// Through this service clients can send requests to a server.
102 /// Through this service a server session can receive requests from a client.
104 [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
105 public interface IService
108 /// Set the name of this client.
109 /// Name is a convenient way to recognize your client.
110 /// Naming you client is not mandatory.
111 /// In the absence of a name the session ID is often used instead.
113 /// <param name="aClientName"></param>
114 [OperationContract(IsOneWay = true)]
115 void SetName(string aClientName);
120 /// <param name="aLayout"></param>
121 [OperationContract(IsOneWay = true)]
122 void SetLayout(TableLayout aLayout);
125 /// Put the given text in the given field on your display.
126 /// Fields are often just lines of text.
128 /// <param name="aTextFieldIndex"></param>
129 [OperationContract(IsOneWay = true)]
130 void SetText(TextField aTextField);
133 /// Allows a client to set multiple text fields at once.
135 /// <param name="aTexts"></param>
136 [OperationContract(IsOneWay = true)]
137 void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
140 /// Provides the number of clients currently connected
142 /// <returns></returns>
143 [OperationContract()]
149 /// SharDisplay callback provides a means for a server to notify its clients.
151 public interface ICallback
153 [OperationContract(IsOneWay = true)]
157 /// Tell our client to close its connection.
158 /// Notably sent when the server is shutting down.
160 [OperationContract(IsOneWay = true)]