GUI/SharpDisplayClient.cs
branchMiniDisplay
changeset 446 0cb7b9f6a6f8
parent 445 fe4c711fd7f8
child 447 af40a92d480d
     1.1 --- a/GUI/SharpDisplayClient.cs	Sun Sep 21 21:55:36 2014 +0200
     1.2 +++ b/GUI/SharpDisplayClient.cs	Mon Sep 22 21:59:11 2014 +0200
     1.3 @@ -26,11 +26,75 @@
     1.4  
     1.5  namespace SharpDisplay
     1.6  {
     1.7 -    //That contract need to be in the same namespace than the original assembly
     1.8 -    //otherwise our parameter won't make to the server.
     1.9 -    //See: http://stackoverflow.com/questions/14956377/passing-an-object-using-datacontract-in-wcf/25455292#25455292
    1.10 +
    1.11 +
    1.12 +
    1.13 +    /// <summary>
    1.14 +    /// For client to specify a specific layout.
    1.15 +    /// </summary>
    1.16      [DataContract]
    1.17 -    public class TextField
    1.18 +    public class TableLayout
    1.19 +    {
    1.20 +        public TableLayout()
    1.21 +        {
    1.22 +            Columns = new List<ColumnStyle>();
    1.23 +            Rows = new List<RowStyle>();
    1.24 +            Cells = new List<DataField>();
    1.25 +        }
    1.26 +
    1.27 +        public TableLayout(int aColumnCount, int aRowCount)
    1.28 +        {
    1.29 +            Columns = new List<ColumnStyle>();
    1.30 +            Rows = new List<RowStyle>();
    1.31 +
    1.32 +            for (int i = 0; i < aColumnCount; i++)
    1.33 +            {
    1.34 +                Columns.Add(new ColumnStyle(SizeType.Percent, 100 / aColumnCount));
    1.35 +            }
    1.36 +
    1.37 +            for (int i = 0; i < aRowCount; i++)
    1.38 +            {
    1.39 +                Rows.Add(new RowStyle(SizeType.Percent, 100 / aRowCount));
    1.40 +            }
    1.41 +        }
    1.42 +
    1.43 +        [DataMember]
    1.44 +        public List<DataField> Cells { get; set; }
    1.45 +
    1.46 +        [DataMember]
    1.47 +        public List<ColumnStyle> Columns { get; set; }
    1.48 +
    1.49 +        [DataMember]
    1.50 +        public List<RowStyle> Rows { get; set; }
    1.51 +
    1.52 +    }
    1.53 +
    1.54 +    /// <summary>
    1.55 +    ///
    1.56 +    /// </summary>
    1.57 +    [DataContract]
    1.58 +    public class DataField
    1.59 +    {
    1.60 +        [DataMember]
    1.61 +        public int Column { get; set; }
    1.62 +
    1.63 +        [DataMember]
    1.64 +        public int Row { get; set; }
    1.65 +
    1.66 +        [DataMember]
    1.67 +        public int ColumnSpan { get; set; }
    1.68 +
    1.69 +        [DataMember]
    1.70 +        public int RowSpan { get; set; }
    1.71 +
    1.72 +    }
    1.73 +
    1.74 +
    1.75 +    /// <summary>
    1.76 +    /// TextField can be send to our server to be displayed on the screen.
    1.77 +    /// </summary>
    1.78 +    [DataContract]
    1.79 +    public class TextField : DataField
    1.80      {
    1.81          public TextField()
    1.82          {
    1.83 @@ -56,7 +120,12 @@
    1.84          public ContentAlignment Alignment { get; set; }
    1.85      }
    1.86  
    1.87 -
    1.88 +    /// <summary>
    1.89 +    /// Define our SharpDisplay service.
    1.90 +    /// Clients and servers must implement it to communicate with one another.
    1.91 +    /// Through this service clients can send requests to a server.
    1.92 +    /// Through this service a server session can receive requests from a client.
    1.93 +    /// </summary>
    1.94      [ServiceContract(CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
    1.95      public interface IService
    1.96      {
    1.97 @@ -70,6 +139,13 @@
    1.98          [OperationContract(IsOneWay = true)]
    1.99          void SetName(string aClientName);
   1.100  
   1.101 +
   1.102 +        /// <summary>
   1.103 +        /// </summary>
   1.104 +        /// <param name="aLayout"></param>
   1.105 +        [OperationContract(IsOneWay = true)]
   1.106 +        void SetLayout(TableLayout aLayout);
   1.107 +
   1.108          /// <summary>
   1.109          /// Put the given text in the given field on your display.
   1.110          /// Fields are often just lines of text.
   1.111 @@ -94,7 +170,9 @@
   1.112  
   1.113      }
   1.114  
   1.115 -
   1.116 +    /// <summary>
   1.117 +    /// SharDisplay callback provides a means for a server to notify its clients.
   1.118 +    /// </summary>
   1.119      public interface ICallback
   1.120      {
   1.121          [OperationContract(IsOneWay = true)]
   1.122 @@ -107,6 +185,9 @@
   1.123          [OperationContract(IsOneWay = true)]
   1.124          void OnCloseOrder();
   1.125      }
   1.126 +
   1.127 +
   1.128 +
   1.129  }
   1.130  
   1.131  
   1.132 @@ -133,6 +214,11 @@
   1.133              Channel.SetName(aClientName);
   1.134          }
   1.135  
   1.136 +        public void SetLayout(TableLayout aLayout)
   1.137 +        {
   1.138 +            Channel.SetLayout(aLayout);
   1.139 +        }
   1.140 +
   1.141          public void SetText(TextField aTextField)
   1.142          {
   1.143              Channel.SetText(aTextField);