⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 biaozhu.cs

📁 运用ArcEngine9.2结合C#开发的gis系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Display;

namespace WindowsApplication1
{
    public partial class biaozhu : Form
    {
        public IMap pMap;
        public string Biaozhu;
        public string pRenderField;
        IField pField;
        IFields pFields;

        public IAnnotateLayerProperties AnnotateLayerProperties;
        public int layerIndex;
        public IGeoFeatureLayer pGeoFeatureL;
        public int Num;   
        public int Num2;
        public ITable conntable;
        public biaozhu()
        {
            InitializeComponent();
        }

        private void biaozhu_Load(object sender, EventArgs e)
        {
            int i;
            for (i = 0; i < pMap.LayerCount; i++)     
                comboBox1.Items.Add(pMap.get_Layer(i).Name);    
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int j;
            IFeatureLayer pFeatureLayer;
            IFeatureClass pFeatureClass;

            Num = comboBox1.SelectedIndex;  
            pFeatureLayer = (IFeatureLayer)pMap.get_Layer(comboBox1.SelectedIndex);
            pFeatureClass = conntable as IFeatureClass;
           pFields = pFeatureClass.Fields;
            for (j = 0; j < pFields.FieldCount; j++)        
            {
                pField = pFields.get_Field(j);
                comboBox2.Items.Add(pField.Name);            
            }

        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            Biaozhu = comboBox2.SelectedItem.ToString();    
            listBox1.Items.Clear();
            listBox1.Enabled = true;
            ITable pTable;
            pTable = (ITable)pMap.get_Layer(0);

            Num2 = comboBox2.SelectedIndex;

            pField = pFields.get_Field(Num2);//给右侧的属性值列表框添加字段            
            IQueryFilter pQueryFilter;
            pQueryFilter = new QueryFilterClass();
            pQueryFilter.AddField(pField.Name);

            int rowCount = pTable.RowCount(pQueryFilter);
            for (int i = 0; i < rowCount; i++)
            {
                listBox1.Items.Add(pTable.GetRow(i).get_Value(comboBox2.SelectedIndex).ToString());
            }
 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer pGeoFeatureL = pMap.get_Layer(Num) as IGeoFeatureLayer;

            IGeoFeatureLayer m_pGeoFeatureLayer = (IGeoFeatureLayer)pGeoFeatureL;
            IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl;
            pAnnoLayerPropsColl = m_pGeoFeatureLayer.AnnotationProperties;
            pAnnoLayerPropsColl.Clear();

            IRgbColor pRGBColor = new RgbColorClass();

            pRGBColor.Blue = 0;
            pRGBColor.Red = 250;
            pRGBColor.Green = 0;


            IFormattedTextSymbol pTextSymboll = new TextSymbolClass();
            pTextSymboll.Color = pRGBColor;

            ILabelEngineLayerProperties pLabel = new LabelEngineLayerPropertiesClass();
            pLabel.IsExpressionSimple = true;
            pLabel.Expression = "[" + comboBox2.SelectedItem.ToString() + "]";
            pLabel.Symbol = pTextSymboll;

            AnnotateLayerProperties = (IAnnotateLayerProperties)pLabel;

            pAnnoLayerPropsColl.Add(AnnotateLayerProperties);
            m_pGeoFeatureLayer.DisplayAnnotation = true;


            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -