Adding support for vendor, product and serial number.
Strating to add support for requests.
2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10 using CodeProject.Dialog;
12 namespace SharpDisplayManager
14 public partial class MainForm : Form
16 DateTime LastTickTime;
21 LastTickTime = DateTime.Now;
22 iDisplay = new Display();
24 InitializeComponent();
27 marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
28 marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
29 checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
32 private void buttonFont_Click(object sender, EventArgs e)
34 //fontDialog.ShowColor = true;
35 //fontDialog.ShowApply = true;
36 fontDialog.ShowEffects = true;
37 //fontDialog.ShowHelp = true;
39 //fontDlg.MaxSize = 40;
40 //fontDlg.MinSize = 22;
42 //fontDialog.Parent = this;
43 //fontDialog.StartPosition = FormStartPosition.CenterParent;
45 //DlgBox.ShowDialog(fontDialog);
47 //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
48 if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
51 //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
53 //MessageBox.Show("Ok");
54 marqueeLabelTop.Font = fontDialog.Font;
55 marqueeLabelBottom.Font = fontDialog.Font;
56 Properties.Settings.Default.DisplayFont = fontDialog.Font;
57 Properties.Settings.Default.Save();
58 //label1.Font = fontDlg.Font;
59 //textBox1.BackColor = fontDlg.Color;
60 //label1.ForeColor = fontDlg.Color;
64 private void buttonCapture_Click(object sender, EventArgs e)
66 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
67 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
68 bmp.Save("c:\\capture.png");
71 private void timer_Tick(object sender, EventArgs e)
73 //Update our animations
74 DateTime NewTickTime = DateTime.Now;
76 marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
77 marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
80 if (iDisplay.IsOpen())
83 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
84 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
85 //Send it to our display
86 for (int i = 0; i < bmp.Width; i++)
88 for (int j = 0; j < bmp.Height; j++)
92 uint color=(uint)bmp.GetPixel(i, j).ToArgb();
93 iDisplay.SetPixel(i, j, Convert.ToInt32((checkBoxShowBorders.Checked?color!=0xFFFFFFFF:color == 0xFF000000)));
98 iDisplay.SwapBuffers();
102 //Compute instant FPS
103 toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS";
105 LastTickTime = NewTickTime;
109 private void buttonOpen_Click(object sender, EventArgs e)
118 toolStripStatusLabelConnect.Text = "Connection error";
123 private void buttonClose_Click(object sender, EventArgs e)
129 private void buttonClear_Click(object sender, EventArgs e)
132 iDisplay.SwapBuffers();
135 private void buttonFill_Click(object sender, EventArgs e)
138 iDisplay.SwapBuffers();
141 private void trackBarBrightness_Scroll(object sender, EventArgs e)
143 Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
144 Properties.Settings.Default.Save();
145 iDisplay.SetBrightness(trackBarBrightness.Value);
149 private void UpdateStatus()
151 if (iDisplay.IsOpen())
153 buttonFill.Enabled = true;
154 buttonClear.Enabled = true;
155 buttonOpen.Enabled = false;
156 buttonClose.Enabled = true;
157 trackBarBrightness.Enabled = true;
158 trackBarBrightness.Minimum = iDisplay.MinBrightness();
159 trackBarBrightness.Maximum = iDisplay.MaxBrightness();
160 trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
161 trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
162 trackBarBrightness.SmallChange = 1;
163 iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
165 toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
166 //+ " - " + iDisplay.SerialNumber();
170 buttonFill.Enabled = false;
171 buttonClear.Enabled = false;
172 buttonOpen.Enabled = true;
173 buttonClose.Enabled = false;
174 trackBarBrightness.Enabled = false;
175 toolStripStatusLabelConnect.Text = "Disconnected";
179 private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
181 Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
182 Properties.Settings.Default.Save();