Ejemplo n.º 1
0
 public void StopSearch()
 {
     Searcher.StopSearch();
     State = ExplorerState.SearchFinished;
     if (StateChangedEvent != null)
     {
         StateChangedEvent.Invoke(State);
     }
 }
Ejemplo n.º 2
0
 public void Search(string path, string fileName)
 {
     State = ExplorerState.Searching;
     Items.Clear();
     Searcher.Search(path, fileName);
     if (StateChangedEvent != null)
     {
         StateChangedEvent.Invoke(State);
     }
 }
Ejemplo n.º 3
0
 void SearchFinished(string fileName)
 {
     State = ExplorerState.SearchFinished;
     if (StateChangedEvent != null)
     {
         StateChangedEvent.Invoke(State);
     }
     if (SearcherProgressEvent != null)
     {
         SearcherProgressEvent.Invoke(fileName);
     }
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
        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);
        }