コード例 #1
0
        public static IFeatureClass CreateAnnoFeatureClass(IFeatureWorkspaceAnno ifeatureWorkspaceAnno_0,
                                                           IFeatureDataset ifeatureDataset_0, IFeatureClass ifeatureClass_0, double double_0, esriUnits esriUnits_0,
                                                           IAnnotateLayerPropertiesCollection iannotateLayerPropertiesCollection_0,
                                                           ISymbolCollection isymbolCollection_0, string string_0)
        {
            IObjectClassDescription annotationFeatureClassDescriptionClass = new AnnotationFeatureClassDescription();
            IFields requiredFields = annotationFeatureClassDescriptionClass.RequiredFields;
            int     num            =
                requiredFields.FindField(
                    (annotationFeatureClassDescriptionClass as IFeatureClassDescription).ShapeFieldName);

            if (num != -1)
            {
                IField            field            = requiredFields.Field[num];
                IGeometryDef      geometryDef      = field.GeometryDef;
                ISpatialReference spatialReference = geometryDef.SpatialReference;
                LayerOp.ChangeCoordinateSystem(ifeatureWorkspaceAnno_0 as IGeodatabaseRelease, spatialReference, false);
                (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
                (field as IFieldEdit).GeometryDef_2 = geometryDef;
            }
            IFeatureClassDescription featureClassDescription =
                annotationFeatureClassDescriptionClass as IFeatureClassDescription;
            IGraphicsLayerScale graphicsLayerScaleClass = new GraphicsLayerScale()
            {
                ReferenceScale = double_0,
                Units          = esriUnits_0
            };
            UID           instanceCLSID       = annotationFeatureClassDescriptionClass.InstanceCLSID;
            UID           classExtensionCLSID = annotationFeatureClassDescriptionClass.ClassExtensionCLSID;
            IFeatureClass featureClass        = ifeatureWorkspaceAnno_0.CreateAnnotationClass(string_0, requiredFields,
                                                                                              instanceCLSID, classExtensionCLSID, featureClassDescription.ShapeFieldName, "", ifeatureDataset_0,
                                                                                              ifeatureClass_0, iannotateLayerPropertiesCollection_0, graphicsLayerScaleClass, isymbolCollection_0,
                                                                                              true);

            return(featureClass);
        }
コード例 #2
0
        public static void ConvertLabels2StandardAnno(IMap imap_0, ILayer ilayer_0, string string_0, double double_0,
                                                      IWorkspace iworkspace_0, bool bool_0, bool bool_1, esriLabelWhichFeatures esriLabelWhichFeatures_0)
        {
            int i;
            IAnnotateLayerProperties     bool0;
            IElementCollection           elementCollection;
            IElementCollection           elementCollection1;
            ILabelEngineLayerProperties2 d;
            ISymbolIdentifier2           symbolIdentifier2;
            IAnnotationLayer             annotationLayer;

            if (iworkspace_0.Type != esriWorkspaceType.esriFileSystemWorkspace && ilayer_0 is IGeoFeatureLayer)
            {
                IGeoFeatureLayer        ilayer0      = ilayer_0 as IGeoFeatureLayer;
                IFeatureClass           featureClass = ilayer0.FeatureClass;
                IAnnotationLayerFactory fDOGraphicsLayerFactoryClass =
                    new FDOGraphicsLayerFactory() as IAnnotationLayerFactory;
                ISymbolCollection2 symbolCollectionClass = new SymbolCollection() as ISymbolCollection2;
                IAnnotateLayerPropertiesCollection annotateLayerPropertiesCollectionClass =
                    new AnnotateLayerPropertiesCollection();
                IAnnotateLayerPropertiesCollection annotationProperties = ilayer0.AnnotationProperties;
                for (i = 0; i < annotationProperties.Count; i++)
                {
                    annotationProperties.QueryItem(i, out bool0, out elementCollection, out elementCollection1);
                    if (bool0 != null)
                    {
                        annotateLayerPropertiesCollectionClass.Add(bool0);
                        d = bool0 as ILabelEngineLayerProperties2;
                        IClone symbol = d.Symbol as IClone;
                        symbolCollectionClass.AddSymbol(symbol.Clone() as ISymbol,
                                                        string.Concat(bool0.Class, " ", i.ToString()), out symbolIdentifier2);
                        d.SymbolID = symbolIdentifier2.ID;
                    }
                }
                bool0 = null;
                d     = null;
                IGraphicsLayerScale graphicsLayerScaleClass = new GraphicsLayerScale()
                {
                    ReferenceScale = double_0,
                    Units          = imap_0.MapUnits
                };
                IFeatureClassDescription annotationFeatureClassDescriptionClass =
                    new AnnotationFeatureClassDescription() as IFeatureClassDescription;
                IFields requiredFields =
                    (annotationFeatureClassDescriptionClass as IObjectClassDescription).RequiredFields;
                IField field =
                    requiredFields.Field[requiredFields.FindField(annotationFeatureClassDescriptionClass.ShapeFieldName)
                    ];
                (field.GeometryDef as IGeometryDefEdit).SpatialReference_2 =
                    (featureClass as IGeoDataset).SpatialReference;
                IOverposterProperties overposterProperties = (imap_0 as IMapOverposter).OverposterProperties;
                if (!bool_1)
                {
                    LayerOp.CreateAnnoFeatureClass(iworkspace_0 as IFeatureWorkspaceAnno, featureClass.FeatureDataset,
                                                   null, graphicsLayerScaleClass.ReferenceScale, graphicsLayerScaleClass.Units,
                                                   annotateLayerPropertiesCollectionClass, symbolCollectionClass as ISymbolCollection, string_0);
                    annotationLayer = fDOGraphicsLayerFactoryClass.OpenAnnotationLayer(
                        iworkspace_0 as IFeatureWorkspace, featureClass.FeatureDataset, string_0);
                }
                else
                {
                    LayerOp.CreateAnnoFeatureClass(iworkspace_0 as IFeatureWorkspaceAnno, featureClass.FeatureDataset,
                                                   featureClass, graphicsLayerScaleClass.ReferenceScale, graphicsLayerScaleClass.Units,
                                                   annotateLayerPropertiesCollectionClass, symbolCollectionClass as ISymbolCollection, string_0);
                    annotationLayer = fDOGraphicsLayerFactoryClass.OpenAnnotationLayer(
                        iworkspace_0 as IFeatureWorkspace, featureClass.FeatureDataset, string_0);
                }
                IActiveView imap0 = imap_0 as IActiveView;
                (annotationLayer as IGraphicsLayer).Activate(imap0.ScreenDisplay);
                for (i = 0; i < annotateLayerPropertiesCollectionClass.Count; i++)
                {
                    annotateLayerPropertiesCollectionClass.QueryItem(i, out bool0, out elementCollection,
                                                                     out elementCollection1);
                    if (bool0 != null)
                    {
                        bool0.FeatureLayer      = ilayer0;
                        bool0.GraphicsContainer = annotationLayer as IGraphicsContainer;
                        bool0.AddUnplacedToGraphicsContainer = bool_0;
                        bool0.CreateUnplacedElements         = true;
                        bool0.DisplayAnnotation  = true;
                        bool0.FeatureLinked      = bool_1;
                        bool0.LabelWhichFeatures = esriLabelWhichFeatures_0;
                        bool0.UseOutput          = true;
                        d                   = bool0 as ILabelEngineLayerProperties2;
                        d.SymbolID          = i;
                        d.AnnotationClassID = i;
                        (d.OverposterLayerProperties as IOverposterLayerProperties2).TagUnplaced = true;
                    }
                }
                annotateLayerPropertiesCollectionClass.Sort();
                IAnnotateMapProperties annotateMapPropertiesClass = new AnnotateMapProperties()
                {
                    AnnotateLayerPropertiesCollection = annotateLayerPropertiesCollectionClass
                };
                ITrackCancel cancelTrackerClass = new CancelTracker();
                (imap_0.AnnotationEngine as IAnnotateMap2).Label(overposterProperties, annotateMapPropertiesClass,
                                                                 imap_0, cancelTrackerClass);
                for (i = 0; i < annotateLayerPropertiesCollectionClass.Count; i++)
                {
                    annotateLayerPropertiesCollectionClass.QueryItem(i, out bool0, out elementCollection,
                                                                     out elementCollection1);
                    if (bool0 != null)
                    {
                        bool0.FeatureLayer = null;
                    }
                }
                imap_0.AddLayer(annotationLayer as ILayer);
                ilayer0.DisplayAnnotation = false;
                imap0.Refresh();
            }
        }