public override void FillDatabase(Teigha.DatabaseServices.Database pDb)
{
IFeatureClassContainer pFeatureClassContainer = pCADFeatureDataset as IFeatureClassContainer;
IEnumFeatureClass pEnumFeatureClass = pFeatureClassContainer.Classes;
IFeatureClass pFeatureClass = pEnumFeatureClass.Next();
while (pFeatureClass != null)
{
LoadLayer(pFeatureClass, pDb);
Debug.WriteLine(pFeatureClass.FeatureType.ToString() + "-" + pFeatureClass.AliasName + "-" + pFeatureClass.ShapeType.ToString());
pFeatureClass = pEnumFeatureClass.Next();
}
}
private void LoadLayer(IFeatureClass pFeatureClass, Teigha.DatabaseServices.Database pDb)
{
int indx = pFeatureClass.FindField("Layer");
int idxColor = pFeatureClass.FindField("Color");
int idxText = pFeatureClass.FindField("TxtMemo");
int idxHandle = pFeatureClass.FindField("Handle");
pCursor = pFeatureClass.Search(null, false);
IFeature pFeature2 = pCursor.NextFeature();
//写入点线
if (pFeatureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
{
while (pFeature2 != null)
{
string geoName = "C_" + pFeature2.get_Value(indx).ToString();
string sAnnotation = pFeature2.get_Value(idxText).ToString();
IPoint pPoint = pFeature2.Shape as IPoint;
double x = 0, y = 0;
pPoint.QueryCoords(out x, out y);
Point3d pt = new Point3d(x, y, 0);
addTextEnt(modelSpaceId, pt, pt, sAnnotation, 2, TextHorizontalMode.TextLeft, TextVerticalMode.TextTop, LayerNames[geoName], ttfStyleId);
pFeature2 = pCursor.NextFeature();
}
}
else
{
if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
{
while (pFeature2 != null)
{
IPoint pt = pFeature2.Shape as IPoint;
pFeature2 = pCursor.NextFeature();
}
}
else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
short shtColor = 1;
while ((pFeature2 = pCursor.NextFeature()) != null)
{
string geoName = "C_" + pFeature2.get_Value(indx).ToString();
}
}
else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
{
short shtColor = 1;
while ((pFeature2 = pCursor.NextFeature()) != null)
{
string geoName = "C_" + pFeature2.get_Value(indx).ToString();
}
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
pCursor = null;
}
}