Server/ClientData.cs
author StephaneLenclud
Tue, 16 Aug 2016 12:59:32 +0200
changeset 235 ba14a29944c4
parent 176 01c72c29cfaf
child 279 10f0de70b69b
permissions -rw-r--r--
Removing JSON type converter from ear manager.
Using bindings for some application settings.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 //
     7 using SharpLib.Display;
     8 
     9 namespace SharpDisplayManager
    10 {
    11     /// <summary>
    12     /// A UI thread copy of a client relevant data.
    13     /// Keeping this copy in the UI thread helps us deal with threading issues.
    14     /// </summary>
    15     public class ClientData
    16     {
    17         public ClientData(string aSessionId, ICallback aCallback)
    18         {
    19             SessionId = aSessionId;
    20             Name = "";
    21             Priority = Priorities.Default;
    22             Fields = new List<DataField>();
    23             Layout = new TableLayout(1, 2); //Default to one column and two rows
    24             Callback = aCallback;
    25             HasNewLayout = true;            
    26         }
    27 
    28         public string SessionId { get; set; }
    29         public string Name { get; set; }
    30         public uint Priority { get; set; }
    31         public List<DataField> Fields { get; set; }
    32         public TableLayout Layout { get; set; }
    33         public ICallback Callback { get; set; }
    34 
    35         public bool HasNewLayout { get; set; }
    36 
    37         //Client management
    38         public DateTime LastSwitchTime { get; set; }
    39 
    40         /// <summary>
    41         /// Look up the corresponding field in our field collection.
    42         /// </summary>
    43         /// <param name="aField"></param>
    44         /// <returns></returns>
    45         public DataField FindSameFieldAs(DataField aField)
    46         {
    47             foreach (DataField field in Fields)
    48             {
    49                 if (field.IsSameAs(aField))
    50                 {
    51                     return field;
    52                 }                
    53             }
    54 
    55             return null;
    56         }
    57 
    58 
    59         /// <summary>
    60         /// Look up the corresponding field in our field collection.
    61         /// </summary>
    62         /// <param name="aField"></param>
    63         /// <returns></returns>
    64         public int FindSameFieldIndex(DataField aField)
    65         {
    66             int i = 0;
    67             foreach (DataField field in Fields)
    68             {
    69                 if (field.IsSameAs(aField))
    70                 {
    71                     return i;
    72                 }
    73                 i++;
    74             }
    75 
    76             return -1;
    77         }
    78 
    79 
    80     }
    81 }