예제 #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();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Get the raster names.
        /// </summary>
        /// <param name="sPath">The s path.</param>
        /// <param name="pWorkspaceList">The p workspace list.</param>
        /// <returns>List&lt;System.String&gt;.</returns>
        public static List <string> GetRasterNames(string sPath, List <WorkspaceInfo> pWorkspaceList)
        {
            IWorkspace    workspace = ControlAPI.GetWorkspace(sPath, DataType.raster, pWorkspaceList);
            List <string> result;

            if (workspace == null)
            {
                result = null;
            }
            else
            {
                List <string>    list            = new List <string>();
                IEnumDatasetName enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
                try
                {
                    IDatasetName datasetName;
                    while ((datasetName = enumDatasetName.Next()) != null)
                    {
                        list.Add(datasetName.Name);
                    }
                    result = list;
                }
                finally
                {
                    Marshal.ReleaseComObject(enumDatasetName);
                }
            }
            return(result);
        }
예제 #3
0
 /// <summary>
 /// Lists the SHP files.
 /// </summary>
 /// <param name="sPath">The s path.</param>
 /// <param name="imageListBoxControl1">The image ListBox control1.</param>
 /// <param name="pWorkspaceList">The p workspace list.</param>
 /// <param name="geometryType">Type of the geometry.</param>
 public static void ListShpFiles(string sPath, ImageListBoxControl imageListBoxControl1, List <WorkspaceInfo> pWorkspaceList, esriGeometryType geometryType)
 {
     string[] files = Directory.GetFiles(sPath, "*.shp");
     if (files != null && files.Length != 0)
     {
         IWorkspace workspace = ControlAPI.GetWorkspace(sPath, DataType.shp, pWorkspaceList);
         ControlAPI.AddFeatureClassToListBox(workspace, imageListBoxControl1, DataType.shp, geometryType);
     }
 }