Fixing designer issues with controls being outside our dialog.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Runtime.InteropServices;
9 namespace SharpDisplayManager
17 iDevice = IntPtr.Zero;
21 public bool Open(TMiniDisplayType aType)
23 if (iDevice == IntPtr.Zero)
25 iDevice = MiniDisplayOpen(aType);
27 return iDevice != IntPtr.Zero;
32 MiniDisplayClose(iDevice);
33 iDevice = IntPtr.Zero;
38 return iDevice != IntPtr.Zero;
43 MiniDisplayClear(iDevice);
48 MiniDisplayFill(iDevice);
51 public void SwapBuffers()
53 MiniDisplaySwapBuffers(iDevice);
56 public int MaxBrightness()
58 return MiniDisplayMaxBrightness(iDevice);
61 public int MinBrightness()
63 return MiniDisplayMinBrightness(iDevice);
66 public void SetBrightness(int aBrightness)
68 if (!IsOpen()) return;
70 MiniDisplaySetBrightness(iDevice, aBrightness);
73 public int WidthInPixels()
75 return MiniDisplayWidthInPixels(iDevice);
78 public int HeightInPixels()
80 return MiniDisplayHeightInPixels(iDevice);
83 public void SetPixel(int aX, int aY, int aValue)
85 MiniDisplaySetPixel(iDevice,aX,aY,aValue);
88 public void RequestPowerSupplyStatus()
90 MiniDisplayRequestPowerSupplyStatus(iDevice);
93 public void RequestDeviceId()
95 MiniDisplayRequestDeviceId(iDevice);
98 public void RequestFirmwareRevision()
100 MiniDisplayRequestFirmwareRevision(iDevice);
103 public bool PowerSupplyStatus()
105 bool res = MiniDisplayPowerSupplyStatus(iDevice);
109 public TMiniDisplayRequest AttemptRequestCompletion()
111 return MiniDisplayAttemptRequestCompletion(iDevice);
114 public TMiniDisplayRequest CurrentRequest()
116 return MiniDisplayCurrentRequest(iDevice);
119 public bool IsRequestPending()
121 return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
125 public string Vendor()
127 IntPtr ptr = MiniDisplayVendor(iDevice);
128 string str = Marshal.PtrToStringUni(ptr);
132 public string Product()
134 IntPtr ptr = MiniDisplayProduct(iDevice);
135 string str = Marshal.PtrToStringUni(ptr);
139 public string SerialNumber()
141 IntPtr ptr = MiniDisplaySerialNumber(iDevice);
142 string str = Marshal.PtrToStringUni(ptr);
146 public string DeviceId()
148 IntPtr ptr = MiniDisplayDeviceId(iDevice);
149 string str = Marshal.PtrToStringAnsi(ptr);
153 public string FirmwareRevision()
155 IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
156 string str = Marshal.PtrToStringAnsi(ptr);
160 //Our display device handle
163 public enum TMiniDisplayType
165 EMiniDisplayAutoDetect, /*Not yet implemented*/
166 EMiniDisplayFutabaGP1212A01,
167 EMiniDisplayFutabaGP1212A02
171 public enum TMiniDisplayRequest
173 EMiniDisplayRequestNone,
174 EMiniDisplayRequestDeviceId,
175 EMiniDisplayRequestFirmwareRevision,
176 EMiniDisplayRequestPowerSupplyStatus
179 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
180 public static extern IntPtr MiniDisplayOpen(TMiniDisplayType aType);
182 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
183 public static extern void MiniDisplayClose(IntPtr aDevice);
185 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
186 public static extern void MiniDisplayClear(IntPtr aDevice);
188 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
189 public static extern void MiniDisplayFill(IntPtr aDevice);
191 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
192 public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
194 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
195 public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
197 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
198 public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
200 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
201 public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
203 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
204 public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
206 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
207 public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
209 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
210 public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
212 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
213 public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
215 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
216 public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
218 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
219 public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
221 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
222 public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
224 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
225 public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
227 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
228 [return: MarshalAs(UnmanagedType.I1)]
229 public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
231 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
232 public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
234 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
235 public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
237 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
238 public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
240 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
241 public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
243 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
244 public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
246 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
247 public static extern void MiniDisplayCancelRequest(IntPtr aDevice);