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@10
|
88 |
public string Vendor()
|
sl@10
|
89 |
{
|
sl@10
|
90 |
IntPtr ptr = MiniDisplayVendor(iDevice);
|
sl@10
|
91 |
string str = Marshal.PtrToStringUni(ptr);
|
sl@10
|
92 |
return str;
|
sl@10
|
93 |
}
|
sl@4
|
94 |
|
sl@10
|
95 |
public string Product()
|
sl@10
|
96 |
{
|
sl@10
|
97 |
IntPtr ptr = MiniDisplayProduct(iDevice);
|
sl@10
|
98 |
string str = Marshal.PtrToStringUni(ptr);
|
sl@10
|
99 |
return str;
|
sl@10
|
100 |
}
|
sl@10
|
101 |
|
sl@10
|
102 |
public string SerialNumber()
|
sl@10
|
103 |
{
|
sl@10
|
104 |
IntPtr ptr = MiniDisplaySerialNumber(iDevice);
|
sl@10
|
105 |
string str = Marshal.PtrToStringUni(ptr);
|
sl@10
|
106 |
return str;
|
sl@10
|
107 |
}
|
sl@4
|
108 |
|
sl@3
|
109 |
//Our display device handle
|
sl@3
|
110 |
IntPtr iDevice;
|
sl@3
|
111 |
|
sl@10
|
112 |
public enum TMiniDisplayRequest
|
sl@10
|
113 |
{
|
sl@10
|
114 |
EMiniDisplayRequestNone,
|
sl@10
|
115 |
EMiniDisplayRequestDeviceId,
|
sl@10
|
116 |
EMiniDisplayRequestFirmwareRevision,
|
sl@10
|
117 |
EMiniDisplayRequestPowerSupplyStatus
|
sl@10
|
118 |
}
|
sl@10
|
119 |
|
sl@3
|
120 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
121 |
public static extern IntPtr MiniDisplayOpen();
|
sl@3
|
122 |
|
sl@3
|
123 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
124 |
public static extern void MiniDisplayClose(IntPtr aDevice);
|
sl@3
|
125 |
|
sl@3
|
126 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
127 |
public static extern void MiniDisplayClear(IntPtr aDevice);
|
sl@3
|
128 |
|
sl@3
|
129 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
130 |
public static extern void MiniDisplayFill(IntPtr aDevice);
|
sl@3
|
131 |
|
sl@3
|
132 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
133 |
public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
|
sl@3
|
134 |
|
sl@3
|
135 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
136 |
public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
|
sl@3
|
137 |
|
sl@3
|
138 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
139 |
public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
|
sl@3
|
140 |
|
sl@3
|
141 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@3
|
142 |
public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
|
sl@3
|
143 |
|
sl@4
|
144 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
145 |
public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
|
sl@4
|
146 |
|
sl@4
|
147 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
148 |
public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
|
sl@4
|
149 |
|
sl@4
|
150 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@4
|
151 |
public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
|
sl@4
|
152 |
|
sl@10
|
153 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
154 |
public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
|
sl@10
|
155 |
|
sl@10
|
156 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
157 |
public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
|
sl@10
|
158 |
|
sl@10
|
159 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
160 |
public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
|
sl@10
|
161 |
|
sl@10
|
162 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
163 |
public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
|
sl@10
|
164 |
|
sl@10
|
165 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
166 |
public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
|
sl@10
|
167 |
|
sl@10
|
168 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
169 |
public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
|
sl@10
|
170 |
|
sl@10
|
171 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
172 |
public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
|
sl@10
|
173 |
|
sl@10
|
174 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
175 |
public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
|
sl@10
|
176 |
|
sl@10
|
177 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
178 |
public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
|
sl@10
|
179 |
|
sl@10
|
180 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
181 |
public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
|
sl@10
|
182 |
|
sl@10
|
183 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
184 |
public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
|
sl@10
|
185 |
|
sl@10
|
186 |
[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
sl@10
|
187 |
public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
|
sl@10
|
188 |
|
sl@10
|
189 |
|
sl@10
|
190 |
|
sl@10
|
191 |
|
sl@10
|
192 |
|
sl@3
|
193 |
|
sl@3
|
194 |
}
|
sl@3
|
195 |
}
|