private void AjouterCoordonnee_Click(object sender, RoutedEventArgs e) { bool modificationOK = false; POI p = new POI(); fenetrePOI fenetrePOI = new fenetrePOI(p); fenetrePOI.Owner = this; fenetrePOI.ShowDialog(); if (fenetrePOI.NewPOI != null) { p.Id = p.Id; p.Latitude = fenetrePOI.NewPOI.Latitude; p.Longitude = fenetrePOI.NewPOI.Longitude; p.Description = fenetrePOI.NewPOI.Description; Console.WriteLine("DEBUG newPoi to string : " + p.Draw()); PolylineActuel.CollectionDeCoordonnes.Add(p); modificationOK = true; UpdateListBox(); } if (!modificationOK) { MessageBox.Show("L'ajout à échouée", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ModifierCoordonnee_Click(object sender, RoutedEventArgs e) { bool modificationOK = false; POI p = (POI)ListBox.SelectedItem; if (p == null) { modificationOK = true; MessageBox.Show("Aucun élément de la ListBox est sélectionné", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error); } else { fenetrePOI fenetrePOI = new fenetrePOI(p); fenetrePOI.Owner = this; fenetrePOI.ShowDialog(); if (fenetrePOI.NewPOI != null) { foreach (CartoObj oInCollection in PolylineActuel.CollectionDeCoordonnes) { if (oInCollection is POI) { POI poiInCollection = oInCollection as POI; if (poiInCollection.Id == p.Id) { if (PolylineActuel.CollectionDeCoordonnes.Remove(poiInCollection)) { POI newPOI = new POI(); newPOI.Id = p.Id; newPOI.Latitude = fenetrePOI.NewPOI.Latitude; newPOI.Longitude = fenetrePOI.NewPOI.Longitude; newPOI.Description = fenetrePOI.NewPOI.Description; Console.WriteLine("DEBUG newPoi to string : " + newPOI.Draw()); PolylineActuel.CollectionDeCoordonnes.Add(newPOI); modificationOK = true; } break; } } } } else { modificationOK = true; } UpdateListBox(); } if (!modificationOK) { MessageBox.Show("La modification à échouée", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void tbModifier_Click(object sender, RoutedEventArgs e) { bool modificationOK = false; ICartoObj o = (ICartoObj)ListBox.SelectedItem; if (o == null) { modificationOK = true; MessageBox.Show("Aucun élément de la ListBox est sélectionné", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error); } else { Carte.Children.Clear(); if (o is POI) { POI p = o as POI; fenetrePOI fenetrePOI = new fenetrePOI(p); fenetrePOI.Owner = this; fenetrePOI.ShowDialog(); if (fenetrePOI.NewPOI != null) { foreach (ICartoObj oInCollection in PersonneConnectee.ObservableCollection) { if (oInCollection is POI) { POI poiInCollection = oInCollection as POI; if (poiInCollection.Id == p.Id) { if (PersonneConnectee.ObservableCollection.Remove(poiInCollection)) { POI newPOI = new POI(); newPOI.Id = p.Id; newPOI.Latitude = fenetrePOI.NewPOI.Latitude; newPOI.Longitude = fenetrePOI.NewPOI.Longitude; newPOI.Description = fenetrePOI.NewPOI.Description; Console.WriteLine("DEBUG newPoi to string : " + newPOI.Draw()); PersonneConnectee.ObservableCollection.Add(newPOI); modificationOK = true; } break; } } } } else { modificationOK = true; } } if (o is Polyline) { Polyline p = o as Polyline; Console.WriteLine("DEBUG polyline dans modifier fenetre principale:\n" + p.Draw()); FenetrePolyline fenetrePolyline = new FenetrePolyline(p); fenetrePolyline.Owner = this; fenetrePolyline.ShowDialog(); if (fenetrePolyline.NewPolyline != null) { foreach (ICartoObj oInCollection in PersonneConnectee.ObservableCollection) { if (oInCollection is Polyline) { Polyline polylineInCollection = oInCollection as Polyline; if (polylineInCollection.Id == p.Id) { if (PersonneConnectee.ObservableCollection.Remove(polylineInCollection)) { Polyline newPolyline = new Polyline(); newPolyline.Id = p.Id; newPolyline.Epaisseur = fenetrePolyline.NewPolyline.Epaisseur; newPolyline.Couleur = fenetrePolyline.NewPolyline.Couleur; newPolyline.NomTrajet = fenetrePolyline.NewPolyline.NomTrajet; newPolyline.CollectionDeCoordonnes = new List <Coordonnees>(fenetrePolyline.NewPolyline.CollectionDeCoordonnes); PersonneConnectee.ObservableCollection.Add(newPolyline); modificationOK = true; } break; } } } } else { modificationOK = true; } } //} //if (o is Polygon) //{ // Polygon p = o as Polygon; // foreach (ICartoObj oInCollection in PersonneConnectee.ObservableCollection) // { // if (oInCollection is Polygon) // { // Polygon polygonInCollection = oInCollection as Polygon; // if (polygonInCollection.Id == p.Id) // { // if (PersonneConnectee.ObservableCollection.Remove(polygonInCollection)) // { // MessageBox.Show("Suppression du polyline OK", "", MessageBoxButton.OK, MessageBoxImage.Information); // suppressionOK = true; // } // break; // } // } // } //} UpdateListBox(); } if (!modificationOK) { MessageBox.Show("La modification à échouée", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Map_DoubleClick(object sender, MouseEventArgs e) { e.Handled = true; if (comboNewElem.SelectedItem != null)//si on a sélectionné qqch dans la comboBox { //Get the mouse click coordinates Point mousePosition = e.GetPosition(Carte); //Convert the mouse coordinates to a locatoin on the map Location location = Carte.ViewportPointToLocation(mousePosition); if (comboNewElem.SelectedItem.ToString().Contains("POI")) { POI p = new POI(location.Latitude, location.Longitude, ""); fenetrePOI fenetrePOI = new fenetrePOI(p); fenetrePOI.Owner = this; fenetrePOI.ShowDialog(); if (fenetrePOI.NewPOI != null) { p.Latitude = fenetrePOI.NewPOI.Latitude; p.Longitude = fenetrePOI.NewPOI.Longitude; p.Description = fenetrePOI.NewPOI.Description; PersonneConnectee.ObservableCollection.Add(p); Carte.Children.Clear(); afficherPOI(p); UpdateListBox(); } } else if (comboNewElem.SelectedItem.ToString().Contains("POLYLINE")) { if (!_addPolylineEnCour) { _polylineEnCour = new Polyline(); _addPolylineEnCour = true; Carte.Children.Clear(); } tbStopAdd.Visibility = Visibility.Visible; if (!_stopAddPoi) { //ajouter des poi au trajet POI p = new POI(location.Latitude, location.Longitude, ""); fenetrePOI fenetrePOI = new fenetrePOI(p); fenetrePOI.Owner = this; fenetrePOI.ShowDialog(); if (fenetrePOI.NewPOI != null) { p.Latitude = fenetrePOI.NewPOI.Latitude; p.Longitude = fenetrePOI.NewPOI.Longitude; p.Description = fenetrePOI.NewPOI.Description; _polylineEnCour.CollectionDeCoordonnes.Add(p); afficherPOI(p); } } //else --> dans tbStopAdd_Click } } }