Ejemplo n.º 1
0
        public FormSettings()
        {
            InitializeComponent();

            tbxApiKey.Text         = VirusScannerSettings.GetApiKeyFromFile();
            tbxApiKey.TextChanged += tbxApiKey_TextChanged;
        }
Ejemplo n.º 2
0
        public FormMain()
        {
            InitializeComponent();
            var drives = DriveInfo.GetDrives();

            _scanner = new VirusScanner();
            var fixedDrives = drives.Where(d => d.DriveType == DriveType.Fixed);
            var fileSystemMonitoringUnits = fixedDrives.Select(drive => new FileSystemMonitoringUnit(drive.RootDirectory.FullName));

            _monitoringUnitController = new MonitoringUnitController(
                fileSystemMonitoringUnits,
                new IAlertBehavior[]
            {
                new FileAlertBehavior(_scanner)
            }, new NoMatchingBehaviorBehavior());
            _scanner.VirusFound  += Scanner_VirusFound;
            _scanner.NewFileScan += VirusScanner_NewScanFile;
            foreach (var unit in _monitoringUnitController.Units)
            {
                unit.NewAlert += Unit_NewAlert;
            }
            var key = VirusScannerSettings.GetApiKeyFromFile();

            if (key != null)
            {
                _scanner.Start(key);
                _scanner.VirusTotalQueue.StateChanged += VirusTotalQueue_StateChanged;
                _monitoringUnitController.Start();
            }
            else
            {
                MessageBox.Show(Resources.FormMain_FormMain_Virus_Total_API_Key_Not_found,
                                Resources.FormMain_FormMain_Virus_Total_API_Key_missing);
            }
        }