Now requesting extra info on auto start-up too.
2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10 using System.ServiceModel;
11 using System.ServiceModel.Channels;
12 using System.Diagnostics;
13 using SharpDisplayInterface;
16 namespace SharpDisplayClient
18 public partial class MainForm : Form
22 ContentAlignment Alignment;
23 TextField iTextFieldTop;
27 InitializeComponent();
28 Alignment = ContentAlignment.MiddleLeft;
29 iTextFieldTop = new TextField(0);
33 private void MainForm_Load(object sender, EventArgs e)
35 iCallback = new Callback(this);
36 //Instance context is then managed by our client class
37 InstanceContext instanceContext = new InstanceContext(iCallback);
38 iClient = new Client(instanceContext);
40 //Connect using unique name
41 //string name = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
42 string name = "Client-" + (iClient.ClientCount() - 1);
43 iClient.SetName(name);
44 //Text = Text + ": " + name;
45 Text = "[[" + name + "]] " + iClient.SessionId;
48 textBoxTop.Text = iClient.Name;
49 textBoxBottom.Text = iClient.SessionId;
55 public delegate void CloseConnectionDelegate();
56 public delegate void CloseDelegate();
61 public void CloseConnectionThreadSafe()
63 if (this.InvokeRequired)
65 //Not in the proper thread, invoke ourselves
66 CloseConnectionDelegate d = new CloseConnectionDelegate(CloseConnectionThreadSafe);
67 this.Invoke(d, new object[] { });
71 //We are in the proper thread
74 Trace.TraceInformation("Closing client: " + iClient.SessionId);
76 Trace.TraceInformation("Closed client: " + iClient.SessionId);
87 public void CloseThreadSafe()
89 if (this.InvokeRequired)
91 //Not in the proper thread, invoke ourselves
92 CloseDelegate d = new CloseDelegate(CloseThreadSafe);
93 this.Invoke(d, new object[] { });
97 //We are in the proper thread
103 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
105 CloseConnectionThreadSafe();
108 public bool IsClientReady()
110 return (iClient != null && iClient.State == CommunicationState.Opened);
113 private void buttonAlignLeft_Click(object sender, EventArgs e)
115 Alignment = ContentAlignment.MiddleLeft;
116 textBoxTop.TextAlign = HorizontalAlignment.Left;
117 textBoxBottom.TextAlign = HorizontalAlignment.Left;
120 private void buttonAlignCenter_Click(object sender, EventArgs e)
122 Alignment = ContentAlignment.MiddleCenter;
123 textBoxTop.TextAlign = HorizontalAlignment.Center;
124 textBoxBottom.TextAlign = HorizontalAlignment.Center;
127 private void buttonAlignRight_Click(object sender, EventArgs e)
129 Alignment = ContentAlignment.MiddleRight;
130 textBoxTop.TextAlign = HorizontalAlignment.Right;
131 textBoxBottom.TextAlign = HorizontalAlignment.Right;
134 private void buttonSetTopText_Click(object sender, EventArgs e)
136 //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
137 iTextFieldTop.Text = textBoxTop.Text;
138 iClient.SetText(iTextFieldTop);
141 private void buttonSetText_Click(object sender, EventArgs e)
143 //iClient.SetText(0,"Top");
144 //iClient.SetText(1, "Bottom");
145 //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
147 iClient.SetTexts(new TextField[]
149 new TextField(0, textBoxTop.Text, Alignment),
150 new TextField(1, textBoxBottom.Text, Alignment)