sl@0
|
1 |
using System;
|
sl@0
|
2 |
using System.Collections.Generic;
|
sl@0
|
3 |
using System.ComponentModel;
|
sl@0
|
4 |
using System.Data;
|
sl@0
|
5 |
using System.Drawing;
|
sl@0
|
6 |
using System.Linq;
|
sl@0
|
7 |
using System.Text;
|
sl@0
|
8 |
using System.Threading.Tasks;
|
sl@0
|
9 |
using System.Windows.Forms;
|
sl@0
|
10 |
using CodeProject.Dialog;
|
sl@0
|
11 |
|
sl@0
|
12 |
namespace SharpDisplayManager
|
sl@0
|
13 |
{
|
sl@0
|
14 |
public partial class MainForm : Form
|
sl@0
|
15 |
{
|
sl@2
|
16 |
DateTime LastTickTime;
|
sl@3
|
17 |
Display iDisplay;
|
sl@2
|
18 |
|
sl@0
|
19 |
public MainForm()
|
sl@0
|
20 |
{
|
sl@2
|
21 |
LastTickTime = DateTime.Now;
|
sl@3
|
22 |
iDisplay = new Display();
|
sl@2
|
23 |
|
sl@0
|
24 |
InitializeComponent();
|
sl@0
|
25 |
}
|
sl@0
|
26 |
|
sl@0
|
27 |
private void buttonFont_Click(object sender, EventArgs e)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
//fontDialog.ShowColor = true;
|
sl@0
|
30 |
//fontDialog.ShowApply = true;
|
sl@0
|
31 |
fontDialog.ShowEffects = true;
|
sl@0
|
32 |
//fontDialog.ShowHelp = true;
|
sl@0
|
33 |
|
sl@0
|
34 |
//fontDlg.MaxSize = 40;
|
sl@0
|
35 |
//fontDlg.MinSize = 22;
|
sl@0
|
36 |
|
sl@0
|
37 |
//fontDialog.Parent = this;
|
sl@0
|
38 |
//fontDialog.StartPosition = FormStartPosition.CenterParent;
|
sl@0
|
39 |
|
sl@0
|
40 |
//DlgBox.ShowDialog(fontDialog);
|
sl@0
|
41 |
|
sl@0
|
42 |
//if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
|
sl@0
|
43 |
if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
|
sl@4
|
46 |
//MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
|
sl@0
|
47 |
|
sl@0
|
48 |
//MessageBox.Show("Ok");
|
sl@4
|
49 |
marqueeLabelTop.Font = fontDialog.Font;
|
sl@4
|
50 |
marqueeLabelBottom.Font = fontDialog.Font;
|
sl@0
|
51 |
//label1.Font = fontDlg.Font;
|
sl@0
|
52 |
//textBox1.BackColor = fontDlg.Color;
|
sl@0
|
53 |
//label1.ForeColor = fontDlg.Color;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
private void buttonCapture_Click(object sender, EventArgs e)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
|
sl@0
|
60 |
tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
|
sl@0
|
61 |
bmp.Save("c:\\capture.png");
|
sl@0
|
62 |
}
|
sl@2
|
63 |
|
sl@2
|
64 |
private void timer_Tick(object sender, EventArgs e)
|
sl@2
|
65 |
{
|
sl@2
|
66 |
//Update our animations
|
sl@2
|
67 |
DateTime NewTickTime = DateTime.Now;
|
sl@2
|
68 |
|
sl@2
|
69 |
marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
|
sl@2
|
70 |
marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
|
sl@2
|
71 |
|
sl@2
|
72 |
LastTickTime = NewTickTime;
|
sl@4
|
73 |
|
sl@4
|
74 |
//Update our display
|
sl@4
|
75 |
if (iDisplay.IsOpen())
|
sl@4
|
76 |
{
|
sl@4
|
77 |
//Draw to bitmap
|
sl@4
|
78 |
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
|
sl@4
|
79 |
tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
|
sl@4
|
80 |
//Send it to our display
|
sl@4
|
81 |
for (int i = 0; i < bmp.Width; i++)
|
sl@4
|
82 |
{
|
sl@4
|
83 |
for (int j = 0; j < bmp.Height; j++)
|
sl@4
|
84 |
{
|
sl@4
|
85 |
unchecked
|
sl@4
|
86 |
{
|
sl@4
|
87 |
uint color=(uint)bmp.GetPixel(i, j).ToArgb();
|
sl@4
|
88 |
iDisplay.SetPixel(i, j, Convert.ToInt32(color!=0xFFFFFFFF));
|
sl@4
|
89 |
}
|
sl@4
|
90 |
}
|
sl@4
|
91 |
}
|
sl@4
|
92 |
|
sl@4
|
93 |
iDisplay.SwapBuffers();
|
sl@4
|
94 |
|
sl@4
|
95 |
}
|
sl@2
|
96 |
}
|
sl@3
|
97 |
|
sl@3
|
98 |
private void buttonOpen_Click(object sender, EventArgs e)
|
sl@3
|
99 |
{
|
sl@3
|
100 |
if (iDisplay.Open())
|
sl@3
|
101 |
{
|
sl@3
|
102 |
trackBarBrightness.Minimum = iDisplay.MinBrightness();
|
sl@3
|
103 |
trackBarBrightness.Maximum = iDisplay.MaxBrightness();
|
sl@3
|
104 |
}
|
sl@3
|
105 |
|
sl@3
|
106 |
}
|
sl@3
|
107 |
|
sl@3
|
108 |
private void buttonClose_Click(object sender, EventArgs e)
|
sl@3
|
109 |
{
|
sl@3
|
110 |
iDisplay.Close();
|
sl@3
|
111 |
}
|
sl@3
|
112 |
|
sl@3
|
113 |
private void buttonClear_Click(object sender, EventArgs e)
|
sl@3
|
114 |
{
|
sl@3
|
115 |
iDisplay.Clear();
|
sl@3
|
116 |
iDisplay.SwapBuffers();
|
sl@3
|
117 |
}
|
sl@3
|
118 |
|
sl@3
|
119 |
private void buttonFill_Click(object sender, EventArgs e)
|
sl@3
|
120 |
{
|
sl@3
|
121 |
iDisplay.Fill();
|
sl@3
|
122 |
iDisplay.SwapBuffers();
|
sl@3
|
123 |
}
|
sl@3
|
124 |
|
sl@3
|
125 |
private void trackBarBrightness_Scroll(object sender, EventArgs e)
|
sl@3
|
126 |
{
|
sl@3
|
127 |
iDisplay.SetBrightness(trackBarBrightness.Value);
|
sl@3
|
128 |
}
|
sl@0
|
129 |
}
|
sl@0
|
130 |
}
|