diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml
index baaca9f..a93d6b3 100644
--- a/GisDevelop_Exp/MainWindow.xaml
+++ b/GisDevelop_Exp/MainWindow.xaml
@@ -30,8 +30,20 @@
+
-
+
+
+
+
+
+
diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs
index 4809bbb..a6f3f6e 100644
--- a/GisDevelop_Exp/MainWindow.xaml.cs
+++ b/GisDevelop_Exp/MainWindow.xaml.cs
@@ -31,6 +31,9 @@ enum CURRENTOPERATION
SelectQuery = 0,
IdentifyQuery,
PanMap,
+ DrawPoint,
+ DrawLine,
+ DrawPolygon,
}
namespace GisDevelop_Exp
@@ -47,6 +50,13 @@ namespace GisDevelop_Exp
private ServiceFeatureTable _featureTable;
+ private List linePoints;
+ private List linesList;
+
+ private SimpleMarkerSymbol pointSymbol;
+ private SimpleLineSymbol lineSymbol;
+ private SimpleFillSymbol fillSymbol;
+
private readonly Dictionary _basemapOptions = new Dictionary()
{
{ "Streets (Raster)", new Basemap(BasemapStyle.OSMStreets) },
@@ -67,9 +77,19 @@ namespace GisDevelop_Exp
public MainWindow()
{
InitializeComponent();
+
+ pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 3);
+ lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 1);
+ fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.Blue,new SimpleLineSymbol(SimpleLineSymbolStyle.Solid,System.Drawing.Color.Pink,1));
+
+ linePoints = new List();
+ linesList = new List();
+
m_CurOper = CURRENTOPERATION.NullOpe;
Initialize();
EagleMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard);
+ GraphicsOverlay graphicLayer = new GraphicsOverlay();
+ MainMapView.GraphicsOverlays.Add(graphicLayer);
}
private void Initialize()
@@ -108,9 +128,10 @@ namespace GisDevelop_Exp
ShapefileFeatureTable openedFeature = await ShapefileFeatureTable.OpenAsync(filePath);
FeatureLayer opendFeatureLayer = new FeatureLayer(openedFeature);
MainMapView.Map.OperationalLayers.Add(opendFeatureLayer);
- await MainMapView.SetViewpointGeometryAsync(opendFeatureLayer.FullExtent);
+ await MainMapView.SetViewpointGeometryAsync(openedFeature.Extent);
}
}
+ AddLayerNameToList();
}
private async void OpenGeoDatabase()
@@ -135,14 +156,17 @@ namespace GisDevelop_Exp
await table.LoadAsync();
FeatureLayer layer = new FeatureLayer(table);
layer.Name = table.TableName;
- geodatabaseMap.OperationalLayers.Add(layer);
+ // geodatabaseMap.OperationalLayers.Add(layer);
_featureLayer = layer;
+ MainMapView.Map.OperationalLayers.Add(layer);
}
Viewpoint geodatabaseViewPoint = new Viewpoint(_featureLayer.FullExtent);
- geodatabaseMap.InitialViewpoint = geodatabaseViewPoint;
- MainMapView.Map = geodatabaseMap;
+ // geodatabaseMap.InitialViewpoint = geodatabaseViewPoint;
+ MainMapView.Map.InitialViewpoint = geodatabaseViewPoint;
+ // MainMapView.Map = geodatabaseMap;
}
+ AddLayerNameToList();
}
private void Menu_OpenGeodatabase_Click(object sender, RoutedEventArgs e)
@@ -249,6 +273,7 @@ namespace GisDevelop_Exp
pMap.OperationalLayers.Add(_featureLayer);
MainMapView.Map = pMap;
MainMapView.SelectionProperties.Color = Color.Cyan;
+ AddLayerNameToList();
}
private void BasemapChooser_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -300,6 +325,7 @@ namespace GisDevelop_Exp
FeatureLayer featureLayer = new FeatureLayer(portalItem, 0);
map.OperationalLayers.Add(featureLayer);
MainMapView.Map = map;
+ AddLayerNameToList();
}
private void MainMapView_OnGeoViewTapped(object? sender, GeoViewInputEventArgs e)
@@ -477,6 +503,190 @@ namespace GisDevelop_Exp
aMap.InitialViewpoint = geodatabaseViewPoint;
MainMapView.Map = aMap;
}
+ AddLayerNameToList();
+ }
+
+ private void LayerListBox_OnPreviewMouseMove(object sender, MouseEventArgs e)
+ {
+ if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
+ {
+ var pos = e.GetPosition(LayerListBox);
+ if (pos.X < 20) return;
+ System.Windows.Media.HitTestResult result =
+ System.Windows.Media.VisualTreeHelper.HitTest(LayerListBox, pos);
+ if (result == null) return;
+ var listBoxItem = Utils.FindVisualParent(result.VisualHit);
+
+ if (listBoxItem == null) return;
+ DataObject dataObj = new DataObject(listBoxItem.Content as CheckBox);
+ DragDrop.DoDragDrop(LayerListBox, dataObj, DragDropEffects.Move);
+ }
+ }
+
+ private void LayerListBox_OnDrop(object sender, DragEventArgs e)
+ {
+ var pos = e.GetPosition(sender as ListBox);
+ var result = System.Windows.Media.VisualTreeHelper.HitTest(LayerListBox, pos);
+ if (result == null)
+ {
+ return;
+ }
+
+ var sourcePerson = e.Data.GetData(typeof(CheckBox)) as CheckBox;
+ if (sourcePerson == null)
+ {
+ return;
+ }
+
+ var listBoxItem = Utils.FindVisualParent(result.VisualHit);
+ if (listBoxItem == null)
+ {
+ return;
+ }
+
+ var targetPerson = listBoxItem.Content as CheckBox;
+ if (ReferenceEquals(targetPerson, sourcePerson))
+ {
+ return;
+ }
+
+ int targetIndex = LayerListBox.Items.IndexOf(targetPerson);
+ int sourceIndex = LayerListBox.Items.IndexOf(sourcePerson);
+ LayerListBox.Items.Remove(sourcePerson);
+ LayerListBox.Items.Insert(targetIndex, sourcePerson);
+ MoveLayer(sourcePerson.ToolTip as string,targetPerson.ToolTip as string);
+ }
+
+ private void AddLayerNameToList()
+ {
+ LayerListBox.Items.Clear();
+ LayerListBox.AllowDrop = true;
+ LayerCollection pLayers = MainMapView.Map.OperationalLayers;
+ if (pLayers.Count <= 0) return;
+ for (int i = pLayers.Count - 1; i >= 0; i--)
+ {
+ CheckBox cb = new CheckBox()
+ {
+ Margin = new Thickness()
+ {
+ Left = 0,
+ Top = 5,
+ Right = 0,
+ Bottom = 5
+ }
+ };
+ Console.WriteLine(pLayers[i].Name);
+ cb.Content = pLayers[i].Name;
+ cb.ToolTip = pLayers[i].Name;
+ cb.Name = pLayers[i].Name;
+ cb.IsChecked = true;
+ cb.Focusable = false;
+ cb.Checked += new RoutedEventHandler(Checked_Layers_CheckBox);
+ cb.Unchecked += new RoutedEventHandler(UnChecked_Layers_CheckBox);
+ LayerListBox.Items.Add(cb);
+ }
+ }
+
+ private void UnChecked_Layers_CheckBox(object sender, RoutedEventArgs e)
+ {
+ CheckBox cb = sender as CheckBox;
+ cb.IsChecked = false;
+ int index = GetLayerIndex(cb.ToolTip as string);
+ MainMapView.Map.OperationalLayers[index].IsVisible = false;
+ }
+
+ private void Checked_Layers_CheckBox(object sender, RoutedEventArgs e)
+ {
+ CheckBox cb = sender as CheckBox;
+ cb.IsChecked = true;
+ int index = GetLayerIndex(cb.ToolTip as string);
+ MainMapView.Map.OperationalLayers[index].IsVisible = true;
+ }
+
+ internal static class Utils
+ {
+ public static T FindVisualParent(DependencyObject obj) where T : class
+ {
+ while (obj != null)
+ {
+ if (obj is T)
+ return obj as T;
+ obj = System.Windows.Media.VisualTreeHelper.GetParent(obj);
+ }
+ return null;
+ }
+ }
+
+ private Layer GetLayer(string name)
+ {
+ LayerCollection pLayers = MainMapView.Map.OperationalLayers;
+ for (int i = pLayers.Count - 1; i >= 0; i--)
+ {
+ if (pLayers[i].Name.Equals(name))
+ {
+ return pLayers[i];
+ }
+ }
+
+ return null;
+ }
+
+ private void MoveLayer(string sourceLayer, string targetLayer)
+ {
+ LayerCollection pLayers = MainMapView.Map.OperationalLayers;
+ Layer sourcLayer = GetLayer(sourceLayer);
+ pLayers.Remove(sourcLayer);
+ int targerIndex = GetLayerIndex(targetLayer);
+ }
+
+ private int GetLayerIndex(string name)
+ {
+ LayerCollection pLayers = MainMapView.Map.OperationalLayers;
+ for (int i = pLayers.Count - 1; i >= 0; i--)
+ {
+ if (pLayers[i].Name.Equals(name))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ private void Menu_Point_Symbol_Click(object sender, RoutedEventArgs e)
+ {
+ m_CurOper = CURRENTOPERATION.DrawPoint;
+ }
+
+ private void MainMapView_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ IInputElement mv = (IInputElement)sender;
+ MapPoint location = MainMapView.ScreenToLocation(e.GetPosition(mv));
+
+ if (m_CurOper == CURRENTOPERATION.DrawPoint)
+ {
+ Graphic gPT = new Graphic(location, pointSymbol);
+ MainMapView.GraphicsOverlays[0].Graphics.Add(gPT);
+ }
+ }
+
+ private void Menu_Layers_Options_OnClick(object sender, RoutedEventArgs e)
+ {
+ OptionsWindow op = new OptionsWindow();
+ op.PointSymbol = pointSymbol;
+ op.LineSymbol = lineSymbol;
+ op.FillSymbol = fillSymbol;
+ op.ShowDialog();
+ }
+
+ private void Menu_Point_Draw_Line_OnClick(object sender, RoutedEventArgs e)
+ {
+ m_CurOper = CURRENTOPERATION.DrawLine;
+ }
+
+ private void Menu_Point_Draw_Polygon_OnClick(object sender, RoutedEventArgs e)
+ {
+ m_CurOper = CURRENTOPERATION.DrawPolygon;
}
}
}
\ No newline at end of file