コード例 #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())));
 }