예제 #1
0
 public ProcessIcon()
 {
     ni = new NotifyIcon();
     try
     {
         switcherLib = new SwitcherLib("SbzProfileSwitcher.json", true);
     }
     catch (Exception ex)
     {
         throw new Exception("Error connecting to SBZ Control Panel: " + ex.Message);
     }
 }
예제 #2
0
        public ContextMenuStrip Create(SwitcherLib switcherLib)
        {
            this.switcherLib = switcherLib;

            ContextMenuStrip   menu = new ContextMenuStrip();
            ToolStripMenuItem  item;
            ToolStripMenuItem  optionsMenu;
            ToolStripSeparator sep;

            // Add each profile
            int profileIdx = 0;

            foreach (var profile in switcherLib.GetProfileNames())
            {
                int thisProfileIdx = profileIdx;
                item        = new ToolStripMenuItem();
                item.Text   = profile;
                item.Click += delegate(object sender, EventArgs e)
                {
                    Profile_Click(sender, e, thisProfileIdx);
                };
                profileIdx++;
                menu.Items.Add(item);
            }

            // Separator
            sep = new ToolStripSeparator();
            menu.Items.Add(sep);

            // Options Menu
            optionsMenu      = new ToolStripMenuItem();
            optionsMenu.Text = "Options";
            menu.Items.Add(optionsMenu);

            // Config
            item        = new ToolStripMenuItem();
            item.Text   = "Edit Config";
            item.Click += new EventHandler(Edit_Config_Click);
            optionsMenu.DropDownItems.Add(item);

            item        = new ToolStripMenuItem();
            item.Text   = "Reload Config";
            item.Click += new EventHandler(Reload_Config_Click);
            optionsMenu.DropDownItems.Add(item);

            item        = new ToolStripMenuItem();
            item.Text   = "Show Device Names";
            item.Click += new EventHandler(Device_Names_Click);
            optionsMenu.DropDownItems.Add(item);

            item        = new ToolStripMenuItem();
            item.Text   = "Enable Windows Startup";
            item.Click += delegate(object sender, EventArgs e)
            {
                Windows_Startup_Click(sender, e, true);
            };
            optionsMenu.DropDownItems.Add(item);

            item        = new ToolStripMenuItem();
            item.Text   = "Disable Windows Startup";
            item.Click += delegate(object sender, EventArgs e)
            {
                Windows_Startup_Click(sender, e, false);
            };
            optionsMenu.DropDownItems.Add(item);

            // Separator
            sep = new ToolStripSeparator();
            menu.Items.Add(sep);

            // Exit.
            item        = new ToolStripMenuItem();
            item.Text   = "Exit";
            item.Click += new EventHandler(Exit_Click);
            menu.Items.Add(item);

            return(menu);
        }
예제 #3
0
 void Device_Names_Click(object sender, EventArgs e)
 {
     string[] deviceNames = SwitcherLib.GetAudioDeviceNames();
     NotepadHelper.ShowMessage(string.Join("\r\n", deviceNames));
 }