public void StopSearch() { Searcher.StopSearch(); State = ExplorerState.SearchFinished; if (StateChangedEvent != null) { StateChangedEvent.Invoke(State); } }
public void Search(string path, string fileName) { State = ExplorerState.Searching; Items.Clear(); Searcher.Search(path, fileName); if (StateChangedEvent != null) { StateChangedEvent.Invoke(State); } }
void SearchFinished(string fileName) { State = ExplorerState.SearchFinished; if (StateChangedEvent != null) { StateChangedEvent.Invoke(State); } if (SearcherProgressEvent != null) { SearcherProgressEvent.Invoke(fileName); } }
public BrowserModel() { CurrentDirectory = ""; Searcher = new FileSearcher(); _iconLoader = new IconLoader(); Searcher.SearcherEvent += SearchCallback; Searcher.SearchFinishedEvent += SearchFinished; Searcher.SearchProgressEvent += Searcher_SearchProgressEvent; _items = new ObservableCollection <DirectoryItem>(); State = ExplorerState.Browsing; }
/// <summary> /// Explores the tests defined within the specified test source and populates the model with them. /// </summary> /// <param name="testModel">The test model to populate</param> /// <param name="testSource">The test source to explore</param> /// <param name="consumer">An action to perform on each top-level test discovered from each source, or null if no action is required</param> public override void Explore(TestModel testModel, TestSource testSource, Action <ITest> consumer) { var state = new ExplorerState(testModel); foreach (IAssemblyInfo assembly in testSource.Assemblies) { state.ExploreAssembly(assembly, consumer); } foreach (ITypeInfo type in testSource.Types) { state.ExploreType(type, consumer); } }
public bool Browse(string path) { if (path.Length == 0) { return(false); } if (State == ExplorerState.Searching) { StopSearch(); } else if (CurrentDirectory.CompareTo(path) == 0 && State == ExplorerState.Browsing) { return(true); } var dir = new DirectoryInfo(path); DirectoryInfo[] dirs = dir.GetDirectories(); _items.Clear(); State = ExplorerState.Browsing; foreach (var val in dirs) { _items.Add(new DirectoryItem(val.Name, val.FullName, "", "Directory", "")); } FileInfo[] files = dir.GetFiles(); foreach (var val in files) { _items.Add( new DirectoryItem( val.Name, val.FullName, val.Length.ToString(), val.Extension.ToString(), val.LastWriteTime.ToString())); } CurrentDirectory = path; OnPropertyChanged("Items"); OnPropertyChanged("CurrentDirectory"); return(true); }