Reichrh 2022-11-30 19:06
浏览 4
已结题

ArcEngine二次开发利用trackbar进行矢量图层实时渲染

ArcEngine想要不依靠按钮完成矢量图层的简单渲染

img

主窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;

namespace GIS软件
{
    public partial class FormGIS : Form
    {
        public FormGIS(/*string Form_name*/)
        {
            InitializeComponent();
            //this.Text = Form_name;
            //this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void FormGIS_Load(object sender, EventArgs e)
        {

        }

        private void 输入矢量文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofDShp.ShowDialog() == DialogResult.OK)
            {
                //string sFile = ofDShp.FileName;
                //string sFile_path = sFile.Substring(0, sFile.LastIndexOf('\\'));
                //string sFile_name = sFile.Substring(sFile.LastIndexOf('\\') + 1);

                FileInfo sFile = new FileInfo(ofDShp.FileName);

                //string sFile_path = sFile.Directory.ToString();
                string sFile_path = sFile.DirectoryName;
                string sFile_name = sFile.Name;

                axMapControl1.AddShapeFile(sFile_path, sFile_name);

            }
            axMapControl1.Refresh();
        }
        private void 简单渲染HSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormHSV hsvFsimpleRender = new FormHSV(this.axMapControl1);

            //hsvFsimpleRender.Show();

            if (hsvFsimpleRender.ShowDialog() == DialogResult.OK)
            {


                IHsvColor hsvFeature = new HsvColor();
                hsvFeature.Hue = hsvFsimpleRender.H;
                hsvFeature.Saturation = hsvFsimpleRender.S;
                hsvFeature.Value = hsvFsimpleRender.V;

                ISimpleFillSymbol sfsFeature = new SimpleFillSymbol();
                sfsFeature.Style = esriSimpleFillStyle.esriSFSSolid;

                sfsFeature.Outline.Width = 1;
                sfsFeature.Color = hsvFeature as IColor;

                ISimpleRenderer srFeature = new SimpleRenderer();
                srFeature.Symbol = sfsFeature as ISymbol;

                IFeatureLayer flWord = null; /*axMapControl1.get_Layer(0) as IFeatureLayer;*/
                int IlayerCount = axMapControl1.LayerCount;
                for (int i = 0; i < IlayerCount; i++)
                {
                    ILayer iLayerTemp = axMapControl1.get_Layer(i);
                    if (hsvFsimpleRender.Strlayername == iLayerTemp.Name)
                    {
                        flWord = iLayerTemp as IFeatureLayer;
                    }
                }

                //if (flWord == null)
                //{
                //    MessageBox.Show("您当前选择的图层不是矢量图层,请重新选择后,在进行渲染!");
                //    return;
                //}

                IGeoFeatureLayer gflWord = flWord as IGeoFeatureLayer;
                gflWord.Renderer = srFeature as IFeatureRenderer;

                axMapControl1.Refresh();

            }
        }
    }
}
调用的简单渲染HSV窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Controls;

namespace GIS软件
{
    public partial class FormHSV : Form
    {
        AxMapControl axMapControl1;

        string m_StrlayerName;
        int m_iundH;
        int m_iundS;
        int m_iundV;

        public string Strlayername
        {
            get
            {
                return m_StrlayerName = CBlayers.Text;
            }
            set
            {
                m_StrlayerName = value;
            }

        }
        public int H
        {
            get
            {
                return m_iundH = tbH.Value;
            }
            set
            {
                m_iundH = value;
            }

        }

        public int S
        {
            get
            {
                return m_iundS = tbS.Value;
            }
            set
            {
                m_iundS = value;
            }

        }

        public int V
        {
            get
            {
                return m_iundV = tbV.Value;
            }
            set
            {
                m_iundV = value;
            }

        }

        public FormHSV()
        {
            InitializeComponent();
        }
        public FormHSV(AxMapControl mapForRender)
        {
            InitializeComponent();

            axMapControl1 = mapForRender;
        }

        private void FormHSV_Load(object sender, EventArgs e)
        {
            int IlayerCount = axMapControl1.LayerCount;
            for (int i = 0; i < IlayerCount; i++)
            {
                string sLayerName = axMapControl1.get_Layer(i).Name;
                CBlayers.Items.Add(sLayerName as object);
            }
        }

        private void btOK_Click(object sender, EventArgs e)
        {
            m_StrlayerName = CBlayers.Text;
            m_iundH = tbH.Value;
            m_iundS = tbS.Value;
            m_iundV = tbV.Value;

            this.DialogResult = DialogResult.OK;

        }

        private void btNO_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void tbH_Scroll(object sender, EventArgs e)
        {
            //MessageBox.Show(tbH.Value.ToString());
            m_StrlayerName = CBlayers.Text;
            m_iundH = tbH.Value;
            m_iundS = tbS.Value;
            m_iundV = tbV.Value;


        }
    }
}
不利用按钮直接滑动trackbar的滑块就可以实时改变图层颜色
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月8日
    • 创建了问题 11月30日

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料