Server/ClientData.cs
author StephaneLenclud
Thu, 21 Jan 2016 20:32:51 +0100
changeset 181 503b711d5e8c
parent 175 391bce3c8368
child 184 7b6aa551eb6c
permissions -rw-r--r--
Published v0.8.0.0.
     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             Fields = new List<DataField>();
    22             Layout = new TableLayout(1, 2); //Default to one column and two rows
    23             Callback = aCallback;
    24             HasNewLayout = true;            
    25         }
    26 
    27         public string SessionId { get; set; }
    28         public string Name { get; set; }
    29         public List<DataField> Fields { get; set; }
    30         public TableLayout Layout { get; set; }
    31         public ICallback Callback { get; set; }
    32 
    33         public bool HasNewLayout { get; set; }
    34 
    35         //Client management
    36         public DateTime LastSwitchTime { get; set; }
    37 
    38         /// <summary>
    39         /// Look up the corresponding field in our field collection.
    40         /// </summary>
    41         /// <param name="aField"></param>
    42         /// <returns></returns>
    43         public DataField FindSameFieldAs(DataField aField)
    44         {
    45             foreach (DataField field in Fields)
    46             {
    47                 if (field.IsSameAs(aField))
    48                 {
    49                     return field;
    50                 }                
    51             }
    52 
    53             return null;
    54         }
    55 
    56 
    57         /// <summary>
    58         /// Look up the corresponding field in our field collection.
    59         /// </summary>
    60         /// <param name="aField"></param>
    61         /// <returns></returns>
    62         public int FindSameFieldIndex(DataField aField)
    63         {
    64             int i = 0;
    65             foreach (DataField field in Fields)
    66             {
    67                 if (field.IsSameAs(aField))
    68                 {
    69                     return i;
    70                 }
    71                 i++;
    72             }
    73 
    74             return -1;
    75         }
    76 
    77 
    78     }
    79 }