建立完文本注記TextElement後,可以選擇以螢幕注記的形式加到螢幕上,也可以通過下面的方式轉為注記圖層要素:
IFeatureClass annocls = 擷取注記圖層
IDataset pDataset = annocls as IDataset;
ITransactions pTransactions = pDataset.Workspace as ITransactions;
pTransactions.StartTransaction();
IFDOGraphicsLayerFactory pFDOGLFactory = new FDOGraphicsLayerFactoryClass();
ILayer tmpLayer = pFDOGLFactory.OpenGraphicsLayer(pDataset.Workspace as IFeatureWorkspace, annocls.FeatureDataset, pDataset.Name);
IFDOGraphicsLayer pFDOGLayer = tmpLayer as IFDOGraphicsLayer;
IElementCollection pElementColl = new ElementCollectionClass();
pFDOGLayer.BeginAddElements();
////每新增100個送出下,最後再送出下。防止過多轉換失敗
if ((pElementColl != null) && (pElementColl.Count == 100))
{
pFDOGLayer.DoAddElements(pElementColl, 0);
pFDOGLayer.EndAddElements();
pElementColl.Clear();
pTransactions.CommitTransaction();
pTransactions.StartTransaction();
pFDOGLayer.BeginAddElements();
}
if (pElementColl.Count > 0)
pFDOGLayer.DoAddElements(pElementColl, 0);
pFDOGLayer.EndAddElements();
pElementColl.Clear();
pTransactions.CommitTransaction();