arcengine动态显示所需字段值
需求:实现和GIS桌面端中Identify的类似功能,鼠标滑动的时候可以显示鼠标所在位置的要素的指定字段的值.。
主要操作流程:
①先打开一个对话框,用于选择需要显示的图层和字段名
②点击确定之后,在mapControl上鼠标滑动的时候利用axMapControl的showTips功能实现实时显示,相对于Identify,取消的点击查看属性,和只能查看所有属性的弊端。
主窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls; namespace MapChuanzhi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int s_flag = 0;
private void button2_Click(object sender, EventArgs e)
{
IMap pMap = this.axMapControl1.Map;
Form2 frm2 = new Form2(pMap);
frm2.formDelegate += new FormDelegate(Display);
frm2.StartPosition = FormStartPosition.CenterScreen;
frm2.ShowDialog();
s_flag = 1;
} string LayerName = "";
List<string> FieldList = new List<string>();
public void Display(List<string> lc)
{
LayerName = lc[0].ToString();
FieldList.Clear();
for (int j = 1; j < lc.Count; j++)
{
FieldList.Add(lc[j].ToString());
}
} private void axMapControl1_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
{
switch (s_flag)
{
case 1:
showtips(FieldList, e);
break;
default:
break;
}
} private void showtips(List<string> index, IMapControlEvents2_OnMouseMoveEvent e)
{ StringBuilder sb = new StringBuilder();
string headd = string.Format("{0}:{1}", "图层", LayerName);
sb.AppendLine(headd);
sb.AppendLine( "————————");
for (int i = 0; i < this.axMapControl1.Map.LayerCount; i++)
{
if (axMapControl1.get_Layer(i).Name.ToString().Equals(LayerName))
{ for (int j = 0; j < index.Count; j++)
{ IFeatureLayer pFLayer = axMapControl1.Map.get_Layer(i) as IFeatureLayer;
pFLayer.DisplayField = index[j].ToString();
pFLayer.ShowTips = true;
string Text = pFLayer.get_TipText(e.mapX, e.mapY, axMapControl1.ActiveView.FullExtent.Width / 1000);
if (string.IsNullOrWhiteSpace(Text))
{
break;
}
sb.AppendLine(string.Format("{0}:{1}",index[j].ToString(),Text));
} if (sb.Length == headd.Length + "————————".Length + 4)
sb.Clear();
toolTip1.SetToolTip(axMapControl1, sb.ToString()); }
}
} }
}
属性窗口代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto; namespace MapChuanzhi
{
public delegate void FormDelegate(List<string> FormMessage);
public partial class Form2 : Form
{
private ESRI.ArcGIS.Carto.IMap pMap; public Form2( ESRI.ArcGIS.Carto.IMap pMap)
{
InitializeComponent();
// TODO: Complete member initialization
this.pMap = pMap;
} private void Form2_Load(object sender, EventArgs e)
{
for (int i = 0; i < pMap.LayerCount; i++)
{
this.comboBox1.Items.Add(pMap.get_Layer(i).Name.ToString());
}
}
string selectItems;
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
selectItems=comboBox1.SelectedItem.ToString();
for (int i = 0; i < pMap.LayerCount; i++)
{
if (pMap.get_Layer(i).Name.ToString() == selectItems)
{
IFeatureLayer pFLayer = pMap.get_Layer(i) as IFeatureLayer;
IFeatureClass pFClass = pFLayer.FeatureClass;
this.checkedListBox1.Items.Clear();
for (int j = 0; j < pFClass.Fields.FieldCount; j++)
{
this.checkedListBox1.Items.Add(pFClass.Fields.get_Field(j).Name);
}
try
{
checkedListBox1.Items.Remove("Shape");
}
catch (Exception)
{ throw;
}
}
}
} /***************窗体委托传值*********************/
public FormDelegate formDelegate;
private void button1_Click(object sender, EventArgs e)
{
if (this.checkedListBox1.CheckedItems == null || this.comboBox1.SelectedItem== null)
return;
List<string> cz = new List<string>();
cz.Add(comboBox1.SelectedItem.ToString());
for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
{
cz.Add(checkedListBox1.CheckedItems[i].ToString());
}
try
{
cz.Remove("Shape");
}
catch
{ }
formDelegate(cz);
this.Dispose();
} private void button2_Click(object sender, EventArgs e)
{
if (this.button2.Text == "全选")
{
for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
{
this.checkedListBox1.SetItemChecked(i, true);
this.button2.Text = "取消全选";
}
}
else
{
for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
{
this.checkedListBox1.SetItemChecked(i, false);
this.button2.Text = "全选";
}
}
} }
}
arcengine动态显示所需字段值的更多相关文章
- Laravel 校验规则之字段值唯一性校验
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] laravel validator unique 'name' => 'required|unique:test,disp ...
- QGis(三)查询矢量图层的要素属性字段值(转载)
QGis(三)查询矢量图层的要素属性字段值 https://github.com/gwaldron/osgearth/issues/489 当加载一个矢量图层后,如果要查看要素的属性字段值,则需要实现 ...
- 因DataTable的字段值为DBNull引发的异常
1 问题重现 (1)新建项目DBNullExp.项目属性为"控制台应用程序": (2)在项目下新建数据集Schools(数据集文件的后缀名为.xsd): watermark/2/t ...
- SQL Server 动态行转列(参数化表名、分组列、行转列字段、字段值)
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现代码(SQL Codes) 方法一:使用拼接SQL,静态列字段: 方法二:使用拼接SQL, ...
- MSCRM CRM 获取PickList 字段值函数解决方案
表单中有很多picklist字段 不想写链接stringmap代码: 实体ID查询方法: SELECT ObjectTypeCode from Entity where name='实体名称' 调 ...
- Mysql Sql语句令某字段值等于原值加上一个字符串
MySQL连贯字符串不能利用加号(+),而利用concat. 比方在aa表的name字段前加字符'x',利用: update aa set name=concat('x',name); 替换: UPD ...
- gridView RowDataBound事件 鼠标经过行颜色变化及根据字段值显示指定内容
protected void gvBarInfo_RowDataBound(object sender, GridViewRowEventArgs e) { if ...
- SQL 按特定字段值排序
SQL 按特定字段值排序的代码,有需要的朋友可以参考下. id, name shandong01 name1 shandong02 name2 shandong03 name3 beijing01 n ...
- GridView控件RowDataBound事件中获取列字段值的几种途径 !!!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == ...
- java 使用BeanUtils.copyProperties(Object source,Object target) 复制字段值
BeanUtils.copyProperties(person, wsPerson);把person的字段值,复制给wsPerson // 只复制两个实体中,字段名称一样的 很有用的一个功能...
随机推荐
- 92、kkfile打印当前页
使用kkfile预览pdf时,有肯能需要打印其中的某一张.如果pdf中有几百张,那么打印加载就会很慢.打印当前页就不会出现这个问题. 这个是我编译后的,有需要的请联系QQ: 1842988062
- JS学习-Web Worker
Web Worker 在专用workers的情况下,DedicatedWorkerGlobalScope 对象代表了worker的上下文(专用workers是指标准worker仅在单一脚本中被使用:共 ...
- mac SIP系统完整性保护关闭方法
许多Mac用户反应,装了部分软件后打不开,那可能是sip系统完整性没有关闭.下面我们就来看一下如何关闭sip系统完整性. 检查状态 在sip系统完整性关闭前,我们先检查是否启用了SIP系统完整性保护. ...
- 解决idea中按退格键(Backspace)回到上一行问题
开始学习java时,第一次用idea,该问题困扰一上午,网上也没有解决方案,最后自己摸索如下.打开File-> Settings->Editor->Smart Keys,将To pr ...
- mybatis lombok 报错: java: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor
1. 报错原因:jdk版本太高,lombok版本太低 2. 解决办法:安装更高版本的依赖包,可以去Maven Repository: lombok去查:https://mvnrepository.co ...
- linux清除日志和文件缓存
1.查找大文件,从根目录 find / -type f -size +800M 2.查看磁盘挂载情况及挂载目录 df -lh 3.查看内存使用情况 free -m 4.清除缓存 echo 3 > ...
- uniapp 报错 签名不对 请检查签名是否与开放平台上填写的一致
问题描述 用签名工具 输入包名 获取签名 在微信开放平台申请app 用获取的签名申请 申请成功后 在hbuilderx上云打包apk 分享 报 签名不对 请检查签名是否与开放平台上填写的一致 ...
- 【PyQt6】Python中QDateTime的常用方法总结
前置 QtDesigner里拖了一个QDateTimeEdit,设置时间格式为"yyyy/MM/dd HH:mm:ss" 常用函数 dt1 = object1.dateTime() ...
- element-ui的确认消息弹框校验;$prompt校验
this.$prompt('请输入您的姓名', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', inputPattern: /^.+$ ...
- 标记一下CF教育场的网址
(因为太难翻了,做到哪里标到哪,自用 Educational Codeforces Round 1 Educational Codeforces Round 2 Educational Codefor ...