public void SetDisplayBrightness(uint brightness)
        {
            DisplayController dispController = DisplayController.Instance;

            //set the brightness of each attached display
            foreach (Display display in dispController.AttachedDisplays)
            {
                if (display.IsValid)
                {
                    dispController.SetAttachedDisplayBrightness(display, brightness);
                }
            }

            //also set the brightness of the integrated display, if there is one
            dispController.SetIntegratedDisplayBrightness(brightness);
        }
        private void _OnDisplayRefresh()
        {
            //have to re-check whether there are multiple monitors and if all monitors support brightness changes
            DisplayController controller = DisplayController.Instance;

            MultipleDisplaysConnected = (controller.AttachedDisplays.Count > 1 || (controller.AttachedDisplays.Count == 1 && controller.IntegratedDisplaySupported == true)) ? true : false;

            NoSupportDetected = false;
            foreach (Display display in controller.AttachedDisplays)
            {
                if (display.SupportsBrightness() == false)
                {
                    NoSupportDetected = true;
                    break;
                }
            }

            if (m_brightnessDimmer.Status == DimmerStatus.Idle)
            {
                m_brightnessDimmer.AdjustBrightness(m_currentBrightness, m_currentBrightness, 0.0);
            }
        }
        private void _InitializeApp(Window window)
        {
            DisplayController dispController = DisplayController.Instance;

            _LoadAppData();

            if (m_startMinimized)
            {
                window.Hide();
                window.ShowInTaskbar = false;
            }

            /*wait for the display controller to finish initializing before proceeding.
             * if something went wrong this call will throw a win32exception*/
            dispController.Initialization.Wait();

            WindowTitle = "Unblind " + m_versionMajor.ToString() + "." + m_versionMinor.ToString() + "." + m_versionIteration.ToString();

            if (dispController.AttachedDisplays.Count > 0)
            {
                bool supportsBrightness = true;
                foreach (Display display in dispController.AttachedDisplays)
                {
                    if (m_firstRun && supportsBrightness && display.SupportsBrightness() == false)
                    {
                        supportsBrightness = false;
                        MessageBox.Show("It appears that one or more of your displays do not support the DDC/CI protocol required to change the brightness via software. Unblind may or may not be able to control these displays.", "Hmm...", MessageBoxButton.OK);
                    }

                    //determine the highest minimum brightness and lowest maximum brightness among all displays and use these as the brightness limits
                    if (display.MinBrightness > m_minDisplayBrightness)
                    {
                        MinDisplayBrightness = MathHelpers.Greater(display.MinBrightness, (uint)1);
                    }
                    if (display.MaxBrightness > m_maxDisplayBrightness)
                    {
                        MaxDisplayBrightness = MathHelpers.Greater(display.MaxBrightness, (uint)1);
                    }
                    if (display.SupportsBrightness() == false)
                    {
                        NoSupportDetected = true;
                    }
                }
            }
            else if (dispController.IntegratedDisplaySupported == true)
            {
                MinDisplayBrightness = 0;
                MaxDisplayBrightness = 100;
            }

            if (dispController.AttachedDisplays.Count > 1 || (dispController.AttachedDisplays.Count >= 1 && dispController.IntegratedDisplaySupported == true))
            {
                MultipleDisplaysConnected = true;
            }

            dispController.OnDisplayRefesh += _OnDisplayRefresh;

            CurrentBrightnessTransitionStatus = DimmerStatus.Idle;

            _UpdateTimeToNextPeriod();

            m_brightnessDimmer.SetDisplayBrightness((m_brightnessScheduler.CurrentTimePeriod == TimePeriod.Day) ? (uint)m_brightnessScheduler.DayBrightness : (uint)m_brightnessScheduler.NightBrightness);

            m_systemClockTimer.Start();
        }