Fixing ClickOnce installer missing DLL.
2 // Copyright (C) 2014-2015 Stéphane Lenclud.
4 // This file is part of SharpDisplayManager.
6 // SharpDisplayManager is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // SharpDisplayManager is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with SharpDisplayManager. If not, see <http://www.gnu.org/licenses/>.
21 using System.Collections.Generic;
22 using System.ComponentModel;
27 using System.Threading.Tasks;
28 using System.Windows.Forms;
29 using System.ServiceModel;
30 using System.ServiceModel.Channels;
31 using System.Diagnostics;
35 namespace SharpDisplayClient
37 public partial class MainForm : Form
39 public StartParams Params { get; set; }
42 DisplayClient iClient;
44 ContentAlignment Alignment;
45 DataField iTextFieldTop;
53 InitializeComponent();
54 Alignment = ContentAlignment.MiddleLeft;
55 iTextFieldTop = new DataField(0);
61 /// <param name="sender"></param>
62 /// <param name="e"></param>
63 private void MainForm_Load(object sender, EventArgs e)
65 iClient = new DisplayClient(this);
68 //Connect using unique name
69 //string name = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
70 string name = "Client-" + (iClient.ClientCount() - 1);
71 iClient.SetName(name);
72 //Text = Text + ": " + name;
73 Text = "[[" + name + "]] " + iClient.SessionId;
76 textBoxTop.Text = iClient.Name;
77 textBoxBottom.Text = iClient.SessionId;
81 //Parameters where specified use them
82 if (Params.TopText != "")
84 textBoxTop.Text = Params.TopText;
87 if (Params.BottomText != "")
89 textBoxBottom.Text = Params.BottomText;
92 Location = Params.Location;
94 SetBasicLayoutAndText();
101 public delegate void CloseConnectionDelegate();
102 public delegate void CloseDelegate();
107 public void CloseConnectionThreadSafe()
109 if (this.InvokeRequired)
111 //Not in the proper thread, invoke ourselves
112 CloseConnectionDelegate d = new CloseConnectionDelegate(CloseConnectionThreadSafe);
113 this.Invoke(d, new object[] { });
117 //We are in the proper thread
120 string sessionId = iClient.SessionId;
121 Trace.TraceInformation("Closing client: " + sessionId);
123 Trace.TraceInformation("Closed client: " + sessionId);
133 public void CloseThreadSafe()
135 if (this.InvokeRequired)
137 //Not in the proper thread, invoke ourselves
138 CloseDelegate d = new CloseDelegate(CloseThreadSafe);
139 this.Invoke(d, new object[] { });
143 //We are in the proper thread
149 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
151 CloseConnectionThreadSafe();
154 public bool IsClientReady()
156 return (iClient != null && iClient.IsReady());
159 private void buttonAlignLeft_Click(object sender, EventArgs e)
161 Alignment = ContentAlignment.MiddleLeft;
162 textBoxTop.TextAlign = HorizontalAlignment.Left;
163 textBoxBottom.TextAlign = HorizontalAlignment.Left;
166 private void buttonAlignCenter_Click(object sender, EventArgs e)
168 Alignment = ContentAlignment.MiddleCenter;
169 textBoxTop.TextAlign = HorizontalAlignment.Center;
170 textBoxBottom.TextAlign = HorizontalAlignment.Center;
173 private void buttonAlignRight_Click(object sender, EventArgs e)
175 Alignment = ContentAlignment.MiddleRight;
176 textBoxTop.TextAlign = HorizontalAlignment.Right;
177 textBoxBottom.TextAlign = HorizontalAlignment.Right;
180 private void buttonSetTopText_Click(object sender, EventArgs e)
182 //TextField top = new TextField(0, textBoxTop.Text, ContentAlignment.MiddleLeft);
183 iTextFieldTop.Text = textBoxTop.Text;
184 iTextFieldTop.Alignment = Alignment;
185 bool res = iClient.SetField(iTextFieldTop);
189 MessageBox.Show("Create you fields first", "Field update error", MessageBoxButtons.OK, MessageBoxIcon.Error);
195 private void buttonSetText_Click(object sender, EventArgs e)
197 SetBasicLayoutAndText();
200 void SetBasicLayoutAndText()
202 //Set one column two lines layout
203 TableLayout layout = new TableLayout(1, 2);
204 iClient.SetLayout(layout);
207 iClient.CreateFields(new DataField[]
209 new DataField(0, textBoxTop.Text, Alignment),
210 new DataField(1, textBoxBottom.Text, Alignment)
215 private void buttonLayoutUpdate_Click(object sender, EventArgs e)
217 //Define a 2 by 2 layout
218 TableLayout layout = new TableLayout(2,2);
219 //Second column only takes up 25%
220 layout.Columns[1].Width = 25F;
221 //Send layout to server
222 iClient.SetLayout(layout);
225 private void buttonSetBitmap_Click(object sender, EventArgs e)
232 Bitmap bitmap = new Bitmap(x2,y2);
233 Pen blackPen = new Pen(Color.Black, 3);
235 // Draw line to screen.
236 using (var graphics = Graphics.FromImage(bitmap))
238 graphics.DrawLine(blackPen, x1, y1, x2, y2);
239 graphics.DrawLine(blackPen, x1, y2, x2, y1);
242 DataField field = new DataField(0, bitmap);
243 //field.ColumnSpan = 2;
244 iClient.SetField(field);
247 private void buttonBitmapLayout_Click(object sender, EventArgs e)
249 SetLayoutWithBitmap();
253 /// Define a layout with a bitmap field on the left and two lines of text on the right.
255 private void SetLayoutWithBitmap()
257 //Define a 2 by 2 layout
258 TableLayout layout = new TableLayout(2, 2);
259 //First column only takes 25%
260 layout.Columns[0].Width = 25F;
261 //Second column takes up 75%
262 layout.Columns[1].Width = 75F;
263 //Send layout to server
264 iClient.SetLayout(layout);
266 //Set a bitmap for our first field
272 Bitmap bitmap = new Bitmap(x2, y2);
273 Pen blackPen = new Pen(Color.Black, 3);
275 // Draw line to screen.
276 using (var graphics = Graphics.FromImage(bitmap))
278 graphics.DrawLine(blackPen, x1, y1, x2, y2);
279 graphics.DrawLine(blackPen, x1, y2, x2, y1);
282 //Create a bitmap field from the bitmap we just created
283 DataField field = new DataField(0, bitmap);
284 //We want our bitmap field to span across two rows
288 iClient.CreateFields(new DataField[]
291 new DataField(1, textBoxTop.Text, Alignment),
292 new DataField(2, textBoxBottom.Text, Alignment)
297 private void buttonIndicatorsLayout_Click(object sender, EventArgs e)
299 //Define a 2 by 4 layout
300 TableLayout layout = new TableLayout(2, 4);
302 layout.Columns[0].Width = 87.5F;
304 layout.Columns[1].Width = 12.5F;
305 //Send layout to server
306 iClient.SetLayout(layout);
308 //Create a bitmap for our indicators field
314 Bitmap bitmap = new Bitmap(x2, y2);
315 Pen blackPen = new Pen(Color.Black, 3);
317 // Draw line to screen.
318 using (var graphics = Graphics.FromImage(bitmap))
320 graphics.DrawLine(blackPen, x1, y1, x2, y2);
321 graphics.DrawLine(blackPen, x1, y2, x2, y1);
324 //Create a bitmap field from the bitmap we just created
325 DataField indicator1 = new DataField(2, bitmap);
326 //Create a bitmap field from the bitmap we just created
327 DataField indicator2 = new DataField(3, bitmap);
328 //Create a bitmap field from the bitmap we just created
329 DataField indicator3 = new DataField(4, bitmap);
330 //Create a bitmap field from the bitmap we just created
331 DataField indicator4 = new DataField(5, bitmap);
334 DataField textFieldTop = new DataField(0, textBoxTop.Text, Alignment);
335 textFieldTop.RowSpan = 2;
337 DataField textFieldBottom = new DataField(1, textBoxBottom.Text, Alignment);
338 textFieldBottom.RowSpan = 2;
342 iClient.CreateFields(new DataField[]
354 private void buttonUpdateTexts_Click(object sender, EventArgs e)
357 bool res = iClient.SetFields(new DataField[]
359 new DataField(0, textBoxTop.Text, Alignment),
360 new DataField(1, textBoxBottom.Text, Alignment)
365 MessageBox.Show("Create you fields first", "Field update error", MessageBoxButtons.OK, MessageBoxIcon.Error);
370 private void buttonLayoutOneTextField_Click(object sender, EventArgs e)
372 //Set one column two lines layout
373 TableLayout layout = new TableLayout(1, 1);
374 iClient.SetLayout(layout);
377 iClient.CreateFields(new DataField[]
379 new DataField(0, textBoxTop.Text, Alignment)