Beispiel #1
0
        private static void throwActionEvent(FileEventHandler evento, object sender, FileEventArgs args, int[] items)
        {
            if (evento == null)
            {
                return;
            }

            if (items != null)
            {
                int idx   = items[0] + 1;
                int total = items[1];

                if (args.State == State.Complete && idx != total)
                {
                    return;
                }

                int progreso = Convert.ToInt32(
                    (decimal.Divide(idx, total) * 100)
                    + (decimal.Divide(args.Progress, total))
                    );

                args.Progress = progreso;
            }

            evento(sender, args);
        }
Beispiel #2
0
 /// <summary>
 /// Copies all variables specified in <paramref cref="fileWatchInfo"/> to the new instance.
 /// </summary>
 /// <param name="fileWatchInfo"></param>
 protected FileWatchInfo(FileWatchInfo fileWatchInfo)
 {
     _changeTypes           = new List <FileWatchChangeType>(fileWatchInfo.ChangeTypes);
     _filter                = new List <string>(fileWatchInfo._filter);
     _eventHandler          = fileWatchInfo.EventHandler;
     _path                  = fileWatchInfo.Path.ToLowerInvariant();
     _includeSubdirectories = fileWatchInfo.IncludeSubdirectories;
 }
Beispiel #3
0
        internal void OnFileClosed(object sender, FileEventArgs e)
        {
            FileEventHandler ev = FileClosed;

            if (ev != null)
            {
                ev(this, e);
            }
        }
Beispiel #4
0
        internal void OnFileOpening(object sender, FileEventArgs e)
        {
            FileEventHandler ev = FileOpening;

            if (ev != null)
            {
                ev(this, e);
            }
        }
Beispiel #5
0
        internal void OnStyleUpdate(object sender, FileEventArgs e)
        {
            FileEventHandler ev = StyleUpdate;

            if (ev != null)
            {
                ev(this, e);
            }
        }
Beispiel #6
0
        public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler,
                                       IEnumerable <string> filter, IEnumerable <FileWatchChangeType> changeTypes)
        {
            var id = GetFirstFreeId();
            var fileWatcherInfo = new FileWatcherInfo(id, path, includeSubDirectories, eventHandler,
                                                      filter, changeTypes);

            return(Subscribe(fileWatcherInfo));
        }
Beispiel #7
0
        //protected IFiler Filer;

        public FileHandlerController(ISaver saver, ILoader loader, IFiler filer, FilerNS.IFiler gameFiler, GameNS.Game game, FilerForm view)
        {
            Saver             = saver;
            Loader            = loader;
            View              = view;
            theGame           = game;
            Filer             = filer;
            FilerGame         = gameFiler;
            FileHandled       = new FileEventHandler(OnFileEvent);
            View.FileHandled += FileHandled;
            Filer.CreateSaveFolder();
            View.setDirectory(Filer.getSaveLocation());
        }
        /// <summary>Gets the files in the specified directory.</summary>
        /// <param name="path">The directory to get files.</param>
        /// <param name="handler">The <see cref="FileEventHandler"/> object to call on each file found.</param>
        /// <param name="recursive">if set to <c>true</c>, include files in sub directories recursively.</param>
        public void GetFiles(string path, FileEventHandler handler, bool recursive)
        {
            foreach (string fileName in Directory.GetFiles(path))
            {
                bool cancel = false;
                handler(fileName, ref cancel);
                if (cancel)
                {
                    return;
                }
            }

            // Check subdirs
            if (recursive)
            {
                foreach (string folderName in Directory.GetDirectories(path))
                {
                    GetFiles(folderName, handler, recursive);
                }
            }
        }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the FileWatchInfo class,
 /// which can be used to subscribe to watch the specified path.
 /// Events will be filtered by the given strings and the given changetypes.
 /// </summary>
 /// <param name="path">The path to watch. Must end with '\' for directories.</param>
 /// <param name="includeSubDirectories">Specifies whether to also report changes in subdirectories.</param>
 /// <param name="eventHandler">Reference to the method handling all events.</param>
 /// <param name="filter">Filter strings.</param>
 /// <param name="changeTypes">Changetypes to report events for.</param>
 protected FileWatchInfo(string path, bool includeSubDirectories, FileEventHandler eventHandler,
                         IEnumerable <string> filter, IEnumerable <FileWatchChangeType> changeTypes)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path", "The specified path is a null reference.");
     }
     if (filter == null)
     {
         filter = new List <string>();
     }
     if (changeTypes == null)
     {
         throw new ArgumentNullException("changeTypes", "The specified changeTypes is a null reference.");
     }
     _includeSubdirectories = includeSubDirectories;
     _eventHandler          = eventHandler;
     _changeTypes           = new List <FileWatchChangeType>(changeTypes);
     _filter = new List <string>(filter);
     SetPath(path);  // Makes sure the path is set as a directory
 }
 public FileWatcherInfo(int id, string path, bool includeSubdirectories, FileEventHandler eventHandler,
                        IEnumerable <string> filter, IEnumerable <FileWatchChangeType> changeTypes) :
     base(path, includeSubdirectories, eventHandler, filter, changeTypes)
 {
     _id = id;
 }
Beispiel #11
0
 public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler,
                                IEnumerable <string> filter)
 {
     return(Subscribe(path, includeSubDirectories, eventHandler, filter, new FileWatchChangeType[0]));
 }
Beispiel #12
0
 public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler)
 {
     return(Subscribe(path, includeSubDirectories, eventHandler, new string[0]));
 }
Beispiel #13
0
        public ProbeNppPlugin()
        {
            try
            {
                _instance = this;
                _nppWindow = NppWindow;

                _settings = new Settings(this);
                try
                {
                    _settings.Load();
                }
                catch (Exception ex)
                {
                    Errors.Show(_nppWindow, ex, "Exception when attempting to load ProbeNpp settings.");
                }

                ProbeEnvironment.Initialize();
                ProbeEnvironment.AppChanged += new EventHandler(_env_AppChanged);

                TempManager.Init(Path.Combine(ConfigDir, "Temp"));

                LoadLexerConfig();

                _autoCompletionManager = new AutoCompletion.AutoCompletionManager();
                _smartIndentManager = new AutoCompletion.SmartIndentManager();

                Ready += new NppEventHandler(Plugin_Ready);
                Shutdown += new NppEventHandler(Plugin_Shutdown);
                FileOpened += new FileEventHandler(Plugin_FileOpened);
                FileClosed += new FileEventHandler(Plugin_FileClosed);
                FileActivated += new FileEventHandler(Plugin_FileActivated);
                FileSaved += new FileEventHandler(ProbeNppPlugin_FileSaved);
                LanguageChanged += new LanguageTypeEventHandler(Plugin_LanguageChanged);
                SelectionChanged += new NppEventHandler(Plugin_SelectionChanged);
                Modification += new ModifiedEventHandler(Plugin_Modification);

                CharAdded += new CharAddedEventHandler(ProbeNppPlugin_CharAdded);

                _fileBackground.Execute += new EventHandler(FileBackground_Execute);

                _functionFileScanner = new AutoCompletion.FunctionFileScanner();
                _fileScannerDefer.Execute += new EventHandler(FileScanner_Execute);
                _fileScannerDefer.Activity += new EventHandler(FileScanner_Activity);
            }
            catch (Exception ex)
            {
                Errors.Show(_nppWindow, ex, "The ProbeNpp plug-in thrown an error while initializing.");
            }
        }
Beispiel #14
0
 public FileWatcherInfo(int id, string path, bool includeSubdirectories, FileEventHandler eventHandler,
     IEnumerable<string> filter, IEnumerable<FileWatchChangeType> changeTypes) :
     base(path, includeSubdirectories, eventHandler, filter, changeTypes)
 {
   _id = id;
 }
 public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler,
     IEnumerable<string> filter, IEnumerable<FileWatchChangeType> changeTypes)
 {
   var id = GetFirstFreeId();
   var fileWatcherInfo = new FileWatcherInfo(id, path, includeSubDirectories, eventHandler,
                                             filter, changeTypes);
   return Subscribe(fileWatcherInfo);
 }
 public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler,
     IEnumerable<string> filter)
 {
   return Subscribe(path, includeSubDirectories, eventHandler, filter, new FileWatchChangeType[0]);
 }
 public FileWatchInfo Subscribe(string path, bool includeSubDirectories, FileEventHandler eventHandler)
 {
   return Subscribe(path, includeSubDirectories, eventHandler, new string[0]);
 }
        protected override void Initialize()
        {
            base.Initialize ();

            folderOpenIcon = Context.GetIcon (Stock.OpenFolder);
            folderClosedIcon = Context.GetIcon (Stock.ClosedFolder);

            fileRenamedHandler = (FileEventHandler) Runtime.DispatchService.GuiDispatch (new FileEventHandler (OnFolderRenamed));
            fileRemovedHandler = (FileEventHandler) Runtime.DispatchService.GuiDispatch (new FileEventHandler (OnFolderRemoved));
        }
        protected override void Initialize()
        {
            fileAddedHandler = (ProjectFileEventHandler) Runtime.DispatchService.GuiDispatch (new ProjectFileEventHandler (OnAddFile));
            fileRemovedHandler = (ProjectFileEventHandler) Runtime.DispatchService.GuiDispatch (new ProjectFileEventHandler (OnRemoveFile));

            createdHandler = (FileEventHandler) Runtime.DispatchService.GuiDispatch (new FileEventHandler (OnSystemFileAdded));
            deletedHandler = (FileEventHandler) Runtime.DispatchService.GuiDispatch (new FileEventHandler (OnSystemFileDeleted));
            renamedHandler = (FileEventHandler) Runtime.DispatchService.GuiDispatch (new FileEventHandler (OnSystemFileRenamed));

            Runtime.ProjectService.FileAddedToProject += fileAddedHandler;
            Runtime.ProjectService.FileRemovedFromProject += fileRemovedHandler;

            Runtime.FileService.FileRenamed += renamedHandler;
            Runtime.FileService.FileRemoved += deletedHandler;
            Runtime.FileService.FileCreated += createdHandler;
        }
Beispiel #20
0
    /// <summary>
    /// Gets the files in the specified directory.
    /// </summary>
    /// <param name="path">The directory to get files.</param>
    /// <param name="handler">The <see cref="FileEventHandler"/> object to call on each file found.</param>
    /// <param name="recursive">if set to <c>true</c>, include files in sub directories recursively.</param>
    public void GetFiles(string path, FileEventHandler handler, bool recursive)
    {
      foreach (var fileName in Directory.GetFiles(path))
      {
        var cancel = false;
        handler(fileName, ref cancel);
        if (cancel)
        {
          return;
        }
      }

      // Check subdirs
      if (recursive)
      {
        foreach (var folderName in Directory.GetDirectories(path))
        {
          GetFiles(folderName, handler, true);
        }
      }
    }
Beispiel #21
0
 public void setFileEventHandler(FileEventHandler eventHandler)
 {
     fileEventHandler = eventHandler;
 }