Exemplo n.º 1
0
 /// <summary>
 /// Opens a dialog so the user can select an existing shapefile or file geodatabase
 /// feature class.
 /// </summary>
 /// <param name="title">title for dialog</param>
 /// <returns>dataset name object for the selected feature class or null </returns>
 private IDatasetName SelectFeatureClass(string title, esriGeometryType geom)
 {
     try
     {
         IGxObjectFilter           shpFilter = new GxFilterShapefilesClass();
         IGxObjectFilter           gdbFilter = new GxFilterFGDBFeatureClassesClass();
         IGxDialog                 dlg       = new GxDialogClass();
         IGxObjectFilterCollection filters   = (IGxObjectFilterCollection)dlg;
         filters.AddFilter(shpFilter, false);
         filters.AddFilter(gdbFilter, true);
         dlg.Title = title;
         IDatasetName  dsName  = null;
         IEnumGxObject objects = null;
         if (dlg.DoModalOpen(0, out objects))
         {
             IGPUtilities2 util = new GPUtilitiesClass();
             string        name = objects.Next().FullName;
             dsName = (IDatasetName)util.CreateFeatureClassName(name);
             IFeatureWorkspace ws  = (IFeatureWorkspace)((IName)dsName.WorkspaceName).Open();
             IFeatureClass     fc  = ws.OpenFeatureClass(System.IO.Path.GetFileName(name));
             esriGeometryType  shp = fc.ShapeType;
             if (!(geom == esriGeometryType.esriGeometryAny &&
                   (shp == esriGeometryType.esriGeometryPoint ||
                    shp == esriGeometryType.esriGeometryPolyline ||
                    shp == esriGeometryType.esriGeometryPolygon)) &&
                 shp != geom)
             {
                 ShowError("Wrong geometry type.");
                 dsName = null;
             }
             dsName = (IDatasetName)((IDataset)fc).FullName;
         }
         return(dsName);
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
         return(null);
     }
 }
        public AoFeatureClassName(string p)
        {
            IGPUtilities util = new GPUtilitiesClass();

            m_fcn = util.CreateFeatureClassName(p) as IFeatureClassName;
        }