private void Map_RightButtonDown(object sender, MouseEventArgs e) { Point mousePosition = e.GetPosition(Map); Location mouseLocation = Map.ViewportPointToLocation(mousePosition); //Ajouter la coordonne a une list temp et pin if (collectionCoordonnees.Count == 0) { PoiWindow poiWindow = new PoiWindow(); poiWindow.Description = "Début"; poiWindow.Latitude = mouseLocation.Latitude.ToString(); poiWindow.Longitude = mouseLocation.Longitude.ToString(); poiWindow.ShowDialog(); if (poiWindow.Poi != null) { collectionCoordonnees.Add(poiWindow.Poi); } poiWindow.Close(); } else { collectionCoordonnees.Add(new Coordonnees(mouseLocation.Latitude, mouseLocation.Longitude)); } UpdateMainWindow(); Map.Focus(); e.Handled = true; }
public void Créer_Click(object sender, RoutedEventArgs e) { if (ComboBoxChoixObjet.SelectedIndex == 1) { PoiWindow poiWindow = new PoiWindow(); poiWindow.Owner = this; poiWindow.ShowDialog(); if (poiWindow.Poi != null) { myPersonalMapData.ObservableCollection.Add(poiWindow.Poi); UpdateMainWindow(); } poiWindow.Close(); } else if (ComboBoxChoixObjet.SelectedIndex == 2) { PolylineWindow polylineWindow = new PolylineWindow(); polylineWindow.Owner = this; polylineWindow.ShowDialog(); if (polylineWindow.Polyline != null) { myPersonalMapData.ObservableCollection.Add(polylineWindow.Polyline); UpdateMainWindow(); } polylineWindow.Close(); } else if (ComboBoxChoixObjet.SelectedIndex == 3) { PolygonWindow polygonWindow = new PolygonWindow(); polygonWindow.Owner = this; polygonWindow.ShowDialog(); if (polygonWindow.Polygon != null) { myPersonalMapData.ObservableCollection.Add(polygonWindow.Polygon); UpdateMainWindow(); } polygonWindow.Close(); } ListBox.SelectedIndex = 0; }
private void Modifier_Click(object sender, RoutedEventArgs e) { if (myPersonalMapData.ObservableCollection.Count == 0) { return; } int position = ListBox.SelectedIndex; ICartoObj i = myPersonalMapData.ObservableCollection.ElementAt(position); if (i is POI) { POI p = i as POI; PoiWindow poiWindow = new PoiWindow(p); poiWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = poiWindow.Poi; ListBox.SelectedIndex = position; poiWindow.Close(); } if (i is Polyline) { Polyline p = i as Polyline; PolylineWindow polylineWindow = new PolylineWindow(p); polylineWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = polylineWindow.Polyline; ListBox.SelectedIndex = position; polylineWindow.Close(); } if (i is Polygon) { Polygon p = i as Polygon; PolygonWindow polygonWindow = new PolygonWindow(p); polygonWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = polygonWindow.Polygon; ListBox.SelectedIndex = position; polygonWindow.Close(); } UpdateMainWindow(); }
private void Map_DoubleClick(object sender, MouseEventArgs e) { Console.WriteLine("Double click!"); Point mousePosition = e.GetPosition(Map); Location mouseLocation = Map.ViewportPointToLocation(mousePosition); bool pinPresent = false; //Tester si on click sur une pin for (int i = 0; i < myPersonalMapData.ObservableCollection.Count; i++) { ICartoObj obj = myPersonalMapData.ObservableCollection[i]; if (obj is POI) { Coordonnees coords = new Coordonnees(((POI)obj).Latitude, ((POI)obj).Longitude); if (coords.IsPointClose(new Coordonnees(mouseLocation.Latitude, mouseLocation.Longitude), 0.001)) { Console.WriteLine("trouve: des = {0}", ((POI)obj).Description); PoiWindow poiWindow = new PoiWindow((POI)obj); poiWindow.ShowDialog(); myPersonalMapData.ObservableCollection[i] = poiWindow.Poi; poiWindow.Close(); pinPresent = true; break; } } if (obj is Polyline) { foreach (ICartoObj cartoObj in ((Polyline)obj).Collection) { if (((Coordonnees)cartoObj).IsPointClose(new Coordonnees(mouseLocation.Latitude, mouseLocation.Longitude), 0.001)) { ListBox.SelectedItem = ((Polyline)obj).Description; PolylineWindow polylineWindow = new PolylineWindow((Polyline)obj); polylineWindow.ShowDialog(); myPersonalMapData.ObservableCollection[ListBox.SelectedIndex] = polylineWindow.Polyline; polylineWindow.Close(); pinPresent = true; break; } } } e.Handled = true; } if (!pinPresent) { //Créé une pin ou trajet POI poi = new POI("", new Coordonnees(mouseLocation.Latitude, mouseLocation.Longitude)); PoiWindow poiWindow = new PoiWindow(); poiWindow.Latitude = poi.Latitude.ToString(); poiWindow.Longitude = poi.Longitude.ToString(); poiWindow.Description = ""; poiWindow.ShowDialog(); if (poiWindow.Poi != null) { myPersonalMapData.ObservableCollection.Add(poiWindow.Poi); } poiWindow.Close(); } UpdateMainWindow(); }