Simplifying client construction.
Fixing our borders and sorting out our color issues.
Adding inverse colors options.
2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
11 using CodeProject.Dialog;
12 using System.Drawing.Imaging;
13 using System.ServiceModel;
14 using System.Threading;
15 using System.Diagnostics;
17 using SharpDisplayClient;
20 namespace SharpDisplayManager
22 public partial class MainForm : Form
24 DateTime LastTickTime;
26 System.Drawing.Bitmap iBmp;
27 bool iCreateBitmap; //Workaround render to bitmap issues when minimized
28 ServiceHost iServiceHost;
30 /// Our collection of clients
32 public Dictionary<string, ClientData> iClients;
37 LastTickTime = DateTime.Now;
38 iDisplay = new Display();
39 iClients = new Dictionary<string, ClientData>();
41 InitializeComponent();
43 //We have a bug when drawing minimized and reusing our bitmap
44 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
45 iCreateBitmap = false;
47 //this.tableLayoutPanel.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel_CellPaint);
50 private void MainForm_Load(object sender, EventArgs e)
54 if (Properties.Settings.Default.DisplayConnectOnStartup)
56 OpenDisplayConnection();
61 private void tableLayoutPanel_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
63 var panel = sender as TableLayoutPanel;
64 //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
65 var rectangle = e.CellBounds;
66 using (var pen = new Pen(Color.Black, 1))
68 pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
69 pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
71 if (e.Row == (panel.RowCount - 1))
73 rectangle.Height -= 1;
76 if (e.Column == (panel.ColumnCount - 1))
81 e.Graphics.DrawRectangle(pen, rectangle);
86 private void buttonFont_Click(object sender, EventArgs e)
88 //fontDialog.ShowColor = true;
89 //fontDialog.ShowApply = true;
90 fontDialog.ShowEffects = true;
91 fontDialog.Font = marqueeLabelTop.Font;
93 fontDialog.FixedPitchOnly = checkBoxFixedPitchFontOnly.Checked;
95 //fontDialog.ShowHelp = true;
97 //fontDlg.MaxSize = 40;
98 //fontDlg.MinSize = 22;
100 //fontDialog.Parent = this;
101 //fontDialog.StartPosition = FormStartPosition.CenterParent;
103 //DlgBox.ShowDialog(fontDialog);
105 //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
106 if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
109 //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
111 //MessageBox.Show("Ok");
112 marqueeLabelTop.Font = fontDialog.Font;
113 marqueeLabelBottom.Font = fontDialog.Font;
114 cds.Font = fontDialog.Font;
115 Properties.Settings.Default.Save();
124 void CheckFontHeight()
126 //Show font height and width
127 labelFontHeight.Text = "Font height: " + cds.Font.Height;
128 float charWidth = IsFixedWidth(cds.Font);
129 if (charWidth == 0.0f)
131 labelFontWidth.Visible = false;
135 labelFontWidth.Visible = true;
136 labelFontWidth.Text = "Font width: " + charWidth;
139 //Now check font height and show a warning if needed.
140 if (marqueeLabelBottom.Font.Height > marqueeLabelBottom.Height)
142 labelWarning.Text = "WARNING: Selected font is too height by " + (marqueeLabelBottom.Font.Height - marqueeLabelBottom.Height) + " pixels!";
143 labelWarning.Visible = true;
147 labelWarning.Visible = false;
152 private void buttonCapture_Click(object sender, EventArgs e)
154 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
155 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
156 //Bitmap bmpToSave = new Bitmap(bmp);
157 bmp.Save("D:\\capture.png");
159 marqueeLabelTop.Text = "Sweet";
162 string outputFileName = "d:\\capture.png";
163 using (MemoryStream memory = new MemoryStream())
165 using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
167 bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
168 byte[] bytes = memory.ToArray();
169 fs.Write(bytes, 0, bytes.Length);
176 private void CheckForRequestResults()
178 if (iDisplay.IsRequestPending())
180 switch (iDisplay.AttemptRequestCompletion())
182 case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
183 toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
184 //Issue next request then
185 iDisplay.RequestPowerSupplyStatus();
188 case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
189 if (iDisplay.PowerSupplyStatus())
191 toolStripStatusLabelPower.Text = "ON";
195 toolStripStatusLabelPower.Text = "OFF";
197 //Issue next request then
198 iDisplay.RequestDeviceId();
201 case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
202 toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
203 //No more request to issue
210 public delegate uint ColorProcessingDelegate(uint aPixel);
212 public static uint ColorUntouched(uint aPixel)
217 public static uint ColorInversed(uint aPixel)
222 public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
224 public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
226 return aBmp.Width - aX - 1;
229 public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
231 return iBmp.Height - aY - 1;
234 public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
239 public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
245 //This is our timer tick responsible to perform our render
246 private void timer_Tick(object sender, EventArgs e)
248 //Update our animations
249 DateTime NewTickTime = DateTime.Now;
251 marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
252 marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
255 if (iDisplay.IsOpen())
257 CheckForRequestResults();
262 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
264 tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
265 //iBmp.Save("D:\\capture.png");
268 //Select our pixel processing routine
269 ColorProcessingDelegate colorFx;
271 if (cds.InverseColors)
273 colorFx = ColorInversed;
277 colorFx = ColorUntouched;
280 //Select proper coordinate translation functions
281 //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
282 CoordinateTranslationDelegate screenX;
283 CoordinateTranslationDelegate screenY;
285 if (cds.ReverseScreen)
287 screenX = ScreenReversedX;
288 screenY = ScreenReversedY;
296 //Send it to our display
297 for (int i = 0; i < iBmp.Width; i++)
299 for (int j = 0; j < iBmp.Height; j++)
303 uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
304 //Apply color effects
305 color = colorFx(color);
306 //For some reason when the app is minimized in the task bar only the alpha of our color is set.
307 //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
308 //iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
309 iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), color);
314 iDisplay.SwapBuffers();
318 //Compute instant FPS
319 toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " / " + (1000/timer.Interval).ToString() + " FPS";
321 LastTickTime = NewTickTime;
325 private void OpenDisplayConnection()
327 CloseDisplayConnection();
329 if (iDisplay.Open((Display.TMiniDisplayType)cds.DisplayType))
332 iDisplay.RequestFirmwareRevision();
337 toolStripStatusLabelConnect.Text = "Connection error";
341 private void CloseDisplayConnection()
347 private void buttonOpen_Click(object sender, EventArgs e)
349 OpenDisplayConnection();
352 private void buttonClose_Click(object sender, EventArgs e)
354 CloseDisplayConnection();
357 private void buttonClear_Click(object sender, EventArgs e)
360 iDisplay.SwapBuffers();
363 private void buttonFill_Click(object sender, EventArgs e)
366 iDisplay.SwapBuffers();
369 private void trackBarBrightness_Scroll(object sender, EventArgs e)
371 cds.Brightness = trackBarBrightness.Value;
372 Properties.Settings.Default.Save();
373 iDisplay.SetBrightness(trackBarBrightness.Value);
379 /// CDS stands for Current Display Settings
381 private DisplaySettings cds
385 DisplaysSettings settings = Properties.Settings.Default.DisplaySettings;
386 if (settings == null)
388 settings = new DisplaysSettings();
390 Properties.Settings.Default.DisplaySettings = settings;
393 //Make sure all our settings have been created
394 while (settings.Displays.Count <= Properties.Settings.Default.CurrentDisplayIndex)
396 settings.Displays.Add(new DisplaySettings());
399 DisplaySettings displaySettings = settings.Displays[Properties.Settings.Default.CurrentDisplayIndex];
400 return displaySettings;
405 /// Check if the given font has a fixed character pitch.
407 /// <param name="ft"></param>
408 /// <returns>0.0f if this is not a monospace font, otherwise returns the character width.</returns>
409 public float IsFixedWidth(Font ft)
411 Graphics g = CreateGraphics();
412 char[] charSizes = new char[] { 'i', 'a', 'Z', '%', '#', 'a', 'B', 'l', 'm', ',', '.' };
413 float charWidth = g.MeasureString("I", ft, Int32.MaxValue, StringFormat.GenericTypographic).Width;
415 bool fixedWidth = true;
417 foreach (char c in charSizes)
418 if (g.MeasureString(c.ToString(), ft, Int32.MaxValue, StringFormat.GenericTypographic).Width != charWidth)
429 private void UpdateStatus()
431 //Synchronize UI with settings
434 checkBoxShowBorders.Checked = cds.ShowBorders;
435 tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
436 marqueeLabelTop.Font = cds.Font;
437 marqueeLabelBottom.Font = cds.Font;
439 checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
440 checkBoxReverseScreen.Checked = cds.ReverseScreen;
441 checkBoxInverseColors.Checked = cds.InverseColors;
442 comboBoxDisplayType.SelectedIndex = cds.DisplayType;
443 timer.Interval = cds.TimerInterval;
444 maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
447 if (iDisplay.IsOpen())
449 //Only setup brightness if display is open
450 trackBarBrightness.Minimum = iDisplay.MinBrightness();
451 trackBarBrightness.Maximum = iDisplay.MaxBrightness();
452 trackBarBrightness.Value = cds.Brightness;
453 trackBarBrightness.LargeChange = Math.Max(1, (iDisplay.MaxBrightness() - iDisplay.MinBrightness()) / 5);
454 trackBarBrightness.SmallChange = 1;
455 iDisplay.SetBrightness(cds.Brightness);
457 buttonFill.Enabled = true;
458 buttonClear.Enabled = true;
459 buttonOpen.Enabled = false;
460 buttonClose.Enabled = true;
461 trackBarBrightness.Enabled = true;
462 toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
463 //+ " - " + iDisplay.SerialNumber();
465 if (iDisplay.SupportPowerOnOff())
467 buttonPowerOn.Enabled = true;
468 buttonPowerOff.Enabled = true;
472 buttonPowerOn.Enabled = false;
473 buttonPowerOff.Enabled = false;
476 if (iDisplay.SupportClock())
478 buttonShowClock.Enabled = true;
479 buttonHideClock.Enabled = true;
483 buttonShowClock.Enabled = false;
484 buttonHideClock.Enabled = false;
489 buttonFill.Enabled = false;
490 buttonClear.Enabled = false;
491 buttonOpen.Enabled = true;
492 buttonClose.Enabled = false;
493 trackBarBrightness.Enabled = false;
494 buttonPowerOn.Enabled = false;
495 buttonPowerOff.Enabled = false;
496 buttonShowClock.Enabled = false;
497 buttonHideClock.Enabled = false;
498 toolStripStatusLabelConnect.Text = "Disconnected";
499 toolStripStatusLabelPower.Text = "N/A";
505 private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
507 //Save our show borders setting
508 tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
509 cds.ShowBorders = checkBoxShowBorders.Checked;
510 Properties.Settings.Default.Save();
514 private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
516 //Save our connect on startup setting
517 Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
518 Properties.Settings.Default.Save();
521 private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
523 //Save our reverse screen setting
524 cds.ReverseScreen = checkBoxReverseScreen.Checked;
525 Properties.Settings.Default.Save();
528 private void checkBoxInverseColors_CheckedChanged(object sender, EventArgs e)
530 //Save our inverse colors setting
531 cds.InverseColors = checkBoxInverseColors.Checked;
532 Properties.Settings.Default.Save();
535 private void MainForm_Resize(object sender, EventArgs e)
537 if (WindowState == FormWindowState.Minimized)
540 //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
541 iCreateBitmap = true;
545 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
551 public void StartServer()
553 iServiceHost = new ServiceHost
556 new Uri[] { new Uri("net.tcp://localhost:8001/") }
559 iServiceHost.AddServiceEndpoint(typeof(IService), new NetTcpBinding(SecurityMode.None, true), "DisplayService");
563 public void StopServer()
565 if (iClients.Count > 0 && !iClosing)
569 BroadcastCloseEvent();
573 if (MessageBox.Show("Force exit?", "Waiting for clients...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
575 iClosing = false; //We make sure we force close if asked twice
580 //We removed that as it often lags for some reason
581 //iServiceHost.Close();
585 public void BroadcastCloseEvent()
587 Trace.TraceInformation("BroadcastCloseEvent - start");
589 var inactiveClients = new List<string>();
590 foreach (var client in iClients)
592 //if (client.Key != eventData.ClientName)
596 Trace.TraceInformation("BroadcastCloseEvent - " + client.Key);
597 client.Value.Callback.OnCloseOrder(/*eventData*/);
601 inactiveClients.Add(client.Key);
606 if (inactiveClients.Count > 0)
608 foreach (var client in inactiveClients)
610 iClients.Remove(client);
611 Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(client, false)[0]);
616 private void buttonStartClient_Click(object sender, EventArgs e)
618 Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
619 clientThread.Start();
623 private void buttonSuspend_Click(object sender, EventArgs e)
625 LastTickTime = DateTime.Now; //Reset timer to prevent jump
626 timer.Enabled = !timer.Enabled;
629 buttonSuspend.Text = "Run";
633 buttonSuspend.Text = "Pause";
637 private void buttonCloseClients_Click(object sender, EventArgs e)
639 BroadcastCloseEvent();
642 private void treeViewClients_AfterSelect(object sender, TreeViewEventArgs e)
647 //Delegates are used for our thread safe method
648 public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
649 public delegate void RemoveClientDelegate(string aSessionId);
650 public delegate void SetTextDelegate(string SessionId, TextField aTextField);
651 public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
652 public delegate void SetClientNameDelegate(string aSessionId, string aName);
658 /// <param name="aSessionId"></param>
659 /// <param name="aCallback"></param>
660 public void AddClientThreadSafe(string aSessionId, ICallback aCallback)
662 if (this.InvokeRequired)
664 //Not in the proper thread, invoke ourselves
665 AddClientDelegate d = new AddClientDelegate(AddClientThreadSafe);
666 this.Invoke(d, new object[] { aSessionId, aCallback });
670 //We are in the proper thread
671 //Add this session to our collection of clients
672 ClientData newClient = new ClientData(aSessionId, aCallback);
673 Program.iMainForm.iClients.Add(aSessionId, newClient);
674 //Add this session to our UI
675 UpdateClientTreeViewNode(newClient);
682 /// <param name="aSessionId"></param>
683 public void RemoveClientThreadSafe(string aSessionId)
685 if (this.InvokeRequired)
687 //Not in the proper thread, invoke ourselves
688 RemoveClientDelegate d = new RemoveClientDelegate(RemoveClientThreadSafe);
689 this.Invoke(d, new object[] { aSessionId });
693 //We are in the proper thread
694 //Remove this session from both client collection and UI tree view
695 if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
697 Program.iMainForm.iClients.Remove(aSessionId);
698 Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
701 if (iClosing && iClients.Count == 0)
703 //We were closing our form
704 //All clients are now closed
705 //Just resume our close operation
715 /// <param name="aLineIndex"></param>
716 /// <param name="aText"></param>
717 public void SetTextThreadSafe(string aSessionId, TextField aTextField)
719 if (this.InvokeRequired)
721 //Not in the proper thread, invoke ourselves
722 SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe);
723 this.Invoke(d, new object[] { aSessionId, aTextField });
727 ClientData client = iClients[aSessionId];
730 //Make sure all our texts are in place
731 while (client.Texts.Count < (aTextField.Index + 1))
733 //Add a text field with proper index
734 client.Texts.Add(new TextField(client.Texts.Count));
736 client.Texts[aTextField.Index] = aTextField;
738 //We are in the proper thread
739 //Only support two lines for now
740 if (aTextField.Index == 0)
742 marqueeLabelTop.Text = aTextField.Text;
743 marqueeLabelTop.TextAlign = aTextField.Alignment;
745 else if (aTextField.Index == 1)
747 marqueeLabelBottom.Text = aTextField.Text;
748 marqueeLabelBottom.TextAlign = aTextField.Alignment;
752 UpdateClientTreeViewNode(client);
760 /// <param name="aTexts"></param>
761 public void SetTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<TextField> aTextFields)
763 if (this.InvokeRequired)
765 //Not in the proper thread, invoke ourselves
766 SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe);
767 this.Invoke(d, new object[] { aSessionId, aTextFields });
771 //We are in the proper thread
772 ClientData client = iClients[aSessionId];
775 //Populate our client with the given text fields
777 foreach (TextField textField in aTextFields)
779 if (client.Texts.Count < (j + 1))
781 client.Texts.Add(textField);
785 client.Texts[j] = textField;
789 //Only support two lines for now
790 for (int i = 0; i < aTextFields.Count; i++)
792 if (aTextFields[i].Index == 0)
794 marqueeLabelTop.Text = aTextFields[i].Text;
795 marqueeLabelTop.TextAlign = aTextFields[i].Alignment;
797 else if (aTextFields[i].Index == 1)
799 marqueeLabelBottom.Text = aTextFields[i].Text;
800 marqueeLabelBottom.TextAlign = aTextFields[i].Alignment;
805 UpdateClientTreeViewNode(client);
814 /// <param name="aSessionId"></param>
815 /// <param name="aName"></param>
816 public void SetClientNameThreadSafe(string aSessionId, string aName)
818 if (this.InvokeRequired)
820 //Not in the proper thread, invoke ourselves
821 SetClientNameDelegate d = new SetClientNameDelegate(SetClientNameThreadSafe);
822 this.Invoke(d, new object[] { aSessionId, aName });
826 //We are in the proper thread
828 ClientData client = iClients[aSessionId];
833 //Update our tree-view
834 UpdateClientTreeViewNode(client);
842 /// <param name="aClient"></param>
843 private void UpdateClientTreeViewNode(ClientData aClient)
850 TreeNode node = null;
851 //Check that our client node already exists
852 //Get our client root node using its key which is our session ID
853 TreeNode[] nodes = treeViewClients.Nodes.Find(aClient.SessionId, false);
856 //We already have a node for that client
858 //Clear children as we are going to recreate them below
863 //Client node does not exists create a new one
864 treeViewClients.Nodes.Add(aClient.SessionId, aClient.SessionId);
865 node = treeViewClients.Nodes.Find(aClient.SessionId, false)[0];
871 if (aClient.Name != "")
873 //We have a name, us it as text for our root node
874 node.Text = aClient.Name;
875 //Add a child with SessionId
876 node.Nodes.Add(new TreeNode(aClient.SessionId));
880 //No name, use session ID instead
881 node.Text = aClient.SessionId;
884 if (aClient.Texts.Count > 0)
886 //Create root node for our texts
887 TreeNode textsRoot = new TreeNode("Text");
888 node.Nodes.Add(textsRoot);
889 //For each text add a new entry
890 foreach (TextField field in aClient.Texts)
892 textsRoot.Nodes.Add(new TreeNode(field.Text));
900 private void buttonAddRow_Click(object sender, EventArgs e)
902 if (tableLayoutPanel.RowCount < 6)
904 tableLayoutPanel.RowCount++;
909 private void buttonRemoveRow_Click(object sender, EventArgs e)
911 if (tableLayoutPanel.RowCount > 1)
913 tableLayoutPanel.RowCount--;
918 private void buttonAddColumn_Click(object sender, EventArgs e)
920 if (tableLayoutPanel.ColumnCount < 8)
922 tableLayoutPanel.ColumnCount++;
927 private void buttonRemoveColumn_Click(object sender, EventArgs e)
929 if (tableLayoutPanel.ColumnCount > 1)
931 tableLayoutPanel.ColumnCount--;
936 private void buttonAlignLeft_Click(object sender, EventArgs e)
938 marqueeLabelTop.TextAlign = ContentAlignment.MiddleLeft;
939 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleLeft;
942 private void buttonAlignCenter_Click(object sender, EventArgs e)
944 marqueeLabelTop.TextAlign = ContentAlignment.MiddleCenter;
945 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleCenter;
948 private void buttonAlignRight_Click(object sender, EventArgs e)
950 marqueeLabelTop.TextAlign = ContentAlignment.MiddleRight;
951 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleRight;
954 private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e)
956 Properties.Settings.Default.CurrentDisplayIndex = comboBoxDisplayType.SelectedIndex;
957 cds.DisplayType = comboBoxDisplayType.SelectedIndex;
958 Properties.Settings.Default.Save();
959 if (iDisplay.IsOpen())
961 OpenDisplayConnection();
970 private void maskedTextBoxTimerInterval_TextChanged(object sender, EventArgs e)
972 if (maskedTextBoxTimerInterval.Text != "")
974 int interval = Convert.ToInt32(maskedTextBoxTimerInterval.Text);
978 timer.Interval = interval;
979 cds.TimerInterval = timer.Interval;
980 Properties.Settings.Default.Save();
985 private void buttonPowerOn_Click(object sender, EventArgs e)
990 private void buttonPowerOff_Click(object sender, EventArgs e)
995 private void buttonShowClock_Click(object sender, EventArgs e)
997 iDisplay.ShowClock();
1000 private void buttonHideClock_Click(object sender, EventArgs e)
1002 iDisplay.HideClock();
1008 /// A UI thread copy of a client relevant data.
1009 /// Keeping this copy in the UI thread helps us deal with threading issues.
1011 public class ClientData
1013 public ClientData(string aSessionId, ICallback aCallback)
1015 SessionId = aSessionId;
1017 Texts = new List<TextField>();
1018 Callback = aCallback;
1021 public string SessionId { get; set; }
1022 public string Name { get; set; }
1023 public List<TextField> Texts { get; set; }
1024 public ICallback Callback { get; set; }