Ejemplo n.º 1
0
        private void AddMonitorManager(TabItem tab, MonitorManager manager)
        {
            Trace("");
            Trace("Adding monitor Manager: " + manager.GetType().Name);
            StackPanel tabContent = new StackPanel()
            {
                Orientation = Orientation.Vertical
            };

            tab.Content = tabContent;

            MonitorSliders masterSlider = new MonitorSliders(manager.MasterMonitor);

            tabContent.Children.Add(masterSlider);

            int            supportBrightness  = 0;
            int            supportContrast    = 0;
            int            supportTemperature = 0;
            List <Monitor> monitors           = manager.GetMonitorsList();

            foreach (Monitor monitor in monitors)
            {
                Trace("- " + monitor.ToStringDbg());
                MonitorSliders slider = new MonitorSliders(monitor);
                tabContent.Children.Add(slider);
                if (monitor.SupportsBrightness)
                {
                    supportBrightness++;
                }
                if (monitor.SupportsContrast)
                {
                    supportContrast++;
                }
                if (monitor.SupportsTemperature)
                {
                    supportTemperature++;
                }
            }

            // "< 2" or "== 0" whichever works better
            if (supportBrightness == 0)
            {
                masterSlider.BrightnessSliderLabel.Visibility = Visibility.Collapsed;
                masterSlider.BrightnessSlider.Visibility      = Visibility.Collapsed;
                masterSlider.BrightnessSliderText.Visibility  = Visibility.Collapsed;
            }
            if (supportContrast == 0)
            {
                masterSlider.ContrastSliderLabel.Visibility = Visibility.Collapsed;
                masterSlider.ContrastSlider.Visibility      = Visibility.Collapsed;
                masterSlider.ContrastSliderText.Visibility  = Visibility.Collapsed;
            }
            if (supportTemperature == 0)
            {
                masterSlider.TemperatureSliderLabel.Visibility = Visibility.Collapsed;
                masterSlider.TemperatureSlider.Visibility      = Visibility.Collapsed;
                masterSlider.TemperatureSliderText.Visibility  = Visibility.Collapsed;
            }
        }
Ejemplo n.º 2
0
        private void KeyDown(KeyEventArgs args)
        {
            pressedKeys.Add(args.KeyCode);

            if (pressedKeys.Contains(Keys.LControlKey))
            {
                // Handle profile changing 1/2/3/n
            }

            if (pressedKeys.Contains(Keys.LMenu)) // left alt
            {
                if (args.KeyCode == Keys.PageUp || args.KeyCode == Keys.PageDown ||
                    args.KeyCode == Keys.Home || args.KeyCode == Keys.End)
                {
                    int monitorNum = 0;
                    if (pressedKeys.Contains(Keys.D1))
                    {
                        monitorNum = 1;                                // Sorry
                    }
                    else if (pressedKeys.Contains(Keys.D2))
                    {
                        monitorNum = 2;                                     // Sorry for that too
                    }
                    else if (pressedKeys.Contains(Keys.D3))
                    {
                        monitorNum = 3;                                     // And for that
                    }
                    else if (pressedKeys.Contains(Keys.D4))
                    {
                        monitorNum = 4;                                     // And that
                    }
                    else if (pressedKeys.Contains(Keys.D5))
                    {
                        monitorNum = 5;                                     // I'm sooooo sorry
                    }
                    else if (pressedKeys.Contains(Keys.D6))
                    {
                        monitorNum = 6;                                     // ;(
                    }
                    else if (pressedKeys.Contains(Keys.D7))
                    {
                        monitorNum = 7;                                     // HAHA
                    }
                    else if (pressedKeys.Contains(Keys.D8))
                    {
                        monitorNum = 8;                                     // I lied
                    }
                    else if (pressedKeys.Contains(Keys.D9))
                    {
                        monitorNum = 9;                                     // I'm perfectly fine with all these
                    }
                    StackPanel     panel = (StackPanel)MainWindow.Instance.MonitorManagerTabControl.SelectedContent;
                    MonitorSliders s     = (MonitorSliders)panel.Children[monitorNum];
                    switch (args.KeyCode)
                    {
                    case Keys.PageUp:
                        //s.BrightnessSlider.Value = (int)(s.BrightnessSlider.Value * 1.05) + 1;
                        s.BrightnessSlider.Value += 5;
                        break;

                    case Keys.PageDown:
                        //s.BrightnessSlider.Value = (int)(s.BrightnessSlider.Value * 0.95) - 1;
                        s.BrightnessSlider.Value -= 5;
                        break;

                    case Keys.Home:
                        //s.ContrastSlider.Value = (int)(s.ContrastSlider.Value * 1.05) + 1;
                        s.ContrastSlider.Value += 5;
                        break;

                    case Keys.End:
                        //s.ContrastSlider.Value = (int)(s.ContrastSlider.Value * 0.95) - 1;
                        s.ContrastSlider.Value -= 5;
                        break;
                    }
                }
            }
        }