Adding and removing row is now working.
Can now have any number of text field.
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;
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 iClient = new Client(iCallback);
38 //Connect using unique name
39 //string name = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
40 string name = "Client-" + (iClient.ClientCount() - 1);
41 iClient.SetName(name);
42 //Text = Text + ": " + name;
43 Text = "[[" + name + "]] " + iClient.SessionId;
46 textBoxTop.Text = iClient.Name;
47 textBoxBottom.Text = iClient.SessionId;
53 public delegate void CloseConnectionDelegate();
54 public delegate void CloseDelegate();
59 public void CloseConnectionThreadSafe()
61 if (this.InvokeRequired)
63 //Not in the proper thread, invoke ourselves
64 CloseConnectionDelegate d = new CloseConnectionDelegate(CloseConnectionThreadSafe);
65 this.Invoke(d, new object[] { });
69 //We are in the proper thread
72 Trace.TraceInformation("Closing client: " + iClient.SessionId);
74 Trace.TraceInformation("Closed client: " + iClient.SessionId);
85 public void CloseThreadSafe()
87 if (this.InvokeRequired)
89 //Not in the proper thread, invoke ourselves
90 CloseDelegate d = new CloseDelegate(CloseThreadSafe);
91 this.Invoke(d, new object[] { });
95 //We are in the proper thread
101 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
103 CloseConnectionThreadSafe();
106 public bool IsClientReady()
108 return (iClient != null && iClient.State == CommunicationState.Opened);
111 private void buttonAlignLeft_Click(object sender, EventArgs e)
113 Alignment = ContentAlignment.MiddleLeft;
114 textBoxTop.TextAlign = HorizontalAlignment.Left;
115 textBoxBottom.TextAlign = HorizontalAlignment.Left;
118 private void buttonAlignCenter_Click(object sender, EventArgs e)
120 Alignment = ContentAlignment.MiddleCenter;
121 textBoxTop.TextAlign = HorizontalAlignment.Center;
122 textBoxBottom.TextAlign = HorizontalAlignment.Center;
125 private void buttonAlignRight_Click(object sender, EventArgs e)
127 Alignment = ContentAlignment.MiddleRight;
128 textBoxTop.TextAlign = HorizontalAlignment.Right;
129 textBoxBottom.TextAlign = HorizontalAlignment.Right;
132 private void buttonSetTopText_Click(object sender, EventArgs e)
134 //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
135 iTextFieldTop.Text = textBoxTop.Text;
136 iTextFieldTop.Alignment = Alignment;
137 iClient.SetText(iTextFieldTop);
140 private void buttonSetText_Click(object sender, EventArgs e)
142 //iClient.SetText(0,"Top");
143 //iClient.SetText(1, "Bottom");
144 //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
146 iClient.SetTexts(new TextField[]
148 new TextField(0, textBoxTop.Text, Alignment),
149 new TextField(1, textBoxBottom.Text, Alignment)