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
        //如果可以隐藏,返回此filename的相同文件位置
        private static List <int> check_other(IEnumerable <string> ll, string filename)
        {
            bool       imex2 = false;
            bool       imex3 = false;
            int        llen  = ll.Count();
            List <int> pos   = new List <int>();

            for (int i = 0; i < llen; i++)
            {
                string file = ll.ElementAt(i);
                if (getname(filename) == getname(file))
                {
                    if (ShowFile.check_extension(getextension(file)))
                    {
                        pos.Add(i);
                        continue;
                    }
                    if (getextension(file) == ShowFile.mex2)
                    {
                        imex2 = true;
                        pos.Add(i);
                        continue;
                    }
                    if (getextension(file) == ShowFile.mex3)
                    {
                        imex3 = true;
                        pos.Add(i);
                        continue;
                    }
                }
                if (getextension(file) == ShowFile.special)
                {
                    if (getname(filename) + ".shp" == getname(file))
                    {
                        pos.Add(i);
                        continue;
                    }
                }
            }
            if (!(imex2 && imex3))
            {
                pos.Clear();
            }
            return(pos);
        }
Beispiel #3
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, ""));
                        }
                    }
                }
            }
        }