Cleaning up control creation code.
2 using System.Windows.Forms;
3 using System.Collections;
4 using System.ServiceModel;
5 using System.Collections.Generic;
7 using System.Diagnostics;
10 namespace SharpDisplay
13 /// Implement our display services.
14 /// Each client connection has such a session object server side.
17 ConcurrencyMode = ConcurrencyMode.Multiple,
18 InstanceContextMode = InstanceContextMode.PerSession
20 class Session : IService, IDisposable
22 public string SessionId { get; set; }
23 public string Name { get; set; }
27 Trace.TraceInformation("Server session opening.");
28 //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then.
29 SessionId = OperationContext.Current.SessionId;
30 ICallback callback = OperationContext.Current.GetCallbackChannel<ICallback>();
32 SharpDisplayManager.Program.iMainForm.AddClientThreadSafe(SessionId,callback);
38 Trace.TraceInformation("Server session closing.");
39 SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId);
43 public void SetName(string aClientName)
46 SharpDisplayManager.Program.iMainForm.SetClientNameThreadSafe(SessionId, Name);
47 //Disconnect(aClientName);
49 //Register our client and its callback interface
50 //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
51 //Program.iMainForm.iClients.Add(aClientName, callback);
52 //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName);
53 //For some reason MP still hangs on that one
54 //callback.OnConnected();
57 public void SetLayout(TableLayout aLayout)
59 SharpDisplayManager.Program.iMainForm.SetClientLayoutThreadSafe(SessionId, aLayout);
62 //From IDisplayService
63 public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
65 SharpDisplayManager.Program.iMainForm.SetClientTextsThreadSafe(SessionId, aTextFields);
69 public void SetText(TextField aTextField)
71 SharpDisplayManager.Program.iMainForm.SetClientTextThreadSafe(SessionId, aTextField);
75 public void SetBitmap(BitmapField aBitmapField)
77 SharpDisplayManager.Program.iMainForm.SetClientBitmapThreadSafe(SessionId, aBitmapField);
81 public int ClientCount()
83 return SharpDisplayManager.Program.iMainForm.iClients.Count;