Now displaying font width and height.
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 SharpDisplayInterface;
18 using SharpDisplayClient;
21 namespace SharpDisplayManager
23 public partial class MainForm : Form
25 DateTime LastTickTime;
27 System.Drawing.Bitmap iBmp;
28 bool iCreateBitmap; //Workaround render to bitmap issues when minimized
29 ServiceHost iServiceHost;
31 /// Our collection of clients
33 public Dictionary<string, ClientData> iClients;
38 LastTickTime = DateTime.Now;
39 iDisplay = new Display();
40 iClients = new Dictionary<string, ClientData>();
42 InitializeComponent();
44 //We have a bug when drawing minimized and reusing our bitmap
45 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
46 iCreateBitmap = false;
49 private void MainForm_Load(object sender, EventArgs e)
53 if (Properties.Settings.Default.DisplayConnectOnStartup)
55 OpenDisplayConnection();
60 private void buttonFont_Click(object sender, EventArgs e)
62 //fontDialog.ShowColor = true;
63 //fontDialog.ShowApply = true;
64 fontDialog.ShowEffects = true;
65 fontDialog.Font = marqueeLabelTop.Font;
67 fontDialog.FixedPitchOnly = checkBoxFixedPitchFontOnly.Checked;
69 //fontDialog.ShowHelp = true;
71 //fontDlg.MaxSize = 40;
72 //fontDlg.MinSize = 22;
74 //fontDialog.Parent = this;
75 //fontDialog.StartPosition = FormStartPosition.CenterParent;
77 //DlgBox.ShowDialog(fontDialog);
79 //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
80 if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
83 //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
85 //MessageBox.Show("Ok");
86 marqueeLabelTop.Font = fontDialog.Font;
87 marqueeLabelBottom.Font = fontDialog.Font;
88 cds.Font = fontDialog.Font;
89 Properties.Settings.Default.Save();
98 void CheckFontHeight()
100 //Show font height and width
101 labelFontHeight.Text = "Font height: " + cds.Font.Height;
102 float charWidth = IsFixedWidth(cds.Font);
103 if (charWidth == 0.0f)
105 labelFontWidth.Visible = false;
109 labelFontWidth.Visible = true;
110 labelFontWidth.Text = "Font width: " + charWidth;
113 //Now check font height and show a warning if needed.
114 if (marqueeLabelBottom.Font.Height > marqueeLabelBottom.Height)
116 labelWarning.Text = "WARNING: Selected font is too height by " + (marqueeLabelBottom.Font.Height - marqueeLabelBottom.Height) + " pixels!";
117 labelWarning.Visible = true;
121 labelWarning.Visible = false;
126 private void buttonCapture_Click(object sender, EventArgs e)
128 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
129 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
130 //Bitmap bmpToSave = new Bitmap(bmp);
131 bmp.Save("D:\\capture.png");
133 marqueeLabelTop.Text = "Sweet";
136 string outputFileName = "d:\\capture.png";
137 using (MemoryStream memory = new MemoryStream())
139 using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
141 bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
142 byte[] bytes = memory.ToArray();
143 fs.Write(bytes, 0, bytes.Length);
150 private void CheckForRequestResults()
152 if (iDisplay.IsRequestPending())
154 switch (iDisplay.AttemptRequestCompletion())
156 case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
157 toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
158 //Issue next request then
159 iDisplay.RequestPowerSupplyStatus();
162 case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
163 if (iDisplay.PowerSupplyStatus())
165 toolStripStatusLabelPower.Text = "ON";
169 toolStripStatusLabelPower.Text = "OFF";
171 //Issue next request then
172 iDisplay.RequestDeviceId();
175 case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
176 toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
177 //No more request to issue
184 public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
187 public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
189 return aBmp.Width - aX - 1;
192 public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
194 return iBmp.Height - aY - 1;
197 public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
202 public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
208 //This is our timer tick responsible to perform our render
209 private void timer_Tick(object sender, EventArgs e)
211 //Update our animations
212 DateTime NewTickTime = DateTime.Now;
214 marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
215 marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
218 if (iDisplay.IsOpen())
220 CheckForRequestResults();
225 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
227 tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
228 //iBmp.Save("D:\\capture.png");
230 //Select proper coordinate translation functions
231 //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
232 CoordinateTranslationDelegate screenX;
233 CoordinateTranslationDelegate screenY;
235 if (cds.ReverseScreen)
237 screenX = ScreenReversedX;
238 screenY = ScreenReversedY;
246 //Send it to our display
247 for (int i = 0; i < iBmp.Width; i++)
249 for (int j = 0; j < iBmp.Height; j++)
253 uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
254 //For some reason when the app is minimized in the task bar only the alpha of our color is set.
255 //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
256 iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
261 iDisplay.SwapBuffers();
265 //Compute instant FPS
266 toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " / " + (1000/timer.Interval).ToString() + " FPS";
268 LastTickTime = NewTickTime;
272 private void OpenDisplayConnection()
274 CloseDisplayConnection();
276 if (iDisplay.Open((Display.TMiniDisplayType)cds.DisplayType))
279 iDisplay.RequestFirmwareRevision();
284 toolStripStatusLabelConnect.Text = "Connection error";
288 private void CloseDisplayConnection()
294 private void buttonOpen_Click(object sender, EventArgs e)
296 OpenDisplayConnection();
299 private void buttonClose_Click(object sender, EventArgs e)
301 CloseDisplayConnection();
304 private void buttonClear_Click(object sender, EventArgs e)
307 iDisplay.SwapBuffers();
310 private void buttonFill_Click(object sender, EventArgs e)
313 iDisplay.SwapBuffers();
316 private void trackBarBrightness_Scroll(object sender, EventArgs e)
318 cds.Brightness = trackBarBrightness.Value;
319 Properties.Settings.Default.Save();
320 iDisplay.SetBrightness(trackBarBrightness.Value);
326 /// CDS stands for Current Display Settings
328 private DisplaySettings cds
332 DisplaysSettings settings = Properties.Settings.Default.DisplaySettings;
333 if (settings == null)
335 settings = new DisplaysSettings();
337 Properties.Settings.Default.DisplaySettings = settings;
340 //Make sure all our settings have been created
341 while (settings.Displays.Count <= Properties.Settings.Default.CurrentDisplayIndex)
343 settings.Displays.Add(new DisplaySettings());
346 DisplaySettings displaySettings = settings.Displays[Properties.Settings.Default.CurrentDisplayIndex];
347 return displaySettings;
352 /// Check if the given font has a fixed character pitch.
354 /// <param name="ft"></param>
355 /// <returns>0.0f if this is not a monospace font, otherwise returns the character width.</returns>
356 public float IsFixedWidth(Font ft)
358 Graphics g = CreateGraphics();
359 char[] charSizes = new char[] { 'i', 'a', 'Z', '%', '#', 'a', 'B', 'l', 'm', ',', '.' };
360 float charWidth = g.MeasureString("I", ft, Int32.MaxValue, StringFormat.GenericTypographic).Width;
362 bool fixedWidth = true;
364 foreach (char c in charSizes)
365 if (g.MeasureString(c.ToString(), ft, Int32.MaxValue, StringFormat.GenericTypographic).Width != charWidth)
376 private void UpdateStatus()
378 //Synchronize UI with settings
381 checkBoxShowBorders.Checked = cds.ShowBorders;
382 tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
383 marqueeLabelTop.Font = cds.Font;
384 marqueeLabelBottom.Font = cds.Font;
386 checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
387 checkBoxReverseScreen.Checked = cds.ReverseScreen;
388 comboBoxDisplayType.SelectedIndex = cds.DisplayType;
389 timer.Interval = cds.TimerInterval;
390 maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
393 if (iDisplay.IsOpen())
395 //Only setup brightness if display is open
396 trackBarBrightness.Minimum = iDisplay.MinBrightness();
397 trackBarBrightness.Maximum = iDisplay.MaxBrightness();
398 trackBarBrightness.Value = cds.Brightness;
399 trackBarBrightness.LargeChange = Math.Max(1, (iDisplay.MaxBrightness() - iDisplay.MinBrightness()) / 5);
400 trackBarBrightness.SmallChange = 1;
401 iDisplay.SetBrightness(cds.Brightness);
403 buttonFill.Enabled = true;
404 buttonClear.Enabled = true;
405 buttonOpen.Enabled = false;
406 buttonClose.Enabled = true;
407 trackBarBrightness.Enabled = true;
408 toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
409 //+ " - " + iDisplay.SerialNumber();
411 if (iDisplay.SupportPowerOnOff())
413 buttonPowerOn.Enabled = true;
414 buttonPowerOff.Enabled = true;
418 buttonPowerOn.Enabled = false;
419 buttonPowerOff.Enabled = false;
422 if (iDisplay.SupportClock())
424 buttonShowClock.Enabled = true;
425 buttonHideClock.Enabled = true;
429 buttonShowClock.Enabled = false;
430 buttonHideClock.Enabled = false;
435 buttonFill.Enabled = false;
436 buttonClear.Enabled = false;
437 buttonOpen.Enabled = true;
438 buttonClose.Enabled = false;
439 trackBarBrightness.Enabled = false;
440 buttonPowerOn.Enabled = false;
441 buttonPowerOff.Enabled = false;
442 buttonShowClock.Enabled = false;
443 buttonHideClock.Enabled = false;
444 toolStripStatusLabelConnect.Text = "Disconnected";
445 toolStripStatusLabelPower.Text = "N/A";
451 private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
453 //Save our show borders setting
454 tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
455 cds.ShowBorders = checkBoxShowBorders.Checked;
456 Properties.Settings.Default.Save();
459 private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
461 //Save our connect on startup setting
462 Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
463 Properties.Settings.Default.Save();
466 private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
468 //Save our reverse screen setting
469 cds.ReverseScreen = checkBoxReverseScreen.Checked;
470 Properties.Settings.Default.Save();
473 private void MainForm_Resize(object sender, EventArgs e)
475 if (WindowState == FormWindowState.Minimized)
478 //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
479 iCreateBitmap = true;
483 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
489 public void StartServer()
491 iServiceHost = new ServiceHost
493 typeof(DisplayServer),
494 new Uri[] { new Uri("net.tcp://localhost:8001/") }
497 iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetTcpBinding(SecurityMode.None,true), "DisplayService");
501 public void StopServer()
503 if (iClients.Count > 0 && !iClosing)
507 BroadcastCloseEvent();
511 if (MessageBox.Show("Force exit?", "Waiting for clients...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
513 iClosing = false; //We make sure we force close if asked twice
518 //We removed that as it often lags for some reason
519 //iServiceHost.Close();
523 public void BroadcastCloseEvent()
525 Trace.TraceInformation("BroadcastCloseEvent - start");
527 var inactiveClients = new List<string>();
528 foreach (var client in iClients)
530 //if (client.Key != eventData.ClientName)
534 Trace.TraceInformation("BroadcastCloseEvent - " + client.Key);
535 client.Value.Callback.OnCloseOrder(/*eventData*/);
539 inactiveClients.Add(client.Key);
544 if (inactiveClients.Count > 0)
546 foreach (var client in inactiveClients)
548 iClients.Remove(client);
549 Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(client, false)[0]);
554 private void buttonStartClient_Click(object sender, EventArgs e)
556 Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
557 clientThread.Start();
561 private void buttonSuspend_Click(object sender, EventArgs e)
563 LastTickTime = DateTime.Now; //Reset timer to prevent jump
564 timer.Enabled = !timer.Enabled;
567 buttonSuspend.Text = "Run";
571 buttonSuspend.Text = "Pause";
575 private void buttonCloseClients_Click(object sender, EventArgs e)
577 BroadcastCloseEvent();
580 private void treeViewClients_AfterSelect(object sender, TreeViewEventArgs e)
585 //Delegates are used for our thread safe method
586 public delegate void AddClientDelegate(string aSessionId, IDisplayServiceCallback aCallback);
587 public delegate void RemoveClientDelegate(string aSessionId);
588 public delegate void SetTextDelegate(string SessionId, TextField aTextField);
589 public delegate void SetTextsDelegate(string SessionId, System.Collections.Generic.IList<TextField> aTextFields);
590 public delegate void SetClientNameDelegate(string aSessionId, string aName);
596 /// <param name="aSessionId"></param>
597 /// <param name="aCallback"></param>
598 public void AddClientThreadSafe(string aSessionId, IDisplayServiceCallback aCallback)
600 if (this.InvokeRequired)
602 //Not in the proper thread, invoke ourselves
603 AddClientDelegate d = new AddClientDelegate(AddClientThreadSafe);
604 this.Invoke(d, new object[] { aSessionId, aCallback });
608 //We are in the proper thread
609 //Add this session to our collection of clients
610 ClientData newClient = new ClientData(aSessionId, aCallback);
611 Program.iMainForm.iClients.Add(aSessionId, newClient);
612 //Add this session to our UI
613 UpdateClientTreeViewNode(newClient);
620 /// <param name="aSessionId"></param>
621 public void RemoveClientThreadSafe(string aSessionId)
623 if (this.InvokeRequired)
625 //Not in the proper thread, invoke ourselves
626 RemoveClientDelegate d = new RemoveClientDelegate(RemoveClientThreadSafe);
627 this.Invoke(d, new object[] { aSessionId });
631 //We are in the proper thread
632 //Remove this session from both client collection and UI tree view
633 if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
635 Program.iMainForm.iClients.Remove(aSessionId);
636 Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
639 if (iClosing && iClients.Count == 0)
641 //We were closing our form
642 //All clients are now closed
643 //Just resume our close operation
653 /// <param name="aLineIndex"></param>
654 /// <param name="aText"></param>
655 public void SetTextThreadSafe(string aSessionId, TextField aTextField)
657 if (this.InvokeRequired)
659 //Not in the proper thread, invoke ourselves
660 SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe);
661 this.Invoke(d, new object[] { aSessionId, aTextField });
665 ClientData client = iClients[aSessionId];
668 //Make sure all our texts are in place
669 while (client.Texts.Count < (aTextField.Index + 1))
671 //Add a text field with proper index
672 client.Texts.Add(new TextField(client.Texts.Count));
674 client.Texts[aTextField.Index] = aTextField;
676 //We are in the proper thread
677 //Only support two lines for now
678 if (aTextField.Index == 0)
680 marqueeLabelTop.Text = aTextField.Text;
681 marqueeLabelTop.TextAlign = aTextField.Alignment;
683 else if (aTextField.Index == 1)
685 marqueeLabelBottom.Text = aTextField.Text;
686 marqueeLabelBottom.TextAlign = aTextField.Alignment;
690 UpdateClientTreeViewNode(client);
698 /// <param name="aTexts"></param>
699 public void SetTextsThreadSafe(string aSessionId, System.Collections.Generic.IList<TextField> aTextFields)
701 if (this.InvokeRequired)
703 //Not in the proper thread, invoke ourselves
704 SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe);
705 this.Invoke(d, new object[] { aSessionId, aTextFields });
709 //We are in the proper thread
710 ClientData client = iClients[aSessionId];
713 //Populate our client with the given text fields
715 foreach (TextField textField in aTextFields)
717 if (client.Texts.Count < (j + 1))
719 client.Texts.Add(textField);
723 client.Texts[j] = textField;
727 //Only support two lines for now
728 for (int i = 0; i < aTextFields.Count; i++)
730 if (aTextFields[i].Index == 0)
732 marqueeLabelTop.Text = aTextFields[i].Text;
733 marqueeLabelTop.TextAlign = aTextFields[i].Alignment;
735 else if (aTextFields[i].Index == 1)
737 marqueeLabelBottom.Text = aTextFields[i].Text;
738 marqueeLabelBottom.TextAlign = aTextFields[i].Alignment;
743 UpdateClientTreeViewNode(client);
752 /// <param name="aSessionId"></param>
753 /// <param name="aName"></param>
754 public void SetClientNameThreadSafe(string aSessionId, string aName)
756 if (this.InvokeRequired)
758 //Not in the proper thread, invoke ourselves
759 SetClientNameDelegate d = new SetClientNameDelegate(SetClientNameThreadSafe);
760 this.Invoke(d, new object[] { aSessionId, aName });
764 //We are in the proper thread
766 ClientData client = iClients[aSessionId];
771 //Update our tree-view
772 UpdateClientTreeViewNode(client);
780 /// <param name="aClient"></param>
781 private void UpdateClientTreeViewNode(ClientData aClient)
788 TreeNode node = null;
789 //Check that our client node already exists
790 //Get our client root node using its key which is our session ID
791 TreeNode[] nodes = treeViewClients.Nodes.Find(aClient.SessionId, false);
794 //We already have a node for that client
796 //Clear children as we are going to recreate them below
801 //Client node does not exists create a new one
802 treeViewClients.Nodes.Add(aClient.SessionId, aClient.SessionId);
803 node = treeViewClients.Nodes.Find(aClient.SessionId, false)[0];
809 if (aClient.Name != "")
811 //We have a name, us it as text for our root node
812 node.Text = aClient.Name;
813 //Add a child with SessionId
814 node.Nodes.Add(new TreeNode(aClient.SessionId));
818 //No name, use session ID instead
819 node.Text = aClient.SessionId;
822 if (aClient.Texts.Count > 0)
824 //Create root node for our texts
825 TreeNode textsRoot = new TreeNode("Text");
826 node.Nodes.Add(textsRoot);
827 //For each text add a new entry
828 foreach (TextField field in aClient.Texts)
830 textsRoot.Nodes.Add(new TreeNode(field.Text));
838 private void buttonAddRow_Click(object sender, EventArgs e)
840 if (tableLayoutPanel.RowCount < 6)
842 tableLayoutPanel.RowCount++;
847 private void buttonRemoveRow_Click(object sender, EventArgs e)
849 if (tableLayoutPanel.RowCount > 1)
851 tableLayoutPanel.RowCount--;
856 private void buttonAddColumn_Click(object sender, EventArgs e)
858 if (tableLayoutPanel.ColumnCount < 8)
860 tableLayoutPanel.ColumnCount++;
865 private void buttonRemoveColumn_Click(object sender, EventArgs e)
867 if (tableLayoutPanel.ColumnCount > 1)
869 tableLayoutPanel.ColumnCount--;
874 private void buttonAlignLeft_Click(object sender, EventArgs e)
876 marqueeLabelTop.TextAlign = ContentAlignment.MiddleLeft;
877 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleLeft;
880 private void buttonAlignCenter_Click(object sender, EventArgs e)
882 marqueeLabelTop.TextAlign = ContentAlignment.MiddleCenter;
883 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleCenter;
886 private void buttonAlignRight_Click(object sender, EventArgs e)
888 marqueeLabelTop.TextAlign = ContentAlignment.MiddleRight;
889 marqueeLabelBottom.TextAlign = ContentAlignment.MiddleRight;
892 private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e)
894 Properties.Settings.Default.CurrentDisplayIndex = comboBoxDisplayType.SelectedIndex;
895 cds.DisplayType = comboBoxDisplayType.SelectedIndex;
896 Properties.Settings.Default.Save();
897 if (iDisplay.IsOpen())
899 OpenDisplayConnection();
908 private void maskedTextBoxTimerInterval_TextChanged(object sender, EventArgs e)
910 if (maskedTextBoxTimerInterval.Text != "")
912 int interval = Convert.ToInt32(maskedTextBoxTimerInterval.Text);
916 timer.Interval = interval;
917 cds.TimerInterval = timer.Interval;
918 Properties.Settings.Default.Save();
923 private void buttonPowerOn_Click(object sender, EventArgs e)
928 private void buttonPowerOff_Click(object sender, EventArgs e)
933 private void buttonShowClock_Click(object sender, EventArgs e)
935 iDisplay.ShowClock();
938 private void buttonHideClock_Click(object sender, EventArgs e)
940 iDisplay.HideClock();
946 /// A UI thread copy of a client relevant data.
947 /// Keeping this copy in the UI thread helps us deal with threading issues.
949 public class ClientData
951 public ClientData(string aSessionId, IDisplayServiceCallback aCallback)
953 SessionId = aSessionId;
955 Texts = new List<TextField>();
956 Callback = aCallback;
959 public string SessionId { get; set; }
960 public string Name { get; set; }
961 public List<TextField> Texts { get; set; }
962 public IDisplayServiceCallback Callback { get; set; }