private void VisualizeFile(string filename, string fullpath, MatchReason reason) { Row row = new Row(); Cell cell1 = new Cell(); CellStyle cellStyle1 = new CellStyle(); Cell cell2 = new Cell(); CellStyle cellStyle2 = new CellStyle(); cell1.Text = filename; cell1.Icon = GetIconForFile(fullpath); cell1.Image = Properties.Resources.Information; // HACK: fake bitmap with same size as icon cell1.CellStyle = cellStyle1; cell2.CellStyle = cellStyle2; row.Cells.AddRange(new XPTable.Models.Cell[] { cell1, cell2 }); row.ChildIndex = 0; row.Editable = false; StyleRow(row, reason); lock (tableModel) { tableModel.Rows.Add(row); } }
private void StyleRow(Row row, MatchReason reason) { Cell cell1 = row.Cells[0]; cell1.Tag = reason.status; Cell cell2 = row.Cells[1]; cell2.Text = reason.text; cell1.ForeColor = Color.Black; if (reason.status == MatchReason.Status.Excluded) { cell1.ForeColor = Color.FromArgb(255, 0, 0); } if (reason.status == MatchReason.Status.Included) { cell1.ForeColor = Color.FromArgb(180, 130, 0); } FontStyle style = FontStyle.Regular; if (reason.status == MatchReason.Status.Included) { style = FontStyle.Bold; } if (reason.status == MatchReason.Status.Excluded) { style = FontStyle.Strikeout; } cell1.CellStyle.Font = new System.Drawing.Font("Courier", 8.00F, style, System.Drawing.GraphicsUnit.Point, ((byte)(0))); cell2.CellStyle.Font = new System.Drawing.Font("Arial", 8.25F, FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); }
private static void CreateActivity(object source, ActivityType type, string path1, string path2) { try { // find relevant folder FoldersRow folder = Context.Model.FindFolder(source as FileSystemWatcher); if (folder == null) { throw new Exception("Expected folder not found for activity: " + path1); } // test folder ignore filter MatchReason reason = new MatchReason(); bool passed = folder.PassesFilters(path1, reason); if (type == Model.ActivityType.Renamed) { // when renaming be more tolerant and see also final names passed = passed || folder.PassesFilters(path2, reason); } // create and register activity Activity activity = new Activity(type, DateTime.Now, path1, path2, passed, reason.text); folder.AddActivity(activity); // signal worker to process new activity Worker.Current.Signal(); } catch (Exception e) { // add error into log ActivityLog.Current.AddEventLog(Properties.Resources.Error, e.Message); } }
public bool PassesGlobalFilters(string path, MatchReason reason) { if (PassesGlobalIncludes(path, reason)) { return(true); } return(PassesGlobalExcludes(path, reason)); }
public bool PassesGlobalExcludes(string path, MatchReason reason) { // it must not match any global exclude foreach (GlobalExcludeFiltersRow row in GlobalExcludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { reason.Set(row.Mask, MatchReason.Status.Excluded); return(false); } } return(true); }
public FilterMenu(ProjectFilters parent, string path, string reason, MatchReason.Status status) { InitializeComponent(); menuExtender = new MenuExtender(); menuExtender.ImageList = imageList; this.path = path.Replace('/', '\\'); this.status = status; this.reason = reason; this.parent = parent; RebuildFilterMenu(); }
public bool PassesGlobalIncludes(string path, MatchReason reason) { // it must match at least one global include foreach (GlobalIncludeFiltersRow row in GlobalIncludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { reason.Set(row.Mask, MatchReason.Status.Included); return(true); } } // didn't match any include return(false); }
public bool PassesLocalExcludes(string path, MatchReason reason) { ExcludeFiltersRow[] excludes = GetExcludeFiltersRows(); // it must not match any global exclude foreach (ExcludeFiltersRow exclude in excludes) { FileMask wildcard = new FileMask(exclude.Mask); if (wildcard.IsMatch(path)) { reason.Set(exclude.Mask, MatchReason.Status.Excluded); return(false); } } // passed excludes return(true); }
public bool PassesFilters(string path, MatchReason reason) { Model model = Table.DataSet as Model; if (model.PassesGlobalIncludes(path, reason)) { return(true); } if (!model.PassesGlobalExcludes(path, reason)) { return(false); } if (PassesLocalIncludes(path, reason)) { return(true); } return(PassesLocalExcludes(path, reason)); }
public bool PassesLocalIncludes(string path, MatchReason reason) { IncludeFiltersRow[] includes = GetIncludeFiltersRows(); // it must match at least one global include foreach (IncludeFiltersRow include in includes) { FileMask wildcard = new FileMask(include.Mask); if (wildcard.IsMatch(path)) { reason.Set(include.Mask, MatchReason.Status.Included); return(true); } } // didn't match any include return(false); }
private void TesterDoWork(object sender, DoWorkEventArgs e) { lock (monitor) { WorkerData data = (WorkerData)e.Argument; data.worker.ReportProgress(-1, null); // the sender is the BackgroundWorker object we need it to // report progress and check for cancellation. try { MatchReason reason = new MatchReason(); TesterFileEnumerator(data.path, reason, data); } catch (CancelException) { e.Cancel = true; } } }
private void ReEvalDoWork(object sender, DoWorkEventArgs e) { lock (monitor2) { WorkerData data = (WorkerData)e.Argument; int count = tableModel.Rows.Count; for (int i = 0; i < count; i++) { if (data.worker.CancellationPending) { throw new CancelException(); } lock (tableModel) { Row row = tableModel.Rows[i]; if (row != null) { string path = row.Cells[0].Text; MatchReason reason = new MatchReason(); lock (data.folder) { try { data.folder.PassesFilters(path, reason); } catch (Exception) { // hack } } StyleRow(row, reason); } } } } }
public bool PassesLocalExcludes(string path, MatchReason reason) { ExcludeFiltersRow[] excludes = GetExcludeFiltersRows(); // it must not match any global exclude foreach (ExcludeFiltersRow exclude in excludes) { FileMask wildcard = new FileMask(exclude.Mask); if (wildcard.IsMatch(path)) { reason.Set(exclude.Mask, MatchReason.Status.Excluded); return false; } } // passed excludes return true; }
private static void CreateActivity(object source, ActivityType type, string path1, string path2) { try { // find relevant folder FoldersRow folder = Context.Model.FindFolder(source as FileSystemWatcher); if (folder == null) throw new Exception("Expected folder not found for activity: " + path1); // test folder ignore filter MatchReason reason = new MatchReason(); bool passed = folder.PassesFilters(path1, reason); if (type == Model.ActivityType.Renamed) { // when renaming be more tolerant and see also final names passed = passed || folder.PassesFilters(path2, reason); } // create and register activity Activity activity = new Activity(type, DateTime.Now, path1, path2, passed, reason.text); folder.AddActivity(activity); // signal worker to process new activity Worker.Current.Signal(); } catch (Exception e) { // add error into log ActivityLog.Current.AddEventLog(Properties.Resources.Error, e.Message); } }
public bool PassesLocalIncludes(string path, MatchReason reason) { IncludeFiltersRow[] includes = GetIncludeFiltersRows(); // it must match at least one global include foreach (IncludeFiltersRow include in includes) { FileMask wildcard = new FileMask(include.Mask); if (wildcard.IsMatch(path)) { reason.Set(include.Mask, MatchReason.Status.Included); return true; } } // didn't match any include return false; }
private void TesterFileEnumerator(String path, MatchReason reason, WorkerData data) { if (data.worker.CancellationPending) { throw new CancelException(); } // first look into directories String[] dirs = Directory.GetDirectories(path); foreach (String dir in dirs) { if (data.worker.CancellationPending) { throw new CancelException(); } string filename = ChopFilename(dir, data.len); // optimization, directory must pass global exclude filters // this is here mainly to not traverse .svn subdirectories reason.Reset(); if (data.model.PassesGlobalFilters(filename, reason)) { TesterFileEnumerator(dir, reason, data); } else { data.worker.ReportProgress(0, new ReportInfo(filename, dir, reason)); } Thread.Sleep(10); // don't hung the UI thread } String[] files = Directory.GetFiles(path); // next look for files foreach (String file in files) { if (data.worker.CancellationPending) { throw new CancelException(); } string filename = ChopFilename(file, data.len); reason.Reset(); lock (data.folder) { try { if (data.folder.PassesFilters(filename, reason)) { data.worker.ReportProgress(0, new ReportInfo(filename, file, reason)); } else { data.worker.ReportProgress(0, new ReportInfo(filename, file, reason)); } } catch (Exception) { // hack } } Thread.Sleep(10); // don't hung the UI thread } }
public bool PassesGlobalExcludes(string path, MatchReason reason) { // it must not match any global exclude foreach (GlobalExcludeFiltersRow row in GlobalExcludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { reason.Set(row.Mask, MatchReason.Status.Excluded); return false; } } return true; }
public bool PassesFilters(string path, MatchReason reason) { Model model = Table.DataSet as Model; if (model.PassesGlobalIncludes(path, reason)) return true; if (!model.PassesGlobalExcludes(path, reason)) return false; if (PassesLocalIncludes(path, reason)) return true; return PassesLocalExcludes(path, reason); }
public bool PassesGlobalIncludes(string path, MatchReason reason) { // it must match at least one global include foreach (GlobalIncludeFiltersRow row in GlobalIncludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { reason.Set(row.Mask, MatchReason.Status.Included); return true; } } // didn't match any include return false; }
public bool PassesLocalFilters(string path, MatchReason reason) { if (PassesLocalIncludes(path, reason)) return true; return PassesLocalExcludes(path, reason); }
public ReportInfo(string filename, string fullpath, MatchReason reason) { this.filename = filename; this.reason = reason.Clone(); this.fullpath = fullpath; }