http://blog.csdn.net/mydriverc/article/details/1675613


    //IFeatureWorkspaceAnno Example

    //The following example show how to use the CreateAnnotationClass on IFeatureWorkspaceAnno 
    //to create a new feature-linked annotation class. In this function, the annotation class is
    //feature-linked to the feature class that is supplied as an argument and is created in the
    //same feature dataset as the feature class it is linked to.     //The label expression is a simple expression of the values in the field called
    //DESCRIPTION in the feature class it is linked to. A text symbol for the feature-linked
    //annotation is red with a font of "Courier New".     //e.g., nameOfFeatureClass = "States";
    //on ArcSDE use ISqlSyntax::QualifyTableName for fully qualified table names.
    public IFeatureClass IFeatureWorkspaceAnno_Example(IFeatureClass featureClass)
    {
        IDataset dataset = (IDataset)featureClass;
        //cast for the feature workspace from the workspace
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)dataset.Workspace;
        IFeatureWorkspaceAnno featureWorkspaceAnno = (IFeatureWorkspaceAnno)dataset.Workspace;
        //set up the reference scale
        ESRI.ArcGIS.Carto.IGraphicsLayerScale graphicLayerScale =
            new ESRI.ArcGIS.Carto.GraphicsLayerScaleClass();
        IGeoDataset geoDataset = (IGeoDataset)dataset;
        graphicLayerScale.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
        graphicLayerScale.ReferenceScale = 2000;
        //set up symbol collection
        ESRI.ArcGIS.Display.ISymbolCollection symbolCollection =
            new ESRI.ArcGIS.Display.SymbolCollectionClass();         #region "MakeText"
        ESRI.ArcGIS.Display.IFormattedTextSymbol myTextSymbol =
            new ESRI.ArcGIS.Display.TextSymbolClass();
        //set the font for myTextSymbol
        stdole.IFontDisp myFont = new stdole.StdFontClass() as stdole.IFontDisp;
        myFont.Name = "Courier New";
        myFont.Size = 9;
        myTextSymbol.Font = myFont;
        //set the Color for myTextSymbol to be Dark Red
        ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
        rgbColor.Red = 150;
        rgbColor.Green = 0;
        rgbColor.Blue = 0;
        myTextSymbol.Color = (ESRI.ArcGIS.Display.IColor)rgbColor;
        //Set other properties for myTextSymbol
        myTextSymbol.Angle = 0;
        myTextSymbol.RightToLeft = false;
        myTextSymbol.VerticalAlignment = ESRI.ArcGIS.Display.esriTextVerticalAlignment.esriTVABaseline;
        myTextSymbol.HorizontalAlignment = ESRI.ArcGIS.Display.esriTextHorizontalAlignment.esriTHAFull;
        myTextSymbol.CharacterSpacing = 200;
        myTextSymbol.Case = ESRI.ArcGIS.Display.esriTextCase.esriTCNormal;
        #endregion         symbolCollection.set_Symbol(0, (ESRI.ArcGIS.Display.ISymbol)myTextSymbol);
        //set up the annotation labeling properties including the expression
        ESRI.ArcGIS.Carto.IAnnotateLayerProperties annoProps = new
            ESRI.ArcGIS.Carto.LabelEngineLayerPropertiesClass();
        annoProps.FeatureLinked = true;
        annoProps.AddUnplacedToGraphicsContainer = false;
        annoProps.CreateUnplacedElements = true;
        annoProps.DisplayAnnotation = true;
        annoProps.UseOutput = true;         ESRI.ArcGIS.Carto.ILabelEngineLayerProperties layerEngineLayerProps =
            (ESRI.ArcGIS.Carto.ILabelEngineLayerProperties)annoProps;
        ESRI.ArcGIS.Carto.IAnnotationExpressionEngine annoExpressionEngine =
            new ESRI.ArcGIS.Carto.AnnotationVBScriptEngineClass();
        layerEngineLayerProps.ExpressionParser = annoExpressionEngine;
        layerEngineLayerProps.Expression = "[DESCRIPTION]";
        layerEngineLayerProps.IsExpressionSimple = true;
        layerEngineLayerProps.Offset = 0;
        layerEngineLayerProps.SymbolID = 0;
        layerEngineLayerProps.Symbol = myTextSymbol;         ESRI.ArcGIS.Carto.IAnnotateLayerTransformationProperties annoLayerTransProp =
            (ESRI.ArcGIS.Carto.IAnnotateLayerTransformationProperties)annoProps;
        annoLayerTransProp.ReferenceScale = graphicLayerScale.ReferenceScale;
        annoLayerTransProp.Units = graphicLayerScale.Units;
        annoLayerTransProp.ScaleRatio = 1;         ESRI.ArcGIS.Carto.IAnnotateLayerPropertiesCollection annoPropsColl =
            new ESRI.ArcGIS.Carto.AnnotateLayerPropertiesCollectionClass();
        annoPropsColl.Add(annoProps);
        //use the AnnotationFeatureClassDescription to get the list of required
        //fields and the default name of the shape field
        IObjectClassDescription oCDesc = new ESRI.ArcGIS.Carto.AnnotationFeatureClassDescriptionClass();
        IFeatureClassDescription fCDesc = (IFeatureClassDescription)oCDesc;
       
        //create the new class
        return featureWorkspaceAnno.CreateAnnotationClass("AnnoTest",
            oCDesc.RequiredFields, oCDesc.InstanceCLSID, oCDesc.ClassExtensionCLSID,
            fCDesc.ShapeFieldName, "", featureClass.FeatureDataset, featureClass,
            annoPropsColl, graphicLayerScale, symbolCollection, true);
    }

创建注记图层C# IFeatureWorkspaceAnno的更多相关文章

  1. 用IFeatureWorkspaceAnno.CreateAnnotationClass 创建注记图层时报“The application is not licensed to modify or create schema”的错误的解决方案。

    用IFeatureWorkspaceAnno.CreateAnnotationClass 的方法创建注记图层的时候报"The application is not licensed to m ...

  2. 【ESRI论坛6周年征文】ArcEngine注记(Anno/ Label/Element等)处理专题 -入门篇

    原发表于ESRI中国社区,转过来.我的社区帐号:jhlong http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=122097 ----------- ...

  3. ArcEngine标注和注记

    转自原文 ArcEngine标注和注记 标注和注记是ArcEngine中提供的两种使用文字信息标注地图要素的方式.其中标注是作为图层的属性存在的,可以动态创建,注记作为地理要素被存储.需要注意的是Sh ...

  4. AE指定字段转成注记

    转自原文 ae指定字段转成注记 ArcMap中有一个功能是Label Features,就是可以将图层内指定字段值显示以Label形式显示在主窗口上,在Label Features后,用右键点击图层, ...

  5. 【ArcEngine入门与提高】Element(元素)、Annotation(注记)旋转

    因项目需要,需要做一个旋转注记的工具.因为注记这玩意用的比较少,网上资源也很少,所以做起来相当头疼.在经过一番研究之后,终于搞清楚注记的存储原理了,原来是和Element的类似,只不过注记是要把Ele ...

  6. WebGIS中自定义互联网地图局部注记的一种方案

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.    前言 实际项目中我们经常会遇到这样一种场景:地图底图可能是互 ...

  7. ArcGis 创建Annotation注记要素类、添加注记要素 并加载到Activeview AO C#

    AO中一般有两种方式存储图面注记元素,一种使用TextElement,它是文档级的元素,编辑后要通过文档(mxd)保存:另一种是使用Annotation要素类,它是一个独立的要素类(featurecl ...

  8. 创建文本注记TextElement

    1.创建一个字体 /// <summary> /// 字体设置 /// </summary> /// <param name="size">Th ...

  9. 创建线注记LineElement

    1.根据2点创建一条线 /// <summary> /// 创建线 /// </summary> /// <param name="pnt1"> ...

随机推荐

  1. 【cookie】【浏览器】各大浏览器对cookie的限制

  2. 《零基础入门学习Python》【第一版】视频课后答案第004讲

    1.while语句中,当条件为真时,它会一直循环下去,比如下面的例子,不过可以用Ctral + C来强制结束 while 'C': print("i love you") 2.观察 ...

  3. 第一章 pyhton基础

    一 .pyhton2与python3的区别 在pyhton2中,其中编码默认使用的是ascii编码,输出格式为print"xxx",输入为raw_input(“请输入”),在整型中 ...

  4. 零基础学Python不迷茫——基本学习路线及教程!

    什么是Python? 在过去的2018年里,Python成功的证明了它自己有多火,它那“简洁”与明了的语言成功的吸引了大批程序员与大数据应用这的注意,的确,它的实用性的确是配的上它的热度.   Pyt ...

  5. Android开发工具——Gradle知识汇总

    1.什么是构建工具 Eclipse大家都知道是一种IDE(集成开发环境),最初是用来做Java开发的,而Android是基于Java语言的,所以最初Google还是希望Android能在Eclipse ...

  6. thymeleaf和artTemplate

    Company最近项目中使用了两个模板引擎,分别是Java服务器端的模板引擎Thymeleaf和前端的模板引擎artTemplate, 其实对于这两个模板引擎 理论上应该是不应该放在一起记录的,但是b ...

  7. vue.js 利用SocketCluster实现动态添加数据及排序

    直接上代码 html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...

  8. 检测SQLserver数据库链接是否正常

    select * From [数据库链接名].master.dbo.sysdatabases where name='数据库名' and status<>512

  9. 树状数组 Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains

    C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  10. php 注册与登录

    <body background="timg.jpg"><div class="dak"> <div class="zu ...