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_KeyDown(object sender, KeyEventArgs e) { Console.WriteLine("Map_KeyDown"); if (e.Key == Key.Enter) { Console.WriteLine(collectionCoordonnees.Count); if (collectionCoordonnees.Count > 1) { if (collectionCoordonnees.Count > 2 && collectionCoordonnees[0].IsPointClose(new Coordonnees(collectionCoordonnees[collectionCoordonnees.Count - 1].Latitude, collectionCoordonnees[collectionCoordonnees.Count - 1].Longitude), 0.001)) { //Cree la surface //Modifier tout les elements en Coordonnees for (int i = 0; i < collectionCoordonnees.Count; i++) { if (collectionCoordonnees[i] is POI) { collectionCoordonnees[i] = new Coordonnees(collectionCoordonnees[i].Latitude, collectionCoordonnees[i].Longitude); } } collectionCoordonnees.RemoveAt(collectionCoordonnees.Count - 1); PolygonWindow polygonWindow = new PolygonWindow(); polygonWindow.Collection = collectionCoordonnees; polygonWindow.Remplissage = "Red"; polygonWindow.Contour = "Black"; polygonWindow.Opacite = 0.5; polygonWindow.ShowDialog(); if (polygonWindow.Polygon != null) { myPersonalMapData.ObservableCollection.Add(polygonWindow.Polygon); collectionCoordonnees.Clear(); } polygonWindow.Close(); } else { //Modifier le dernier element en POI Coordonnees coordonnees = collectionCoordonnees[collectionCoordonnees.Count - 1]; collectionCoordonnees.RemoveAt(collectionCoordonnees.Count - 1); POI poi = new POI("Fin", new Coordonnees(coordonnees.Latitude, coordonnees.Longitude)); collectionCoordonnees.Add(poi); //Fabrique la polyline PolylineWindow polylineWindow = new PolylineWindow(); polylineWindow.Collection = collectionCoordonnees; polylineWindow.Couleur = "Black"; polylineWindow.Epaisseur = "5"; polylineWindow.Description = ((POI)collectionCoordonnees[0]).Description + " vers " + ((POI)collectionCoordonnees[collectionCoordonnees.Count - 1]).Description; polylineWindow.ShowDialog(); if (polylineWindow.Polyline != null) { //Ajoute tout myPersonalMapData.ObservableCollection.Add(polylineWindow.Polyline); collectionCoordonnees.Clear(); } else { POI p = (POI)collectionCoordonnees[collectionCoordonnees.Count - 1]; Coordonnees coods = new Coordonnees(p.Latitude, p.Longitude); collectionCoordonnees.RemoveAt(collectionCoordonnees.Count - 1); collectionCoordonnees.Add(coods); } polylineWindow.Close(); } UpdateMainWindow(); } } e.Handled = true; }