示例#1
0
        public void RemoveChild(string path)
        {
            DirectoryData removingChild = FindChild(path);

            if (removingChild != null)
            {
                Children.Remove(removingChild);
            }
        }
示例#2
0
        public void Update(string oldPath, string newPath)
        {
            DirectoryData updatingChild = FindChild(oldPath);

            if (updatingChild != null)
            {
                updatingChild._dInfo = new DirectoryInfo(newPath);
                OnPropertyChanged("FullName");
                OnPropertyChanged("Name");
            }
        }
示例#3
0
        // 07/09/2014 by aldentea : watcher生成時の例外処理を追加.
        #region *ツリービューの項目が開かれた時(treeViewItem_Expanded)
        void treeViewItem_Expanded(object sender, RoutedEventArgs e)
        {
            stopwatch.Start();
            Debug.WriteLine("treeViewItem_Expanded start.");

            var item = e.Source as TreeViewItem;

            if (item != null)
            {
                item.BringIntoView();

                // 監視を開始する
                DirectoryData dData = (DirectoryData)item.Header;
                string        path  = dData.FullName;
                Debug.WriteLine(path);
                FileSystemWatcher watcher;
                try
                {
                    watcher = new System.IO.FileSystemWatcher(path);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("treeViewItem_Expanded abort.");
                    // CDドライブにディスクが入っていないときなど.
                    return;
                }
                watcher.NotifyFilter = NotifyFilters.DirectoryName;
                // とりあえずCreatedイベントとRemoveイベントだけ処理する.
                watcher.Created += new FileSystemEventHandler(watcher_Created);
                watcher.Deleted += new FileSystemEventHandler(watcher_Deleted);
                watcher.Renamed += new RenamedEventHandler(watcher_Renamed);
                //watcher.SynchronizingObject = this;
                watcher.EnableRaisingEvents = true;
                watchers.Add(dData, watcher);


                //e.Handled = true;
            }
            stopwatch.Stop();
            Debug.WriteLine(string.Format("treeViewItem_Expanded end. {0}ms.", stopwatch.ElapsedMilliseconds));
            stopwatch.Reset();
        }
示例#4
0
 void UpdateChild(DirectoryData parent, string oldPath, string newPath)
 {
     parent.Update(oldPath, newPath);
 }
示例#5
0
 void RemoveChildFrom(DirectoryData parent, string path)
 {
     parent.RemoveChild(path);
 }
示例#6
0
 void AddChildTo(DirectoryData parent, string path)
 {
     parent.AddChild(path);
 }