Fixing string measurement issues. Font dialog now properly initialized with
loaded font.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Runtime.InteropServices;
9 namespace SharpDisplayManager
17 iDevice = IntPtr.Zero;
23 if (iDevice == IntPtr.Zero)
25 iDevice = MiniDisplayOpen();
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 string Vendor()
90 IntPtr ptr = MiniDisplayVendor(iDevice);
91 string str = Marshal.PtrToStringUni(ptr);
95 public string Product()
97 IntPtr ptr = MiniDisplayProduct(iDevice);
98 string str = Marshal.PtrToStringUni(ptr);
102 public string SerialNumber()
104 IntPtr ptr = MiniDisplaySerialNumber(iDevice);
105 string str = Marshal.PtrToStringUni(ptr);
109 //Our display device handle
112 public enum TMiniDisplayRequest
114 EMiniDisplayRequestNone,
115 EMiniDisplayRequestDeviceId,
116 EMiniDisplayRequestFirmwareRevision,
117 EMiniDisplayRequestPowerSupplyStatus
120 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
121 public static extern IntPtr MiniDisplayOpen();
123 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
124 public static extern void MiniDisplayClose(IntPtr aDevice);
126 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
127 public static extern void MiniDisplayClear(IntPtr aDevice);
129 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
130 public static extern void MiniDisplayFill(IntPtr aDevice);
132 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
133 public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
135 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
136 public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
138 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
139 public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
141 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
142 public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
144 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
145 public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
147 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
148 public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
150 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
151 public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
153 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
154 public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
156 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
157 public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
159 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
160 public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
162 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
163 public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
165 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
166 public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
168 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
169 public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
171 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
172 public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
174 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
175 public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
177 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
178 public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
180 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
181 public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
183 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
184 public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
186 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
187 public static extern void MiniDisplayCancelRequest(IntPtr aDevice);