예제 #1
0
        public BrightnessMonitor()
        {
            currentInstance = WMITool.GetDisplayInstance();

            prevBrightness = WMITool.GetBrightness();
            prevState      = WMITool.GetBatteryState();
        }
예제 #2
0
        public void BrightnessTick(int currBrightness)
        {
            int currState = WMITool.GetBatteryState();

            if (currState != prevState)
            {
                WMITool.SetBrightness(currentInstance, prevBrightness);
                BrightnessChanged?.Invoke(prevBrightness);
            }

            prevState      = currState;
            prevBrightness = currBrightness;
        }
예제 #3
0
 public void StartMonitor()
 {
     WMITool.BrightnessChanged((object sender, EventArrivedEventArgs e) => BrightnessTick(int.Parse(e.NewEvent.Properties["Brightness"].Value.ToString())));
 }