Exemple #1
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);
 }
Exemple #2
0
        public static void Event(KeyEvent ke, Action <string> cb)
        {
            var detector = new DriveDetector();

            switch (ke)
            {
            case KeyEvent.inserted:
                detector.DeviceArrived += (sender, args) => cb(args.Drive);
                break;

            case KeyEvent.removed:
                detector.DeviceRemoved += (sender, args) => cb(args.Drive);
                break;
            }
        }