Пример #1
0
        private void tbStopAdd_Click(object sender, RoutedEventArgs e)
        {
            _stopAddPoi = true;

            if (comboNewElem.SelectedItem.ToString().Contains("POLYLINE"))
            {
                Carte.Children.Clear();
                //afficher le trajet dans la fentetre de polyline
                FenetrePolyline fenetrePolyline = new FenetrePolyline(_polylineEnCour);
                fenetrePolyline.Owner = this;
                fenetrePolyline.ShowDialog();
                if (fenetrePolyline.NewPolyline != null)//l'ajouter à la collection si on clique sur ok
                {
                    _polylineEnCour.Epaisseur = fenetrePolyline.NewPolyline.Epaisseur;
                    _polylineEnCour.Couleur   = fenetrePolyline.NewPolyline.Couleur;
                    _polylineEnCour.NomTrajet = fenetrePolyline.NewPolyline.NomTrajet;
                    _polylineEnCour.CollectionDeCoordonnes = new List <Coordonnees>(fenetrePolyline.NewPolyline.CollectionDeCoordonnes);
                    PersonneConnectee.ObservableCollection.Add(_polylineEnCour);

                    afficherTrajet(_polylineEnCour);

                    UpdateListBox();
                }

                _stopAddPoi          = false;
                tbStopAdd.Visibility = Visibility.Collapsed;
                _addPolylineEnCour   = false;
                _polylineEnCour      = null;
            }
        }
Пример #2
0
        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);
            }
        }