77范文网 - 专业文章范例文档资料分享平台

ArcGIS Engine(10)

来源:网络收集 时间:2020-02-21 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

图3

2.2 设置控件属性

设置相应控件的相关属性,如下表所示(空则不用修改): 控件 SymbologyControl PictureBox Label Label Label Label Label NumericUpDown NumericUpDown NumericUpDown Button Button Button Button Button GroupBox GroupBox ColorDialog OpenFileDialog ContextMenuStrip Name属性 axSymbologyControl ptbPreview lblColor lblSize lblWidth lblAngle lblOutlineColor nudSize nudWidth nudAngle btnColor btnOutlineColor btnMoreSymbols btnOK btnCancel groupBox1 groupBox2 colorDialog openFileDialog Text属性 颜色 大小 线宽 角度 外框颜色 (设置为空) (设置为空) 更多符号 确定 取消 预览 设置 其它 DialogResult属性设为OK Filter属性设置为:Styles 文件|*.ServerStyle contextMenuStripMoreSymbol 2.3 添加引用

在解决方案资源管理器中添加ArcGIS Engine的ESRI.ArcGIS.Geodatabase引用,在SymbolSelectorFrm.cs文件中添加

如下引用代码:

using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Display;

using ESRI.ArcGIS.esriSystem;

using ESRI.ArcGIS.SystemUI;

using ESRI.ArcGIS.Controls;

using ESRI.ArcGIS.Geodatabase;

2.4 初始化

(1) 添加SymbolSelectorFrm的全局变量,代码如下:

private IStyleGalleryItem pStyleGalleryItem;

private ILegendClass pLegendClass;

private ILayer pLayer;

public ISymbol pSymbol;

public Image pSymbolImage;

(2) 修改SymbolSelectorFrm的构造函数,传入图层和图例接口。代码如下:

///

/// 构造函数,初始化全局变量

///

///

///

public SymbolSelectorFrm(ILegendClass tempLegendClass, ILayer tempLayer) {

InitializeComponent();

this.pLegendClass = tempLegendClass;

this.pLayer = tempLayer; }

(3) 添加SymbolControl的SymbologyStyleClass设置函数SetFeatureClassStyle(),代码如下:

///

/// 初始化SymbologyControl的StyleClass,图层如果已有符号,则把符号添加到SymbologyControl中的第一个符号,并选中

///

///

private void SetFeatureClassStyle(esriSymbologyStyleClass symbologyStyleClass) {

this.axSymbologyControl.StyleClass = symbologyStyleClass;

ISymbologyStyleClass pSymbologyStyleClass = this.axSymbologyControl.GetStyleClass(symbologyStyleClass);

if (this.pLegendClass != null)

{

IStyleGalleryItem currentStyleGalleryItem = new ServerStyleGalleryItem();

currentStyleGalleryItem.Name = \当前符号\

currentStyleGalleryItem.Item = pLegendClass.Symbol;

pSymbologyStyleClass.AddItem(currentStyleGalleryItem,0);

this.pStyleGalleryItem = currentStyleGalleryItem;

}

pSymbologyStyleClass.SelectItem(0); }

(4) 添加注册表读取函数ReadRegistry(),此函数从注册表中读取ArcGIS的安装路径,代码如下:

///

/// 从注册表中取得指定软件的路径

///

///

///

private string ReadRegistry(string sKey) {

//Open the subkey for reading

Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sKey, true);

if (rk == null) return \

// Get the data from a specified item in the key.

return (string)rk.GetValue(\ }

(5) 添加SymbolSelectorFrm的Load事件。根据图层类型为SymbologyControl导入相应的符号样式文件,如点、线、面,并设置控件的可视性。代码如下:

private void SymbolSelectorFrm_Load(object sender, EventArgs e) {

//取得ArcGIS安装路径

string sInstall = ReadRegistry(\

//载入ESRI.ServerStyle文件到SymbologyControl

this.axSymbologyControl.LoadStyleFile(sInstall + \

//确定图层的类型(点线面),设置好SymbologyControl的StyleClass,设置好各控件的可见性(visible)

IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

switch (((IFeatureLayer)pLayer).FeatureClass.ShapeType) {

case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:

this.SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassMarkerSymbols);

this.lblAngle.Visible = true;

this.nudAngle.Visible = true;

this.lblSize.Visible = true;

this.nudSize.Visible = true;

this.lblWidth.Visible = false;

this.nudWidth.Visible = false;

this.lblOutlineColor.Visible = false;

this.btnOutlineColor.Visible = false;

break;

case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:

this.SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassLineSymbols);

this.lblAngle.Visible = false;

this.nudAngle.Visible = false;

this.lblSize.Visible = false;

this.nudSize.Visible = false;

this.lblWidth.Visible = true;

this.nudWidth.Visible = true;

this.lblOutlineColor.Visible = false;

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库ArcGIS Engine(10)在线全文阅读。

ArcGIS Engine(10).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/778423.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: