예제 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Test for wmi brightness control system support
            // Check if wmi brightness functions are supported
            try
            {
                Brightness.GetBrightnes();
            }
            catch (System.Management.ManagementException ex)
            {
                if (ex.Message.Trim() == "Not supported")
                {
                    MessageBox.Show(
                        "It seems like your system doesn't support WMI Brightness control\n" +
                        "(Usually only supported by laptops and tablets)\n\n" +
                        "Bye!",
                        "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Shutdown(1);
                }
            }

            // Set system tray icon
            notifyIcon             = new System.Windows.Forms.NotifyIcon();
            notifyIcon.MouseDown  += new System.Windows.Forms.MouseEventHandler(NotifyIcon_Click);
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu();
            notifyIcon.ContextMenu.MenuItems.Add("About", new EventHandler(About));
            notifyIcon.ContextMenu.MenuItems.Add("Exit", new EventHandler(ShutDown));
            Stream iconStream = GetResourceStream(new Uri("pack://application:,,,/BrightControl;component/Resources/trayIcon.ico")).Stream;

            notifyIcon.Icon    = new System.Drawing.Icon(iconStream);
            notifyIcon.Text    = "BrightControl";
            notifyIcon.Visible = true;
        }
예제 #2
0
        private void UpdateBrightness(object o)
        {
            // Check for a change
            if (sliderVal == sliderValOld)
            {
                return;
            }
            sliderValOld = sliderVal;

            // Update brightness
            Brightness.SetBrightness((byte)sliderVal);
        }
예제 #3
0
        public void Show_Slider(int bottomLeftX, int bottomLeftY)
        {
            Top  = bottomLeftY - Height;
            Left = bottomLeftX - Width;

            if (hidingAnimation != null)
            {
                BeginAnimation(OpacityProperty, null);
            }

            Opacity = SLIDER_OPACITY;

            // Set initial slider value
            percentageSlider.Value = Brightness.GetBrightnes();
            sliderVal = sliderValOld = (int)percentageSlider.Value;

            // Use a time for the updater to avoid repeptive needless updates
            updateBoxTimer = new Timer(UpdateBrightness, null, BRIGHTNESS_UPDATE_INTERVAL, BRIGHTNESS_UPDATE_INTERVAL);

            Show();
            Activate();
        }