Exemple #1
0
        private void DDCBrightness_MouseUp(object sender, EventArgs e)
        {
            Setup.Logger.Instance().LogDump("DDCControl", "DDCBrightness Mouse Up Called");
            if (_config.TurnOffDDCControl == true)
            {
                SetMonitorState(-1);
                SetMonitorWake();
                return;
            }


            try
            {
                Window window = Window.GetWindow(this);
                var    wih    = new WindowInteropHelper(window);
                IntPtr hWnd   = wih.Handle;
                brightnessControl = new FrontView.Libs.DDCControl.BrightnessControl(hWnd);



                if (brightnessControl != null && brightnessInfo.current != -1)
                {
                    brightnessControl.SetBrightness((short)brightnessInfo.current, 0);
                    brightnessControl.SetContrast((short)brightnessInfo.current, 0);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        private void DDCBrightness_MouseDown(object sender, EventArgs e)
        {
            if (_config.TurnOffDDCControl == true)
            {
                // Turn Monitor Off Completely
                SetMonitorState(2);
                return;
            }


            try
            {
                Window window = Window.GetWindow(this);
                var    wih    = new WindowInteropHelper(window);
                IntPtr hWnd   = wih.Handle;
                brightnessControl = new FrontView.Libs.DDCControl.BrightnessControl(hWnd);

                // AGain Change just gets levels at startup.
                //brightnessInfo = brightnessControl.GetBrightnessCapabilities(0);
                //contrastInfo = brightnessControl.GetContrastCapabilities(0);

                if (brightnessControl != null && brightnessInfo.current != -1)
                {
                    brightnessControl.SetBrightness((short)brightnessInfo.minimum, 0);
                    brightnessControl.SetContrast((short)brightnessInfo.minimum, 0);
                }
            }
            catch (Exception)
            {
            }
        }
        private void DDCBrightness_MouseUp(object sender, EventArgs e)
        {
            try
            {

                Window window = Window.GetWindow(this);
                var wih = new WindowInteropHelper(window);
                IntPtr hWnd = wih.Handle;
                brightnessControl = new FrontView.Libs.DDCControl.BrightnessControl(hWnd);



                if (brightnessControl != null && brightnessInfo.current != -1)
                {
                    brightnessControl.SetBrightness((short)brightnessInfo.current, 0);
                    brightnessControl.SetContrast((short)brightnessInfo.current, 0);
                }
            }
            catch (Exception )
            {

            }
        }
        private void DDCBrightness_MouseDown(object sender, EventArgs e)
        {
            try
            {
                Window window = Window.GetWindow(this);
                var wih = new WindowInteropHelper(window);
                IntPtr hWnd = wih.Handle;
                brightnessControl = new FrontView.Libs.DDCControl.BrightnessControl(hWnd);

                // AGain Change just gets levels at startup.
                //brightnessInfo = brightnessControl.GetBrightnessCapabilities(0);
                //contrastInfo = brightnessControl.GetContrastCapabilities(0);

                if (brightnessControl != null && brightnessInfo.current != -1)
                {
                    brightnessControl.SetBrightness((short)brightnessInfo.minimum, 0);
                    brightnessControl.SetContrast((short)brightnessInfo.minimum, 0);
                }
            }
            catch (Exception )
            {
              
            }
        }
Exemple #5
0
        public void SetBrightnessContrast(bool turnonoff)
        {
            
            if (_config.UseDDCControl == false)
            {
                return;
            }
            Logger.Instance().Trace("DDCControl", "brightnessInfo Before Check:" + brightnessInfo.current + " maximum:" + brightnessInfo.maximum + " minimum:" + brightnessInfo.minimum);

            if (brightnessInfo.maximum == -1  )
            {
                Logger.Instance().Trace("DDCControl", "Maximum equals -1 : can't be set : try now to set " );
                Logger.Instance().Trace("DDCControl", "brightnessInfo:" + brightnessInfo.current + " maximum:" + brightnessInfo.maximum + " minimum:" + brightnessInfo.minimum);
                InitDDCControl();
            }


            try
            {
                Window window = Window.GetWindow(this);
                var wih = new WindowInteropHelper(window);
                IntPtr hWnd = wih.Handle;
                brightnessControl = new FrontView.Libs.DDCControl.BrightnessControl(hWnd);
                // false equals set to zero/lowest possible/save current values first
                //brightnessControl.GetMonitorCapabilities(0);

                if (turnonoff == false)
                {
                    
                   // Change here - don't get Current Levels to confusing/just get current levels at start of FrontView and use those until restart.
                   // brightnessInfo = brightnessControl.GetBrightnessCapabilities(0);
                 //   contrastInfo = brightnessControl.GetContrastCapabilities(0);

                    Logger.Instance().Trace("DDCControl", "brightnessControl now equal " + brightnessControl.GetMonitors());
                    Logger.Instance().Trace("DDCControl", "brightnessInfo:" + brightnessInfo.current + " maximum:" + brightnessInfo.maximum + " minimum:" + brightnessInfo.minimum);

                    if (brightnessControl != null && brightnessInfo.minimum != -1)
                    {
                        brightnessControl.SetBrightness((short)brightnessInfo.minimum, 0);
                        brightnessControl.SetContrast((short)brightnessInfo.minimum, 0);
                    }

                }

                //true equals reset to previous values
                if (turnonoff == true)
                {

                    Logger.Instance().Trace("DDCControl", "brightnessControl now equal " + brightnessControl.GetMonitors());
                    Logger.Instance().Trace("DDCControl", "brightnessInfo:"+brightnessInfo.current +" maximum:"+brightnessInfo.maximum+" minimum:"+brightnessInfo.minimum);

                    if (brightnessControl != null && brightnessInfo.current != -1)
                    {
                        brightnessControl.SetBrightness((short)brightnessInfo.current, 0);
                        brightnessControl.SetContrast((short)contrastInfo.current, 0);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance().Trace("DDCControl", "Exception in SetBrightness/Contrast:"+ex);
            }

       }