private static void Finalize(
     uint pdwNumberOfPhysicalMonitors,
     NativeStructures.PHYSICAL_MONITOR[] pPhysicalMonitorArray)
 {
     var destroyPhysicalMonitors = NativeMethods.DestroyPhysicalMonitors(
         pdwNumberOfPhysicalMonitors,
         pPhysicalMonitorArray);
     if (!destroyPhysicalMonitors)
         throw new Win32Exception(Marshal.GetLastWin32Error());
 }
예제 #2
0
        private unsafe static void TestStructureSizes(List <string> errors, Dictionary <string, int> nativeData)
        {
            Dictionary <string, int> managedData = NativeStructures.ToDictionary(x => x.Name, x => Marshal.SizeOf(x));

            var difference = nativeData.Keys.Except(managedData.Keys);

            if (difference.Any())
            {
                errors.Add("Structure lists are different: " + string.Join(", ", difference) + ".");
                return;
            }

            foreach (string key in nativeData.Keys)
            {
                int nativeSize  = nativeData[key];
                int managedSize = managedData[key];

                if (nativeSize != managedSize)
                {
                    errors.Add("Structure " + key + " declarations are different. Expected size is " + nativeSize.ToString(CultureInfo.InvariantCulture) + " actual size is " + managedSize.ToString(CultureInfo.InvariantCulture) + ".");
                }
            }
        }
        private static uint GetMonitorHandleMinMaxCurBirghtness(
            out NativeStructures.PHYSICAL_MONITOR[] pPhysicalMonitorArray,
            out uint pdwMinimumBrightness,
            out uint pdwCurrentBrightness,
            out uint pdwMaximumBrightness)
        {
            var hMonitor = NativeMethods.MonitorFromWindow(
                NativeMethods.GetDesktopWindow(),
                NativeConstants.MONITOR_DEFAULTTOPRIMARY);

            var pdwNumberOfPhysicalMonitors = 0u;
            var numberOfPhysicalMonitorsFromHmonitor = NativeMethods.GetNumberOfPhysicalMonitorsFromHMONITOR(
                hMonitor,
                ref pdwNumberOfPhysicalMonitors);
            if (!numberOfPhysicalMonitorsFromHmonitor)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            pPhysicalMonitorArray = new NativeStructures.PHYSICAL_MONITOR[pdwNumberOfPhysicalMonitors];
            var physicalMonitorsFromHmonitor = NativeMethods.GetPhysicalMonitorsFromHMONITOR(
                hMonitor,
                pdwNumberOfPhysicalMonitors,
                pPhysicalMonitorArray);
            if (!physicalMonitorsFromHmonitor)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            pdwMinimumBrightness = 0u;
            pdwCurrentBrightness = 0u;
            pdwMaximumBrightness = 0u;
            var getMonitorBrightness = NativeMethods.GetMonitorBrightness(
                pPhysicalMonitorArray[0].hPhysicalMonitor,
                ref pdwMinimumBrightness,
                ref pdwCurrentBrightness,
                ref pdwMaximumBrightness);
            if (!getMonitorBrightness)
                throw new Win32Exception(Marshal.GetLastWin32Error());
            return pdwNumberOfPhysicalMonitors;
        }
예제 #4
0
 internal static IReadOnlyCollection <string> GetManagedStructureNames()
 {
     return(NativeStructures.Select(x => x.Name).ToList());
 }
예제 #5
0
파일: Win32.cs 프로젝트: drdelta/hikari
 public static extern bool GetMonitorTechnologyType(
     IntPtr hMonitor, ref NativeStructures.MC_DISPLAY_TECHNOLOGY_TYPE pdtyDisplayTechnologyType);
예제 #6
0
파일: Win32.cs 프로젝트: drdelta/hikari
 public static extern bool GetMonitorInfo(IntPtr hmon, ref NativeStructures.MonitorInfoEx mi);
예제 #7
0
파일: Win32.cs 프로젝트: drdelta/hikari
 public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, 
     ref NativeStructures.DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
예제 #8
0
파일: Monitor.cs 프로젝트: drdelta/hikari
 public Monitor(NativeStructures.PHYSICAL_MONITOR physicalMonitor)
 {
     HPhysicalMonitor = physicalMonitor.hPhysicalMonitor;
     Name = physicalMonitor.szPhysicalMonitorDescription;
     CheckCapabilities();
 }
예제 #9
0
 public static extern int ph_crosscorr(ref NativeStructures.Digest x, ref NativeStructures.Digest y, out double pcc, double threshold = 0.90);
예제 #10
0
 public static extern int ph_image_digest(string file, double sigma, double gamma, out NativeStructures.Digest digest, int N = 180);
 private double Similarity(ref NativeStructures.Digest digest1, ref NativeStructures.Digest digest2)
 {
     double result;
     NativeFunctions.ph_crosscorr(ref digest1, ref digest2, out result);
     return 1f - result;
 }
 private bool Hash(String imagePath, out NativeStructures.Digest hash)
 {
     return NativeFunctions.ph_image_digest(imagePath, 1.0, 1.0, out hash) != -1;
 }
예제 #13
0
 public RadialHash(NativeStructures.Digest digest)
 {
     this.Digest = digest;
 }