ArcGIS Engine(10)

2020-02-21 18:22

图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;


ArcGIS Engine(10).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:审计案例分析及答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: