ArcGIS for Silverlight 图形的绘制与编辑基本例子
2013-08-02 11:50
471 查看
效果图:
MainPage.xaml.cs
本实例采用VS2010+Silverlight 5.0编写,如需源码请点击 SilverlightApplication10.zip 下载。
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Symbols; using ESRI.ArcGIS.Client.Geometry; namespace SilverlightApplication10 { /// <summary> /// ArcGIS for Silverlight 图形的绘制与编辑基本例子 /// </summary> public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); // 用于编辑 edit = new EditGeometry { Map = map1 }; // 用于绘制 draw = new Draw { FillSymbol = graphicSymbol, Map = map1 }; } public EditGeometry edit; public Draw draw; public Graphic grahpic; public SimpleFillSymbol graphicSymbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(Color.FromArgb(33, 00, 255, 00)), BorderBrush = new SolidColorBrush(Colors.Green), BorderThickness = 2 }; private void button1_Click(object sender, RoutedEventArgs e) { textBox1.Text += Environment.NewLine + "开始绘制图形 ..."; draw.DrawComplete -= new EventHandler<DrawEventArgs>(draw_DrawComplete); draw.DrawComplete += new EventHandler<DrawEventArgs>(draw_DrawComplete); draw.DrawMode = DrawMode.Polygon; draw.IsEnabled = true; } void draw_DrawComplete(object sender, DrawEventArgs e) { textBox1.Text += Environment.NewLine + "绘制图形结束 ..."; draw.DrawComplete -= new EventHandler<DrawEventArgs>(draw_DrawComplete); draw.IsEnabled = false; // 创建对象 grahpic = new Graphic { Geometry = e.Geometry, Symbol = graphicSymbol }; // 添加到地图 GraphicsLayer layer1 = map1.Layers["graphicsLayer"] as GraphicsLayer; layer1.Graphics.Add(grahpic); } private void button2_Click(object sender, RoutedEventArgs e) { if (grahpic != null) { textBox1.Text += Environment.NewLine + "开始编辑图形 ..."; // 添加事件 edit.IsEnabled = true; edit.StartEdit(grahpic); edit.GeometryEdit -= new EventHandler<EditGeometry.GeometryEditEventArgs>(edit_GeometryEdit); edit.GeometryEdit += new EventHandler<EditGeometry.GeometryEditEventArgs>(edit_GeometryEdit); } else { textBox1.Text += Environment.NewLine + "请先绘制图形!"; } } void edit_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e) { textBox1.Text += Environment.NewLine + "图形编辑类别:" + e.Action; // 取消编辑或完成编辑时,改变编辑对象的状态 if (e.Action.Equals(EditGeometry.Action.EditCanceled) || e.Action.Equals(EditGeometry.Action.EditCompleted)) { textBox1.Text += Environment.NewLine + "编辑图形结束 ..."; edit.GeometryEdit -= new EventHandler<EditGeometry.GeometryEditEventArgs>(edit_GeometryEdit); edit.IsEnabled = false; edit.StopEdit(); } } } }
MainPage.xaml.cs
本实例采用VS2010+Silverlight 5.0编写,如需源码请点击 SilverlightApplication10.zip 下载。
相关文章推荐
- opencv-python 基本例子3个---显示图片,绘制图形,人脸识别
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等--绘制点、线、圆,显示提示信息
- ArcGIS API for Javascript 3.21地图开发实例(一、图形绘制和删除及popup弹出层)
- ArcGIS API for Silverlight 绘制降雨路径动画
- ArcGIS for Android Runtime100 基本操作(五)——绘制图层和符号渲染
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(一)
- ArcGIS API For Javacsript编辑客户端图形
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(四)--动态绘制点
- ArcGIS API for Silverlight 编辑Geometry
- ArcGIS API for Silverlight 绘制降雨路径动画
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(四)--动态绘制点
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图
- ArcGIS API for Silverlight 编辑Geometry
- (十一)ArcGIS API For Javacsript编辑客户端图形
- ArcGIS API for Silverlight 调用GP服务绘制等值面
- ArcGis For Silverlight API,地图显示Gis,绘制点,线,绘制图等(一)
- ArcGIS API for Silverlight 绘制降雨路径动画
- 使用ArcGIS API for Silverlight + Visifire绘制地图统计图