sl@3: using System; sl@3: using System.Collections.Generic; sl@3: using System.Linq; sl@3: using System.Text; sl@3: using System.Threading.Tasks; sl@3: // sl@3: using System.Runtime.InteropServices; sl@3: sl@3: namespace SharpDisplayManager sl@3: { sl@3: class Display sl@3: { sl@3: sl@3: //Constructor sl@3: public Display() sl@3: { sl@3: iDevice = IntPtr.Zero; sl@3: } sl@3: sl@3: // sl@3: public bool Open() sl@3: { sl@3: if (iDevice == IntPtr.Zero) sl@3: { sl@6: iDevice = MiniDisplayOpen(); sl@3: } sl@3: return iDevice != IntPtr.Zero; sl@3: } sl@3: sl@3: public void Close() sl@3: { sl@3: MiniDisplayClose(iDevice); sl@3: iDevice = IntPtr.Zero; sl@3: } sl@3: sl@3: public bool IsOpen() sl@3: { sl@3: return iDevice != IntPtr.Zero; sl@3: } sl@3: sl@3: public void Clear() sl@3: { sl@3: MiniDisplayClear(iDevice); sl@3: } sl@3: sl@3: public void Fill() sl@3: { sl@3: MiniDisplayFill(iDevice); sl@3: } sl@3: sl@3: public void SwapBuffers() sl@3: { sl@3: MiniDisplaySwapBuffers(iDevice); sl@3: } sl@3: sl@3: public int MaxBrightness() sl@3: { sl@3: return MiniDisplayMaxBrightness(iDevice); sl@3: } sl@3: sl@3: public int MinBrightness() sl@3: { sl@3: return MiniDisplayMinBrightness(iDevice); sl@3: } sl@3: sl@3: public void SetBrightness(int aBrightness) sl@3: { sl@3: if (!IsOpen()) return; sl@3: sl@3: MiniDisplaySetBrightness(iDevice, aBrightness); sl@3: } sl@3: sl@4: public int WidthInPixels() sl@4: { sl@4: return MiniDisplayWidthInPixels(iDevice); sl@4: } sl@4: sl@4: public int HeightInPixels() sl@4: { sl@4: return MiniDisplayHeightInPixels(iDevice); sl@4: } sl@4: sl@4: public void SetPixel(int aX, int aY, int aValue) sl@4: { sl@4: MiniDisplaySetPixel(iDevice,aX,aY,aValue); sl@4: } sl@4: sl@4: sl@4: sl@3: //Our display device handle sl@3: IntPtr iDevice; sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern IntPtr MiniDisplayOpen(); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern void MiniDisplayClose(IntPtr aDevice); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern void MiniDisplayClear(IntPtr aDevice); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern void MiniDisplayFill(IntPtr aDevice); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern void MiniDisplaySwapBuffers(IntPtr aDevice); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern int MiniDisplayMinBrightness(IntPtr aDevice); sl@3: sl@3: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@3: public static extern int MiniDisplayMaxBrightness(IntPtr aDevice); sl@3: sl@4: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@4: public static extern int MiniDisplayWidthInPixels(IntPtr aDevice); sl@4: sl@4: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@4: public static extern int MiniDisplayHeightInPixels(IntPtr aDevice); sl@4: sl@4: [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] sl@4: public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue); sl@4: sl@3: sl@3: } sl@3: }