Beispiel #1
0
        private void Btn_AddTitle_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = Tool_.PutRGB(0, 0, 0);
            stdole.IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp;
            font.Bold       = true;
            font.Italic     = true;
            textSymbol.Font = font;
            textSymbol.Size = m_pEnvelopDrawed.Width * 20;
            IGraphicsContainer pGraphicsContainer = Ctrl_PageLayout.ActiveView.GraphicsContainer;
            ITextElement       pTextElement       = new TextElementClass
            {
                ScaleText = true,
                Symbol    = textSymbol,
                Text      = "Title"
            };

            if (m_pTitleElement != null)
            {
                pGraphicsContainer.DeleteElement(m_pTitleElement);
            }
            IElement pElement  = pTextElement as IElement;
            IPoint   pPosition = new PointClass();

            pPosition.PutCoords(
                m_pEnvelopDrawed.XMin + (m_pEnvelopDrawed.XMax - m_pEnvelopDrawed.XMin) / 2,
                m_pEnvelopDrawed.YMin + (m_pEnvelopDrawed.YMax - m_pEnvelopDrawed.YMin) / 2);
            pElement.Geometry = pPosition;
            pGraphicsContainer.AddElement(pElement, 0);
            m_pTitleElement = pElement;
            Ctrl_PageLayout.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="lstvalue"></param>
        /// <param name="pageXPart">在X方向所在位置占整个page的比例比例</param>
        /// <param name="pageYPart">在Y方向所在位置占整个page的比例比例</param>
        /// <returns></returns>
        public bool AddText(List <string> lstvalue, double pageXPart, double pageYPart, string fountName, double fontSize)
        {
            pTextElement = new TextElementClass();
            string sValue = lstvalue[0];

            for (int i = 1; i < lstvalue.Count; i++)
            {
                sValue += "\n" + lstvalue[i];
            }
            pTextElement.Text = sValue;

            IElement    pElment = pTextElement as IElement;
            ITextSymbol pSymbol = new TextSymbolClass();

            pSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            stdole.Font pFont;
            pFont               = new stdole.StdFontClass();
            pFont.Name          = fountName;
            pFont.Size          = (decimal)fontSize;
            pSymbol.Font        = pFont as stdole.IFontDisp;
            pTextElement.Symbol = pSymbol;
            IPoint    pPoint = new PointClass();
            IEnvelope pEnv   = new EnvelopeClass();

            pEnv = this.mainPage.ActiveView.Extent;

            pPoint.PutCoords((pEnv.XMin + pEnv.YMax) * pageXPart, (pEnv.YMin + pEnv.YMax) * pageYPart);

            addText(pTextElement, pPoint);
            return(true);
        }
        // 添加标题
        private void AddTitle()
        {
            // 注记放置位置
            IEnvelope pEnv   = axPageLayoutControl_main.Extent;
            IPoint    pPoint = new PointClass()
            {
                X = (pEnv.XMin + pEnv.XMax) / 2,
                Y = pEnv.YMax - 3
            };

            // 文本符号
            stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
            pFont.Name = "arial";
            ITextSymbol pSymbol = new TextSymbolClass()
            {
                Size  = 360.0,
                Font  = pFont,
                Color = GetRgbColor(0, 0, 0)
            };
            // 添加文本对象
            IElement pElement = new TextElementClass()
            {
                Text     = "观看预设点可见性专题图",
                Size     = 360.0,
                Symbol   = pSymbol,
                Geometry = pPoint
            };

            (axPageLayoutControl_main.PageLayout as IGraphicsContainer).AddElement(pElement, 0);
            axPageLayoutControl_main.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        private void button7_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = m_pFillColor;
            stdole.IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp;
            font.Bold       = true;
            font.Italic     = true;
            textSymbol.Font = font;
            textSymbol.Size = trackBar1.Value;
            IMap curMap = frmMainOper(OperationType.GetMap) as IMap;

            (curMap as IGraphicsContainer).DeleteAllElements();
            for (int i = 0; i < m_pTarFeatureClass.FeatureCount(null); i++)
            {
                ITextElement curText = new TextElementClass();
                curText.ScaleText = true;
                curText.Symbol    = textSymbol;
                curText.Text      = m_pTarFeatureClass.GetFeature(i).get_Value(m_nTarFieldIndex).ToString();
                IElement  curElement  = curText as IElement;
                IEnvelope curEnvelope = m_pTarFeatureClass.GetFeature(i).Extent;
                IPoint    position    = new PointClass();
                position.PutCoords(curEnvelope.XMin + (curEnvelope.XMax - curEnvelope.XMin) / 2, curEnvelope.YMin + (curEnvelope.YMax - curEnvelope.YMin));
                curElement.Geometry = position;
                (curMap as IGraphicsContainer).AddElement(curElement, i);
            }
            frmMainOper(OperationType.RefreshMapCtrl);
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            IFeatureClass  pFeatureClass  = (IFeatureClass)m_FeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, true);

            IFeature pFeatrue = pFeatureCursor.NextFeature();

            while (pFeatrue != null)
            {
                IFields pFields = pFeatrue.Fields;
                int     i       = pFields.FindField(cbx_Field.SelectedItem.ToString());

                IEnvelope pEnvelope = pFeatrue.Extent;
                IPoint    pPoint    = new PointClass();
                pPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2);

                stdole.IFontDisp pFont;
                pFont = new stdole.StdFontClass() as stdole.IFontDisp;

                pFont.Name          = lbl_PreviewFont.Font.Name;
                pFont.Italic        = lbl_PreviewFont.Font.Italic;
                pFont.Underline     = lbl_PreviewFont.Font.Underline;
                pFont.Bold          = lbl_PreviewFont.Font.Bold;
                pFont.Size          = (decimal)lbl_PreviewFont.Font.Size;
                pFont.Strikethrough = lbl_PreviewFont.Font.Strikeout;

                IRgbColor pRGB = new RgbColorClass();
                pRGB.Red   = (int)lbl_PreviewFont.ForeColor.R;
                pRGB.Green = (int)lbl_PreviewFont.ForeColor.G;
                pRGB.Blue  = (int)lbl_PreviewFont.ForeColor.B;

                ITextSymbol pTextSymbol = new TextSymbolClass();

                pTextSymbol.Size  = lbl_PreviewFont.Font.Size;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = pRGB;

                ITextElement pTextEle = new TextElementClass();
                pTextEle.Text      = pFeatrue.get_Value(i).ToString();
                pTextEle.ScaleText = true;
                pTextEle.Symbol    = pTextSymbol;

                IElement pEle = (IElement)pTextEle;
                pEle.Geometry = pPoint;

                IActiveView        pActiveView         = (IActiveView)m_MapControl.Map;
                IGraphicsContainer pGraphicsContatiner = (IGraphicsContainer)m_MapControl.Map;

                pGraphicsContatiner.AddElement(pEle, 0);

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                pPoint   = null;
                pEle     = null;
                pFeatrue = pFeatureCursor.NextFeature();
            }
        }
Beispiel #6
0
 /// <summary>
 /// 创建字体对象
 /// </summary>
 /// <param name="size">字体大小 默认为16</param>
 /// <param name="bold">是否为加粗字体 默认为不加粗</param>
 /// <returns>返回 IFontDisp 对象</returns>
 public static stdole.IFontDisp CreateFontDisp(int size = 16, bool bold = false)
 {
     stdole.IFontDisp fontDisp = new stdole.StdFontClass() as stdole.IFontDisp;
     fontDisp.Bold      = bold;
     fontDisp.Name      = "Arial";
     fontDisp.Italic    = false;
     fontDisp.Underline = false;
     fontDisp.Size      = size;
     return(fontDisp);
 }
        ///<summary>Generate a default FontDisp object.</summary>
        ///
        ///<returns>An stdole.IFontDisp interface</returns>
        ///
        ///<remarks></remarks>
        public stdole.IFontDisp GetFontDisp(int size, bool isbold = false)
        {
            stdole.IFontDisp fontDisp = new stdole.StdFontClass() as stdole.IFontDisp; // Dynamic Cast
            fontDisp.Bold      = isbold;
            fontDisp.Name      = "Arial";
            fontDisp.Italic    = false;
            fontDisp.Underline = false;
            fontDisp.Size      = size;

            return(fontDisp);
        }
Beispiel #8
0
        private void mnuAnnotation_Click(object sender, EventArgs e)
        {
            IGraphicsContainer pGraphicsContainer = MainMap.Map as IGraphicsContainer;
            ILayer             pLayer             = MainMap.get_Layer(0);
            IGeoFeatureLayer   pGeoFeatureLayer   = pLayer as IGeoFeatureLayer;

            // 清空当前图层标注集合
            IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFeatureLayer.AnnotationProperties;

            pAnnoProps.Clear();

            // 建立标注文本符号
            stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
            pFont.Name = "宋体";
            pFont.Size = 9;

            IRgbColor pColor = new RgbColorClass();

            pColor.Red   = 250;
            pColor.Blue  = 10;
            pColor.Green = 50;

            ITextSymbol pTextSymbol = new TextSymbolClass();

            pTextSymbol.Font  = pFont;
            pTextSymbol.Color = pColor as IColor;

            // 设置标注位置
            ILineLabelPosition pPosition = new LineLabelPositionClass();

            pPosition.Parallel      = false;
            pPosition.Perpendicular = false;

            ILineLabelPlacementPriorities   pPlacement = new LineLabelPlacementPrioritiesClass();
            IBasicOverposterLayerProperties pBasic     = new BasicOverposterLayerProperties();

            pBasic.FeatureType       = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasic.LineLabelPosition = pPosition;

            // 新建一个图层标注引擎对象
            ILabelEngineLayerProperties pLabelEngine = new LabelEngineLayerPropertiesClass();

            pLabelEngine.Symbol = pTextSymbol;
            pLabelEngine.BasicOverposterLayerProperties = pBasic;
            pLabelEngine.IsExpressionSimple             = true;
            pLabelEngine.Expression = "[ADCODE93]";
            IAnnotateLayerProperties pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;

            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatureLayer.DisplayAnnotation = true;

            MainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #9
0
        public void MapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left hand mouse button
            if (e.button == 1)
            {
                //Create a point and grab hold of the IPoint inteface
                IPoint pPoint = new PointClass();
                //Set point properties

                pPoint.PutCoords(e.mapX, e.mapY);

                ITextSymbol pTextSymbol = new TextSymbolClass();

                stdole.IFontDisp pFont;
                pFont = new stdole.StdFontClass() as stdole.IFontDisp;

                pFont.Name          = textBox1.Font.Name;
                pFont.Italic        = textBox1.Font.Italic;
                pFont.Underline     = textBox1.Font.Underline;
                pFont.Bold          = textBox1.Font.Bold;
                pFont.Size          = (decimal)textBox1.Font.Size;
                pFont.Strikethrough = textBox1.Font.Strikeout;

                IRgbColor pRGB = new RgbColorClass();
                pRGB.Red   = (int)textBox1.ForeColor.R;
                pRGB.Green = (int)textBox1.ForeColor.G;
                pRGB.Blue  = (int)textBox1.ForeColor.B;


                pTextSymbol.Size  = textBox1.Font.Size;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = pRGB;



                ITextElement pTextEle = new TextElementClass();
                pTextEle.Text      = textBox1.Text;
                pTextEle.ScaleText = true;
                pTextEle.Symbol    = pTextSymbol;

                IElement pEle = (IElement)pTextEle;
                pEle.Geometry = pPoint;

                IActiveView        pActiveView         = (IActiveView)m_MapControl.Map;
                IGraphicsContainer pGraphicsContatiner = (IGraphicsContainer)m_MapControl.Map;

                pGraphicsContatiner.AddElement(pEle, 0);

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            this.Close();
        }
        private stdole.IFontDisp ToFontDisp(System.Drawing.Font font)
        {
            stdole.IFont aFont;
            aFont               = new stdole.StdFontClass();
            aFont.Name          = font.Name;
            aFont.Size          = (decimal)font.Size;
            aFont.Bold          = font.Bold;
            aFont.Italic        = font.Italic;
            aFont.Strikethrough = font.Strikeout;
            aFont.Underline     = font.Underline;

            return(aFont as stdole.IFontDisp);
        }
Beispiel #11
0
        /// <summary>
        /// 改变一个图层的标注符号和标注字段
        /// </summary>
        /// <param name="feaLayer"></param>
        private void ChangeLayerAnno(IFeatureLayer feaLayer)
        {
            IGeoFeatureLayer geoLayer = feaLayer as IGeoFeatureLayer;

            if (geoLayer == null)
            {
                return;
            }

            geoLayer.AnnotationProperties.Clear();

            RgbColorClass color = new RgbColorClass();

            color.Red   = 255;
            color.Blue  = 0;
            color.Green = 0;

            TextSymbolClass txtSymbol = new TextSymbolClass();

            stdole.StdFontClass font = new stdole.StdFontClass();
            font.Name       = "黑体";
            font.Size       = 12;
            txtSymbol.Font  = font as stdole.IFontDisp;
            txtSymbol.Color = color;

            LineLabelPositionClass linePos = new LineLabelPositionClass();

            linePos.Parallel      = false;
            linePos.Perpendicular = true;
            linePos.Above         = true;

            LineLabelPlacementPrioritiesClass   linePlac = new LineLabelPlacementPrioritiesClass();
            BasicOverposterLayerPropertiesClass basOve   = new BasicOverposterLayerPropertiesClass();

            //不屏蔽这句有些线图层的标注不显示
            //basOve.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
            basOve.LineLabelPosition            = linePos;
            basOve.LineLabelPlacementPriorities = linePlac;

            LabelEngineLayerPropertiesClass labelProp = new LabelEngineLayerPropertiesClass();

            labelProp.BasicOverposterLayerProperties = basOve;
            labelProp.Symbol     = txtSymbol;
            labelProp.Expression = "[" + feaLayer.DisplayField + "]";

            geoLayer.AnnotationProperties.Add(labelProp);
        }
Beispiel #12
0
        private void mnuLabel_Click(object sender, EventArgs e)
        {
            IGraphicsContainer pGraphicsContainer = MainMap.Map as IGraphicsContainer;
            ILayer             pLayer             = MainMap.get_Layer(0);
            IFeatureLayer      pFeatureLayer      = pLayer as IFeatureLayer;
            IFeatureClass      pFeatureClass      = pFeatureLayer.FeatureClass;

            int fldIndex = pFeatureClass.Fields.FindField("ADCODE93");

            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                IEnvelope pEnvelope = pFeature.Shape.Envelope;
                IPoint    pPoint    = new PointClass();
                pPoint.PutCoords(pEnvelope.XMin + pEnvelope.Width / 2, pEnvelope.YMin + pEnvelope.Height / 2);

                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "宋体";
                pFont.Size = 9;

                IRgbColor pColor = new RgbColorClass();
                pColor.Red   = 110;
                pColor.Blue  = 200;
                pColor.Green = 60;

                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = pColor as IColor;

                ITextElement pTextElement = new TextElementClass();
                pTextElement.Text      = pFeature.get_Value(fldIndex).ToString();
                pTextElement.ScaleText = true;
                pTextElement.Symbol    = pTextSymbol;
                IElement pElement = pTextElement as IElement;
                pElement.Geometry = pPoint;
                pGraphicsContainer.AddElement(pElement, 0);

                pFeature = pFeatureCursor.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
            GC.Collect();
            GC.WaitForPendingFinalizers();

            MainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #13
0
        public void ProportionalRenderer1(IFeatureLayer featLayer, string fieldName, IColorRamp colorRamp, int size)
        {
            IGeoFeatureLayer            geoFeatureLayer;
            IFeatureLayer               featureLayer;
            IProportionalSymbolRenderer proportionalSymbolRenderer;
            ITable             table;
            ICursor            cursor;
            IDataStatistics    dataStatistics;
            IStatisticsResults statisticsResult;

            stdole.IFontDisp fontDisp;

            geoFeatureLayer       = featLayer as IGeoFeatureLayer;
            featureLayer          = geoFeatureLayer as IFeatureLayer;
            table                 = geoFeatureLayer as ITable;
            cursor                = table.Search(null, true);
            dataStatistics        = new DataStatisticsClass();
            dataStatistics.Cursor = cursor;
            dataStatistics.Field  = fieldName;
            statisticsResult      = dataStatistics.Statistics;
            if (statisticsResult != null)
            {
                IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                fillSymbol.Color = colorRamp.get_Color(0);
                ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass();

                fontDisp      = new stdole.StdFontClass() as stdole.IFontDisp;
                fontDisp.Name = "arial";
                fontDisp.Size = 20;
                characterMarkerSymbol.Font                      = fontDisp;
                characterMarkerSymbol.CharacterIndex            = 90;
                characterMarkerSymbol.Color                     = colorRamp.get_Color(4);
                characterMarkerSymbol.Size                      = size;
                proportionalSymbolRenderer                      = new ProportionalSymbolRendererClass();
                proportionalSymbolRenderer.ValueUnit            = esriUnits.esriUnknownUnits;
                proportionalSymbolRenderer.Field                = fieldName;
                proportionalSymbolRenderer.FlanneryCompensation = false;
                proportionalSymbolRenderer.MinDataValue         = statisticsResult.Minimum;
                proportionalSymbolRenderer.MaxDataValue         = statisticsResult.Maximum;
                proportionalSymbolRenderer.BackgroundSymbol     = fillSymbol;
                proportionalSymbolRenderer.MinSymbol            = characterMarkerSymbol as ISymbol;
                proportionalSymbolRenderer.LegendSymbolCount    = 10;
                proportionalSymbolRenderer.CreateLegendSymbols();
                geoFeatureLayer.Renderer = proportionalSymbolRenderer as IFeatureRenderer;
            }
        }
Beispiel #14
0
        //ProportionalSymbolRenderer
        private void button4_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer            geoFeatureLayer;
            IFeatureLayer               featureLayer;
            IProportionalSymbolRenderer proportionalSymbolRenderer;
            ITable             table;
            ICursor            cursor;
            IDataStatistics    dataStatistics;
            IStatisticsResults statisticsResult;

            stdole.IFontDisp fontDisp;

            geoFeatureLayer       = getGeoLayer("Continents");
            featureLayer          = geoFeatureLayer as IFeatureLayer;
            table                 = geoFeatureLayer as ITable;
            cursor                = table.Search(null, true);
            dataStatistics        = new DataStatisticsClass();
            dataStatistics.Cursor = cursor;
            dataStatistics.Field  = "sqmi";
            statisticsResult      = dataStatistics.Statistics;
            if (statisticsResult != null)
            {
                IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                fillSymbol.Color = getRGB(0, 255, 0);
                ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass();
                fontDisp      = new stdole.StdFontClass() as stdole.IFontDisp;
                fontDisp.Name = "arial";
                fontDisp.Size = 20;
                characterMarkerSymbol.Font                      = fontDisp;
                characterMarkerSymbol.CharacterIndex            = 90;
                characterMarkerSymbol.Color                     = getRGB(255, 0, 0);
                characterMarkerSymbol.Size                      = 8;
                proportionalSymbolRenderer                      = new ProportionalSymbolRendererClass();
                proportionalSymbolRenderer.ValueUnit            = esriUnits.esriUnknownUnits;
                proportionalSymbolRenderer.Field                = "sqmi";
                proportionalSymbolRenderer.FlanneryCompensation = false;
                proportionalSymbolRenderer.MinDataValue         = statisticsResult.Minimum;
                proportionalSymbolRenderer.MaxDataValue         = statisticsResult.Maximum;
                proportionalSymbolRenderer.BackgroundSymbol     = fillSymbol;
                proportionalSymbolRenderer.MinSymbol            = characterMarkerSymbol as ISymbol;
                proportionalSymbolRenderer.LegendSymbolCount    = 10;
                proportionalSymbolRenderer.CreateLegendSymbols();
                geoFeatureLayer.Renderer = proportionalSymbolRenderer as IFeatureRenderer;
            }
            this.axMapControl1.Refresh();
        }
Beispiel #15
0
        private void textelementlable()
        {
            IFeatureLayer  pfl          = getlayerbyname(cbxLayer.SelectedItem.ToString());
            IFeatureClass  featureclass = pfl.FeatureClass;
            IFeatureCursor pFeatureCursor;

            pFeatureCursor = featureclass.Search(null, true);
            IFeature pFeat = pFeatureCursor.NextFeature();

            while (pFeat != null)
            {
                IFields   pFields = pFeat.Fields;
                int       i       = pFields.FindField(cbxField.SelectedItem.ToString());;
                IEnvelope pEnv    = pFeat.Extent;
                IPoint    pPoint  = new PointClass();
                pPoint.PutCoords(pEnv.XMin + pEnv.Width / 2, pEnv.YMin + pEnv.Height / 2);
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = comboBox2.SelectedItem.ToString();
                ITextSymbol pTextSymbol = new TextSymbolClass();

                pTextSymbol.Size = Convert.ToInt16(comboBox3.SelectedItem.ToString());
                pTextSymbol.Font = pFont;
                if (pRGB.NullColor)
                {
                    pRGB.Red   = 110;
                    pRGB.Blue  = 200;
                    pRGB.Green = 60;
                }
                pTextSymbol.Color = pRGB;

                ITextElement pTextEle = new TextElementClass();
                pTextEle.Text      = pFeat.get_Value(i).ToString();
                pTextEle.ScaleText = true;
                pTextEle.Symbol    = pTextSymbol;
                IElement pEle = pTextEle as IElement;
                pEle.Geometry = pPoint;
                IActiveView        pActiveView        = pMap as IActiveView;
                IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer;
                pGraphicsContainer.AddElement(pEle, 0);
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                pPoint = null;
                pEle   = null;
                pFeat  = pFeatureCursor.NextFeature();
            }
        }
        /// <summary>
        /// Optional, wire the cboFont's SelectedValueChanged event if you want
        /// to use this tool control to set the default text font of the document
        /// </summary>
        private void cboFont_SelectedValueChanged(object sender, EventArgs e)
        {
            //Change document default text font
            if (m_application != null)
            {
                IMxDocument mxDoc = m_application.Document as IMxDocument;
                if (!mxDoc.DefaultTextFont.Name.Equals(cboFont.SelectedValue.ToString()))
                {
                    FontFamily ff = (FontFamily)cboFont.SelectedItem;

                    //Use the stdole to create the font
                    stdole.IFontDisp newFont = new stdole.StdFontClass() as stdole.IFontDisp;
                    newFont.Name = ff.GetName(1);
                    newFont.Size = mxDoc.DefaultTextFont.Size;

                    //Alternative: Create a .Net Font object then convert
                    //Font f = new Font(ff.GetName(1), (float)mxDoc.DefaultTextFont.Size);
                    //stdole.IFontDisp newFont = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(f);

                    //Set other font properties
                    if (mxDoc.DefaultTextFont.Bold)
                    {
                        newFont.Bold = true;
                    }
                    if (mxDoc.DefaultTextFont.Italic)
                    {
                        newFont.Italic = true;
                    }
                    if (mxDoc.DefaultTextFont.Underline)
                    {
                        newFont.Underline = true;
                    }
                    if (mxDoc.DefaultTextFont.Strikethrough)
                    {
                        newFont.Strikethrough = true;
                    }

                    mxDoc.DefaultTextFont = newFont;

                    //Set dirty flag with change
                    IDocumentDirty docDirty = mxDoc as IDocumentDirty;
                    docDirty.SetDirty();
                }
            }
        }
        //添加文本
        public bool AddText()
        {
            pTextElement      = new TextElementClass();
            pTextElement.Text = "输入文本";

            IElement    pElment = pTextElement as IElement;
            ITextSymbol pSymbol = new TextSymbolClass();

            pSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            stdole.Font pFont;
            pFont               = new stdole.StdFontClass();
            pFont.Name          = "verdana";
            pFont.Size          = 40;
            pSymbol.Font        = pFont as stdole.IFontDisp;
            pTextElement.Symbol = pSymbol;
            addText(pTextElement, null);
            return(true);
        }
        public static void TextElementLabel(IMapControl2 mapControl, IFeatureLayer featureLayer, string fieldName)
        {
            IMap pMap = mapControl.Map;
            // 获取图层所有要素
            IFeatureCursor pFeatureCursor = featureLayer.FeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                IFields pFields = pFeature.Fields;
                // 找出标注字段的索引号
                int index = pFields.FindField(fieldName);
                // 得到要素的Envelope对象
                IEnvelope pEnv   = pFeature.Extent;
                IPoint    pPoint = new PointClass()
                {
                    X = pEnv.XMin + pEnv.Width / 2,
                    Y = pEnv.YMin + pEnv.Height / 2
                };
                // 新建字体对象
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "arial";
                // 设置文本符号
                ITextSymbol pTextSymbol = new TextSymbolClass()
                {
                    Size  = 20,
                    Font  = pFont,
                    Color = AeUtils.GetRgbColor(255, 0, 0)
                };
                // 添加文本对象
                IElement pTextElement = new TextElementClass()
                {
                    Text      = pFeature.get_Value(index).ToString(),
                    ScaleText = true,
                    Symbol    = pTextSymbol
                };
                pTextElement.Geometry = pPoint;
                (pMap as IGraphicsContainer).AddElement(pTextElement, 0);
                mapControl.Refresh(esriViewDrawPhase.esriViewGraphics);
                pFeature = pFeatureCursor.NextFeature();
            }
        }
Beispiel #19
0
        //标注
        public static void TextElementLabel(IMap pMap, IFeatureClass pFeatureClass, string fieldName)
        {
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, true);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                IFields pFields = pFeature.Fields;
                int     i       = pFields.FindField(fieldName);
                //得到要素的Envelope
                IEnvelope pEnv   = pFeature.Extent;
                IPoint    pPoint = new PointClass();
                //确定字符要素的Geometry,它是envelope的中心点
                pPoint.PutCoords(pEnv.XMin + pEnv.Width / 2, pEnv.YMin + pEnv.Height / 2);
                //新建字体对象,设置字体的属性
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "Arial";
                IRgbColor pColor = new RgbColorClass();
                pColor.Red  = 110; pColor.Green = 200;
                pColor.Blue = 60;
                //产生一个文本符号
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Size  = 3;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = pColor;
                //产生一个文本元素对象
                ITextElement pTextElement = new TextElementClass();
                pTextElement.Text      = pFeature.get_Value(i).ToString();
                pTextElement.ScaleText = true;
                pTextElement.Symbol    = pTextSymbol;
                IElement pElement = pTextElement as IElement;
                pElement.Geometry = pPoint;
                IActiveView        pActiveView        = pMap as IActiveView;
                IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer;
                //将文本元素加入地图
                pGraphicsContainer.AddElement(pElement, 0);
                //刷新地图(局部刷新)
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                pFeature = pFeatureCursor.NextFeature();
            }
        }
Beispiel #20
0
        public static void ShowLabel(IFeatureLayer featureLayer, string fieldName, IMapControl2 mapControl)
        {
            // 逐一对每一个要素添加Label
            IFeatureCursor pFeatureCursor = featureLayer.FeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                // 注记摆放位置
                IEnvelope pEnvelope = pFeature.Extent;
                IPoint    pPoint    = new PointClass()
                {
                    X = pEnvelope.XMin + pEnvelope.Width / 2,
                    Y = pEnvelope.YMin + pEnvelope.Height / 2
                };
                // 文本符号
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "arial";
                ITextSymbol pSymbol = new TextSymbolClass()
                {
                    Size  = 20,
                    Font  = pFont,
                    Color = GetRgbColor(255, 0, 0)
                };
                // 添加文本对象
                int      index        = pFeature.Fields.FindField(fieldName);
                IElement pTextElement = new TextElementClass()
                {
                    Text      = pFeature.get_Value(index).ToString(),
                    ScaleText = true,
                    Symbol    = pSymbol,
                    Geometry  = pPoint
                };
                (mapControl.Map as IGraphicsContainer).AddElement(pTextElement, 0);
                mapControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                pFeature = pFeatureCursor.NextFeature();
            }
        }
Beispiel #21
0
        private void Annotation()
        {
            string           fieldname    = cbxField.SelectedItem.ToString();
            IFeatureLayer    featureLayer = getlayerbyname(cbxLayer.SelectedItem.ToString());
            IGeoFeatureLayer pGeoFeatLyr  = featureLayer as IGeoFeatureLayer;

            stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
            pFont.Name = comboBox2.SelectedItem.ToString();
            ITextSymbol pTextSymbol = new TextSymbolClass();

            pTextSymbol.Size = Convert.ToInt16(comboBox3.SelectedItem.ToString());
            pTextSymbol.Font = pFont;
            if (pRGB.NullColor)
            {
                pRGB.Red   = 255;
                pRGB.Blue  = 0;
                pRGB.Green = 0;
            }
            pTextSymbol.Color = pRGB;
            IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFeatLyr.AnnotationProperties;

            pAnnoProps.Clear();
            ILabelEngineLayerProperties pLabelEngine = new LabelEngineLayerPropertiesClass();

            pLabelEngine.Symbol     = pTextSymbol;
            pLabelEngine.Expression = "[" + fieldname + "]";
            IAnnotateLayerProperties pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;

            pAnnoLayerProps.DisplayAnnotation  = true;
            pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatLyr.DisplayField      = fieldname;
            pGeoFeatLyr.DisplayAnnotation = true;
            IActiveView pActiveView = pMap as IActiveView;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        // 显示观看预设点注记
        private void ShowViewerFIDLabel()
        {
            IFeatureLayer  pFeatureLayer  = GetLayerByName("Viewer") as IFeatureLayer;
            IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                // 注记放置位置
                IEnvelope pEnv   = pFeature.Extent;
                IPoint    pPoint = new PointClass()
                {
                    X = pEnv.XMin, Y = pEnv.YMin + 0.0001
                };
                // 文本符号
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "arial";
                ITextSymbol pSymbol = new TextSymbolClass()
                {
                    Size  = 24,
                    Font  = pFont,
                    Color = GetRgbColor(255, 0, 0)
                };
                // 添加文本对象
                IElement pElement = new TextElementClass()
                {
                    Text      = pFeature.get_Value(0) + "号观看预设点",
                    ScaleText = true,
                    Symbol    = pSymbol,
                    Geometry  = pPoint
                };
                (m_pMapC2.Map as IGraphicsContainer).AddElement(pElement, 0);
                m_pMapC2.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                pFeature = pFeatureCursor.NextFeature();
            }
        }
        /// <summary>
        /// Optional, wire the cboFont's SelectedValueChanged event if you want
        /// to use this tool control to set the default text font of the document
        /// </summary>
        private void cboFont_SelectedValueChanged(object sender, EventArgs e)
        {
            //Change document default text font
            if (m_application != null)
            {
                IMxDocument mxDoc = m_application.Document as IMxDocument;
                if (!mxDoc.DefaultTextFont.Name.Equals(cboFont.SelectedValue.ToString()))
                {
                    FontFamily ff = (FontFamily)cboFont.SelectedItem;
                   
                    //Use the stdole to create the font
                    stdole.IFontDisp newFont = new stdole.StdFontClass() as stdole.IFontDisp;
                    newFont.Name = ff.GetName(1);
                    newFont.Size = mxDoc.DefaultTextFont.Size;

                    //Alternative: Create a .Net Font object then convert
                    //Font f = new Font(ff.GetName(1), (float)mxDoc.DefaultTextFont.Size);
                    //stdole.IFontDisp newFont = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(f);

                    //Set other font properties
                    if (mxDoc.DefaultTextFont.Bold)
                        newFont.Bold = true;
                    if (mxDoc.DefaultTextFont.Italic)
                        newFont.Italic = true;
                    if (mxDoc.DefaultTextFont.Underline)
                        newFont.Underline = true;
                    if (mxDoc.DefaultTextFont.Strikethrough)
                        newFont.Strikethrough = true;

                    mxDoc.DefaultTextFont = newFont;
                    
                    //Set dirty flag with change
                    IDocumentDirty docDirty = mxDoc as IDocumentDirty;
                    docDirty.SetDirty();
                }
            }
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)m_FeatureLayer;

            //清除原有注记
            pGeoFeatureLayer.DisplayAnnotation = false;
            m_MapControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);


            //得到图层的标注属性集合对象
            IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFeatureLayer.AnnotationProperties;

            //清空这个集合内的对象
            pAnnoProps.Clear();

            IAnnotateLayerProperties        pAnnoLayerProps;
            ILineLabelPlacementPriorities   pPlacement;
            ILineLabelPosition              pPosition;
            IBasicOverposterLayerProperties pBasic;
            ILabelEngineLayerProperties     pLabelEngine;


            //设置文本属性
            stdole.IFontDisp pFont;
            pFont = new stdole.StdFontClass() as stdole.IFontDisp;

            pFont.Name          = lbl_PreviewFont.Font.Name;
            pFont.Italic        = lbl_PreviewFont.Font.Italic;
            pFont.Underline     = lbl_PreviewFont.Font.Underline;
            pFont.Bold          = lbl_PreviewFont.Font.Bold;
            pFont.Size          = (decimal)lbl_PreviewFont.Font.Size;
            pFont.Strikethrough = lbl_PreviewFont.Font.Strikeout;

            IRgbColor pRGB = new RgbColorClass();

            pRGB.Red   = (int)lbl_PreviewFont.ForeColor.R;
            pRGB.Green = (int)lbl_PreviewFont.ForeColor.G;
            pRGB.Blue  = (int)lbl_PreviewFont.ForeColor.B;

            ITextSymbol pTextSymbol = new TextSymbolClass();

            pTextSymbol.Size  = lbl_PreviewFont.Font.Size;
            pTextSymbol.Font  = pFont;
            pTextSymbol.Color = pRGB;

            //设置注记文本的位置
            pPosition               = new LineLabelPositionClass();
            pPosition.Parallel      = false;
            pPosition.Perpendicular = true;

            pPlacement = new LineLabelPlacementPrioritiesClass();

            pBasic                   = new BasicOverposterLayerPropertiesClass();
            pBasic.FeatureType       = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasic.LineLabelPosition = pPosition;

            //新建一个图层注记引擎对象,并设置它的属性
            pLabelEngine        = new LabelEngineLayerPropertiesClass();
            pLabelEngine.Symbol = pTextSymbol;
            pLabelEngine.BasicOverposterLayerProperties = pBasic;

            //设置注记字段
            pLabelEngine.Expression = "[" + cbx_Field.SelectedItem.ToString() + "]";

            pAnnoLayerProps = (IAnnotateLayerProperties)pLabelEngine;
            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatureLayer.DisplayAnnotation = true;

            m_MapControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
        //this method is called when the user clicks the "Compare Vertices" button at the bottom of the form
        private void cmdCompare_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboLayer1.SelectedItem.ToString() == "" || cboLayer2.SelectedItem.ToString() == "" || txtOID1.Text == "" || txtOID2.Text == "") //the double pipe is an or operator that "short circuts", meaning that it will bail out early if the condition is true, whereas the single pipe evaluates all conditions
                {
                    MessageBox.Show("Choose polygon layer, or specify OBJECTID.", "Verify Selections...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //show busy mouse
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                IFeatureLayer pFeatureLayer1 = null;
                IFeatureLayer pFeatureLayer2 = null;

                IPointCollection pPtnCollMissingVertices = new MultipointClass(); //point collection for missing vertices and used for graphics layer
                IPoint           pPointMissing           = new PointClass();      //used for graphics layer

                //get access to polygon layer 1
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    if (pMap.get_Layer(i) is IFeatureLayer)
                    {
                        if (pMap.get_Layer(i).Name.ToString() == cboLayer1.SelectedItem.ToString())
                        {
                            pFeatureLayer1 = pMap.get_Layer(i) as IFeatureLayer;
                            break;
                        }
                    }
                }

                //get access to polygon layer 2
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    if (pMap.get_Layer(i) is IFeatureLayer)
                    {
                        if (pMap.get_Layer(i).Name.ToString() == cboLayer2.SelectedItem.ToString())
                        {
                            pFeatureLayer2 = pMap.get_Layer(i) as IFeatureLayer;
                            break;
                        }
                    }
                }

                //clear the x,y report list box
                lstMissingVertices.Items.Clear();


                //get vertices for feature 1
                //set up query filter for feature 1
                IQueryFilter pQueryFilter = new QueryFilter();
                pQueryFilter.WhereClause = "OBJECTID = " + txtOID1.Text;

                //set up feature cursor for feature 1
                IFeatureCursor pFeatureCursor = pFeatureLayer1.Search(pQueryFilter, false);

                //get feature 1
                IFeature pFeature1 = pFeatureCursor.NextFeature();

                //if no objectid is found
                if (pFeature1 == null)
                {
                    MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //get feature 1 as a polygon
                IPolygon pPolygon1 = pFeature1.Shape as IPolygon;

                //get the point collection for feature 1
                IPointCollection pPointColl1 = pPolygon1 as IPointCollection;


                //get vertices for feature 2
                //set up query filter for feature 2
                pQueryFilter             = new QueryFilter();
                pQueryFilter.WhereClause = "OBJECTID = " + txtOID2.Text;

                //set up feature cursor for feature 2
                pFeatureCursor = null; //reuse the feature cursor from above
                pFeatureCursor = pFeatureLayer2.Search(pQueryFilter, false);

                //get feature 2
                IFeature pFeature2 = pFeatureCursor.NextFeature();

                //if no objectid is found
                if (pFeature2 == null)
                {
                    MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //get feature 1 as a polygon
                IPolygon pPolygon2 = pFeature2.Shape as IPolygon;

                //get the point collection for feature 1
                IPointCollection pPointColl2 = pPolygon2 as IPointCollection;


                //loop through point collection and check for missing vertices
                IPoint  pPoint1;
                IPoint  pPoint2;
                Boolean blnFound;


                //loop through each point in the first collection and check for missing
                for (int i = 0; i < pPointColl1.PointCount; i++)
                {
                    pPoint1 = pPointColl1.get_Point(i);

                    //loop through all the points in the second collection and check for the point from the above collection
                    blnFound = false;
                    for (int j = 0; j < pPointColl2.PointCount; j++)
                    {
                        pPoint2 = pPointColl2.get_Point(j);

                        //check for overlapping points
                        if (pPoint1.X == pPoint2.X && pPoint1.Y == pPoint2.Y)
                        {
                            blnFound = true;
                        }
                    }

                    //if no overlapping points were found, report the missing x,y location to the listbox
                    if (blnFound == false)
                    {
                        lstMissingVertices.Items.Add(pPoint1.X + " " + pPoint1.Y + " " + " Feet" + " (missing from polygon 2)");

                        //add the missing point to a new collection for display on map
                        pPtnCollMissingVertices.AddPoint(pPoint1);
                    }
                }


                //loop through each point in the first collection and check for missing
                for (int i = 0; i < pPointColl2.PointCount; i++)
                {
                    pPoint2 = pPointColl2.get_Point(i);

                    //loop through all the points in the second collection and check for the point from the above collection
                    blnFound = false;
                    for (int j = 0; j < pPointColl1.PointCount; j++)
                    {
                        pPoint1 = pPointColl1.get_Point(j);

                        //check for overlapping points
                        if (pPoint2.X == pPoint1.X && pPoint2.Y == pPoint1.Y)
                        {
                            blnFound = true;
                        }
                    }

                    //if no overlapping points were found, report the missing x,y location to the listbox
                    if (blnFound == false)
                    {
                        lstMissingVertices.Items.Add(pPoint2.X + " " + pPoint2.Y + " " + " Feet" + " (missing from polygon 1)");

                        //add the missing point to a new collection for display on map
                        pPtnCollMissingVertices.AddPoint(pPoint2);
                    }
                }


                //if no missing vertices were found, inform the user
                if (lstMissingVertices.Items.Count < 1)
                {
                    lstMissingVertices.Items.Add("No Missing Vertices Found");
                }


                //display vertices if checkbox is checked
                if (chkDisplayVertices.Checked == true)
                {
                    //show busy mouse
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                    //set up the graphics layer for the display of vertices
                    ICompositeGraphicsLayer2 pCompositeGraphicLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2;
                    ICompositeLayer          pCompositeLayer        = pCompositeGraphicLayer as ICompositeLayer;
                    ILayer             pLayer;
                    IGraphicsLayer     pGraphicsLayer;
                    IGraphicsContainer pGraphicsContainer;

                    //loop through the graphics layer and check for the missing vertices layer.  if found, delete it
                    for (int i = 0; i < pCompositeLayer.Count; i++)
                    {
                        pLayer = pCompositeLayer.Layer[i];
                        if (pLayer.Name == "MissingVertices")
                        {
                            pCompositeGraphicLayer.DeleteLayer("MissingVertices");
                            break;
                        }
                    }


                    //set up a new 'missing vertices' graphics layer
                    pGraphicsLayer           = pCompositeGraphicLayer.AddLayer("MissingVertices", null);
                    pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer;
                    pGraphicsContainer       = pCompositeGraphicLayer.FindLayer("MissingVertices") as IGraphicsContainer;

                    //define the color
                    ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass();
                    rgbColorCls.Red   = 250;
                    rgbColorCls.Green = 0;
                    rgbColorCls.Blue  = 0;

                    //define the font
                    stdole.IFontDisp stdFontCls = new stdole.StdFontClass() as stdole.IFontDisp;
                    stdFontCls.Name = "ESRI Surveyor Marker"; //this one has a thin-line hollow circle
                    stdFontCls.Name = "ESRI Surveyor";        //this one has a bold-line hollow circle
                    stdFontCls.Size = 16;

                    //set the character marker symbol's properties
                    ESRI.ArcGIS.Display.ICharacterMarkerSymbol charMarkerSymb = new ESRI.ArcGIS.Display.CharacterMarkerSymbolClass();
                    charMarkerSymb.Angle          = 0;
                    charMarkerSymb.CharacterIndex = 47;
                    charMarkerSymb.Color          = rgbColorCls;
                    charMarkerSymb.Font           = stdFontCls;
                    charMarkerSymb.Size           = 16;
                    charMarkerSymb.XOffset        = 0;
                    charMarkerSymb.YOffset        = 0;

                    //place the graphics on the map
                    for (int i = 0; i < pPtnCollMissingVertices.PointCount; i++)
                    {
                        pPointMissing = pPtnCollMissingVertices.Point[i];
                        IElement pElement = new MarkerElement();
                        pElement.Geometry = pPointMissing;
                        IMarkerElement pMarkerElement = pElement as IMarkerElement;
                        pMarkerElement.Symbol = charMarkerSymb;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }

                    //refresh the map, in order to see the newly added graphics
                    pActiveView.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    private stdole.IFontDisp ToFontDisp(System.Drawing.Font font)
    {
      stdole.IFont aFont;
      aFont = new stdole.StdFontClass();
      aFont.Name = font.Name;
      aFont.Size = (decimal)font.Size;
      aFont.Bold = font.Bold;
      aFont.Italic = font.Italic;
      aFont.Strikethrough = font.Strikeout;
      aFont.Underline = font.Underline;

      return aFont as stdole.IFontDisp;
    }
        /// <summary>
        /// 绘制瓦斯压力点符号
        /// ge绘制瓦斯压力点的数据结构
        /// editlayer指定需要在哪个图层添加该瓦斯压力点
        /// 2013-12-14
        /// lntu_GISer1
        /// </summary>
        /// <param name="ge"></param>
        /// <param name="pfeaLayer"></param>
        public void DrawGasPressureGE(IFeatureLayer editlayer, GasPressureEntity ge)
        {
            IFeature f;
            IPoint   p;
            //定义一个地物类,把要编辑的图层转化为定义的地物类
            IFeatureClass fc = editlayer.FeatureClass;
            //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
            IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;

            //开始事务操作
            w.StartEditing(false);
            //开始编辑
            w.StartEditOperation();
            //创建一个地物
            f = fc.CreateFeature();
            p = new PointClass();
            //设置点的坐标
            p.PutCoords(Convert.ToDouble(ge.CoordinateX), Convert.ToDouble(ge.CoordinateY));
            try
            {
                //确定图形类型
                f.Shape = p;
                int num3;
                //num3 = editlayer.FeatureClass.Fields.FindField("PRIMARY_KEY");
                //f.set_Value(num3, ge.PrimaryKey);
                num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_X");
                f.set_Value(num3, ge.CoordinateX);
                num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_Y");
                f.set_Value(num3, ge.CoordinateY);
                num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_Z");
                f.set_Value(num3, ge.CoordinateZ);
                num3 = editlayer.FeatureClass.Fields.FindField("DEPTH");
                f.set_Value(num3, ge.Depth);
                num3 = editlayer.FeatureClass.Fields.FindField("GAS_PRESSURE_VALUE");
                f.set_Value(num3, ge.GasPressureValue);
                num3 = editlayer.FeatureClass.Fields.FindField("MEASURE_DATE_TIME");
                f.set_Value(num3, ge.MeasureDateTime);
                //保存地物
                f.Store();
                ICharacterMarkerSymbol pMarkerSymbol;
                pMarkerSymbol = new CharacterMarkerSymbolClass();
                stdole.IFontDisp stdFont = new stdole.StdFontClass() as stdole.IFontDisp;
                stdFont.Name                 = "ESRI Caves 3";
                stdFont.Size                 = 48;
                pMarkerSymbol.Font           = stdFont;
                pMarkerSymbol.CharacterIndex = 107;
                //Symbol颜色
                pMarkerSymbol.Color = getRGB(0, 0, 0);
                //Symbol旋转角度
                pMarkerSymbol.Angle = 0;
                //Symbol大小
                pMarkerSymbol.Size = 48;
                RenderfeatureLayer(editlayer, pMarkerSymbol as ISymbol);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            //结束编辑
            w.StopEditOperation();
            //结束事务操作
            w.StopEditing(true);
        }
 /// <summary>
 /// 绘制瓦斯含量点
 /// </summary>
 /// <param name="editlayer"></param>
 /// <param name="ge"></param>
 public void DrawGasContentPointGE(IFeatureLayer editlayer, GasContentEntity ge)
 {
     IFeature f;
        IPoint p;
        //定义一个地物类,把要编辑的图层转化为定义的地物类
        IFeatureClass fc = editlayer.FeatureClass;
        //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
        IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
        //开始事务操作
        w.StartEditing(false);
        //开始编辑
        w.StartEditOperation();
        //创建一个地物
        f = fc.CreateFeature();
        p = new PointClass();
        //设置点的坐标
        p.PutCoords(Convert.ToDouble(ge.CoordinateX), Convert.ToDouble(ge.CoordinateY));
        try
        {
        //确定图形类型
        f.Shape = p;
        int num3;
        //num3 = editlayer.FeatureClass.Fields.FindField("PRIMARY_KEY");
        //f.set_Value(num3, ge.PrimaryKey);
        num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_X");
        f.set_Value(num3, ge.CoordinateX);
        num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_Y");
        f.set_Value(num3, ge.CoordinateY);
        num3 = editlayer.FeatureClass.Fields.FindField("COORDINATE_Z");
        f.set_Value(num3, ge.CoordinateZ);
        num3 = editlayer.FeatureClass.Fields.FindField("DEPTH");
        f.set_Value(num3, ge.Depth);
        num3 = editlayer.FeatureClass.Fields.FindField("GAS_CONTENT_VALUE");
        f.set_Value(num3, ge.GasContentValue);
        num3 = editlayer.FeatureClass.Fields.FindField("MEASURE_DATE_TIME");
        f.set_Value(num3, ge.MeasureDateTime);
        //保存地物
        f.Store();
        }
        catch (Exception e)
        {
        MessageBox.Show(e.Message);
        }
        ICharacterMarkerSymbol pMarkerSymbol;
        pMarkerSymbol = new CharacterMarkerSymbolClass();
        stdole.IFontDisp stdFont = new stdole.StdFontClass() as stdole.IFontDisp;
        stdFont.Name = "ESRI Hazardous Materials";
        stdFont.Size = 48;
        pMarkerSymbol.Font = stdFont;
        pMarkerSymbol.CharacterIndex = 216;
        //Symbol颜色
        pMarkerSymbol.Color = getRGB(0, 0, 0);
        //Symbol旋转角度
        pMarkerSymbol.Angle = 0;
        //Symbol大小
        pMarkerSymbol.Size = 48;
        RenderfeatureLayer(editlayer, pMarkerSymbol as ISymbol);
        //结束编辑
        w.StopEditOperation();
        //结束事务操作
        w.StopEditing(true);
 }
        //添加文本
        public bool AddText()
        {
            pTextElement = new TextElementClass();
            pTextElement.Text = "输入文本";

            IElement pElment = pTextElement as IElement;
            ITextSymbol pSymbol = new TextSymbolClass();
            pSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            stdole.Font pFont;
            pFont = new stdole.StdFontClass();
            pFont.Name = "verdana";
            pFont.Size = 40;
            pSymbol.Font = pFont as stdole.IFontDisp;
            pTextElement.Symbol = pSymbol;
            addText(pTextElement, null);
            return true;
        }
Beispiel #30
0
        public IFeatureClass CreateStandAloneAnnotationClass(IWorkspace ws, string annoname)
        {
            #region 创建Anno图层
            IFeatureClass featureClass = null;
            try
            {
                //ILayer pLayer = m_pmap.get_Layer(0);
                //IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                //ILayer pSrcLayer = pLayer;
                //IFeatureClass featureClass = pFeatureLayer.FeatureClass;

                //IDataset dataset = (IDataset)featureClass;//cast for the feature workspace from the workspace
                //IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)dataset.Workspace;
                IFeatureWorkspaceAnno featureWorkspaceAnno = (IFeatureWorkspaceAnno)ws;//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.esriMeters;
                graphicLayerScale.ReferenceScale = 500;//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 = false;//这里控制是不是关联的注记层
                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 = "[RefName]";
                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

                featureClass = featureWorkspaceAnno.CreateAnnotationClass(annoname, oCDesc.RequiredFields, oCDesc.InstanceCLSID, oCDesc.ClassExtensionCLSID,
                    fCDesc.ShapeFieldName, "", null, null, annoPropsColl, graphicLayerScale, symbolCollection, true);
                //给新建的图层添加子层
                ISubtypes subtypes = (ISubtypes)featureClass;
                subtypes.SubtypeFieldName = "AnnotationClassID";
                subtypes.AddSubtype(1, "GCD");
                subtypes.AddSubtype(2, "DLDW");
                subtypes.AddSubtype(3, "JMD");
                subtypes.AddSubtype(4, "SXSS");
                subtypes.AddSubtype(5, "DLSS");
                subtypes.AddSubtype(6, "ZBTZ");
                subtypes.AddSubtype(7, "TK");
                subtypes.DefaultSubtypeCode = 1;
                return featureClass;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return featureClass;
            }
            #endregion
        }
Beispiel #31
0
 //比例图
 private void button4_Click(object sender, EventArgs e)
 {
     IGeoFeatureLayer geoFeatureLayer;
     IFeatureLayer featureLayer;
     IProportionalSymbolRenderer proportionalSymbolRenderer;
     ITable table;
     ICursor cursor;
     IDataStatistics dataStatistics;
     IStatisticsResults statisticsResult;
     stdole.IFontDisp fontDisp;
     geoFeatureLayer = getGeoLayer("东丰县行政区域");
     featureLayer = geoFeatureLayer as IFeatureLayer;
     table = geoFeatureLayer as ITable;
     cursor = table.Search(null, true);
     dataStatistics = new DataStatisticsClass();
     dataStatistics.Cursor = cursor;
     dataStatistics.Field = "SHAPE_Area";
     statisticsResult = dataStatistics.Statistics;
     if (statisticsResult != null)
     {
         IFillSymbol fillSymbol = new SimpleFillSymbolClass();
         fillSymbol.Color = getRGB(0, 255, 0);
         ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass();
         fontDisp = new stdole.StdFontClass() as stdole.IFontDisp;
         fontDisp.Name = "arial";
         fontDisp.Size = 20;
         characterMarkerSymbol.Font = fontDisp;
         characterMarkerSymbol.CharacterIndex = 90;
         characterMarkerSymbol.Color = getRGB(255, 0, 0);
         characterMarkerSymbol.Size = 8;
         proportionalSymbolRenderer = new ProportionalSymbolRendererClass();
         proportionalSymbolRenderer.ValueUnit = esriUnits.esriUnknownUnits;
         proportionalSymbolRenderer.Field = "SHAPE_Area";
         proportionalSymbolRenderer.FlanneryCompensation = false;
         proportionalSymbolRenderer.MinDataValue = statisticsResult.Minimum;
         proportionalSymbolRenderer.MaxDataValue = statisticsResult.Maximum;
         proportionalSymbolRenderer.BackgroundSymbol = fillSymbol;
         proportionalSymbolRenderer.MinSymbol = characterMarkerSymbol as ISymbol;
         proportionalSymbolRenderer.LegendSymbolCount = 10;
         proportionalSymbolRenderer.CreateLegendSymbols();
         geoFeatureLayer.Renderer = proportionalSymbolRenderer as IFeatureRenderer;
     }
     this.axMapControl1.Refresh();
 }
        private void UpdateMapControlWithMarker(IMapControl4 updateMapControl, string action)
        {
            IRgbColor redRgbColor = new RgbColorClass();
            redRgbColor.Red = 255;
            redRgbColor.Green = 0;
            redRgbColor.Blue = 0;

            IRgbColor yellowRgbColor = new RgbColorClass();
            yellowRgbColor.Red = 255;
            yellowRgbColor.Green = 255;
            yellowRgbColor.Blue = 115;

            IRgbColor blackRgbcolor = new RgbColorClass();
            blackRgbcolor.Red = 0;
            blackRgbcolor.Green = 0;
            blackRgbcolor.Blue = 0;

            IRgbColor greenRgbColor = new RgbColorClass();
            greenRgbColor.Red = 0;
            greenRgbColor.Green = 255;
            greenRgbColor.Blue = 0;

            IEnvelope extentEnvelope = updateMapControl.Extent;
            IGraphicsContainer graphicsContainer = updateMapControl.Map.BasicGraphicsLayer as IGraphicsContainer;

            if (action == "DeleteMarker")
            {
                DeleteElement(updateMapControl, action);
            }
            else if (action == "AcceptMarker")
            {
                DeleteElement(updateMapControl, action);
            }

            IMultiLayerMarkerSymbol multiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();

            stdole.IFontDisp esriDefaultMarkerFont = new stdole.StdFontClass() as stdole.IFontDisp;
            esriDefaultMarkerFont.Name = "ESRI Default Marker";
            esriDefaultMarkerFont.Size = Convert.ToDecimal(48);

            IPoint markerLocation = new PointClass();
            markerLocation.SpatialReference = updateMapControl.SpatialReference;

            markerLocation.X = extentEnvelope.LowerLeft.X + extentEnvelope.Width / 10;
            markerLocation.Y = extentEnvelope.LowerLeft.Y + extentEnvelope.Height / (10 * (extentEnvelope.Height / extentEnvelope.Width));

            IMarkerElement markerElement = new MarkerElementClass();
            ((IElement)markerElement).Geometry = markerLocation;

            ISimpleMarkerSymbol backgroundMarkerSymbol = new SimpleMarkerSymbolClass();
            backgroundMarkerSymbol.Color = (IColor)yellowRgbColor;
            backgroundMarkerSymbol.Size = 45;
            backgroundMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
            backgroundMarkerSymbol.Outline = true;
            backgroundMarkerSymbol.OutlineColor = blackRgbcolor;
            backgroundMarkerSymbol.OutlineSize = 2;

            multiLayerMarkerSymbol.AddLayer((IMarkerSymbol)backgroundMarkerSymbol);

            if (action == "DeleteMarker")
            {
                ICharacterMarkerSymbol deleteMarkerSymbol = new CharacterMarkerSymbolClass();
                deleteMarkerSymbol.Font = esriDefaultMarkerFont;
                deleteMarkerSymbol.CharacterIndex = 68;
                deleteMarkerSymbol.Color = redRgbColor;
                deleteMarkerSymbol.Size = 48;

                multiLayerMarkerSymbol.AddLayer(deleteMarkerSymbol);

                ((IElementProperties)markerElement).Name = "DeleteMarker";

            }
            else if (action == "AcceptMarker")
            {
                ICharacterMarkerSymbol acceptMarkerSymbol = new CharacterMarkerSymbolClass();

                acceptMarkerSymbol.Font = esriDefaultMarkerFont;
                acceptMarkerSymbol.CharacterIndex = 105;
                acceptMarkerSymbol.Color = greenRgbColor;
                acceptMarkerSymbol.Size = 48;

                multiLayerMarkerSymbol.AddLayer(acceptMarkerSymbol);

                ((IElementProperties)markerElement).Name = "AcceptMarker";
            }

            markerElement.Symbol = (IMarkerSymbol)multiLayerMarkerSymbol;

            graphicsContainer.AddElement((IElement)markerElement, 99);

            updateMapControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
		/// <summary>
		/// Initialize the symbol that would use to highlight selected items
		/// </summary>
    private void InitializeSelectionSymbol()
		{
			//use a character marker symbol:
			ICharacterMarkerSymbol chMrkSym;
			chMrkSym = new CharacterMarkerSymbolClass();
			
      //Set the selection color (yellow)
			IRgbColor color;
			color = new RgbColorClass();
			color.Red = 0;
			color.Green = 255;
			color.Blue = 255;

      //set the font
			stdole.IFont aFont;
			aFont = new stdole.StdFontClass();
			aFont.Name = "ESRI Default Marker";
      aFont.Size = m_symbolSize;
			aFont.Bold = true;			

      //char #41 is just a rectangle
			chMrkSym.CharacterIndex = 41;
			chMrkSym.Color = color as IColor;
			chMrkSym.Font = aFont as stdole.IFontDisp;
      chMrkSym.Size = m_symbolSize;
			
			m_selectionSymbol = chMrkSym as ISymbol;
		}
Beispiel #34
0
        public IFeatureClass CreateStandAloneAnnotationClass(IWorkspace ws, string annoname)
        {
            #region 创建Anno图层
            IFeatureClass featureClass = null;
            try
            {
                //ILayer pLayer = m_pmap.get_Layer(0);
                //IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                //ILayer pSrcLayer = pLayer;
                //IFeatureClass featureClass = pFeatureLayer.FeatureClass;

                //IDataset dataset = (IDataset)featureClass;//cast for the feature workspace from the workspace
                //IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)dataset.Workspace;
                IFeatureWorkspaceAnno featureWorkspaceAnno = (IFeatureWorkspaceAnno)ws;//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.esriMeters;
                graphicLayerScale.ReferenceScale = 500;//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 = false;                                           //这里控制是不是关联的注记层
                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         = "[RefName]";
                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

                featureClass = featureWorkspaceAnno.CreateAnnotationClass(annoname, oCDesc.RequiredFields, oCDesc.InstanceCLSID, oCDesc.ClassExtensionCLSID,
                                                                          fCDesc.ShapeFieldName, "", null, null, annoPropsColl, graphicLayerScale, symbolCollection, true);
                //给新建的图层添加子层
                ISubtypes subtypes = (ISubtypes)featureClass;
                subtypes.SubtypeFieldName = "AnnotationClassID";
                subtypes.AddSubtype(1, "GCD");
                subtypes.AddSubtype(2, "DLDW");
                subtypes.AddSubtype(3, "JMD");
                subtypes.AddSubtype(4, "SXSS");
                subtypes.AddSubtype(5, "DLSS");
                subtypes.AddSubtype(6, "ZBTZ");
                subtypes.AddSubtype(7, "TK");
                subtypes.DefaultSubtypeCode = 1;
                return(featureClass);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(featureClass);
            }
            #endregion
        }