예제 #1
0
 public static uint ValFromPercent(this MinMaxVal <uint> v, double p)
 {
     return((uint)Math.Round(((v.Max - v.Min) * p)));
 }
예제 #2
0
 public static double MinMaxValToPercent(this MinMaxVal <uint> v)
 {
     return(v.Val / (double)(v.Max - v.Min));
 }
        public PhysicalMonitor(Win32.Dxva2.PhysicalMonitorEnumerationApi.PHYSICAL_MONITOR physicalMonitor)
        {
            _physicalMonitor = physicalMonitor;

            Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorCapabilities(_physicalMonitor.hPhysicalMonitor,
                                                                                out _pdwMonitorCapabilities,
                                                                                out _pdwSupportedColorTemperatures);

            Brightness = new MinMaxVal <uint>(
                () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorBrightness(
                    _physicalMonitor.hPhysicalMonitor, out min, out val, out max);
                return(Tuple.Create(min, val, max));
            },
                (min, val, max) =>
                Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorBrightness(_physicalMonitor.hPhysicalMonitor, val));

            Contrast = new MinMaxVal <uint>(
                () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorContrast(
                    _physicalMonitor.hPhysicalMonitor, out min, out val, out max);
                return(Tuple.Create(min, val, max));
            },
                (min, val, max) =>
                Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorContrast(_physicalMonitor.hPhysicalMonitor, val));

            Drive = new RGBSetting <uint>(
                new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueDrive(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_RED_DRIVE, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueDrive(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_RED_DRIVE,
                        val))
                ,
                new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueDrive(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_GREEN_DRIVE, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueDrive(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_GREEN_DRIVE,
                        val))
                , new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueDrive(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_BLUE_DRIVE, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueDrive(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_DRIVE_TYPE.MC_BLUE_DRIVE,
                        val))
                );

            Gain = new RGBSetting <uint>(
                new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueGain(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_RED_GAIN, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueGain(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_RED_GAIN,
                        val))
                ,
                new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueGain(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_GREEN_GAIN, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueGain(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_GREEN_GAIN,
                        val))
                , new MinMaxVal <uint>(
                    () =>
            {
                uint min, val, max;
                Win32.Dxva2.HighlevelMonitorConfigurationApi.GetMonitorRedGreenOrBlueGain(
                    _physicalMonitor.hPhysicalMonitor,
                    Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_BLUE_GAIN, out min,
                    out val, out max);
                return(Tuple.Create(min, val, max));
            },
                    (min, val, max) => Win32.Dxva2.HighlevelMonitorConfigurationApi.SetMonitorRedGreenOrBlueGain(
                        _physicalMonitor.hPhysicalMonitor,
                        Win32.Dxva2.HighlevelMonitorConfigurationApi.MC_GAIN_TYPE.MC_BLUE_GAIN,
                        val))
                );
        }