TableLayout now support row and column styles.
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 /// TextField can be send to our server to be displayed on the screen.
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; }
66 public class DataField
69 public int Column { get; set; }
72 public int Row { get; set; }
75 public int ColumnSpan { get; set; }
78 public int RowSpan { get; set; }
84 /// TextField can be send to our server to be displayed on the screen.
87 public class TextField : DataField
93 Alignment = ContentAlignment.MiddleLeft;
96 public TextField(int aIndex, string aText = "", ContentAlignment aAlignment = ContentAlignment.MiddleLeft)
100 Alignment = aAlignment;
104 public int Index { get; set; }
107 public string Text { get; set; }
110 public ContentAlignment Alignment { get; set; }
114 /// Define our SharpDisplay service.
115 /// Clients and servers must implement it to communicate with one another.
116 /// Through this service clients can send requests to a server.
117 /// Through this service a server session can receive requests from a client.
119 [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
120 public interface IService
123 /// Set the name of this client.
124 /// Name is a convenient way to recognize your client.
125 /// Naming you client is not mandatory.
126 /// In the absence of a name the session ID is often used instead.
128 /// <param name="aClientName"></param>
129 [OperationContract(IsOneWay = true)]
130 void SetName(string aClientName);
135 /// <param name="aLayout"></param>
136 [OperationContract(IsOneWay = true)]
137 void SetLayout(TableLayout aLayout);
140 /// Put the given text in the given field on your display.
141 /// Fields are often just lines of text.
143 /// <param name="aTextFieldIndex"></param>
144 [OperationContract(IsOneWay = true)]
145 void SetText(TextField aTextField);
148 /// Allows a client to set multiple text fields at once.
150 /// <param name="aTexts"></param>
151 [OperationContract(IsOneWay = true)]
152 void SetTexts(System.Collections.Generic.IList<TextField> aTextFields);
155 /// Provides the number of clients currently connected
157 /// <returns></returns>
158 [OperationContract()]
164 /// SharDisplay callback provides a means for a server to notify its clients.
166 public interface ICallback
168 [OperationContract(IsOneWay = true)]
172 /// Tell our client to close its connection.
173 /// Notably sent when the server is shutting down.
175 [OperationContract(IsOneWay = true)]