Пример #1
0
        /// <summary>
        /// Update the slider due to a brightness changed event.
        /// </summary>
        private void EventWatcher_BrightnessChanged(object sender, EventWatcherAsync.BrightnessChangedEventArgs e)
        {
            NotifyIcon.Text = "Brightness " + e.newBrightness.ToString() + "%";

            // Only update the slider if the event was generated from an external source
            // - and NOT caused by BrightnessTray.
            // This helps keep the slider free of being jerky when the user is moving it.

            // e.g. ignore if the user is dragging the slider, or using the scroll wheel on the slider, or up/down keys on the slider.
            // needs to be IsMouseOver for entire form in case of scroll wheel.
            if (!IsMouseOver && !isKeyDown)
            {
                this.Dispatcher.BeginInvoke((Action)(() =>
                {
                    int value = int.Parse(e.newBrightness.ToString());

                    // 0 <= value <= 100

                    this.BrightnessSlider.Value = value;
                    this.percentageLabel.Content = value.ToString() + "%";
                    DrawIcon.updateNotifyIcon(NotifyIcon, value);
                }));
            }
        }