Adding bitmap field object.
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
23 /// For client to specify a specific layout.
26 public class TableLayout
30 Columns = new List<ColumnStyle>();
31 Rows = new List<RowStyle>();
32 Cells = new List<DataField>();
35 public TableLayout(int aColumnCount, int aRowCount)
37 Columns = new List<ColumnStyle>();
38 Rows = new List<RowStyle>();
40 for (int i = 0; i < aColumnCount; i++)
42 Columns.Add(new ColumnStyle(SizeType.Percent, 100 / aColumnCount));
45 for (int i = 0; i < aRowCount; i++)
47 Rows.Add(new RowStyle(SizeType.Percent, 100 / aRowCount));
52 public List<DataField> Cells { get; set; }
55 public List<ColumnStyle> Columns { get; set; }
58 public List<RowStyle> Rows { get; set; }
65 public class DataField
75 public int Index { get; set; }
78 public int Column { get; set; }
81 public int Row { get; set; }
84 public int ColumnSpan { get; set; }
87 public int RowSpan { get; set; }
93 /// TextField can be send to our server to be displayed on the screen.
96 public class TextField : DataField
102 Alignment = ContentAlignment.MiddleLeft;
105 public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
109 Alignment = aAlignment;
113 public string Text { get; set; }
116 public ContentAlignment Alignment { get; set; }
120 /// TextField can be send to our server to be displayed on the screen.
123 public class BitmapField : DataField
129 public BitmapField(int aIndex, Bitmap aBitmap)
136 public Bitmap Bitmap { get; set; }
140 /// Define our SharpDisplay service.
141 /// Clients and servers must implement it to communicate with one another.
142 /// Through this service clients can send requests to a server.
143 /// Through this service a server session can receive requests from a client.
145 [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
146 public interface IService
149 /// Set the name of this client.
150 /// Name is a convenient way to recognize your client.
151 /// Naming you client is not mandatory.
152 /// In the absence of a name the session ID is often used instead.
154 /// <param name="aClientName"></param>
155 [OperationContract(IsOneWay = true)]
156 void SetName(string aClientName);
160 /// <param name="aLayout"></param>
161 [OperationContract(IsOneWay = true)]
162 void SetLayout(TableLayout aLayout);
165 /// Put the given text in the given field on your display.
166 /// Fields are often just lines of text.
168 /// <param name="aTextFieldIndex"></param>
169 [OperationContract(IsOneWay = true)]
170 void SetText(TextField aTextField);
173 /// Allows a client to set multiple text fields at once.
175 /// <param name="aTexts"></param>
176 [OperationContract(IsOneWay = true)]
177 void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
180 /// Provides the number of clients currently connected
182 /// <returns></returns>
183 [OperationContract()]
189 /// SharDisplay callback provides a means for a server to notify its clients.
191 public interface ICallback
193 [OperationContract(IsOneWay = true)]
197 /// Tell our client to close its connection.
198 /// Notably sent when the server is shutting down.
200 [OperationContract(IsOneWay = true)]