ArcEngine标注转注记

 

      public void LabelsTranstoAnnoration(IMap pMap, IFeatureLayer pFeatureLayer, IWorkspace pannworkspace, string AnnLayername, bool featureLinked)
        {
            IConvertLabelsToAnnotation pConvertLabelsToAnnotation;
            ITrackCancel pTrackCancel;
            IGeoFeatureLayer pGeoFeatureLayer;
            IFeatureClass pFeatureClass;
            IFeatureWorkspace pFeatureWorkspace;

            pConvertLabelsToAnnotation = new ConvertLabelsToAnnotationClass();
            pTrackCancel = new CancelTrackerClass();
            pConvertLabelsToAnnotation.Initialize(pMap, esriAnnotationStorageType.esriMapAnnotation,
                                                      esriLabelWhichFeatures.esriAllFeatures, true, pTrackCancel, null);


            pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
            if (pGeoFeatureLayer != null)
            {
                pFeatureClass = pFeatureLayer.FeatureClass;
                IDataset pDataset = pFeatureClass as IDataset;

                pFeatureWorkspace = pannworkspace as IFeatureWorkspace;
                try
                {
                    IFeatureDataset featuredataset = pFeatureClass as IFeatureDataset;
                    pConvertLabelsToAnnotation.AddFeatureLayer(pFeatureLayer, AnnLayername,
                                                                  pFeatureWorkspace, null, false,
                                                                   true, false, true, true, "");
                }
                catch (Exception s)
                {
                    System.Windows.Forms.MessageBox.Show(s.Message);
                }
                //Do the conversion.
                pConvertLabelsToAnnotation.ConvertLabels();
                pGeoFeatureLayer.DisplayAnnotation = false ;
                IActiveView pActiveView = pMap as IActiveView;
                pActiveView.Refresh();
            }
            if (pConvertLabelsToAnnotation != null)
            {
                ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pConvertLabelsToAnnotation);
            }
            if (pTrackCancel != null)
                ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pTrackCancel);
        }
标注转注记

 

posted @ 2018-08-27 22:33  ParanoiaApe  阅读(447)  评论(0)    收藏  举报