Ejemplo n.º 1
0
        //Ouvrir le menu correspondant à la selection
        private void SelectItem(Location pinLocation)
        {
            for (int i = 0; i < User.Liste.Count(); i++)
            {
                if (User.Liste[i] is IIsPointClose)
                {
                    IIsPointClose coo = User.Liste[i] as IIsPointClose;
                    if (coo.IsPointClose(pinLocation, 0.5))
                    {
                        if (coo is POI poi)
                        {
                            OptPOI text = new OptPOI(poi);
                            text.ShowDialog(); //bloque la page

                            Pushpin pin = map.Children[i] as Pushpin;
                            pin.Location = new Location(poi.Latitude, poi.Longitude);
                            StatBar.Text = "POI updated"; //Affichage dans la StatusBar
                        }
                        else if (coo is Polyline polyl)
                        {
                            OptPolyline text = new OptPolyline(polyl);
                            text.ShowDialog(); //bloque la page

                            MapPolyline tmpPolyl = map.Children[i] as MapPolyline;
                            tmpPolyl.Stroke          = new System.Windows.Media.SolidColorBrush(polyl.Couleur);
                            tmpPolyl.StrokeThickness = polyl.Epaisseur;
                            StatBar.Text             = "Polyline updated"; //Affichage dans la StatusBar
                        }
                        else if (coo is Polygon polyg)
                        {
                            OptPolygon text = new OptPolygon(polyg);
                            text.ShowDialog(); //bloque la page

                            MapPolygon tmpPolyg = map.Children[i] as MapPolygon;
                            tmpPolyg.Stroke  = new System.Windows.Media.SolidColorBrush(polyg.CouleurContour);
                            tmpPolyg.Fill    = new System.Windows.Media.SolidColorBrush(polyg.CouleurRemplissage);
                            tmpPolyg.Opacity = polyg.Opacite;
                            StatBar.Text     = "Polygon updated"; //Affichage dans la StatusBar
                        }
                        else
                        {
                            ErrorWindow error = new ErrorWindow("An error has occurred");
                            error.ShowDialog(); //bloque la page
                        }
                        ReloadList();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //Ajouter un item
        private void AddItem(Location pinLocation)
        {
            if (POI_Box.IsSelected == true)
            {
                //La position du pin sur la carte
                Pushpin pin = new Pushpin();

                POI TmpPoi = new POI(pinLocation.Latitude, pinLocation.Longitude, "");

                OptPOI text = new OptPOI(TmpPoi);
                text.ShowDialog(); //bloque la page

                pin.Tag = TmpPoi;
                pinLocation.Latitude  = TmpPoi.Latitude;
                pinLocation.Longitude = TmpPoi.Longitude;

                pin.Location = pinLocation;

                //Ajoute le pin a la carte
                map.Children.Add(pin);

                //Ajoute à la liste
                User.Liste.Add(TmpPoi);
                StatBar.Text = "POI added"; //Affichage dans la StatusBar
            }

            if (Polyline_Box.IsSelected == true)
            {
                if (ListeTmp == null)
                {
                    ListeTmp    = new List <Coordonnees>();
                    PolylineTpm = new MapPolyline
                    {
                        Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue),
                        StrokeThickness = 3,
                        Opacity         = 1,
                        Locations       = new LocationCollection()
                    };
                    map.Children.Add(PolylineTpm);
                }

                ListeTmp.Add(new Coordonnees(pinLocation.Latitude, pinLocation.Longitude));

                PolylineTpm.Locations.Add(new Location(pinLocation.Latitude, pinLocation.Longitude));

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    Polyline TmpPolyline = new Polyline
                    {
                        Coordonnees = ListeTmp
                    };
                    OptPolyline text = new OptPolyline(TmpPolyline);
                    text.ShowDialog(); //bloque la page

                    //Ajoute à la liste
                    PolylineTpm.StrokeThickness = TmpPolyline.Epaisseur;
                    User.Liste.Add(TmpPolyline);
                    map.Children.Remove(PolylineTpm);
                    PolylineTpm.Stroke = new System.Windows.Media.SolidColorBrush(TmpPolyline.Couleur);
                    map.Children.Add(PolylineTpm);

                    PolylineTpm = null;
                    ListeTmp    = null;
                }
                StatBar.Text = "Polyline added"; //Affichage dans la StatusBar
            }

            if (Polygone_Box.IsSelected == true)
            {
                if (ListeTmp == null)
                {
                    ListeTmp   = new List <Coordonnees>();
                    PolygonTpm = new MapPolygon
                    {
                        Fill            = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightBlue),
                        Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue),
                        StrokeThickness = 3,
                        Opacity         = 0.6,
                        Locations       = new LocationCollection()
                    };
                    map.Children.Add(PolygonTpm);
                }

                ListeTmp.Add(new Coordonnees(pinLocation.Latitude, pinLocation.Longitude));

                PolygonTpm.Locations.Add(new Location(pinLocation.Latitude, pinLocation.Longitude));

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    Polygon TmpPolygon = new Polygon
                    {
                        Coordonnees = ListeTmp
                    };
                    OptPolygon text = new OptPolygon(TmpPolygon);
                    text.ShowDialog(); //bloque la page

                    //Ajoute à la liste
                    User.Liste.Add(TmpPolygon);
                    map.Children.Remove(PolygonTpm);
                    PolygonTpm.Fill    = new System.Windows.Media.SolidColorBrush(TmpPolygon.CouleurRemplissage);
                    PolygonTpm.Stroke  = new System.Windows.Media.SolidColorBrush(TmpPolygon.CouleurContour);
                    PolygonTpm.Opacity = TmpPolygon.Opacite;
                    map.Children.Add(PolygonTpm);

                    PolygonTpm = null;
                    ListeTmp   = null;
                }
                StatBar.Text = "Polygon added"; //Affichage dans la StatusBar
            }
        }