Beispiel #1
0
 void ListDir(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Console.WriteLine("Dir:{0}", e.Name);
     }
 }
 private void _fileSystemVisitor_FileFinded(object sender, DirectoryEventArgs e)
 {
     if (e.ItemInformation.Contains(SKIPPED_NON_FILTERED_FILE))
     {
         e.Skip = true;
     }
 }
 private void _fileSystemVisitor_DirectoryFinded1(object sender, DirectoryEventArgs e)
 {
     if (e.ItemInformation.Contains(SKIPPED_NON_FILTERED_FOLDER))
     {
         e.Break = true;
     }
 }
Beispiel #4
0
 void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Console.WriteLine(e.Name);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Callback for adding a new directory.
 /// </summary>
 /// <param name="sender">The scanner calling this delegate.</param>
 /// <param name="args">The event arguments.</param>
 /// <remarks>Directories are only added if they are empty and
 /// the user has specified that empty directories are to be added.</remarks>
 void ProcessDirectory(object sender, DirectoryEventArgs args)
 {
     if (!args.HasMatchingFiles && addEmptyDirectoryEntries_)
     {
         activeZipFile_.AddDirectory(args.Name);
     }
 }
Beispiel #6
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Log.LogMessage(Properties.Resources.UnzipExtracted, e.Name);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Raises the ProcessDirectoryEvent.
 /// </summary>
 /// <param name="directory">The directory for this event.</param>
 /// <param name="hasMatchingFiles">Flag indicating if directory has matching files as determined by the current filter.</param>
 public void OnProcessDirectory(string directory, bool hasMatchingFiles)
 {
     if (ProcessDirectory != null)
     {
         DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles);
         ProcessDirectory(this, args);
     }
 }
Beispiel #8
0
 private void ReportProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (OnProcessDirectory != null)
     {
         FastZipArchiveDirectoryEventArgs args = new FastZipArchiveDirectoryEventArgs(e);
         OnProcessDirectory(this, args);
     }
 }
Beispiel #9
0
        /// <summary>
        ///   Raise the ProcessDirectory event.
        /// </summary>
        /// <param name = "directory">The directory name.</param>
        /// <param name = "hasMatchingFiles">Flag indicating if the directory has matching files.</param>
        private void OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            ProcessDirectoryHandler handler = ProcessDirectory;

            if (handler != null)
            {
                var args = new DirectoryEventArgs(directory, hasMatchingFiles);
                handler(this, args);
                alive_ = args.ContinueRunning;
            }
        }
Beispiel #10
0
 /// <summary>
 /// Callback from the directory task update when new directory data has been loaded
 /// from the server. In this case we're just interested in updating the progress bar until
 /// we get to 100% at which point we stop and update the UI.
 /// </summary>
 private void OnDirectoryChanged(object sender, DirectoryEventArgs args)
 {
     Platform.UIThread(this, delegate
     {
         if (args.CategoryName != null && args.CategoryName == _currentCategory.Name)
         {
             _items = new List <DirForum>(CIX.DirectoryCollection.AllForumsInCategory(_currentCategory.Name));
             SortItems();
         }
     });
 }
Beispiel #11
0
        /// <summary>
        /// Fires the <see cref="ProcessDirectory">process directory</see> delegate.
        /// </summary>
        /// <param name="directory">The directory being processed.</param>
        /// <param name="hasMatchingFiles">Flag indicating if the directory has matching files as determined by the current filter.</param>
        /// <returns>A <see cref="bool"/> of true if the operation should continue; false otherwise.</returns>
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;

            if (ProcessDirectory != null)
            {
                DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles);
                ProcessDirectory(this, args);
                result = args.ContinueRunning;
            }
            return(result);
        }
Beispiel #12
0
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool continueRunning = true;

            if (this.ProcessDirectory != null)
            {
                DirectoryEventArgs e = new DirectoryEventArgs(directory, hasMatchingFiles);
                this.ProcessDirectory(this, e);
                continueRunning = e.ContinueRunning;
            }
            return(continueRunning);
        }
Beispiel #13
0
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;
            ProcessDirectoryHandler processDirectory = ProcessDirectory;

            if (processDirectory != null)
            {
                DirectoryEventArgs directoryEventArgs = new DirectoryEventArgs(directory, hasMatchingFiles);
                processDirectory(this, directoryEventArgs);
                result = directoryEventArgs.ContinueRunning;
            }
            return(result);
        }
Beispiel #14
0
        /// <summary>
        /// Fires the <see cref="ProcessDirectory">process directory</see> delegate.
        /// </summary>
        /// <param name="directory">The directory being processed.</param>
        /// <param name="hasMatchingFiles">Flag indicating if the directory has matching files as determined by the current filter.</param>
        /// <returns>A <see cref="bool"/> of true if the operation should continue; false otherwise.</returns>
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;
            EventHandler <DirectoryEventArgs> handler = ProcessDirectory;

            if (handler != null)
            {
                var args = new DirectoryEventArgs(directory, hasMatchingFiles);
                handler(this, args);
                result = args.ContinueRunning;
            }
            return(result);
        }
Beispiel #15
0
        private void TreeViewerOnDirectorySelected(object sender, DirectoryEventArgs args)
        {
            var item    = args.Item;
            var builder = new StringBuilder();

            builder.AppendLine(item.Path);
            var statistics = item.Statistics;

            builder.AppendLine($"Recog: {statistics.RecogImageCount} / markup: {statistics.MarkupImageCount} / total: {statistics.TotalImageCount}.");
            foreach (var stencil in statistics.Stencils.OrderBy(p => p.Key))
            {
                builder.AppendLine($"{stencil.Key}: markup: {stencil.Value.MarkupPlateCount}, total: {stencil.Value.TotalPlateCount}");
            }
            _txtDirectoryInfo.Text = builder.ToString();
        }
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && this.createEmptyDirectories)
     {
         if (this.events != null)
         {
             this.events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.Name != this.sourceDirectory)
         {
             ZipEntry entry = new ZipEntry(this.nameTransform.TransformDirectory(e.Name));
             this.outputStream.PutNextEntry(entry);
         }
     }
 }
Beispiel #17
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && CreateEmptyDirectories)
     {
         if (_events != null)
         {
             _events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.ContinueRunning && (e.Name != _sourceDirectory))
         {
             ZipEntry entry = _entryFactory.MakeDirectoryEntry(e.Name);
             _outputStream.PutNextEntry(entry);
         }
     }
 }
Beispiel #18
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && this.CreateEmptyDirectories)
     {
         if (this.events_ != null)
         {
             this.events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.ContinueRunning && e.Name != this.sourceDirectory_)
         {
             ZipEntry entry = this.entryFactory_.MakeDirectoryEntry(e.Name);
             this.outputStream_.PutNextEntry(entry);
         }
     }
 }
Beispiel #19
0
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && CreateEmptyDirectories)
            {
                if (events_ != null)
                {
                    events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.Name != sourceDirectory_)
                {
                    ZipEntry entry = entryFactory_.MakeDirectoryEntry(e.Name);
                    outputStream_.PutNextEntry(entry);
                }
            }
        }
Beispiel #20
0
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && createEmptyDirectories)
            {
                if (events != null)
                {
                    events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.Name != sourceDirectory)
                {
                    string   cleanedName = nameTransform.TransformDirectory(e.Name);
                    ZipEntry entry       = new ZipEntry(cleanedName);
                    outputStream.PutNextEntry(entry);
                }
            }
        }
Beispiel #21
0
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && CreateEmptyDirectories)
            {
                if (events_ != null)
                {
                    events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.ContinueRunning)
                {
                    if (e.Name != sourceDirectory_)
                    {
                        ZipEntry entry = entryFactory_.MakeDirectoryEntry(e.Name);
                    }
                }
            }
        }
Beispiel #22
0
        private static void SetToStateAgruments(DirectoryEventArgs e)
        {
            Console.WriteLine("Information: ");
            Console.WriteLine(e.ItemInformation);
            Console.WriteLine(new string('-', 50));
            Console.WriteLine("Do you want to continue?");
            Console.WriteLine("s - skip");
            Console.WriteLine("x - break");
            Console.WriteLine("other button - continue");
            var cki = Console.ReadKey();

            if (cki.KeyChar == 's')
            {
                e.Skip = true;
            }

            if (cki.KeyChar == 'x')
            {
                e.Break = true;
            }

            Console.WriteLine();
        }
Beispiel #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
 {
     SendDirectory((Codec as IHasDirectory).CurrentDirectoryResult, e.DirectoryIsOnRoot);
 }
 protected virtual void OnNotifyThatDirectoryPassedFilteringSuccessfully(DirectoryEventArgs e)
 {
     NotifyThatDirectoryPassedFilteringSuccessfully?.Invoke(this, e);
 }
 protected virtual void OnNotifyThatDirectoryWasFounded(DirectoryEventArgs e)
 {
     NotifyThatDirectoryWasFounded?.Invoke(this, e);
 }
 protected virtual void OnNotifyThatDirectoryNotFiltered(DirectoryEventArgs e)
 {
     NotifyThatDirectoryNotFiltered?.Invoke(this, e);
 }
        public IEnumerable <string> Explore(string directoryPath)
        {
            OnNotifyAboutStartingOfExplore(new DirectoryEventArgs
            {
                DirectoryInfo = new DirectoryInfo(directoryPath)
            });

            var researchDirectories = new Queue <string>();

            researchDirectories.Enqueue(directoryPath);

            while (researchDirectories.Any())
            {
                var currentDirectory = researchDirectories.Dequeue();

                var foundDirectories = Directory.EnumerateDirectories(currentDirectory).Select(d => new DirectoryInfo(d));

                foreach (var directory in foundDirectories)
                {
                    var directoryEventArgs = new DirectoryEventArgs {
                        DirectoryInfo = directory
                    };

                    OnNotifyThatDirectoryWasFounded(directoryEventArgs);

                    if (DirectoryPredicate != null && !DirectoryPredicate(directory))
                    {
                        OnNotifyThatDirectoryNotFiltered(directoryEventArgs);
                        continue;
                    }

                    OnNotifyThatDirectoryPassedFilteringSuccessfully(directoryEventArgs);

                    switch (directoryEventArgs.FurtherAction)
                    {
                    case FurtherAction.Skip:
                        continue;

                    case FurtherAction.Stop:
                        yield break;
                    }

                    yield return(directory.Name);

                    researchDirectories.Enqueue(directory.FullName);
                }

                var foundFiles = Directory.EnumerateFiles(currentDirectory).Select(f => new FileInfo(f));

                foreach (var file in foundFiles)
                {
                    var fileEventArgs = new FileEventArgs {
                        FileInfo = file
                    };

                    OnNotifyThatFileWasFounded(fileEventArgs);

                    if (FilePredicate != null && !FilePredicate(file))
                    {
                        OnNotifyThatFileNotFiltered(fileEventArgs);
                        continue;
                    }

                    OnNotifyThatFilePassedFilteringSuccessfully(fileEventArgs);

                    switch (fileEventArgs.FurtherAction)
                    {
                    case FurtherAction.Skip:
                        continue;

                    case FurtherAction.Stop:
                        yield break;
                    }

                    yield return(file.Name);
                }
            }

            OnNotifyAboutFinishingOfExplore(new DirectoryEventArgs
            {
                DirectoryInfo = new DirectoryInfo(directoryPath)
            });
        }
Beispiel #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void dir_DirectoryResultReturned(object sender, DirectoryEventArgs e)
 {
     RefreshDirectory();
 }
 protected virtual void OnRaiseDirectoryFoundEvent(DirectoryEventArgs directoryEventArgs)
 {
     DirectoryFound?.Invoke(this, directoryEventArgs);
 }
        /// <summary>
        /// Traversal of directory tree
        /// </summary>
        /// <param name="rootDirectory">Root to start traversal</param>
        /// <returns>IEnumerable of directorys'(or files') names</returns>
        public IEnumerable <string> WalkDirectoryTree(DirectoryInfo rootDirectory)
        {
            OnRaiseTraversalStart(new MessageEventArgs($"Traversal start: {rootDirectory}"));
            if (rootDirectory == null)
            {
                throw new ArgumentNullException($"{nameof(rootDirectory)} is required");
            }
            FileInfo[]      files;
            DirectoryInfo[] subDirectories;
            try
            {
                files          = rootDirectory.GetFiles("*.*");
                subDirectories = rootDirectory.GetDirectories();
            }
            catch (UnauthorizedAccessException)
            {
                throw new UnauthorizedAccessException($"You don't have permissions to enter directory {rootDirectory}");
            }

            foreach (FileInfo file in files)
            {
                FileEventArgs fileArgs = new FileEventArgs(file);
                OnRaiseFileFoundEvent(fileArgs);
                if (fileArgs.StopTraversal)
                {
                    yield break;
                }
                if (Filter(file.FullName))
                {
                    FileEventArgs nessesaryFileArgs = new FileEventArgs(file);
                    OnRaiseRequiredFileFoundEvent(nessesaryFileArgs);
                    if (nessesaryFileArgs.StopTraversal)
                    {
                        yield break;
                    }
                    if (!fileArgs.ExcludeFile && !nessesaryFileArgs.ExcludeFile)
                    {
                        yield return(file.FullName);
                    }
                }
            }

            foreach (DirectoryInfo directory in subDirectories)
            {
                DirectoryEventArgs directoryArgs = new DirectoryEventArgs(directory);
                OnRaiseDirectoryFoundEvent(directoryArgs);
                if (directoryArgs.StopTraversal)
                {
                    yield break;
                }
                if (Filter(directory.FullName))
                {
                    DirectoryEventArgs nessesaryDirectoryArgs = new DirectoryEventArgs(directory);
                    OnRaiseRequiredDirectoryFoundEvent(nessesaryDirectoryArgs);
                    if (nessesaryDirectoryArgs.StopTraversal)
                    {
                        yield break;
                    }
                    if (!directoryArgs.ExcludeDirectory && !nessesaryDirectoryArgs.ExcludeDirectory)
                    {
                        yield return(directory.FullName);

                        foreach (var item in WalkDirectoryTree(directory))
                        {
                            yield return(item);
                        }
                    }
                }
            }
            OnRaiseTraversalFinished(new MessageEventArgs($"Traversal finished"));
        }