private void ScanDir(string path) { // uses the file scan to scan all files in a directory and its sub-directories List <string> viruses = new List <string>(); foreach (string file in Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories)) { if (ScanFile(file)) { viruses.Add(file); } } if (viruses.Count == 0) { MessageBox.Show("All clear!"); } else { MessageBox.Show(String.Format("{0} viruses found!", viruses.Count)); foreach (string virus in viruses) { if (SettingsBox.GetItemChecked(NOTIFY_ID)) { MessageBox.Show(virus); } } } }
private void SettingTabsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Dispatcher.Invoke(() => { try { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var block in e.NewItems.Cast <ISettingsTab>()) { SettingsBox.AddSettingsBlock(block); } } if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (var block in e.OldItems.Cast <ISettingsTab>()) { SettingsBox.RemoveSettingsBlock(block); } } } catch (Exception ex) { Debugger.Error(ex.ToString()); } }); }
private async void LoadConfig() { ConfigManager.ConfigManager.Init(); if (!ConfigManager.ConfigManager.GetStatementConfirmed()) { StatementGrid.Visibility = Visibility.Visible; } BiliApi.CookieCollection = ConfigManager.ConfigManager.GetCookieCollection(); SettingsBox.SetSettings(ConfigManager.ConfigManager.GetSettings()); List <DownloadInfo> infos = ConfigManager.ConfigManager.GetDownloadInfos(); foreach (DownloadInfo info in infos) { DownloadQueuePanel.Append(new DownloadTask(info)); } ResultBox.SetHistory(ConfigManager.ConfigManager.GetSearchHistory()); if (BiliApi.CookieCollection != null) { UserInfo userInfo = await UserInfo.GetUserInfoAsync(BiliApi.CookieCollection); if (userInfo != null) { ShowUserInfo(userInfo); LoginBtn.Content = "登出"; } } }
private void gameSettingsToolStripMenuItem_Click(object sender, EventArgs e) { SettingsBox dlg1 = new SettingsBox(); dlg1.ShowDialog(); this.ttX = SettingsBox.column; this.ttM = SettingsBox.mines; this.ttY = SettingsBox.row; }
private Settings(ObservableCollection <ISettingsTab> settingTabs) { InitializeComponent(); this.settingTabs = settingTabs; foreach (var tab in settingTabs) { SettingsBox.AddSettingsBlock(tab); } this.settingTabs.CollectionChanged += SettingTabsOnCollectionChanged; }
private void Home_Hide() { // changes the displayed items to fit non-home screens PathTxt.Show(); PathField.Show(); ScanBtn.Show(); PathBtn.Show(); HomeContent.Hide(); HomePanel.Hide(); SettingsBox.Hide(); SettingsTitle.Hide(); }
private bool ScanFile(string path) {// operation for scanning a file if (Path.GetExtension(path) == ".pdf") { try { PdfDocument file = PdfReader.Open(path); PdfReference nextReference = (PdfReference)file.Internals.Catalog.Elements["/OpenAction"]; if (nextReference == null) { return(false); } PdfDictionary action = (PdfDictionary)nextReference.Value; if (action == null) { return(false); } do { foreach (string pattern in openActionBlacklist) { if (SettingsBox.GetItemChecked(SUSPICIOUS_ID) || Regex.Match(action.ToString(), pattern).Success) { if (SettingsBox.GetItemChecked(REMOVE_ID)) { File.Delete(path); } return(true); } } } // a joke line which basicly iterates over the linked list of open actions while ((nextReference = (PdfReference)action.Elements["/Next"]) == null || (action = (PdfDictionary)nextReference.Value) == null); } catch (UnauthorizedAccessException) { MessageBox.Show(String.Format("couldn't handle {0}. Try to rerun as administrator.", path)); } catch (Exception) { MessageBox.Show(String.Format("{0} is corrupted. Readers may handle it but it prevents us from scanning it fully.", path)); } } return(false); }
private void Awake() { instance = this; }