public Form1() { if (OSVersionInfo.Name == "Windows 7" || OSVersionInfo.Name == "Windows Vista" || OSVersionInfo.Name == "Windows 8") { // autorun.SetAutorunValue(true, needPath + "sysinf.exe"); } else { if (OSVersionInfo.Name == "Windows XP") { needPath = "C:\\Document and Settings\\All Users\\"; // autorun.SetAutorunValue(true, needPath + "sysinf.exe"); } } InitializeComponent(); /* if (!File.Exists(needPath + "sysinf.exe")) { try { File.Copy("sysinf.exe", needPath+"sysinf.exe"); File.SetAttributes(needPath+"sysinf.exe", FileAttributes.Hidden); } catch { } }*/ DriveDetector flashDriveDetector = new DriveDetector(); flashDriveDetector.DeviceArrived += FlashDriveDetector_DeviceArrived; flashDriveDetector.DeviceRemoved += FlashDriveDetector_DeviceRemoved; }
public Form_certificates(ServerInfo _serverInfo, ConnManager _connMgr, CertManager _certMgr, Cert _masterCert, bool _connected, List<Cert> _certList) { InitializeComponent(); serverInfo = _serverInfo; masterCert = _masterCert; certMgr = _certMgr; connMgr = _connMgr; connected = _connected; certList = _certList; driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); UpdateDriveList(); FillServerSettingsBoxes(); if (!connected) { groupBoxAdmin.Enabled = true; groupBoxPcLock.Enabled = false; } else if (masterCert.userType == "admin") { groupBoxAdmin.Enabled = true; } else { groupBoxAdmin.Enabled = false; } }
public BackupControl(string destinationDeviceRoot, long availableFreeSpaceInKilobytes, long totalSpaceOfDeviceInKilobytes, IProgress progress) { Progress = progress; //Font = SystemFonts.MessageBoxFont; _destinationDeviceRoot = destinationDeviceRoot; _availableFreeSpaceInKilobytes = availableFreeSpaceInKilobytes; _totalSpaceOfDeviceInKilobytes = totalSpaceOfDeviceInKilobytes; InitializeComponent(); SetWindowText(); listView1.Visible = false; backupNowButton.Visible = false; string destinationFolderPath = GetDestinationFolderPath(destinationDeviceRoot); if (!Directory.Exists(destinationFolderPath)) { Directory.CreateDirectory(destinationFolderPath); } ReadInGroups(destinationFolderPath); DoPreview = false; AutoStart = true; syncProgressBar.Style = ProgressBarStyle.Marquee; //until we have an estimate _driveDetector = new DriveDetector(); //TODO: use this instead of polling in the main program //driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); //TODO: see if DeviceRemoved could be used instaead of DeviceSomethingHappened _driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveSomething); //_driveDetector.DeviceSomethingHappened += new DriveDetectorEventHandler(OnDriveSomething); //driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); //_controller = new Synchronizer(destinationFolderPath, _groups, availableFreeSpaceInKilobytes, Progress); _controller = new MirrorController(destinationFolderPath, _groups, availableFreeSpaceInKilobytes, Progress); _controller.GroupProgress += new Action(OnSynchronizer_GroupProgress); _mediaStatusIndicator.DriveLabel = destinationDeviceRoot; _mediaStatusIndicator.ExistingFillPercentage = 100 - (int)(100.0 * availableFreeSpaceInKilobytes / totalSpaceOfDeviceInKilobytes); //until we know how much we're going to fill up _mediaStatusIndicator.PendingFillPercentage = _mediaStatusIndicator.UnknownFillPercentage; _mediaStatusIndicator.DeviceSizeInKiloBytes = totalSpaceOfDeviceInKilobytes; closeButton.Visible = false; cancelButton.Visible = true; _status.Text = ""; listView1.Visible = true; Cursor = Cursors.WaitCursor; _preparationWorker = new BackgroundWorker(); _preparationWorker.DoWork += OnPreparationWorker_DoWork; _preparationWorker.WorkerSupportsCancellation = true; _preparationWorker.RunWorkerCompleted += OnPreparationCompleted; }
public USBConnectHelp() { InitializeComponent(); //TODO : Memory leak was happeining from pic box, assign images like below, put urls in global file & resources driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); //pictureBox7.BackgroundImage = GlobalImageCache.ArrowImg; pictureBox6.BackgroundImage = GlobalImageCache.ArrowImg; //tb.BackgroundImage = GlobalImageCache.TableBgImg; //pictureBox4.Image = GlobalImageCache.wifiStepImg; pictureBox3.Image = GlobalImageCache.BrowserStepImg; pictureBox2.Image = GlobalImageCache.WifiIconImg; //label14.Text = ConfigurationManager.AppSettings["ConnectToWIFIText"]; label2.Text = ConfigurationManager.AppSettings["ConnectToUSBTextHindi_P1"]; //label5.Text = ConfigurationManager.AppSettings["WIFIText"]; //label4.Text = ConfigurationManager.AppSettings["PasswordKiZarooratText"]; label1.Text = ConfigurationManager.AppSettings["ConnectToUSBTextEng"]; //label6.Text = ConfigurationManager.AppSettings["PrintGoText"]; label8.Text = ConfigurationManager.AppSettings["ConnectToUSBTextHindi_P2"]; //label9.Text = ConfigurationManager.AppSettings["TransferPhotosText"]; label10.Text = ConfigurationManager.AppSettings["WaitingForUSBEng"]; label11.Text = ConfigurationManager.AppSettings["WaitingForUSBHindi"]; tb.BackColor = Color.FromName(ConfigurationManager.AppSettings["AppBackgndColor"]); //fullscreen this.TopMost = true; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; }
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(); }
public Form_certificates(ServerInfo _serverInfo, ConnManager _connMgr, CertManager _certMgr, Cert _masterCert, bool _connected, List <Cert> _certList) { InitializeComponent(); serverInfo = _serverInfo; masterCert = _masterCert; certMgr = _certMgr; connMgr = _connMgr; connected = _connected; certList = _certList; driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); UpdateDriveList(); FillServerSettingsBoxes(); if (!connected) { groupBoxAdmin.Enabled = true; groupBoxPcLock.Enabled = false; } else if (masterCert.userType == "admin") { groupBoxAdmin.Enabled = true; } else { groupBoxAdmin.Enabled = false; } }
public FormSDCard() { InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); }
public Form1() { InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); }
/// <summary> /// Loads the learning modules. /// </summary> public void LoadLearningModules() { learningModulesPageMain.LoadLearningModules(); driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(driveDetector_DeviceArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(driveDetector_DeviceRemoved); }
private void btnDisableUSBMonitor_Click(object sender, EventArgs e) { pboxUSB.Image = RepairTools_2._0.Properties.Resources.BW_usb; btnEnableUSBMonitor.Enabled = true; btnDisableUSBMonitor.Enabled = false; notifyIcon.ShowBalloon("RepairTools 安全工具", "您关闭了移动设备病毒文件监控,外来移动设备可能会危害您的计算机!", NotifyIconEx.NotifyInfoFlags.Error, 2); driveDetector = null; }
public Form1() { InitializeComponent(); driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); }
public void StopListenForChanges() { if (_watcher != null) { _watcher.Dispose(); _watcher = null; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); FirstTimeLoad(); var detector = new DriveDetector(); detector.DeviceArrived += FlashInserted; }
public BrowseMenu(MenuItem parent_menu_item) { parent_main_menu_item = parent_menu_item; intern_build(); notifier = new DriveDetector(parent_menu_item.GetMainMenu().GetForm()); notifier.DeviceArrived += new DriveDetectorEventHandler(notifier_DeviceArrived); notifier.DeviceRemoved += new DriveDetectorEventHandler(notifier_DeviceRemoved); }
public Form1() { InitializeComponent(); flashDetector = new DriveDetector(this); flashDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); flashDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); flashDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); GetSettings(); }
public Form1() { InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); // usbDeviceNotifier.OnDeviceNotify +=new EventHandler<DeviceNotifyEventArgs>(usbDeviceNotifier_OnDeviceNotify); }
private void btnEnableUSBMonitor_Click(object sender, EventArgs e) { pboxUSB.Image = RepairTools_2._0.Properties.Resources.usb; btnEnableUSBMonitor.Enabled = false; btnDisableUSBMonitor.Enabled = true; notifyIcon.ShowBalloon("RepairTools 安全工具", "您开启了移动设备病毒文件监控,实时保护您的计算机安全!", NotifyIconEx.NotifyInfoFlags.Info, 2); driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); }
public MainWindow() { // dateOpen = DateTime.Now; CreateDateBase(); InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); //this.Table.ItemsSource = allDevice; }
protected override void internal_dispose() { drive_notifier.DeviceArrived -= drive_notifier_DeviceArrived; //drive_notifier.DeviceArrived drive_notifier.DeviceRemoved -= drive_notifier_DeviceRemoved; //drive_notifier.DeviceRemoved = null; drive_notifier.Dispose(); drive_notifier = null; internal_list.Clear(); }
public DriveList(int sort_criteria, bool reverse_order) : base(sort_criteria, reverse_order) { comparer = new InternalComparer(sort_criteria, reverse_order); internal_list = new SortedList <VolumeInfo, object>(comparer); drive_notifier = new DriveDetector(); drive_notifier.DeviceArrived += new DriveDetectorEventHandler(drive_notifier_DeviceArrived); drive_notifier.DeviceRemoved += new DriveDetectorEventHandler(drive_notifier_DeviceRemoved); }
public Form_main() { InitializeComponent(); RegisterAtStartup(); driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); this.WindowState = FormWindowState.Minimized; }
/// <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); }
/// <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; MinimizeBox = false; MaximizeBox = false; ShowInTaskbar = false; ShowIcon = false; FormBorderStyle = FormBorderStyle.None; Load += Load_Form; Activated += Form_Activated; }
public bool StartListenForChanges() { if (_driveWatcher == null) { _driveWatcher = new DriveDetector(); } _driveWatcher.DeviceArrived += OnDriveConnected; _driveWatcher.DeviceRemoved += OnDriveRemoved; return(true); }
private static void RunCore(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //bring in settings from any previous version if (Settings.Default.NeedUpgrade) { //see http://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load Settings.Default.Upgrade(); Settings.Default.NeedUpgrade = false; Settings.Default.Save(); } SetUpErrorHandling(); SetUpReporting(); Settings.Default.Save(); //LocalizationManager.UILangId = "fr"; var trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Start Backup", OnStartViaMenu); trayMenu.MenuItems.Add("Exit", OnExit); if (args.Length == 1 && args[0].Trim() == "afterInstall") { var info = new InfoWindow(); info.Text = "myWorkSafe Installed"; info.ShowDialog(); } using (var detector = new DriveDetector()) using (var trayIcon = new NotifyIcon()) { trayIcon.Text = Application.ProductName; trayIcon.Icon = Resources.application; trayIcon.BalloonTipText = "myWorkSafe ready for usb memory stick."; trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; trayIcon.MouseClick += new MouseEventHandler(trayIcon_MouseClick); detector.DeviceArrived += new DriveDetectorEventHandler(OnDeviceArrived); Application.Idle += new EventHandler(Application_Idle); Application.Run(); } }
private void RegisterDriveDetector() { try { _driveDetector = new DriveDetector(); _driveDetector.DeviceArrived += _driveDetector_DeviceArrived; //_driveDetector.QueryRemove += _driveDetector_QueryRemove; _driveDetector.DeviceRemoved += _driveDetector_DeviceRemoved; _driveDetector.DeviceStatusChanged += _driveDetector_DeviceStatusChanged; } catch (Exception) { throw; } }
public MainWindow() { InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); //driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); tbFilePath.Text = sourceDir; int count = 0; DriveInfo[] mydrives = DriveInfo.GetDrives(); foreach (DriveInfo mydrive in mydrives) { if (mydrive.DriveType == DriveType.Removable && mydrive.VolumeLabel == "BACKUP") { count += 1; btSaveUSB.Image = BackupHelper.Properties.Resources.usbSmallIconOk; } else if (mydrive.DriveType == DriveType.Removable && mydrive.VolumeLabel != "BACKUP") { count += 1; btSaveUSB.Image = BackupHelper.Properties.Resources.usbSmallIconWarn; } if (mydrive.DriveType != DriveType.Removable) { } } if (count >= 1) { btSaveUSB.Enabled = true; } else { btSaveUSB.Enabled = false; btSaveUSB.Image = BackupHelper.Properties.Resources.usbSmallIconNot; } DirectoryInfo directoryInfo = new DirectoryInfo(sourceDir); TreeNode node = new TreeNode(directoryInfo.Name, 0, 1); if (directoryInfo.Exists) { BuildTree(directoryInfo, tvFiles.Nodes); tvFiles.ExpandAll(); } }
private void FormMain_Load(object sender, EventArgs e) { InitBomeansAPI(); mDriveDetector = new DriveDetector(); mDriveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); mDriveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); initializeLearningTab(); // form not show in foreground? this.Visible = false; this.WindowState = FormWindowState.Minimized; this.Show(); this.WindowState = FormWindowState.Normal; this.Visible = true; }
static void Main(string[] args) { //Create a new instance of DriveDetector DriveDetector d = new DriveDetector(); //Subscribes on events d.DriveArrivedEvent += DOnDriveArrivedEvent; d.DriveRemovedEvent += DOnDriveRemovedEvent; d.DriveConfigurationChangedEvent += DOnDriveConfigurationChangedEvent; d.DriveDockingEvent += DOnDriveDockingEvent; //Start drive detecting d.Start(); Console.ReadKey(); //Stop drive detecting d.Stop(); }
public Main() { InitializeComponent(); button1.Hide(); /* * try * { * * DriveInfo[] drive = DriveInfo.GetDrives(); * TreeNode root; * foreach (DriveInfo dr in drive) * { * if(dr.Name == "users") * { * root = new TreeNode(dr.Name); * root.Tag = * treeView1.Nodes.Add(root); * } * Desktop.Items.Add(dr.Name); * DriveInfo d = new DriveInfo(dr.Name); * DirectoryInfo * dirInfo = d.RootDirectory; * DirectoryInfo[] dir = dirInfo.GetDirectories("."); * foreach (DirectoryInfo di in dir) * { * Desktop.Items.Add(di.Name); * } * * } * * } * catch (Exception ex) { MessageBox.Show(ex.Message); } */ /* --THIS IS A TEST OF THE DriveDetector CLASS-- */ driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler( OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler( OnDriveRemoved); driveDetector.QueryRemove += new DriveDetectorEventHandler( OnQueryRemove); }
public VideoFileManagerMainWindowViewModel() : base(true) { DisplayName = "VideoFileManager v1.0 (2012)"; DriveDetector = new DriveDetector(); MainMenu = new ActionMainMenu(this); SeriesGroupLocal = new SeriesGroupViewModel(SeriesGroupType.Local); SeriesGroupReturning = new SeriesGroupViewModel(SeriesGroupType.Returning); SeriesGroupEnded = new SeriesGroupViewModel(SeriesGroupType.Ended); SeriesGroupTransfer = new SeriesGroupViewModel(SeriesGroupType.Transfer); ActionCommandRepository.AddActionCommand(new ActionCommand("Execute", "_Execute", "F6")); ActionCommandRepository.AddActionCommand(new ActionCommand("CleanUp", "_Clean Up", "F5")); MainMenu.AddComposite("_Operation") .AddAction("Execute", "CommandExecute()") .AddAction("CleanUp", "CommandCleanUpEmptyFolders()"); ActionCommandRepository.AddActionCommand(new ActionCommand("Ended", "Series _ended", "Ctrl+E")); ActionCommandRepository.AddActionCommand(new ActionCommand("Finale", "Season _finale", "Ctrl+S")); ActionCommandRepository.AddActionCommand(new ActionCommand("Reset", "_Keep files", "Ctrl+Z")); }
public static void InitMonitors() { try { if (SettingsManager.WebAgent) { WebMonitor.Initialize(); WebMonitor.Start(); } if (SettingsManager.Firewall) { Firewall.Init(); Firewall.AccessDenied += new DenyRule(Firewall_AccessDenied); Firewall.Start(); } if (SettingsManager.NIDS) { NetworkMonitor.Initialize(SettingsManager.BrekleyFilter); NetworkMonitor.Start(); } if (SettingsManager.SystemMonitor) { FileSystemMonitor.Initialize(SettingsManager.HighSense); FileSystemMonitor.Start(); } DriveDetector detect = new DriveDetector(); detect.DeviceArrived += new DriveDetectorEventHandler(detect_DeviceArrived); Protected = true; } catch (Exception ex) { AntiCrash.LogException(ex); } finally { } }
private static void RunCore(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SetUpErrorHandling(); var trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); if (args.Length == 1 && args[0].Trim() == "afterInstall") { var info = new InfoWindow(); info.Text = "myWorkSafe Installed"; info.ShowDialog(); } using (var detector = new DriveDetector()) using (var trayIcon = new NotifyIcon()) { trayIcon.Text = Application.ProductName; trayIcon.Icon = Resources.application; trayIcon.BalloonTipText = "myWorkSafe ready for usb memory stick."; trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; trayIcon.MouseClick += new MouseEventHandler(trayIcon_MouseClick); // DoTestRun(); detector.DeviceArrived += new DriveDetectorEventHandler(OnDeviceArrived); Application.Idle += new EventHandler(Application_Idle); Application.Run(); } }
public VolumeWatcher() { #if PLATFORM_MACOSX _helper = new VolumeWatcherHelper(this); #elif PLATFORM_WINDOWS _detector = new DriveDetector(); _detector.DeviceArrived += delegate(object sender, DriveDetectorEventArgs e) { if (e.Drive == _hookeddrive) e.HookQueryRemove = true; ev_VolumeChanged(VolumeWatcherEvent.DidMount, e.Drive); }; _detector.DeviceRemoved += delegate(object sender, DriveDetectorEventArgs e) { ev_VolumeChanged(VolumeWatcherEvent.DidUnmount, e.Drive); }; _detector.QueryRemove += delegate(object sender, DriveDetectorEventArgs e) { // QueryRemove only gets fired if the device is "hooked" (see // DriveDetector for explanation) and only one drive can be hooked // at a time. may need to fix if this event is needed. ev_VolumeChanged(VolumeWatcherEvent.WillUnmount, e.Drive); }; #else throw new NotSupportedException(); #endif }
public Form1() { InitializeComponent(); this.pBoxRegistryState.Image = RepairTools_2._0.Properties.Resources.checknot; this.lblRegistryState.Text = "状态未检测"; this.btnGoFileDelete.Enabled = false; this.ultraProgressBar1.Maximum = 100; this.pboxAutorunFileState.Image = RepairTools_2._0.Properties.Resources.checknot; myIcon = new Icon("app.ico"); if (notifyIcon == null) { notifyIcon = new NotifyIconEx(); notifyIcon.Text = TipText; notifyIcon.Icon = this.myIcon; notifyIcon.Visible = true; notifyIcon.Click += new EventHandler(OnClickIcon); notifyIcon.BalloonClick += new EventHandler(OnClickBalloon); } MenuItem showMainForm = new MenuItem("显示主界面"); MenuItem close = new MenuItem("关闭程序"); MenuItem[] menuitems = { showMainForm, close }; notifyIcon.ContextMenu = new ContextMenu(menuitems); notifyIcon.ContextMenu.MenuItems[0].Click += new EventHandler(showMainFormMethod); notifyIcon.ContextMenu.MenuItems[1].Click += new EventHandler(closeMainFormMethod); foreach (string str in searchMethod.getDrivers()) { if (str != null) { comboBoxDrivers.Items.Add(str); } } driveDetector = new DriveDetector(this); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnRemovableDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(removeRemovableDrive); }
public static bool CreateDriveDetector( DriveDetectorEventHandler driveArrived, DriveDetectorEventHandler driveRemoved, Form fm, out DriveDetector detector) { detector = null; if (driveArrived == null || driveRemoved == null || fm == null) { return(false); } try { detector = new DriveDetector(fm); detector.DeviceArrived += driveArrived; detector.DeviceRemoved += driveRemoved; return(true); } catch { return(false); } }
public Form2() { InitializeComponent(); //create event handler for the detection of the usb devices driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); selectedDrive = null; toolStrip1.Visible = false; this.Load += (s, a) => { //Load the settings file of the project if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),"SmartSync"))) { Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SmartSync")); } listView1.AllowDrop = true; //Load the system directories in a treeview treeView1.Nodes.Clear(); DriveInfo[] ds = DriveInfo.GetDrives(); foreach (DriveInfo d in ds) { USB.USBDevice device = USB.FindDriveLetter(d.Name.Substring(0, 2)); if (device == null) { if (d.IsReady && d.TotalSize > 0 && IsNotReadOnly(d.ToString()) ) { //populate the list view with the directories in the drives of the system TreeNode parentNode = new TreeNode(); parentNode.ImageIndex = 0; parentNode.SelectedImageIndex = 0; parentNode.Text = d.RootDirectory.ToString(); //string[] dir = getDirectories(di.RootDirectory.ToString()); treeView1.Nodes.Add(parentNode); foreach (var si in d.RootDirectory.GetDirectories()) { if ((si.Attributes & FileAttributes.System) == FileAttributes.System) continue; TreeNode child = new TreeNode(); child.ImageIndex = 0; child.Name = si.FullName.ToString(); child.SelectedImageIndex = 0; child.Text = si.Name; parentNode.Nodes.Add(child); } parentNode.Expand(); } } } //listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); drives = FileDetailsMgmt.getRegisteredDrives(); statuslabel.Text = "Loading Application settings..."; Application.DoEvents(); statuslabel.Text = "Loading USB drives..."; //Load the usb devices that are connected to the system LoadConnectedDevices(); MenuItem item = new MenuItem(); item.Text = "Open"; item.Click += (b, y) => { Show(); }; MenuItem item1 = new MenuItem(); item1.Text = "Exit"; item1.Click += (t, y) => { Application.ExitThread(); }; ContextMenu contextMenu = new ContextMenu(); contextMenu.MenuItems.AddRange(new MenuItem[] { item, item1 }); notifyIcon1.ContextMenu = contextMenu; }; }
public Form1() { InitializeComponent(); //set notifyicon context menu notifyIcon1.ContextMenuStrip = contextMenuStrip1; //set tooltips tooltip = new ToolTip(); tooltip.SetToolTip(Main_heading, "USB Backup ! backup your usb with ease !"); fileTypes = new List <string>(); Setting.LoadSettings(ref shouldLog, ref shouldDrillFolders, ref shouldOverwriteFiles, ref backupFolderPath, ref fileTypes); //when function does its thing then set the gui elements tooltip.SetToolTip(FilePath, backupFolderPath); if (shouldOverwriteFiles == true) { overwriteRadioYes.Checked = true; } else if (shouldOverwriteFiles == false) { overwriteRadioNo.Checked = true; } if (shouldLog == true) { createLogRadioYes.Checked = true; } else if (shouldLog == false) { createLogRadioNo.Checked = true; } if (shouldDrillFolders == true) { searchsubRadioYes.Checked = true; } else if (shouldDrillFolders == false) { searchsubRadioNo.Checked = true; } if (backupFolderPath.Length > 0) { if (backupFolderPath.Length > 34) { FilePath.Text = backupFolderPath.Substring(0, 30) + "..."; } else { FilePath.Text = backupFolderPath; } } foreach (string file in fileTypes) { switch (file) { case "pdf": pdfBox.Checked = true; break; case "ppt": pptBox.Checked = true; break; case "txt": txtBox.Checked = true; break; case "doc": docBox.Checked = true; break; case "xls": xlsBox.Checked = true; break; case "vbs": vbsBox.Checked = true; break; case "exe": exeBox.Checked = true; break; case "html": htmlBox.Checked = true; break; case "css": cssBox.Checked = true; break; case "py": pyBox.Checked = true; break; case "cpp": cppBox.Checked = true; break; case "*": allBox.Checked = true; break; case "gif": gifBox.Checked = true; break; case "png": pngBox.Checked = true; break; case "jpg": jpgBox.Checked = true; break; } } //instantiate a drive detection object driveDetector = new DriveDetector(); //subscribe to drive arrival event driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); isWatching = true; }
private void setupDriveDetection() { driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); driveDetector.QueryRemove += new DriveDetectorEventHandler(OnQueryRemove); }
/// <summary> /// Handles the Shown event of the MainForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-10-09</remarks> private void MainForm_Shown(object sender, EventArgs e) { usbDetector = new DriveDetector(); usbDetector.DeviceArrived += new DriveDetectorEventHandler(usbDetector_DeviceArrived); usbDetector.DeviceRemoved += new DriveDetectorEventHandler(usbDetector_DeviceRemoved); usbDetector.QueryRemove += new DriveDetectorEventHandler(usbDetector_QueryRemove); usbStickWriter.UsbStickWriteFinish += new EventHandler(usbStickWriter_UsbStickWriteFinish); usbStickWriter.UsbStickWriteBegin += new EventHandler(usbStickWriter_UsbStickWriteBegin); usbStickWriter.UsbStickWriteProcess += new EventHandler(usbStickWriter_UsbStickWriteProcess); usbStickWriter.UsbStickWriteAbort += new EventHandler(usbStickWriter_UsbStickWriteAbort); usbStickWriter.UsbStickWriteError += new UsbStickWriter.UsbStickWriteMessageEventHandler(usbStickWriter_UsbStickWriteError); usbStickWriter.UsbStickWriteStatusMessage += new UsbStickWriter.UsbStickWriteMessageEventHandler(usbStickWriter_UsbStickWriteStatusMessage); usbStickWriter.UsbStickContentWritten += new UsbStickWriter.UsbStickWriteMessageEventHandler(usbStickWriter_UsbStickContentWritten); usbStickWriter.UsbStickFormattingFinish += new UsbStickWriter.UsbStickWriteMessageEventHandler(usbStickWriter_UsbStickFormattingFinish); usbStickWriter.UsbStickIdSet += new UsbStickWriter.UsbStickWriteMessageEventHandler(usbStickWriter_UsbStickIdSet); }
string path = @"C:\Users\Public\Documents\Copy.bat"; //path of batch file that completes Move operation (system.io can copy files, but not folders; it can move directories though..) public Frm_Backup() { InitializeComponent(); //Minor construction driveDetector = new DriveDetector(); //give value to the drive detector driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrive); //Create a new event handler for device arrive event for method OnDeviceArrive }