public MainWindow() { InitializeComponent(); physicalMonitors = DisplayConfiguration.GetPhysicalMonitors(DisplayConfiguration.GetCurrentMonitor()); hideStoryboard = (Storyboard)FindResource("hide"); notifyIcon = new System.Windows.Forms.NotifyIcon(); notifyIcon.Text = "Brightness and Contrast"; using (Stream stream = Application.GetResourceStream(new Uri("brightness.ico", UriKind.Relative)).Stream) { notifyIcon.Icon = new System.Drawing.Icon(stream); } notifyIcon.Visible = true; notifyIcon.MouseClick += notifyIcon_MouseClick; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(); notifyIcon.ContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Settings", (sender, e) => SettingsWindow.ShowInstance())); notifyIcon.ContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Quit", (sender, e) => Close())); brightnessSlider.Value = DisplayConfiguration.GetMonitorBrightness(physicalMonitors[0]) * 100; contrastSlider.Value = DisplayConfiguration.GetMonitorContrast(physicalMonitors[0]) * 100; }
public MainWindow() { InitializeComponent(); physicalMonitors = DisplayConfiguration.GetPhysicalMonitors(DisplayConfiguration.GetCurrentMonitor()); notifyIcon = new System.Windows.Forms.NotifyIcon(); notifyIcon.Text = "Brightness"; using (Stream stream = Application.GetResourceStream(new Uri("brightness.ico", UriKind.Relative)).Stream) { notifyIcon.Icon = new System.Drawing.Icon(stream); } notifyIcon.Visible = true; notifyIcon.Click += NotifyIcon_Click; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(); notifyIcon.ContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Settings", (sender, e) => SettingsWindow.ShowInstance())); notifyIcon.ContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Quit", (sender, e) => Close())); brightnessSlider.Value = DisplayConfiguration.GetMonitorBrightness(physicalMonitors[0]) * 100; brightnessToggler.Click += BrightnessToggler_Click; LostFocus += MainWindow_LostFocus; }