Ejemplo n.º 1
0
        /// <summary>
        /// Returns the capabilities of the monitor
        /// </summary>
        private BrightnessInfo getCapabilities()
        {
            var info = new BrightnessInfo();

            try
            {
                using (var monitors = new MonitorsCollector())
                    Dxva2.GetMonitorBrightness(monitors.Primary.hPhysicalMonitor, ref info.Minimum, ref info.Current, ref info.Maximum);

                info.Minimum = 0;
                info.Maximum = 100;
            }
            catch { }
            return(info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the brightness level
        /// </summary>
        public bool SetBrightness(int brightness)
        {
            try
            {
                brightness = Math.Min(Math.Max(brightness, 0), 100);

                using (var monitors = new MonitorsCollector())
                    foreach (Dxva2.PHYSICAL_MONITOR m in monitors)
                    {
                        Dxva2.SetMonitorBrightness(m.hPhysicalMonitor, (short)brightness);
                    }

                this.wmiDriver.SetBrightness(brightness);
                return(true);
            }
            catch { }
            return(false);
        }