Adding VFD application icon.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using System.Windows.Forms;
8 using System.ServiceModel;
9 using System.ServiceModel.Channels;
12 namespace SharpDisplayClient
17 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
18 public class Callback : ICallback, IDisposable
20 private MainForm MainForm { get; set; }
22 public Callback(MainForm aMainForm)
27 public void OnConnected()
29 //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
30 //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
32 MessageBox.Show("OnConnected()", "Client");
36 public void OnCloseOrder()
38 //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
39 //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
41 //MessageBox.Show("OnServerClosing()", "Client");
42 MainForm.CloseConnectionThreadSafe();
43 MainForm.CloseThreadSafe();
57 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
58 public class Client : DuplexClientBase<IService>
60 public string SessionId { get { return InnerChannel.SessionId; } }
62 public Client(ICallback aCallback)
63 : base(new InstanceContext(aCallback), new NetTcpBinding(SecurityMode.None, true), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
66 public void SetName(string aClientName)
68 Channel.SetName(aClientName);
71 public void SetLayout(TableLayout aLayout)
73 Channel.SetLayout(aLayout);
76 public void SetField(DataField aField)
78 Channel.SetField(aField);
81 public void SetFields(System.Collections.Generic.IList<DataField> aFields)
83 Channel.SetFields(aFields);
86 public int ClientCount()
88 return Channel.ClientCount();
93 return State == CommunicationState.Opened || State == CommunicationState.Created;
101 public class DisplayClient
105 private MainForm MainForm { get; set; }
107 public string SessionId { get { return iClient.SessionId; } }
108 public string Name { get; private set; }
109 private TableLayout Layout { get; set; }
110 private System.Collections.Generic.IList<DataField> Fields { get; set; }
113 public DisplayClient(MainForm aMainForm)
115 MainForm = aMainForm;
117 Fields = new DataField[]{};
122 iCallback = new Callback(MainForm);
123 iClient = new Client(iCallback);
134 public bool IsReady()
136 return (iClient != null && iCallback != null && iClient.IsReady());
139 public void CheckConnection()
146 //On reconnect there is a bunch of properties we need to set
149 iClient.SetName(Name);
157 public void SetName(string aClientName)
161 iClient.SetName(aClientName);
165 public void SetLayout(TableLayout aLayout)
169 iClient.SetLayout(aLayout);
173 public void SetField(DataField aField)
175 //TODO: Create fields if not present
177 foreach (DataField field in Fields)
179 if (field.Index == aField.Index)
181 //Update our field then
189 iClient.SetField(aField);
192 public void SetFields(System.Collections.Generic.IList<DataField> aFields)
196 iClient.SetFields(aFields);
200 public int ClientCount()
203 return iClient.ClientCount();