Exemplo n.º 1
0
        /// <summary>
        /// Opens the geodatabase.
        /// </summary>
        /// <param name="sPath">The s path.</param>
        /// <param name="imageListBoxControl1">The image ListBox control1.</param>
        /// <param name="type">The type.</param>
        /// <param name="pWorkspaceList">The p workspace list.</param>
        /// <param name="geometryType">Type of the geometry.</param>
        /// <param name="bAppend">if set to <c>true</c> [b append].</param>
        /// <param name="bAddTable">if set to <c>true</c> [b add table].</param>
        public static void OpenGeodatabase(string sPath, ImageListBoxControl imageListBoxControl1, DataType type, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType, bool bAppend = false, bool bAddTable = false)
        {
            IWorkspace workspace = ControlAPI.GetWorkspace(sPath, type, pWorkspaceList);

            if (workspace != null)
            {
                imageListBoxControl1.BeginUpdate();
                try
                {
                    if (!bAppend)
                    {
                        imageListBoxControl1.Items.Clear();
                    }
                    if (workspace != null)
                    {
                        ControlAPI.AddFeatureDatasetToListBox(workspace, imageListBoxControl1, type);
                        ControlAPI.AddFeatureClassToListBox(workspace, imageListBoxControl1, type, geometryType);
                        if (bAddTable)
                        {
                            ControlAPI.AddTableToListBox(workspace, imageListBoxControl1);
                        }
                    }
                }
                finally
                {
                    imageListBoxControl1.EndUpdate();
                }
            }
        }
Exemplo n.º 2
0
        public static void OpenGeodatabase(string sPath, ImageListBoxControl imageListBoxControl1, DataType type, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType, bool bAppend = false, bool bAddTable = false)
        {
            IWorkspace workspace = ControlAPI.GetWorkspace(sPath, type, pWorkspaceList);

            imageListBoxControl1.BeginUpdate();
            try
            {
                if (!bAppend)
                {
                    imageListBoxControl1.Items.Clear();
                }
                if (workspace != null)
                {
                    ControlAPI.AddFeatureDatasetToListBox(workspace, imageListBoxControl1, type);
                    ControlAPI.AddFeatureClassToListBox(workspace, imageListBoxControl1, type, geometryType);
                    if (bAddTable)
                    {
                        ControlAPI.AddTableToListBox(workspace, imageListBoxControl1);
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("无效的数据,加载数据失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            finally
            {
                imageListBoxControl1.EndUpdate();
            }
        }
Exemplo n.º 3
0
        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Open the folder.
        /// </summary>
        /// <param name="sPath">The s path.</param>
        /// <param name="imageListBoxControl1">The image ListBox control1.</param>
        /// <param name="type">The type.</param>
        /// <param name="pWorkspaceList">The p workspace list.</param>
        /// <param name="geometryType">Type of the geometry.</param>
        public static void OpenFolder(string sPath, ImageListBoxControl imageListBoxControl1, DataType type, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType)
        {
            imageListBoxControl1.BeginUpdate();
            imageListBoxControl1.Items.Clear();
            DirectoryInfo directoryInfo = new DirectoryInfo(sPath);

            DirectoryInfo[] directories = directoryInfo.GetDirectories();
            SortedDictionary <string, IconType> sortedDictionary = new SortedDictionary <string, IconType>();
            List <string> list = null;

            if (type == DataType.all || (type & DataType.raster) == DataType.raster)
            {
                list = ControlAPI.GetRasterNames(sPath, pWorkspaceList);
            }
            DirectoryInfo[] array = directories;
            for (int i = 0; i < array.Length; i++)
            {
                DirectoryInfo directoryInfo2 = array[i];
                if ((directoryInfo2.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    if (directoryInfo2.Name.EndsWith(".gdb", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (type == DataType.all || (type & DataType.gdb) == DataType.gdb)
                        {
                            sortedDictionary.Add(directoryInfo2.Name, IconType.FGDB);
                        }
                    }
                    else if (list == null || !list.Contains(directoryInfo2.Name))
                    {
                        ControlAPI.AddItemToListBox(IconType.Folder, directoryInfo2.Name, imageListBoxControl1);
                    }
                }
            }
            if (type == DataType.all || (type & DataType.mdb) == DataType.mdb)
            {
                FileInfo[] files  = directoryInfo.GetFiles("*.mdb");
                FileInfo[] array2 = files;
                for (int i = 0; i < array2.Length; i++)
                {
                    FileInfo fileInfo = array2[i];
                    sortedDictionary.Add(fileInfo.Name, IconType.PGDB);
                }
            }
            foreach (KeyValuePair <string, IconType> current in sortedDictionary)
            {
                ControlAPI.AddItemToListBox(current.Value, current.Key, imageListBoxControl1);
            }
            if (list != null && list.Count > 0)
            {
                foreach (string current2 in list)
                {
                    ControlAPI.AddItemToListBox(IconType.RasterDataset, current2, imageListBoxControl1);
                }
            }
            if (type == DataType.all || (type & DataType.shp) == DataType.shp)
            {
                ControlAPI.ListShpFiles(sPath, imageListBoxControl1, pWorkspaceList, geometryType);
            }
            if (type == DataType.all || (type & DataType.cad) == DataType.cad)
            {
                ControlAPI.OpenGeodatabase(sPath, imageListBoxControl1, DataType.cad, pWorkspaceList, geometryType, true, false);
            }
            imageListBoxControl1.EndUpdate();
        }