public FlashErrorsWatcher()
        {
            try
            {
                string appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string logLocation;
                if (BridgeManager.Active && BridgeManager.Settings.TargetRemoteIDE)
                {
                    logLocation = Path.Combine(BridgeManager.Settings.SharedDrive, ".FlashDevelop\\flashide");
                    Directory.CreateDirectory(logLocation);
                }
                else
                {
                    logLocation = Path.Combine(appData, Path.Combine("Adobe", "FlashDevelop"));
                }
                Directory.CreateDirectory(logLocation);

                logFile     = Path.Combine(logLocation, "FlashErrors.log");
                docInfo     = Path.Combine(logLocation, "FlashDocument.log");
                publishInfo = Path.Combine(logLocation, "FlashPublish.log");

                fsWatcher = new WatcherEx(logLocation);
                fsWatcher.EnableRaisingEvents = true;
                fsWatcher.Changed            += new FileSystemEventHandler(fsWatcher_Changed);

                updater          = new System.Timers.Timer();
                updater.Interval = 200;
                updater.Elapsed += updater_Tick;
            }
            catch { }
        }
Ejemplo n.º 2
0
 static void hxproj_ProjectUpdating(Project project)
 {
     if (hxproj.MovieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
     {
         string nmmlProj = hxproj.OutputPathAbsolute;
         if (nmmlPath != nmmlProj)
         {
             nmmlPath = nmmlProj;
             StopWatcher();
             if (File.Exists(nmmlPath))
             {
                 watcher                     = new WatcherEx(Path.GetDirectoryName(nmmlPath), Path.GetFileName(nmmlPath));
                 watcher.Changed            += watcher_Changed;
                 watcher.EnableRaisingEvents = true;
                 UpdateProject();
             }
         }
         else
         {
             UpdateProject();
         }
     }
     else
     {
         StopWatcher();
     }
 }
Ejemplo n.º 3
0
        static void hxproj_ProjectUpdating(Project project)
        {
            if (!HandleProject(project))
            {
                StopWatcher();
                return;
            }

            string projectFile = hxproj.OutputPathAbsolute;

            if (projectPath != projectFile)
            {
                projectPath = projectFile;
                StopWatcher();
                if (File.Exists(projectPath))
                {
                    watcher                     = new WatcherEx(Path.GetDirectoryName(projectPath), Path.GetFileName(projectPath));
                    watcher.Changed            += watcher_Changed;
                    watcher.EnableRaisingEvents = true;
                    UpdateProject();
                }
            }
            else
            {
                UpdateProject();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the watcher.
        /// </summary>
        /// <param name="fileOrFolderToWatch">The file or folder to watch.</param>
        /// <param name="includeSubFolder">if set to <c>true</c> [include sub folder].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="FileNotFoundException">The folder (or file) specified does not exist.</exception>
        public bool InitializeWatcher(string fileOrFolderToWatch, bool includeSubFolder)
        {
            if (Directory.Exists(fileOrFolderToWatch) || File.Exists(fileOrFolderToWatch))
            {
                ObservedFiles = new List <ObservedFile>();

                FileWatcher = new WatcherEx(new WatcherInfo
                {
                    ChangesFilters = NotifyFilters.Attributes |
                                     NotifyFilters.CreationTime |
                                     NotifyFilters.DirectoryName |
                                     NotifyFilters.FileName |
                                     NotifyFilters.LastAccess |
                                     NotifyFilters.LastWrite |
                                     NotifyFilters.Security |
                                     NotifyFilters.Size,

                    IncludeSubFolders   = includeSubFolder,
                    WatchesFilters      = WatcherChangeTypes.All,
                    WatchForDisposed    = true,
                    WatchForError       = false,
                    WatchPath           = fileOrFolderToWatch,
                    BufferKBytes        = 8,
                    MonitorPathInterval = 250
                });

                AddEventHandlers();

                return(true);
            }
            else
            {
                throw new FileNotFoundException("The folder (or file) specified does not exist.", fileOrFolderToWatch);
            }
        }
Ejemplo n.º 5
0
        private void Init()
        {
            if (inited && IsValid)
            {
                return;
            }
            inited                      = true;
            updater                     = new Timer();
            updater.Interval            = 500;
            updater.SynchronizingObject = PluginBase.MainForm as Form;
            updater.Elapsed            += updater_Tick;
            toExplore                   = new List <string>();
            toRemove                    = new List <string>();

            // generic models container
            if (IsVirtual)
            {
                try
                {
                    basePath                    = System.IO.Path.GetDirectoryName(Path);
                    masks                       = new string[] { System.IO.Path.GetFileName(Path) };
                    watcher                     = new WatcherEx(System.IO.Path.GetDirectoryName(Path), System.IO.Path.GetFileName(Path));
                    watcher.Deleted            += new FileSystemEventHandler(watcher_Deleted);
                    watcher.Changed            += new FileSystemEventHandler(watcher_Changed);
                    watcher.Renamed            += new RenamedEventHandler(watcher_Renamed);
                    watcher.EnableRaisingEvents = true;
                }
                catch
                {
                    watcher = null;
                    IsValid = false;
                }
            }
            // watched path
            else if (IsValid)
            {
                if (Owner != null)
                {
                    try
                    {
                        basePath = Path;
                        masks    = Owner.GetExplorerMask();
                        watcher  = new WatcherEx(Path); //System.IO.Path.GetDirectoryName(Path));
                        if (!IsTemporaryPath || !watcher.IsRemote)
                        {
                            watcher.Deleted            += new FileSystemEventHandler(watcher_Deleted);
                            watcher.Changed            += new FileSystemEventHandler(watcher_Changed);
                            watcher.Renamed            += new RenamedEventHandler(watcher_Renamed);
                            watcher.EnableRaisingEvents = true;
                        }
                    }
                    catch
                    {
                        watcher = null;
                        IsValid = false;
                    }
                }
            }
        }
Ejemplo n.º 6
0
 internal static void StopWatcher()
 {
     if (watcher != null)
     {
         watcher.Dispose();
         watcher  = null;
         nmmlPath = null;
     }
 }
Ejemplo n.º 7
0
 public void ReleaseWatcher()
 {
     if (watcher != null)
     {
         watcher.EnableRaisingEvents = false;
         watcher.Dispose();
         watcher = null;
         //TraceManager.Add("Release: " + Path);
     }
 }
Ejemplo n.º 8
0
 static void proj_ProjectUpdating(Project project)
 {
     string newConfig = Path.Combine(proj.Directory, "loom.config");
     if (configPath != newConfig)
     {
         configPath = newConfig;
         StopWatcher();
         if (File.Exists(configPath))
         {
             watcher = new WatcherEx(Path.GetDirectoryName(configPath), Path.GetFileName(configPath));
             watcher.Changed += watcher_Changed;
             watcher.EnableRaisingEvents = true;
             UpdateProject();
         }
     }
     else UpdateProject();
 }
Ejemplo n.º 9
0
 private void setWatcher()
 {
     try
     {
         if (Directory.Exists(BackingPath))
         {
             watcher = new WatcherEx(BackingPath);
             if (watcher.IsRemote)
             {
                 watcher.Changed += watcher_Changed;
             }
             else
             {
                 watcher.Created += watcher_Created;
                 watcher.Deleted += watcher_Deleted;
                 watcher.Renamed += watcher_Renamed;
             }
             watcher.EnableRaisingEvents = true;
         }
     }
     catch {}
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes the Watcher object. In the interest of providing a complete 
        /// demonstration, all change events are monitored. This will unlikely be a 
        /// real-world requirement in most cases.
        /// </summary>
        private bool InitWatcher()
        {
            bool result = false;
            if (Directory.Exists(p_applClass.Param.ScanDirectory))
            {
                WatcherInfo info = new WatcherInfo();
                info.ChangesFilters = NotifyFilters.Attributes |
                                      NotifyFilters.CreationTime |
                                      NotifyFilters.DirectoryName |
                                      NotifyFilters.FileName |
                                      NotifyFilters.LastAccess |
                                      NotifyFilters.LastWrite |
                                      NotifyFilters.Security |
                                      NotifyFilters.Size;
                info.FileFilter = p_applClass.Param.getFileExtension();
                info.IncludeSubFolders = false;
                info.WatchesFilters = WatcherChangeTypes.Created | WatcherChangeTypes.Deleted;
                info.WatchForDisposed = false;
                info.WatchForError = false;
                info.WatchPath = p_applClass.Param.ScanDirectory;
                info.BufferKBytes = 32;
                info.MonitorPathInterval = 0;
                fileWatcher = new WatcherEx(info);
                ManageEventHandlers(true);
                result = true;
            }
            else
            {
                MessageBox.Show("Le répertoire Source n'existe pas.\nMerci de vérifier le paramétrage.");
                frmParam frmParametrage = new frmParam(p_applClass);
                if (frmParametrage.ShowDialog() == DialogResult.OK)
                {
                    ClassOutils.SetParamIntoRegistry(p_applClass.Param);
                    if (Directory.Exists(p_applClass.Param.ScanDirectory))
                    {
                        scanDirLabel.Text = "Source : " + p_applClass.Param.ScanDirectory;
                        return this.InitWatcher();
                    }
                    else
                    {
                        scanDirLabel.Text = "Source : " + p_applClass.Param.ScanDirectory;
                    }
                }

            }
            return result;
        }
Ejemplo n.º 11
0
        private void OpenExtension(string p)
        {
            //folderTreeView1.Nodes.Add(p);
            pathCurrentExtension = Path.Combine(folderWithExt, p);
            FS.CreateFoldersPsysicallyUnlessThere(pathCurrentExtension);
            // new WatcherEx(DBSouboru.msdnAspx, "*.cs");
            WatcherInfo info = new WatcherInfo();
            info.ChangesFilters = NotifyFilters.Size;
            //NotifyFilters.FileName |
            //NotifyFilters.DirectoryName ;

            info.IncludeSubFolders = true;
            info.WatchesFilters = WatcherChangeTypes.All;

            info.WatchForDisposed = false;
            info.WatchForError = false;
            info.WatchPath = pathCurrentExtension;
            info.BufferKBytes = 8;
            info.FileFilter = "*.*";
            //-Mus� to b�t men�� interval aby se zm�ny na disk stihli ulo�it a nezobrazovalo to furt ten dialog
            info.MonitorPathInterval = searchInterval / 4;
            fswe = new WatcherEx(info);

            //FileSystemWatcherEx fswe = new FileSystemWatcherEx(pathCurrentExtension);
            //fswe.Created += new FileSystemEventHandler(fswe_Created);
            //fswe.Deleted += new FileSystemEventHandler(fswe_Deleted);
            //fswe.EventPathAvailability += new PathAvailabilityHandler(fswe_EventPathAvailability);
            //fswe.Changed += new FileSystemEventHandler(fswe_Changed);
            //fswe.Renamed += new RenamedEventHandler(fswe_Renamed);

            //FileSystemWatcherEx fswe = new FileSystemWatcherEx(pathCurrentExtension);
            fswe.Created += new FileSystemEventHandler(fswe_Created);
            fswe.Deleted += new FileSystemEventHandler(fswe_Deleted);
            fswe.PathAvailability += new PathAvailabilityHandler(fswe_EventPathAvailability);
            fswe.ChangedSize += new FileSystemEventHandler(fswe_Changed);
            fswe.Renamed += new RenamedEventHandler(fswe_Renamed);

            //fswe.EventPathAvailability += new WatcherExEventHandler(fswe_EventPathAvailability);
            //fswe.EventChangedDirectoryName += new WatcherExEventHandler(fswe_EventChangedDirectoryName);
            //fswe.EventChangedFileName += new WatcherExEventHandler(fswe_EventChangedFileName);
            //fswe.EventCreated += new WatcherExEventHandler(fswe_EventCreated);
            //fswe.EventDeleted += new WatcherExEventHandler(fswe_EventDeleted);
            //fswe.EventRenamed += new WatcherExEventHandler(fswe_EventRenamed);
            //fswe.EventChangedSize += new WatcherExEventHandler(fswe_EventChangedSize);

            //folderTreeView1.DrillToFolder(path);
            //fswe.StartFolderMonitor();
            fswe.Start();

            ReloadFilesOfExtension();
            RA.WriteToKeyString(SettingsForm.LastExt, p);
            OnStatus("Extension " + p + " successfully loaded");
        }