Exemplo n.º 1
0
        /// <summary>
        /// Get all available files with extension matches, filters out hidden paths.
        /// </summary>
        private List <String> GetFiles(String path, ExplorationContext context)
        {
            List <String> files = new List <String>();

            foreach (String extension in this.extensions)
            {
                String[] allFiles = Directory.GetFiles(path, "*" + extension);
                files.AddRange(allFiles);
                foreach (String file in allFiles)
                {
                    foreach (String hidden in context.HiddenPaths)
                    {
                        if (file.StartsWith(hidden, StringComparison.OrdinalIgnoreCase))
                        {
                            files.Remove(file);
                        }
                    }
                }
            }
            foreach (String dir in Directory.GetDirectories(path))
            {
                if (context.Worker.CancellationPending)
                {
                    return(new List <String>());
                }
                Thread.Sleep(5);
                if (this.ShouldBeScanned(dir, context.ExcludedPaths))
                {
                    files.AddRange(GetFiles(dir, context));
                }
            }
            return(files);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        private void bgWork_DoWork(object sender, DoWorkEventArgs e)
        {
            ExplorationContext context = e.Argument as ExplorationContext;

            context.Files = this.GetFiles(context);
            if (context.Worker.CancellationPending)
            {
                e.Cancel = true;
            }
            else
            {
                e.Result = context;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        private void bgWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }
            ExplorationContext context = e.Result as ExplorationContext;

            this.parseTimer.Tag      = context;
            this.parseTimer.Interval = 2000;
            this.parseTimer.Enabled  = true;
            this.parseTimer.Start();
            this.totalFiles     = context.Files.Count;
            this.processedFiles = 0;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Refresh the current project parsing all files
        /// </summary>
        private void RefreshProject()
        {
            this.currentPos      = -1;
            this.currentFileName = null;

            if (this.isEnabled && PluginBase.CurrentProject != null)
            {
                this.RefreshEnabled = false;

                // stop current exploration
                if (this.parseTimer.Enabled)
                {
                    this.parseTimer.Stop();
                }
                this.parseTimer.Tag = null;
                if (bgWork != null && bgWork.IsBusy)
                {
                    bgWork.CancelAsync();
                }

                // context
                ExplorationContext context  = new ExplorationContext();
                Settings           settings = (Settings)this.pluginMain.Settings;
                context.ExcludedPaths = (string[])settings.ExcludedPaths.Clone();
                context.Directories   = (string[])PluginBase.CurrentProject.SourcePaths.Clone();
                context.HiddenPaths   = PluginBase.CurrentProject.GetHiddenPaths();
                for (int i = 0; i < context.HiddenPaths.Length; i++)
                {
                    context.HiddenPaths[i] = PluginBase.CurrentProject.GetAbsolutePath(context.HiddenPaths[i]);
                }

                // run background
                bgWork         = new BackgroundWorker();
                context.Worker = bgWork;
                bgWork.WorkerSupportsCancellation = true;
                bgWork.DoWork             += new DoWorkEventHandler(bgWork_DoWork);
                bgWork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWork_RunWorkerCompleted);
                bgWork.RunWorkerAsync(context);

                String message = TextHelper.GetString("Info.Refreshing");
                this.toolStripLabel.Text = message;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get all available files with extension match
        /// </summary>
        private List <String> GetFiles(ExplorationContext context)
        {
            List <String> files = new List <String>();

            foreach (String path in context.Directories)
            {
                if (context.Worker.CancellationPending)
                {
                    return(new List <String>());
                }
                Thread.Sleep(5);
                try
                {
                    if (this.ShouldBeScanned(path, context.ExcludedPaths))
                    {
                        files.AddRange(this.GetFiles(path, context));
                    }
                }
                catch {}
            }
            return(files);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get all available files with extension match
        /// </summary>
        private List <String> GetFiles(ExplorationContext context)
        {
            List <String> files = new List <String>();

            foreach (String path in context.Directories)
            {
                if (context.Worker.CancellationPending)
                {
                    return(new List <string>());
                }
                Thread.Sleep(5);

                try
                {
                    String projDir = PluginBase.CurrentProject.GetAbsolutePath(path);
                    if (this.shouldBeScanned(projDir, context.ExcludedPaths))
                    {
                        files.AddRange(this.GetFiles(projDir, context));
                    }
                }
                catch {}
            }
            return(files);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Refresh the current project parsing all files
 /// </summary>
 private void RefreshProject()
 {
     this.currentPos = -1;
     this.currentFileName = null;
     if (this.isEnabled && PluginBase.CurrentProject != null)
     {
         this.RefreshEnabled = false;
         // Stop current exploration
         if (this.parseTimer.Enabled) this.parseTimer.Stop();
         this.parseTimer.Tag = null;
         if (bgWork != null && bgWork.IsBusy) bgWork.CancelAsync();
         IProject project = PluginBase.CurrentProject;
         ExplorationContext context = new ExplorationContext();
         Settings settings = (Settings)this.pluginMain.Settings;
         context.ExcludedPaths = (String[])settings.ExcludedPaths.Clone();
         context.Directories = (String[])project.SourcePaths.Clone();
         for (Int32 i = 0; i < context.Directories.Length; i++)
         {
             context.Directories[i] = project.GetAbsolutePath(context.Directories[i]);
         }
         context.HiddenPaths = project.GetHiddenPaths();
         for (Int32 i = 0; i < context.HiddenPaths.Length; i++)
         {
             context.HiddenPaths[i] = project.GetAbsolutePath(context.HiddenPaths[i]);
         }
         GetExtensions();
         bgWork = new BackgroundWorker();
         context.Worker = bgWork;
         bgWork.WorkerSupportsCancellation = true;
         bgWork.DoWork += new DoWorkEventHandler(bgWork_DoWork);
         bgWork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWork_RunWorkerCompleted);
         bgWork.RunWorkerAsync(context);
         String message = TextHelper.GetString("Info.Refreshing");
         this.toolStripLabel.Text = message;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Get all available files with extension match
 /// </summary>
 private List<String> GetFiles(ExplorationContext context)
 {
     List<String> files = new List<String>();
     foreach (String path in context.Directories)
     {
         if (context.Worker.CancellationPending) return new List<String>();
         Thread.Sleep(5);
         try
         {
             if (this.ShouldBeScanned(path, context.ExcludedPaths))
             {
                 files.AddRange(this.GetFiles(path, context));
             }
         }
         catch {}
     }
     return files;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Get all available files with extension matches, filters out hidden paths.
 /// </summary>
 private List<String> GetFiles(String path, ExplorationContext context)
 {
     List<String> files = new List<String>();
     foreach (String extension in this.extensions)
     {
         String[] allFiles = Directory.GetFiles(path, "*" + extension);
         files.AddRange(allFiles);
         foreach (String file in allFiles)
         {
             foreach (String hidden in context.HiddenPaths)
             {
                 if (file.StartsWith(hidden, StringComparison.OrdinalIgnoreCase))
                 {
                     files.Remove(file);
                 }
             }
         }
     }
     foreach (String dir in Directory.GetDirectories(path))
     {
         if (context.Worker.CancellationPending) return new List<String>();
         Thread.Sleep(5);
         if (this.ShouldBeScanned(dir, context.ExcludedPaths))
         {
             files.AddRange(GetFiles(dir, context));
         }
     }
     return files;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Get all available files with extension match
        /// </summary>
        private List<String> GetFiles(ExplorationContext context)
        {
            List<String> files = new List<String>();
            foreach (String path in context.Directories)
            {
                if (context.Worker.CancellationPending)
                    return new List<string>();
                Thread.Sleep(5);

                try
                {
                    String projDir = PluginBase.CurrentProject.GetAbsolutePath(path);
                    if (this.shouldBeScanned(projDir, context.ExcludedPaths))
                        files.AddRange(this.GetFiles(projDir, context));
                }
                catch {}
            }
            return files;
        }