Now having a single class for both text and bitmap field.
Thus we should soon be able to use common functions to pass in fields.
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
71 Alignment = ContentAlignment.MiddleLeft;
77 public DataField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
83 Alignment = aAlignment;
89 public DataField(int aIndex, Bitmap aBitmap)
97 Alignment = ContentAlignment.MiddleLeft;
101 //Generic layout properties
103 public int Index { get; set; }
106 public int Column { get; set; }
109 public int Row { get; set; }
112 public int ColumnSpan { get; set; }
115 public int RowSpan { get; set; }
119 public string Text { get; set; }
122 public ContentAlignment Alignment { get; set; }
126 public Bitmap Bitmap { get; set; }
129 public bool HasBitmap { get{ return Bitmap!=null;} }
134 /// Define our SharpDisplay service.
135 /// Clients and servers must implement it to communicate with one another.
136 /// Through this service clients can send requests to a server.
137 /// Through this service a server session can receive requests from a client.
139 [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
140 public interface IService
143 /// Set the name of this client.
144 /// Name is a convenient way to recognize your client.
145 /// Naming you client is not mandatory.
146 /// In the absence of a name the session ID is often used instead.
148 /// <param name="aClientName"></param>
149 [OperationContract(IsOneWay = true)]
150 void SetName(string aClientName);
154 /// <param name="aLayout"></param>
155 [OperationContract(IsOneWay = true)]
156 void SetLayout(TableLayout aLayout);
159 /// Put the given text in the given field on your display.
160 /// Fields are often just lines of text.
162 /// <param name="aTextFieldIndex"></param>
163 [OperationContract(IsOneWay = true)]
164 void SetText(DataField aField);
167 /// Allows a client to set multiple text fields at once.
169 /// <param name="aTexts"></param>
170 [OperationContract(IsOneWay = true)]
171 void SetTexts(System.Collections.Generic.IList<DataField> aFields);
174 /// Put the given bitmap in the given field on your display.
175 /// Fields are often just lines of text.
177 /// <param name="aBitmapField"></param>
178 [OperationContract(IsOneWay = true)]
179 void SetBitmap(DataField aBitmapField);
182 /// Provides the number of clients currently connected
184 /// <returns></returns>
185 [OperationContract()]
191 /// SharDisplay callback provides a means for a server to notify its clients.
193 public interface ICallback
195 [OperationContract(IsOneWay = true)]
199 /// Tell our client to close its connection.
200 /// Notably sent when the server is shutting down.
202 [OperationContract(IsOneWay = true)]