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. 离线web-ApplicationCache

    https://www.html5rocks.com/en/tutorials/appcache/beginner/ http://diveintohtml5.info/offline.html#fa ...

  2. CVS在update时状态status

    cvs update -Ad 时,terminal 会display如下: P xx.v P xx.c ? xx.v ? xx.c A xx.v M xx.v U xx.v C xx.v 第一个字母: ...

  3. ACM Changchun 2015 A. Too Rich

    You are a rich person, and you think your wallet is too heavy and full now. So you want to give me s ...

  4. eclipse去除js(JavaScript)验证错误

    第一步: 去除eclipse的JS验证: 将windows->preference->Java Script->Validator->Errors/Warnings-> ...

  5. POJ 1849 树的直径 Two

    如果一个点开始遍历一棵树再回到原点那么每条边走两次. 现在是两个人从同一点出发,那么最后遍历完以后两人离得越远越好. 最后两人所处位置的路径上的边走了一次,其他边走了两次. 要使总路程最小,两人最后停 ...

  6. luogu1345 [USACO5.4]奶牛的电信Telecowmunication

    对于每个点,把它拆成有权值为1的边相连的两个点,原边是inf. 边的起点统一加n,ss也加n 这就成了最小割 #include <iostream> #include <cstrin ...

  7. CEO的智力财富第12期-《股权激励》学习笔记

    卷首语---你现在走的第一步,都藏着你未来的样子 今天,又去参加天使岛举办的系列讲座之股权激励,由律大大律师事务所李刚律师主讲,走在路上,我就在想,我为什么要来参加这样的活动呢?我的本职工作和股权没有 ...

  8. SQL Server数据库和MySQL数据库有什么区别?

    SQL Server数据库和MySQL数据库有什么区别呢?详细很多初入IT行业的朋友对于SQL Server数据库和MySQL数据库经常搞混,认为这两种数据库是同一种,其实不然,今天我们来分析一下这两 ...

  9. 【LeetCode】Maximum Depth of Binary Tree(二叉树的最大深度)

    这道题是LeetCode里的第104道题. 给出题目: 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例: 给定 ...

  10. js对文字进行编码

    js对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decodeURIComponent 1 ...