コード例 #1
0
        /// <summary>
        /// Starts observing display information for changes.
        /// </summary>
        /// <remarks>
        /// Display events will be never invoked before calling this method.
        /// </remarks>
        public void StartListening()
        {
            Display.StateChanged +=
                (s, e) =>
            {
                DisplayChanged?.Invoke(s, new DisplayStateEventArgs(EnumMapper.DisplayStateMapper(e.State)));
            };

            SystemSettings.ScreenBacklightTimeChanged +=
                (s, e) =>
            {
                ScreenBacklightTimeChanged?.Invoke(s,
                                                   new SystemInfo.Model.Display.ScreenBacklightTimeChangedEventArgs(e.Value));
            };
        }
コード例 #2
0
        /// <summary>
        /// Starts observing battery information for changes.
        /// </summary>
        /// <remarks>
        /// Event BatteryInfoChanged will be never invoked before calling this method.
        /// </remarks>
        public void StartListening()
        {
            Battery.PercentChanged += (s, e) =>
            {
                var batteryEventArgs = new BatteryEventArgs(e.Percent, IsCharging, BatteryLevelStatus);
                OnBatteryChanged(batteryEventArgs);
            };

            Battery.ChargingStateChanged += (s, e) =>
            {
                var batteryEventArgs = new BatteryEventArgs(BatteryLevel, e.IsCharging, BatteryLevelStatus);
                OnBatteryChanged(batteryEventArgs);
            };

            Battery.LevelChanged += (s, e) =>
            {
                var batteryEventArgs = new BatteryEventArgs(BatteryLevel, IsCharging,
                                                            EnumMapper.BatteryLevelStatusMapper(e.Level));
                OnBatteryChanged(batteryEventArgs);
            };
        }