예제 #1
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns>ContextMenuStrip</returns>
        public ContextMenuStrip Create()
        {
            hideVolumeOSDLib.Init();

            // Add the default menu options.
            ContextMenuStrip   menu = new ContextMenuStrip();
            ToolStripMenuItem  item;
            ToolStripSeparator sep;

            ImageList il = new ImageList();

            il.Images.Add(Resources.Switch);
            il.Images.Add(Resources.SwitchDisabled);
            il.Images.Add(Resources.About);
            il.Images.Add(Resources.Exit);

            menu.ImageList = il;

            // Hide OSD
            item = new ToolStripMenuItem();

            if (!Settings.Default.HideOSD)
            {
                item.Text       = "Hide Volume OSD";
                item.ImageIndex = 1;
            }
            else
            {
                item.Text       = "Show Volume OSD";
                item.ImageIndex = 0;
            }

            item.Click       += new EventHandler(Hide_Click);
            item.CheckOnClick = true;
            item.Checked      = Settings.Default.HideOSD;

            menu.Items.Add(item);
            switchMenu = item;

            // About
            item            = new ToolStripMenuItem();
            item.Text       = "About";
            item.Click     += new EventHandler(About_Click);
            item.ImageIndex = 2;
            //item.im
            menu.Items.Add(item);

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

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

            return(menu);
        }
예제 #2
0
        static void Main(string[] args)
        {
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                if ((args.GetLength(0) == 1))
                {
                    HideVolumeOSDLib lib = new HideVolumeOSDLib(null);

                    lib.Init();

                    if (args[0] == "-hide")
                    {
                        lib.HideOSD();
                    }
                    else
                    if (args[0] == "-show")
                    {
                        lib.ShowOSD();
                    }
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    using (ProcessIcon pi = new ProcessIcon())
                    {
                        pi.Display();

                        if (!InitFailed)
                        {
                            Application.Run();
                        }
                    }
                }

                mutex.ReleaseMutex();
            }
        }