sl@3
|
1 |
using System;
|
sl@3
|
2 |
using System.Collections.Generic;
|
sl@3
|
3 |
using System.Linq;
|
sl@3
|
4 |
using System.Text;
|
sl@3
|
5 |
using System.Threading.Tasks;
|
sl@3
|
6 |
//
|
sl@3
|
7 |
using System.Runtime.InteropServices;
|
sl@3
|
8 |
|
sl@3
|
9 |
namespace SharpDisplayManager
|
sl@3
|
10 |
{
|
sl@3
|
11 |
class Display
|
sl@3
|
12 |
{
|
sl@3
|
13 |
|
sl@3
|
14 |
//Constructor
|
sl@3
|
15 |
public Display()
|
sl@3
|
16 |
{
|
sl@3
|
17 |
iDevice = IntPtr.Zero;
|
sl@3
|
18 |
}
|
sl@3
|
19 |
|
sl@3
|
20 |
//
|
sl@3
|
21 |
public bool Open()
|
sl@3
|
22 |
{
|
sl@3
|
23 |
if (iDevice == IntPtr.Zero)
|
sl@3
|
24 |
{
|
sl@6
|
25 |
iDevice = MiniDisplayOpen();
|
sl@3
|
26 |
}
|
sl@3
|
27 |
return iDevice != IntPtr.Zero;
|
sl@3
|
28 |
}
|
sl@3
|
29 |
|
sl@3
|
30 |
public void Close()
|
sl@3
|
31 |
{
|
sl@3
|
32 |
MiniDisplayClose(iDevice);
|
sl@3
|
33 |
iDevice = IntPtr.Zero;
|
sl@3
|
34 |
}
|
sl@3
|
35 |
|
sl@3
|
36 |
public bool IsOpen()
|
sl@3
|
37 |
{
|
sl@3
|
38 |
return iDevice != IntPtr.Zero;
|
sl@3
|
39 |
}
|
sl@3
|
40 |
|
sl@3
|
41 |
public void Clear()
|
sl@3
|
42 |
{
|
sl@3
|
43 |
MiniDisplayClear(iDevice);
|
sl@3
|
44 |
}
|
sl@3
|
45 |
|
sl@3
|
46 |
public void Fill()
|
sl@3
|
47 |
{
|
sl@3
|
48 |
MiniDisplayFill(iDevice);
|
sl@3
|
49 |
}
|
sl@3
|
50 |
|
sl@3
|
51 |
public void SwapBuffers()
|
sl@3
|
52 |
{
|
sl@3
|
53 |
MiniDisplaySwapBuffers(iDevice);
|
sl@3
|
54 |
}
|
sl@3
|
55 |
|
sl@3
|
56 |
public int MaxBrightness()
|
sl@3
|
57 |
{
|
sl@3
|
58 |
return MiniDisplayMaxBrightness(iDevice);
|
sl@3
|
59 |
}
|
sl@3
|
60 |
|
sl@3
|
61 |
public int MinBrightness()
|
sl@3
|
62 |
{
|
sl@3
|
63 |
return MiniDisplayMinBrightness(iDevice);
|
sl@3
|
64 |
}
|
sl@3
|
65 |
|
sl@3
|
66 |
public void SetBrightness(int aBrightness)
|
sl@3
|
67 |
{
|
sl@3
|
68 |
if (!IsOpen()) return;
|
sl@3
|
69 |
|
sl@3
|
70 |
MiniDisplaySetBrightness(iDevice, aBrightness);
|
sl@3
|
71 |
}
|
sl@3
|
72 |
|
sl@4
|
73 |
public int WidthInPixels()
|
sl@4
|
74 |
{
|
sl@4
|
75 |
return MiniDisplayWidthInPixels(iDevice);
|
sl@4
|
76 |
}
|
sl@4
|
77 |
|
sl@4
|
78 |
public int HeightInPixels()
|
sl@4
|
79 |
{
|
sl@4
|
80 |
return MiniDisplayHeightInPixels(iDevice);
|
sl@4
|
81 |
}
|
sl@4
|
82 |
|
sl@4
|
83 |
public void SetPixel(int aX, int aY, int aValue)
|
sl@4
|
84 |
{
|
sl@4
|
85 |
MiniDisplaySetPixel(iDevice,aX,aY,aValue);
|
sl@4
|
86 |
}
|
sl@4
|
87 |
|
sl@4
|
88 |
|
sl@4
|
89 |
|
sl@3
|
90 |
//Our display device handle
|
sl@3
|
91 |
IntPtr iDevice;
|
sl@3
|
92 |
|
sl@3
|
93 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
94 |
public static extern IntPtr MiniDisplayOpen();
|
sl@3
|
95 |
|
sl@3
|
96 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
97 |
public static extern void MiniDisplayClose(IntPtr aDevice);
|
sl@3
|
98 |
|
sl@3
|
99 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
100 |
public static extern void MiniDisplayClear(IntPtr aDevice);
|
sl@3
|
101 |
|
sl@3
|
102 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
103 |
public static extern void MiniDisplayFill(IntPtr aDevice);
|
sl@3
|
104 |
|
sl@3
|
105 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
106 |
public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
|
sl@3
|
107 |
|
sl@3
|
108 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
109 |
public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
|
sl@3
|
110 |
|
sl@3
|
111 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
112 |
public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
|
sl@3
|
113 |
|
sl@3
|
114 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
115 |
public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
|
sl@3
|
116 |
|
sl@4
|
117 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
118 |
public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
|
sl@4
|
119 |
|
sl@4
|
120 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
121 |
public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
|
sl@4
|
122 |
|
sl@4
|
123 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
124 |
public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
|
sl@4
|
125 |
|
sl@3
|
126 |
|
sl@3
|
127 |
}
|
sl@3
|
128 |
}
|