private void Button_Click(object sender, RoutedEventArgs e) { if ((string)ButtonStart.Content == "开始") { if (!File.Exists("ramecl.exe")) { MessageBox.Show("未找到扫描引擎! 请将引擎安装至当前目录", "提示", MessageBoxButton.OK, MessageBoxImage.Error); return; } _lastcount = 0; _threat = 0; _isfinished = false; _scanInstance = new Scan(); _fileCountTot = 0; string paras = null; VirInfoList.Clear(); DisableAllFuncBtn(); TbCurrentTarget.Text = TbCurrentTarget.Text = @"正在初始化引擎并更新病毒库, 可能需要较长时间... -->检查病毒库更新"; ProcessMetro.Visibility = Visibility.Visible; MetroProcessbar.Start(); FileNameTextBox.Visibility = Visibility.Hidden; FileCountLabel.Content = "0"; TimeLabel.Content = "00:00:00"; ThreatLabel.Content = "0"; SpeedLabel.Content = "0 个/s"; if (!(EngineCloud.IsChecked ?? false)) { paras += " -!cloud"; } if (!(EngineRdmPlus.IsChecked ?? false)) { paras += " -!rdm+"; } if (EngineWorkers.IsChecked ?? false) { var workers = ((int)SliderWorkers.Value).ToString(); paras += " -workers="; paras += workers; } if (LogOutput.IsChecked ?? false) { paras += $" \"-log={Environment.CurrentDirectory}\\ScanLog_{DateTime.Now:yyMMddHHmmss}.log\""; } if (_scanInstance.Start(FileNameTextBox.Text, paras, UpdateVirInfoListView, UpdateResUsageInfoView)) { ButtonStart.Content = "停止"; EngineUpdateWatcher(); FileProcessUpdate(FileNameTextBox.Text); } else { MessageBox.Show("指定扫描对象不存在", "提示", MessageBoxButton.OK, MessageBoxImage.Error); TbCurrentTarget.Text = ""; ProcessMetro.Visibility = Visibility.Hidden; MetroProcessbar.Stop(); FileNameTextBox.Visibility = Visibility.Visible; } } else { _scanInstance.StopScan(); ButtonStart.Content = "开始"; } }
private void Button_Click(object sender, RoutedEventArgs e) { if ((string)ButtonStart.Content == "开始") { if (!File.Exists("conscan.exe")) { MessageBox.Show("未找到扫描引擎! 请将引擎安装至当前目录", "提示", MessageBoxButton.OK, MessageBoxImage.Error); return; } _lastcount = 0; _threat = 0; _isfinished = false; _scanInstance = new Scan(); _fileCountTot = 0; string paras = null; VirInfoList.Clear(); DisableAllFuncBtn(); TbCurrentTarget.Text = TbCurrentTarget.Text = @"正在初始化引擎并更新病毒库, 可能需要较长时间... -->检查病毒库更新"; ProcessMetro.Visibility = Visibility.Visible; MetroProcessbar.Start(); FileNameTextBox.Visibility = Visibility.Hidden; FileCountLabel.Content = "0"; TimeLabel.Content = "00:00:00"; ThreatLabel.Content = "0"; SpeedLabel.Content = "0 个/s"; if (!(EngineCloud.IsChecked ?? false)) { paras += " -cloud=0"; } else { paras += " -cloud=1"; } if (!(EngineAsg.IsChecked ?? false)) { paras += " -enable-asg=0"; } else { paras += " -enable-asg=1"; } if (!(EngineTfe.IsChecked ?? false)) { paras += " -enable-tfe=0"; } else { paras += " -enable-tfe=1"; } if (Treat.IsChecked ?? false) { paras += " -kill"; } if (NonCompound.IsChecked ?? false) { paras += " -!scan-compound"; } if (Thershold.IsChecked ?? false) { paras += $" -rdm.thershold={(int)(ThersholdValue.Value / 10)}"; } if (!(CloudCheck.IsChecked ?? false)) { paras += " -cav.md5=0 -cav.sha1=0"; } if (Filter.IsChecked ?? false) { paras += " \"-regex=#" + FilterValue.Text + "\""; } if (EngineWorkers.IsChecked ?? false) { paras += $" -workers={(int)SliderWorkers.Value}"; } if (LogOutput.IsChecked ?? false) { paras += $" \"-log={Environment.CurrentDirectory}\\ScanLog_{DateTime.Now:yyMMddHHmmss}.log\""; } if (_scanInstance.Start(FileNameTextBox.Text, paras, UpdateVirInfoListView, UpdateResUsageInfoView)) { ButtonStart.Content = "停止"; EngineUpdateWatcher(); FileProcessUpdate(FileNameTextBox.Text); } else { MessageBox.Show("指定扫描对象不存在", "提示", MessageBoxButton.OK, MessageBoxImage.Error); TbCurrentTarget.Text = ""; ProcessMetro.Visibility = Visibility.Hidden; MetroProcessbar.Stop(); FileNameTextBox.Visibility = Visibility.Visible; } } else { _scanInstance.StopScan(); ButtonStart.Content = "开始"; } }