Пример #1
0
 private void method_3(IMap imap_1, ILayer ilayer_0, string string_0, double double_1, IWorkspace iworkspace_1,
                       bool bool_0, bool bool_1, esriLabelWhichFeatures esriLabelWhichFeatures_1)
 {
     if ((iworkspace_1.Type != esriWorkspaceType.esriFileSystemWorkspace) && (ilayer_0 is IGeoFeatureLayer))
     {
         int num;
         IAnnotateLayerProperties     properties;
         IElementCollection           elements;
         IElementCollection           elements2;
         ILabelEngineLayerProperties2 properties2;
         IAnnotationLayer             layer2;
         IGeoFeatureLayer             layer = ilayer_0 as IGeoFeatureLayer;
         IFeatureClass                      featureClass         = layer.FeatureClass;
         IAnnotationLayerFactory            factory              = new FDOGraphicsLayerFactoryClass();
         ISymbolCollection2                 lcs                  = new SymbolCollectionClass();
         IAnnotateLayerPropertiesCollection propertiess          = new AnnotateLayerPropertiesCollectionClass();
         IAnnotateLayerPropertiesCollection annotationProperties = layer.AnnotationProperties;
         for (num = 0; num < annotationProperties.Count; num++)
         {
             annotationProperties.QueryItem(num, out properties, out elements, out elements2);
             if (properties != null)
             {
                 ISymbolIdentifier2 identifier;
                 propertiess.Add(properties);
                 properties2 = properties as ILabelEngineLayerProperties2;
                 IClone symbol = properties2.Symbol as IClone;
                 lcs.AddSymbol(symbol.Clone() as ISymbol, properties.Class + " " + num.ToString(), out identifier);
                 properties2.SymbolID = identifier.ID;
             }
         }
         properties  = null;
         properties2 = null;
         IGraphicsLayerScale scale = new GraphicsLayerScaleClass
         {
             ReferenceScale = double_1,
             Units          = imap_1.MapUnits
         };
         IFeatureClassDescription description  = new AnnotationFeatureClassDescriptionClass();
         IObjectClassDescription  description2 = description as IObjectClassDescription;
         IFields          requiredFields       = description2.RequiredFields;
         IGeometryDefEdit geometryDef          =
             requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName)).GeometryDef as
             IGeometryDefEdit;
         IGeoDataset dataset = featureClass as IGeoDataset;
         geometryDef.SpatialReference_2 = dataset.SpatialReference;
         IMapOverposter        overposter           = imap_1 as IMapOverposter;
         IOverposterProperties overposterProperties = overposter.OverposterProperties;
         if (bool_1)
         {
             this.method_2(iworkspace_1 as IFeatureWorkspaceAnno, featureClass.FeatureDataset, featureClass,
                           scale.ReferenceScale, scale.Units, propertiess, lcs as ISymbolCollection, string_0);
             layer2 = factory.OpenAnnotationLayer(iworkspace_1 as IFeatureWorkspace, featureClass.FeatureDataset,
                                                  string_0);
         }
         else
         {
             this.method_2(iworkspace_1 as IFeatureWorkspaceAnno, featureClass.FeatureDataset, null,
                           scale.ReferenceScale, scale.Units, propertiess, lcs as ISymbolCollection, string_0);
             layer2 = factory.OpenAnnotationLayer(iworkspace_1 as IFeatureWorkspace, featureClass.FeatureDataset,
                                                  string_0);
         }
         IActiveView    view          = imap_1 as IActiveView;
         IScreenDisplay screenDisplay = view.ScreenDisplay;
         (layer2 as IGraphicsLayer).Activate(screenDisplay);
         for (num = 0; num < propertiess.Count; num++)
         {
             propertiess.QueryItem(num, out properties, out elements, out elements2);
             if (properties != null)
             {
                 properties.FeatureLayer      = layer;
                 properties.GraphicsContainer = layer2 as IGraphicsContainer;
                 properties.AddUnplacedToGraphicsContainer = bool_0;
                 properties.CreateUnplacedElements         = true;
                 properties.DisplayAnnotation  = true;
                 properties.FeatureLinked      = bool_1;
                 properties.LabelWhichFeatures = esriLabelWhichFeatures_1;
                 properties.UseOutput          = true;
                 properties2                   = properties as ILabelEngineLayerProperties2;
                 properties2.SymbolID          = num;
                 properties2.AnnotationClassID = num;
                 IOverposterLayerProperties2 overposterLayerProperties =
                     properties2.OverposterLayerProperties as IOverposterLayerProperties2;
                 overposterLayerProperties.TagUnplaced = true;
             }
         }
         propertiess.Sort();
         IAnnotateMapProperties annoMapCmdProps = new AnnotateMapPropertiesClass
         {
             AnnotateLayerPropertiesCollection = propertiess
         };
         ITrackCancel trackCancel = new CancelTrackerClass();
         (imap_1.AnnotationEngine as IAnnotateMap2).Label(overposterProperties, annoMapCmdProps, imap_1,
                                                          trackCancel);
         for (num = 0; num < propertiess.Count; num++)
         {
             propertiess.QueryItem(num, out properties, out elements, out elements2);
             if (properties != null)
             {
                 properties.FeatureLayer = null;
             }
         }
         imap_1.AddLayer(layer2 as ILayer);
         layer.DisplayAnnotation = false;
         view.Refresh();
     }
 }
Пример #2
0
        private void ConvertAnnotation(IMap map, ILayer featureLayer, string annotationFeatureClassName, double scale,
                                       IWorkspace workspace, ILineLabelPosition lineLabelPosition,
                                       IPointPlacementPriorities pointPlacementPriorities,
                                       esriBasicOverposterWeight labelWeight, esriBasicOverposterWeight featureWeight, bool tagUnplaced,
                                       string fontName, double fontSize, IRgbColor rgbColor, string expression, bool featureLinked,
                                       esriLabelWhichFeatures labelWhichFeatures)
        {
            if (workspace.Type != esriWorkspaceType.esriFileSystemWorkspace && featureLayer is IGeoFeatureLayer)
            {
                IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
                IAnnotateLayerPropertiesCollection annotateLayerPropertiesCollectionClass =
                    geoFeatureLayer.AnnotationProperties;
                annotateLayerPropertiesCollectionClass.Clear();
                ILabelEngineLayerProperties     labelEngineLayerProperties     = new LabelEngineLayerPropertiesClass();
                IBasicOverposterLayerProperties basicOverposterLayerProperties =
                    new BasicOverposterLayerPropertiesClass();
                if (lineLabelPosition != null)
                {
                    basicOverposterLayerProperties.LineLabelPosition = lineLabelPosition;
                }
                else if (pointPlacementPriorities != null)
                {
                    basicOverposterLayerProperties.PointPlacementPriorities = pointPlacementPriorities;
                }
                basicOverposterLayerProperties.LabelWeight   = labelWeight;
                basicOverposterLayerProperties.FeatureWeight = featureWeight;

                IOverposterLayerProperties2 overposterLayerProperties2 =
                    basicOverposterLayerProperties as IOverposterLayerProperties2;
                overposterLayerProperties2.TagUnplaced = tagUnplaced;

                labelEngineLayerProperties.BasicOverposterLayerProperties = basicOverposterLayerProperties;
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = fontName;
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Size  = fontSize;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = rgbColor;
                labelEngineLayerProperties.Symbol     = pTextSymbol;
                labelEngineLayerProperties.Expression = expression;

                IAnnotateLayerProperties annotateLayerProperties =
                    labelEngineLayerProperties as IAnnotateLayerProperties;
                annotateLayerProperties.DisplayAnnotation = true;

                IAnnotationLayer annotationLayer =
                    CommonHelper.GetLayerByFeatureClassName(_context.FocusMap, annotationFeatureClassName) as
                    IAnnotationLayer;
                CommonHelper.SetReferenceScale(annotationLayer, scale);
                annotateLayerProperties.FeatureLayer      = geoFeatureLayer;
                annotateLayerProperties.GraphicsContainer = annotationLayer as IGraphicsContainer;
                annotateLayerProperties.AddUnplacedToGraphicsContainer = true;
                annotateLayerProperties.CreateUnplacedElements         = true;
                annotateLayerProperties.DisplayAnnotation  = true;
                annotateLayerProperties.FeatureLinked      = featureLinked;
                annotateLayerProperties.LabelWhichFeatures = labelWhichFeatures;
                annotateLayerProperties.UseOutput          = true;
                annotateLayerPropertiesCollectionClass.Add(annotateLayerProperties);

                annotateLayerPropertiesCollectionClass.Sort();
                IAnnotateMapProperties annotateMapPropertiesClass = new AnnotateMapPropertiesClass()
                {
                    AnnotateLayerPropertiesCollection = annotateLayerPropertiesCollectionClass
                };
                ITrackCancel          cancelTrackerClass   = new CancelTrackerClass();
                IAnnotateMap2         annotateMap2         = map.AnnotationEngine as IAnnotateMap2;
                IOverposterProperties overposterProperties = (map as IMapOverposter).OverposterProperties;
                annotateMap2.Label(overposterProperties, annotateMapPropertiesClass, map, cancelTrackerClass);
                map.AddLayer(annotationLayer as ILayer);
                geoFeatureLayer.DisplayAnnotation = false;
                map.ReferenceScale = scale;
                map.MapScale       = scale;
                IActiveView activeView = map as IActiveView;
                activeView.Refresh();
            }
        }