From 510274879bf90d749bff5316b51e63acbf251141 Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Mon, 25 Nov 2024 11:40:22 +0800 Subject: [PATCH] Draw line and line symbol settings --- GisDevelop_Exp/MainWindow.xaml | 2 +- GisDevelop_Exp/MainWindow.xaml.cs | 24 +++++++ GisDevelop_Exp/OptionsWindow.xaml | 19 +++--- GisDevelop_Exp/OptionsWindow.xaml.cs | 95 ++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 10 deletions(-) diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml index a93d6b3..191babe 100644 --- a/GisDevelop_Exp/MainWindow.xaml +++ b/GisDevelop_Exp/MainWindow.xaml @@ -38,7 +38,7 @@ - + diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs index a6f3f6e..66c1c8b 100644 --- a/GisDevelop_Exp/MainWindow.xaml.cs +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -24,6 +24,7 @@ using Esri.ArcGISRuntime.UI.Controls; using Color = System.Drawing.Color; using Geometry = Esri.ArcGISRuntime.Geometry.Geometry; using Polygon = Esri.ArcGISRuntime.Geometry.Polygon; +using Polyline = Esri.ArcGISRuntime.Geometry.Polyline; enum CURRENTOPERATION { @@ -668,6 +669,23 @@ namespace GisDevelop_Exp Graphic gPT = new Graphic(location, pointSymbol); MainMapView.GraphicsOverlays[0].Graphics.Add(gPT); } + else if (m_CurOper == CURRENTOPERATION.DrawLine) + { + linePoints.Add(location); + if (linePoints.Count > 1) + { + if (linesList.Count > 0) + { + Graphic curGraphic = linesList[linesList.Count - 1]; + MainMapView.GraphicsOverlays[0].Graphics.Remove(curGraphic); + linesList.Remove(curGraphic); + } + Polyline line = new Polyline(linePoints); + Graphic lineGraphic = new Graphic(line, lineSymbol); + MainMapView.GraphicsOverlays[0].Graphics.Add(lineGraphic); + linesList.Add(lineGraphic); + } + } } private void Menu_Layers_Options_OnClick(object sender, RoutedEventArgs e) @@ -682,11 +700,17 @@ namespace GisDevelop_Exp private void Menu_Point_Draw_Line_OnClick(object sender, RoutedEventArgs e) { m_CurOper = CURRENTOPERATION.DrawLine; + linePoints.Clear(); } private void Menu_Point_Draw_Polygon_OnClick(object sender, RoutedEventArgs e) { m_CurOper = CURRENTOPERATION.DrawPolygon; } + + private void MainMapView_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + m_CurOper = CURRENTOPERATION.NullOpe; + } } } \ No newline at end of file diff --git a/GisDevelop_Exp/OptionsWindow.xaml b/GisDevelop_Exp/OptionsWindow.xaml index 2da5c67..b96e1a0 100644 --- a/GisDevelop_Exp/OptionsWindow.xaml +++ b/GisDevelop_Exp/OptionsWindow.xaml @@ -34,9 +34,10 @@ - + - + + @@ -44,13 +45,13 @@ -