示例#1
0
        private void BrightnessHotkeyEvent(bool IsUp)
        {
            (FindResource("hideMe") as Storyboard).Begin(this);

            IniData data = SettingsController.GetCurrentSettings();

            int StepSize = 5;

            if (int.TryParse(data["Hotkeys"]["StepSize"], out int StepSizeValue))
            {
                StepSize = StepSizeValue;
            }

            try
            {
                double StepDouble = (double)StepSize / 100;

                DisplayConfiguration.PHYSICAL_MONITOR Handle = DisplayConfiguration.GetPhysicalMonitors(DisplayConfiguration.GetCurrentMonitor())[0];
                /*Task.Run(() => { try { DisplayConfiguration.SetBrightnessOffset(Handle, IsUp ? StepDouble : -StepDouble); } catch { } });*/

                if (HotkeyPopupWindow.IsVisible)
                {
                    int HotkeyPopupBrightness = int.Parse(HotkeyPopupWindow.PercentText.Text);
                    int NewBrightness         = HotkeyPopupBrightness + (IsUp ? StepSize : -StepSize);

                    if (NewBrightness > 100)
                    {
                        NewBrightness = 100;
                    }
                    else if (NewBrightness < 0)
                    {
                        NewBrightness = 0;
                    }

                    Task.Run(() => { try { DisplayConfiguration.SetMonitorBrightness(Handle, (double)NewBrightness / 100, HotkeyPopupWindow.dwMinimumBrightness, HotkeyPopupWindow.dwMaximumBrightness); } catch { } });

                    HotkeyPopupWindow.PercentText.Text = NewBrightness.ToString();
                    HotkeyPopupWindow.ShowMe(data["Misc"]["HotkeyPopupPosition"]);
                }
                else
                {
                    DisplayConfiguration.MonitorExtremums MonExtems = DisplayConfiguration.GetMonitorExtremums(Handle);
                    double CurrentBrightness = (double)(MonExtems.Current - MonExtems.Min) / (double)(MonExtems.Max - MonExtems.Min);
                    Task.Run(() => { try { DisplayConfiguration.SetBrightnessOffset(Handle, IsUp ? StepDouble : -StepDouble, CurrentBrightness, MonExtems.Min, MonExtems.Max); } catch { } });
                    HotkeyPopupWindow.dwMinimumBrightness = MonExtems.Min;
                    HotkeyPopupWindow.dwMaximumBrightness = MonExtems.Max;
                    HotkeyPopupWindow.dwCurrentBrightness = MonExtems.Current;
                    HotkeyPopupWindow.PercentText.Text    = ((CurrentBrightness * 100) + (IsUp ? StepSize : -StepSize)).ToString();
                    HotkeyPopupWindow.ShowMe(data["Misc"]["HotkeyPopupPosition"]);
                }
            }
            catch { }
        }
示例#2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            UpdateMonitorList();
            SetWindowPosition();
            Show();
            Activate();
            Set_Initial_Brightness();
            AfterUpdateCheck();

            IniData data = SettingsController.GetCurrentSettings();

            DisplayConfiguration.PHYSICAL_MONITOR Handle = DisplayConfiguration.GetPhysicalMonitors(DisplayConfiguration.GetCurrentMonitor())[0];

            try
            {
                DisplayConfiguration.MonitorExtremums MonExtems = DisplayConfiguration.GetMonitorExtremums(Handle);
                double CurrentBrightness = (double)(MonExtems.Current - MonExtems.Min) / (double)(MonExtems.Max - MonExtems.Min);
                HotkeyPopupWindow.dwMinimumBrightness = MonExtems.Min;
                HotkeyPopupWindow.dwMaximumBrightness = MonExtems.Max;
                HotkeyPopupWindow.dwCurrentBrightness = MonExtems.Current;
                HotkeyPopupWindow.PercentText.Text    = (CurrentBrightness * 100).ToString();
            } catch { }
            HotkeyPopupWindow.Show();
            HotkeyPopupWindow.ShowMe(data["Misc"]["HotkeyPopupPosition"]);
        }