Server: Adding scrolling speed setting.
Fixing issue with alignment of newly created text field not being set properly.
Client: Now starting-up first client automatically in debug mode.
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 IsBitmap { get{ return Bitmap!=null;} }
131 public bool IsText { get { return Bitmap == null; } }
133 public bool IsSameLayout(DataField aField)
135 return (aField.ColumnSpan == ColumnSpan && aField.RowSpan == RowSpan);
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 /// Set the given field on your display.
166 /// Fields are often just lines of text or bitmaps.
168 /// <param name="aTextFieldIndex"></param>
169 [OperationContract(IsOneWay = true)]
170 void SetField(DataField aField);
173 /// Allows a client to set multiple fields at once.
175 /// <param name="aFields"></param>
176 [OperationContract(IsOneWay = true)]
177 void SetFields(System.Collections.Generic.IList<DataField> aFields);
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)]