Beispiel #1
0
        /// <summary>
        /// 初始化:检查文件夹是否有子成员,有的话加入特殊节点
        /// </summary>
        void Initialize()
        {
            if (Type == FileSystemObjectType.Folder && CheckChildObject())
            {
                if (ShowFile.check_gdb(Path))  //对于gdb文件夹
                {
                    Geodatabase geo = Geodatabase.Open(Path);
                    if (geo.GetChildDatasets(@"\", "Feature Class").Length != 0 || geo.GetChildDatasets(@"\", "Feature Dataset").Length != 0)
                    {
                        AddSpecialChild();
                    }
                    geo.Close();
                }
                else //对于普通文件夹
                {
                    AddSpecialChild();
                }
            }


            if (Type == FileSystemObjectType.GDB) //对于GDB内feature dataset的文件夹
            {
                Geodatabase geo = Geodatabase.Open(ParentPath);
                if (geo.GetChildDatasets(@Path, "Feature Class").Length != 0 || geo.GetChildDatasets(@Path, "Feature Dataset").Length != 0)
                {
                    AddSpecialChild();
                }
                geo.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 节点被展开后的操作
        /// </summary>
        protected virtual void OnExpanded()
        {
            //是否有特殊节点
            if (HasSpecialChild)
            {
                //将要展开的节点拥有没有列举的子成员(第一次打开)

                //我们需要移除特殊节点,并将子文件夹加入到Children中
                RemoveSpecialChild();
                List <int> li = merge_file();
                if (ShowFile.check_gdb(Path))  //对于geodatabase文件夹的处理
                {
                    Geodatabase geo = Geodatabase.Open(Path);
                    foreach (var fc in geo.GetChildDatasets(@"\", "Feature Class"))
                    {
                        _Children.Add(new FileSystemObjectViewModel(fc, GetFileName(fc), FileSystemObjectType.File, Path));
                    }

                    foreach (var fds in geo.GetChildDatasets(@"\", "Feature Dataset"))
                    {
                        _Children.Add(new FileSystemObjectViewModel(fds, GetFileName(fds), FileSystemObjectType.GDB, Path));
                    }
                    geo.Close();
                }
                else if (Type == FileSystemObjectType.GDB) //对于geodatabase内feature dataset 的处理
                {
                    Geodatabase geo = Geodatabase.Open(ParentPath);
                    foreach (var fc in geo.GetChildDatasets(@Path, "Feature Class"))
                    {
                        _Children.Add(new FileSystemObjectViewModel(fc, GetFileName(fc), FileSystemObjectType.File, Path));
                    }

                    foreach (var fds in geo.GetChildDatasets(Path, "Feature Dataset"))
                    {
                        _Children.Add(new FileSystemObjectViewModel(fds, GetFileName(fds), FileSystemObjectType.GDB, Path));
                    }
                    geo.Close();
                }
                else //对于其他普通文件的处理
                {
                    foreach (var dir in GetSubDirs())
                    {
                        _Children.Add(new FileSystemObjectViewModel(dir, GetFileName(dir), FileSystemObjectType.Folder, ""));
                    }


                    IEnumerable <string> ss = GetSubFiles();
                    for (int i = 0; i < ss.Count(); i++)
                    {
                        bool b = false;
                        for (int pos = 0; pos < li.Count(); pos++)
                        {
                            if (li.ElementAt(pos) == i)
                            {
                                b = true;
                                break;
                            }
                        }
                        if (!b)
                        {
                            _Children.Add(new FileSystemObjectViewModel(ss.ElementAt(i), GetFileName(ss.ElementAt(i)), FileSystemObjectType.File, ""));
                        }
                    }
                }
            }
        }