Ejemplo n.º 1
0
        public DriveStamperUI()
        {
            // Create a simple tray menu with only one item.
            _trayMenu = new ContextMenu();
            _trayMenu.MenuItems.Add("Project", OnProject);
            _trayMenu.MenuItems.Add("Drives", OnDrives);
            _trayMenu.MenuItems.Add("Exit", OnExit);

            // Create a tray icon. In this example we use a
            // standard system icon for simplicity, but you
            // can of course use your own custom icon too.
            _trayIcon      = new NotifyIcon();
            _trayIcon.Text = "Drive Stamper";
            _trayIcon.Icon = new Icon(SystemIcons.Asterisk, 40, 40);

            // Add menu to tray icon and show it.
            _trayIcon.ContextMenu = _trayMenu;
            _trayIcon.Visible     = true;

            DriveDetector = new DriveDetector();

            DriveDetector.DeviceArrived += OnDriveArrived;
            DriveDetector.DeviceRemoved += OnDriveRemoved;

            UpdateDrives();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Set up the hidden form.
 /// </summary>
 /// <param name="detector">DriveDetector object which will receive notification about USB drives, see WndProc</param>
 public DetectorForm(DriveDetector detector)
 {
     mDetector            = detector;
     this.MinimizeBox     = false;
     this.MaximizeBox     = false;
     this.ShowInTaskbar   = false;
     this.ShowIcon        = false;
     this.FormBorderStyle = FormBorderStyle.None;
     this.Load           += new System.EventHandler(this.Load_Form);
     this.Activated      += new EventHandler(this.Form_Activated);
 }