Exemple #1
0
        IEnumerable <FarFile> DoInvokeDeep(ProgressBox progress, Explorer explorer, int depth)
        {
            // stop?
            if (Stopping || progress != null && UIUserStop())
            {
                yield break;
            }

            ++ProcessedDirectoryCount;

            // progress
            if (progress != null && progress.ElapsedFromShow.TotalMilliseconds > 500)
            {
                var directoryPerSecond = ProcessedDirectoryCount / progress.ElapsedFromStart.TotalSeconds;
                progress.Activity = string.Format(null, Res.SearchActivityDeep,
                                                  FoundFileCount, ProcessedDirectoryCount, directoryPerSecond);
                progress.ShowProgress();
            }

            var args = new GetFilesEventArgs(ExplorerModes.Find);

            foreach (var file in explorer.GetFiles(args))
            {
                // stop?
                if (Stopping)
                {
                    break;
                }

                // process and add
                bool add = Directory || !file.IsDirectory;
                if (add && Filter != null)
                {
                    add = Filter(explorer, file);
                }
                if (add)
                {
                    ++FoundFileCount;
                    yield return(new SuperFile(explorer, file));
                }

                // skip if deep or leaf
                if (Depth > 0 && depth >= Depth || !file.IsDirectory)
                {
                    continue;
                }

                Explorer explorer2 = SuperExplorer.ExploreSuperDirectory(explorer, ExplorerModes.Find, file);
                if (explorer2 == null)
                {
                    continue;
                }

                foreach (var file2 in DoInvokeDeep(progress, explorer2, depth + 1))
                {
                    yield return(file2);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// New super panel with a super explorer.
        /// </summary>
        /// <param name="explorer">The panel explorer.</param>
        public SuperPanel(SuperExplorer explorer)
            : base(explorer)
        {
            CurrentLocation = Name;
            Title = Name;

            var plan = new PanelPlan();
            plan.Columns = new FarColumn[] { new SetColumn() { Kind = "N" }, new SetColumn() { Kind = "O" } };
            SetPlan(PanelViewMode.AlternativeFull, plan);
            ViewMode = PanelViewMode.AlternativeFull;
            SortMode = PanelSortMode.Unsorted;
        }
Exemple #3
0
        /// <summary>
        /// New super panel with a super explorer.
        /// </summary>
        /// <param name="explorer">The panel explorer.</param>
        public SuperPanel(SuperExplorer explorer)
            : base(explorer)
        {
            CurrentLocation = Name;
            Title           = Name;

            var plan = new PanelPlan();

            plan.Columns = new FarColumn[] { new SetColumn()
                                             {
                                                 Kind = "N"
                                             }, new SetColumn()
                                             {
                                                 Kind = "O"
                                             } };
            SetPlan(PanelViewMode.AlternativeFull, plan);
            ViewMode = PanelViewMode.AlternativeFull;
            SortMode = PanelSortMode.Unsorted;
        }
Exemple #4
0
        IEnumerable <FarFile> DoInvokeWide(ProgressBox progress)
        {
            var queue = new Queue <Explorer>();

            queue.Enqueue(_RootExplorer);

            while (queue.Count > 0 && !Stopping)
            {
                // cancel?
                if (progress != null && UIUserStop())
                {
                    break;
                }

                // current
                var explorer = queue.Dequeue();
                ++ProcessedDirectoryCount;

                // progress
                if (progress != null && progress.ElapsedFromShow.TotalMilliseconds > 500)
                {
                    var directoryPerSecond = ProcessedDirectoryCount / progress.ElapsedFromStart.TotalSeconds;
                    progress.Activity = string.Format(null, Res.SearchActivityWide,
                                                      FoundFileCount, ProcessedDirectoryCount, queue.Count, directoryPerSecond);
                    progress.ShowProgress();
                }

                var args = new GetFilesEventArgs(ExplorerModes.Find);
                foreach (var file in explorer.GetFiles(args))
                {
                    // stop?
                    if (Stopping)
                    {
                        break;
                    }

                    // process and add
                    bool add = Directory || !file.IsDirectory;
                    if (add && Filter != null)
                    {
                        add = Filter(explorer, file);
                    }
                    if (add)
                    {
                        ++FoundFileCount;
                        yield return(new SuperFile(explorer, file));
                    }

                    // skip if flat or leaf
                    if (!Recurse || !file.IsDirectory)
                    {
                        continue;
                    }

                    Explorer explorer2 = SuperExplorer.ExploreSuperDirectory(explorer, ExplorerModes.Find, file);
                    if (explorer2 != null)
                    {
                        queue.Enqueue(explorer2);
                    }
                }
            }
        }