Exemplo n.º 1
0
        private void tbDetails_Click(object sender, RoutedEventArgs e)
        {
            ICartoObj o = (ICartoObj)ListBox.SelectedItem;
            string    titreFenetre = "", messageFenetre = "";

            if (o == null)
            {
                MessageBox.Show("Aucun élément de la ListBox est sélectionné", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                if (o is POI)
                {
                    POI p = o as POI;
                    titreFenetre   = "Caractéristiques détaillées du POI sélectionné";
                    messageFenetre = p.Draw();
                }
                if (o is Polyline)
                {
                    Polyline p = o as Polyline;
                    titreFenetre   = "Caractéristiques détaillées du trajet (Polyline) sélectionné";
                    messageFenetre = p.Draw();
                }
                if (o is Polygon)
                {
                    Polygon p = o as Polygon;
                    titreFenetre   = "Caractéristiques détaillées de la surface (Polygon) sélectionné";
                    messageFenetre = p.Draw();
                }
                MessageBox.Show(messageFenetre, titreFenetre, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 2
0
 private void UpdateListBox()
 {
     ListBox.Items.Clear();
     foreach (ICartoObj o in PersonneConnectee.ObservableCollection)
     {
         if (o is POI)
         {
             POI p = o as POI;
             //ListBox.Items.Add("POI: " + p.Id + " / " + p.Description);
             ListBox.Items.Add(p);
         }
         if (o is Polyline)
         {
             Polyline p = o as Polyline;
             //ListBox.Items.Add("Trajet: " + p.Id);
             ListBox.Items.Add(p);
         }
         if (o is Polygon)
         {
             Polygon p = o as Polygon;
             //ListBox.Items.Add("Surface: " + p.Id);
             ListBox.Items.Add(p);
         }
     }
 }
Exemplo n.º 3
0
        private void DeleteSelectItem_Click(object sender, RoutedEventArgs e)
        {
            bool      suppressionOK = false;
            ICartoObj o             = (ICartoObj)ListBox.SelectedItem;

            if (o == null)
            {
                suppressionOK = 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;
                    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))
                                {
                                    MessageBox.Show("Suppression du POI OK", "", MessageBoxButton.OK, MessageBoxImage.Information);
                                    suppressionOK = true;
                                }
                                break;
                            }
                        }
                    }
                }
                if (o is Polyline)
                {
                    Polyline p = o as Polyline;
                    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))
                                {
                                    MessageBox.Show("Suppression du polyline OK", "", MessageBoxButton.OK, MessageBoxImage.Information);
                                    suppressionOK = true;
                                }
                                break;
                            }
                        }
                    }
                }
                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 (!suppressionOK)
            {
                MessageBox.Show("La suppresion à échouée", "ERREUR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }