Display is now updated as labels are scrolling.
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 private void buttonFont_Click(object sender, EventArgs e)
29 //fontDialog.ShowColor = true;
30 //fontDialog.ShowApply = true;
31 fontDialog.ShowEffects = true;
32 //fontDialog.ShowHelp = true;
34 //fontDlg.MaxSize = 40;
35 //fontDlg.MinSize = 22;
37 //fontDialog.Parent = this;
38 //fontDialog.StartPosition = FormStartPosition.CenterParent;
40 //DlgBox.ShowDialog(fontDialog);
42 //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
43 if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
46 //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
48 //MessageBox.Show("Ok");
49 marqueeLabelTop.Font = fontDialog.Font;
50 marqueeLabelBottom.Font = fontDialog.Font;
51 //label1.Font = fontDlg.Font;
52 //textBox1.BackColor = fontDlg.Color;
53 //label1.ForeColor = fontDlg.Color;
57 private void buttonCapture_Click(object sender, EventArgs e)
59 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
60 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
61 bmp.Save("c:\\capture.png");
64 private void timer_Tick(object sender, EventArgs e)
66 //Update our animations
67 DateTime NewTickTime = DateTime.Now;
69 marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
70 marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
72 LastTickTime = NewTickTime;
75 if (iDisplay.IsOpen())
78 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
79 tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
80 //Send it to our display
81 for (int i = 0; i < bmp.Width; i++)
83 for (int j = 0; j < bmp.Height; j++)
87 uint color=(uint)bmp.GetPixel(i, j).ToArgb();
88 iDisplay.SetPixel(i, j, Convert.ToInt32(color!=0xFFFFFFFF));
93 iDisplay.SwapBuffers();
98 private void buttonOpen_Click(object sender, EventArgs e)
102 trackBarBrightness.Minimum = iDisplay.MinBrightness();
103 trackBarBrightness.Maximum = iDisplay.MaxBrightness();
108 private void buttonClose_Click(object sender, EventArgs e)
113 private void buttonClear_Click(object sender, EventArgs e)
116 iDisplay.SwapBuffers();
119 private void buttonFill_Click(object sender, EventArgs e)
122 iDisplay.SwapBuffers();
125 private void trackBarBrightness_Scroll(object sender, EventArgs e)
127 iDisplay.SetBrightness(trackBarBrightness.Value);