手机版

东华理工GIS二次开发实验报告(13)

发布时间:2021-06-06   来源:未知    
字号:

主窗体新建渲染图层菜单,并新建子菜单

C# Code

1 private void 获取渲染器信息ToolStripMenuItem_Click(object sender, EventArgs e) 2 {

3 dataoperator dataOperator = new dataoperator(axMapControl1.Map); 4 ILayer layer = dataOperator.getlayerbyname("World Cities"); 5 MessageBox.Show(MapComposer.getrendertypebylayer(layer)); 6 }

新建MapComposer类并输入以下代码 C# Code

1 using System;

2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text;

5 using ESRI.ArcGIS.esriSystem; 6 using ESRI.ArcGIS.Carto;

7 using ESRI.ArcGIS.Controls; 8 using ESRI.ArcGIS.ADF; 9 using ESRI.ArcGIS.SystemUI; 10 using ESRI.ArcGIS.Geometry; 11 using ESRI.ArcGIS.Display; 12 using ESRI.ArcGIS.Geodatabase;

13 namespace MapControlApplication1 14 {

15 class MapComposer 16 {

17 public static string getrendertypebylayer(ILayer layer) 18 {

19 if(layer == null) 20 return "获取失败";

21 IFeatureLayer ftly = (IFeatureLayer)layer; 22 IGeoFeatureLayer gftly = (IGeoFeatureLayer)layer; 23 IFeatureRenderer ftren = gftly.Renderer; 24 if(ftren is ISimpleRenderer) 25 return "ISimpleRenderer";

26 else if(ftren is IUniqueValueRenderer) 27 return "IUniqueValueRenderer"; 28 else if(ftren is IDotDensityRenderer) 29 return "IDotDensityRenderer"; 30 else if(ftren is IChartRenderer) 31 return "IChartRenderer";

32 else if(ftren is IProportionalSymbolRenderer) 33 return "IProportionalSymbolRenderer"; 34 return "未知或者获取渲染器失败"; 35 }

36 public static ISymbol getsymbolfromlayer(ILayer layer) 37 {

38 if(layer == null) 39 return null;

40 IFeatureLayer ftly = (IFeatureLayer)layer; 41 IFeatureCursor ftcs = ftly.Search(null, false); 42 IFeature ft = ftcs.NextFeature(); 43 if(ft == null) 44 return null;

45 IGeoFeatureLayer gftly = ftly as IGeoFeatureLayer; 46 IFeatureRenderer ftren = gftly.Renderer; 47 if(ftren == null) 48 return null;

49 ISymbol syb = ftren.get_SymbolByFeature(ft); 50 return syb; 51 }

52 public static bool RenderSimply(ILayer layer, IColor color) 53 {

54 if(layer == null || color == null) 55 return false;

56 ISymbol symbol = getsymbolfromlayer(layer);

东华理工GIS二次开发实验报告(13).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)