public SingleFileWatcher(ToolStrip ui, string path, SingleFileWathcerChangedHandler callback)
        {
            singleFileWathcerChangedHandler = callback;

            delex = new DelayExecuter(1000, delegate() { singleFileWathcerChangedHandler(); });

            watcher = new System.IO.FileSystemWatcher();
            //監視するディレクトリを指定
            watcher.Path = Path.GetDirectoryName(path);
            //監視するファイルを指定
            watcher.Filter = Path.GetFileName(path);
            //最終更新日時、ファイルサイズの変更を監視する
            watcher.NotifyFilter =
                (System.IO.NotifyFilters.Size
                |System.IO.NotifyFilters.LastWrite);
            //UIのスレッドにマーシャリングする
            watcher.SynchronizingObject = ui;

            //イベントハンドラの追加
            watcher.Changed += new System.IO.FileSystemEventHandler(watcherChanged);
            watcher.Created += new System.IO.FileSystemEventHandler(watcherChanged);

            //監視を開始する
            watcher.EnableRaisingEvents = true;
        }
        public ClasspathWatcher(ToolStrip ui, IProject project, ClasspathWathcerChangedHandler callback)
        {
            classpathWathcerChangedHandler = callback;

            delex = new DelayExecuter(1000, delegate() { classpathWathcerChangedHandler(); });

            int g = 0;
            foreach (PathModel path in ASContext.Context.Classpath)
            {
                if (path.Path.ToString().Length > 2 && !path.Path.ToString().Contains(".swc"))
                {
                    g++;
                }
            }

            String[] _ary = new String[g];

            int n = 0;
            foreach (PathModel path in ASContext.Context.Classpath)
            {
                if (path.Path.ToString().Length > 2 && !path.Path.ToString().Contains(".swc"))
                {
                    _ary[n] = path.Path.ToString();
                    //Console.WriteLine(_ary[n]);
                    n++;
                }
            }

            //TraceManager.Add(n.ToString());

            watchers = new FileSystemWatcher[_ary.Length];

            for (int i = 0, ix = _ary.Length; i < ix; i++)
            {
                watchers[i] = new System.IO.FileSystemWatcher();
                //監視するディレクトリを指定
                watchers[i].Path = _ary[i];
                //最終アクセス日時、最終更新日時、ファイル、フォルダ名の変更を監視する
                watchers[i].NotifyFilter =
                    (System.IO.NotifyFilters.LastWrite
                    | System.IO.NotifyFilters.FileName
                    | System.IO.NotifyFilters.DirectoryName);
                //拡張子
                watchers[i].Filter = "";

                watchers[i].IncludeSubdirectories = true;

                //UIのスレッドにマーシャリングする
                watchers[i].SynchronizingObject = ui;

                //イベントハンドラの追加
                watchers[i].Changed += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Created += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Deleted += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Renamed += new System.IO.RenamedEventHandler(watcher_Renamed);

                //監視を開始する
                watchers[i].EnableRaisingEvents = true;
            }
        }
Beispiel #3
0
        public SingleFileWatcher(ToolStrip ui, string path, SingleFileWathcerChangedHandler callback)
        {
            singleFileWathcerChangedHandler = callback;

            delex = new DelayExecuter(1000, delegate() { singleFileWathcerChangedHandler(); });

            watcher = new System.IO.FileSystemWatcher();
            //監視するディレクトリを指定
            watcher.Path = Path.GetDirectoryName(path);
            //監視するファイルを指定
            watcher.Filter = Path.GetFileName(path);
            //最終更新日時、ファイルサイズの変更を監視する
            watcher.NotifyFilter =
                (System.IO.NotifyFilters.Size
                 | System.IO.NotifyFilters.LastWrite);
            //UIのスレッドにマーシャリングする
            watcher.SynchronizingObject = ui;

            //イベントハンドラの追加
            watcher.Changed += new System.IO.FileSystemEventHandler(watcherChanged);
            watcher.Created += new System.IO.FileSystemEventHandler(watcherChanged);

            //監視を開始する
            watcher.EnableRaisingEvents = true;
        }
        public ClasspathWatcher(ToolStrip ui, IProject project, ClasspathWathcerChangedHandler callback)
        {
            classpathWathcerChangedHandler = callback;

            delex = new DelayExecuter(1000, delegate() { classpathWathcerChangedHandler(); });

            int g = 0;

            foreach (PathModel path in ASContext.Context.Classpath)
            {
                if (path.Path.ToString().Length > 2 && !path.Path.ToString().Contains(".swc"))
                {
                    g++;
                }
            }

            String[] _ary = new String[g];

            int n = 0;

            foreach (PathModel path in ASContext.Context.Classpath)
            {
                if (path.Path.ToString().Length > 2 && !path.Path.ToString().Contains(".swc"))
                {
                    _ary[n] = path.Path.ToString();
                    //Console.WriteLine(_ary[n]);
                    n++;
                }
            }

            //TraceManager.Add(n.ToString());

            watchers = new FileSystemWatcher[_ary.Length];

            for (int i = 0, ix = _ary.Length; i < ix; i++)
            {
                watchers[i] = new System.IO.FileSystemWatcher();
                //監視するディレクトリを指定
                watchers[i].Path = _ary[i];
                //最終アクセス日時、最終更新日時、ファイル、フォルダ名の変更を監視する
                watchers[i].NotifyFilter =
                    (System.IO.NotifyFilters.LastWrite
                     | System.IO.NotifyFilters.FileName
                     | System.IO.NotifyFilters.DirectoryName);
                //拡張子
                watchers[i].Filter = "";

                watchers[i].IncludeSubdirectories = true;

                //UIのスレッドにマーシャリングする
                watchers[i].SynchronizingObject = ui;

                //イベントハンドラの追加
                watchers[i].Changed += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Created += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Deleted += new System.IO.FileSystemEventHandler(watcher_Changed);
                watchers[i].Renamed += new System.IO.RenamedEventHandler(watcher_Renamed);

                //監視を開始する
                watchers[i].EnableRaisingEvents = true;
            }
        }