Example #1
0
        public Bonbon()
        {
            //Load perferences
            preferences = new BonbonPreferences();

            // Create the menu
            ContextMenu trayMenu = getBonbonMenu();

            // Create a tray icon
            trayIcon      = new NotifyIcon();
            trayIcon.Text = "Bonbon";
            //trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40);
            trayIcon.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
            // Add menu to tray icon and show it.
            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible     = true;

            //Add the process event handlers
            processStartEvent.EventArrived += new EventArrivedEventHandler(processStartEvent_EventArrived);
            processStopEvent.EventArrived  += new EventArrivedEventHandler(processStopEvent_EventArrived);
            //Begin watching
            processStartEvent.Start();
            processStopEvent.Start();

            //Get the console window and hide it
            var handle = GetConsoleWindow();

            // Hide
            ShowWindow(handle, SW_HIDE);
        }
Example #2
0
        public BonbonOptions()
        {
            InitializeComponent();

            //Load the preferences file
            preferences = new BonbonPreferences();

            //Bonbon icon
            pictureBox1.Image = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location).ToBitmap();

            //Run on Startup
            cb_RunOnStartup.Checked = preferences.RunOnStartup;

            //Monitors to disable
            foreach (var screen in Screen.AllScreens)
            {
                //if the devicename ends with a number, pair it with a "monitor toggle' value
                int displayNo = Int32.Parse(Regex.Match(screen.DeviceName.ToString(), @"\d+").Value);

                Console.WriteLine(displayNo + " for " + screen.DeviceName.ToString());

                //if the monitor is a primary monitor, append the tag to the list.
                String isPrimary = "";
                if (screen.Primary)
                {
                    isPrimary = " (Primary)";
                }

                if (displayNo == 1)
                {
                    clb_monitors.Items.Add("Display 1" + " - " + screen.DeviceName + isPrimary, preferences.Monitor1Disable);
                }
                else if (displayNo == 2)
                {
                    clb_monitors.Items.Add("Display 2" + " - " + screen.DeviceName + isPrimary, preferences.Monitor2Disable);
                }
                else if (displayNo == 3)
                {
                    clb_monitors.Items.Add("Display 3" + " - " + screen.DeviceName + isPrimary, preferences.Monitor3Disable);
                }
                else if (displayNo == 4)
                {
                    clb_monitors.Items.Add("Display 4" + " - " + screen.DeviceName + isPrimary, preferences.Monitor4Disable);
                }
                else if (displayNo == 5)
                {
                    clb_monitors.Items.Add("Display 5" + " - " + screen.DeviceName + isPrimary, preferences.Monitor5Disable);
                }
            }
        }