Ground work for supporting generic field and bitmap ones.
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;
14 using System.Windows.Forms;
17 namespace SharpDisplay
20 /// For client to specify a specific layout.
23 public class TableLayout
27 Columns = new List<ColumnStyle>();
28 Rows = new List<RowStyle>();
29 Cells = new List<DataField>();
32 public TableLayout(int aColumnCount, int aRowCount)
34 Columns = new List<ColumnStyle>();
35 Rows = new List<RowStyle>();
37 for (int i = 0; i < aColumnCount; i++)
39 Columns.Add(new ColumnStyle(SizeType.Percent, 100 / aColumnCount));
42 for (int i = 0; i < aRowCount; i++)
44 Rows.Add(new RowStyle(SizeType.Percent, 100 / aRowCount));
49 public List<DataField> Cells { get; set; }
52 public List<ColumnStyle> Columns { get; set; }
55 public List<RowStyle> Rows { get; set; }
62 public class DataField
72 public int Index { get; set; }
75 public int Column { get; set; }
78 public int Row { get; set; }
81 public int ColumnSpan { get; set; }
84 public int RowSpan { get; set; }
90 /// TextField can be send to our server to be displayed on the screen.
93 public class TextField : DataField
99 Alignment = ContentAlignment.MiddleLeft;
102 public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
106 Alignment = aAlignment;
110 public string Text { get; set; }
113 public ContentAlignment Alignment { get; set; }
117 /// TextField can be send to our server to be displayed on the screen.
120 public class BitmapField : DataField
126 public BitmapField(int aIndex, Bitmap aBitmap)
133 public Bitmap Bitmap { get; set; }
137 /// Define our SharpDisplay service.
138 /// Clients and servers must implement it to communicate with one another.
139 /// Through this service clients can send requests to a server.
140 /// Through this service a server session can receive requests from a client.
142 [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
143 public interface IService
146 /// Set the name of this client.
147 /// Name is a convenient way to recognize your client.
148 /// Naming you client is not mandatory.
149 /// In the absence of a name the session ID is often used instead.
151 /// <param name="aClientName"></param>
152 [OperationContract(IsOneWay = true)]
153 void SetName(string aClientName);
157 /// <param name="aLayout"></param>
158 [OperationContract(IsOneWay = true)]
159 void SetLayout(TableLayout aLayout);
162 /// Put the given text in the given field on your display.
163 /// Fields are often just lines of text.
165 /// <param name="aTextFieldIndex"></param>
166 [OperationContract(IsOneWay = true)]
167 void SetText(TextField aTextField);
170 /// Allows a client to set multiple text fields at once.
172 /// <param name="aTexts"></param>
173 [OperationContract(IsOneWay = true)]
174 void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
177 /// Put the given bitmap in the given field on your display.
178 /// Fields are often just lines of text.
180 /// <param name="aBitmapField"></param>
181 [OperationContract(IsOneWay = true)]
182 void SetBitmap(BitmapField aBitmapField);
185 /// Provides the number of clients currently connected
187 /// <returns></returns>
188 [OperationContract()]
194 /// SharDisplay callback provides a means for a server to notify its clients.
196 public interface ICallback
198 [OperationContract(IsOneWay = true)]
202 /// Tell our client to close its connection.
203 /// Notably sent when the server is shutting down.
205 [OperationContract(IsOneWay = true)]