Ejemplo n.º 1
0
 //Fonction pour sauvegarder le profil
 private void Save_Button(object sender, RoutedEventArgs e)
 {
     try
     {
         User.Save();
         StatBar.Text = "User " + User.Nom + " " + User.Prenom + " is saved"; //Affichage dans la StatusBar
     }
     catch (Exception)                                                        //"An error occurred while saving the profile"
     {
         ErrorWindow error = new ErrorWindow("The profile could not be loaded");
         error.ShowDialog(); //bloque la page
     }
 }
Ejemplo n.º 2
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.º 3
0
 //Fonction pour exporter les POI d'un ficher .CSV
 private void POI_Export_Button(object sender, RoutedEventArgs e)
 {
     if (ListeCoo.SelectedItem is POI poi)
     {
         using (StreamWriter sw = new StreamWriter(User.Path + poi.Description + ".csv"))
         {
             sw.WriteLine(poi.Latitude.ToString() + ";" + poi.Longitude.ToString() + ";" + poi.Description);
         }
         StatBar.Text = "POI exported"; //Affichage dans la StatusBar
     }
     else
     {
         ErrorWindow error = new ErrorWindow("The file could not be export");
         error.ShowDialog(); //bloque la page
     }
 }
Ejemplo n.º 4
0
        //Fonction pour importer les POI d'un ficher .CSV
        private void POI_Import_Button(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter           = "csv files (*.csv)|*.csv"
            };

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    using (StreamReader sr = new StreamReader(openFileDialog.FileName))
                    {
                        string   line = sr.ReadLine();
                        string[] list = Regex.Split(line, @";+");

                        Pushpin  pin         = new Pushpin();
                        Location pinLocation = new Location();

                        POI TmpPoi = new POI(Convert.ToDouble(list[0]), Convert.ToDouble(list[1]), list[2]);

                        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 imported"; //Affichage dans la StatusBar
                    }
                }
                catch (Exception)
                {
                    ErrorWindow error = new ErrorWindow("The file could not be read");
                    error.ShowDialog(); //bloque la page
                }
            }
        }
        private void OK_Button(object sender, RoutedEventArgs e)
        {
            MyPersonalMapData tmpUser = new MyPersonalMapData(lastName.Text, firstName.Text);

            try
            {
                tmpUser.Load(); //Test s'il existe

                User.Nom    = lastName.Text;
                User.Prenom = firstName.Text;
                User.Load();
                this.Close();
            }
            catch (Exception)
            {
                Window error = new ErrorWindow("An error occurred while loading the profile");
                error.ShowDialog(); //bloque la page
            }
        }
Ejemplo n.º 6
0
        //Fonction pour exporter les Polygons d'un ficher .CSV
        private void Polygon_Export_Button(object sender, RoutedEventArgs e)
        {
            if (ListeCoo.SelectedItem is Polygon poly)
            {
                using (StreamWriter sw = new StreamWriter(User.Path + poly.Description + ".csv"))
                {
                    foreach (Coordonnees coo in poly.Coordonnees)
                    {
                        sw.WriteLine(coo.Latitude.ToString() + ";" + coo.Longitude.ToString() + ";");
                    }
                }

                StatBar.Text = "Polygon exported"; //Affichage dans la StatusBar
            }
            else
            {
                ErrorWindow error = new ErrorWindow("The file could not be export");
                error.ShowDialog(); //bloque la page
            }
        }
Ejemplo n.º 7
0
 //ce centrer sur l'objet selectionné
 private void ListeCoo_DoubleClick(object sender, MouseButtonEventArgs e)
 {
     StatBar.Text = ListeCoo.SelectedItem.ToString(); //Affichage dans la StatusBar
     if (ListeCoo.SelectedItem is POI poi)
     {
         map.Center = new Location(poi.Latitude, poi.Longitude);
     }
     else if (ListeCoo.SelectedItem is Polyline polyl)
     {
         map.Center = new Location(polyl.Coordonnees[0].Latitude, polyl.Coordonnees[0].Longitude);
     }
     else if (ListeCoo.SelectedItem is Polygon polyg)
     {
         map.Center = new Location(polyg.Coordonnees[0].Latitude, polyg.Coordonnees[0].Longitude);
     }
     else
     {
         ErrorWindow error = new ErrorWindow("An error has occurred");
         error.ShowDialog(); //bloque la page
     }
     map.ZoomLevel = 6;
 }
Ejemplo n.º 8
0
        //Fonction pour importer les Polygons d'un ficher .CSV
        private void Polygon_Import_Button(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter           = "csv files (*.csv)|*.csv"
            };

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    using (StreamReader sr = new StreamReader(openFileDialog.FileName))
                    {
                        string line = "";

                        while ((line = sr.ReadLine()) != null)
                        {
                            string[] list = Regex.Split(line, @";+");
                            //C'est que c'est un POI donc ajout du POI
                            if (list[2] != String.Empty)
                            {
                                Pushpin  pin         = new Pushpin();
                                Location pinLocation = new Location();

                                POI TmpPoi = new POI(Convert.ToDouble(list[0]), Convert.ToDouble(list[1]), list[2]);

                                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);
                            }

                            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()
                                };
                            }
                            ListeTmp.Add(new Coordonnees(Convert.ToDouble(list[0]), Convert.ToDouble(list[1])));

                            PolygonTpm.Locations.Add(new Location(Convert.ToDouble(list[0]), Convert.ToDouble(list[1])));
                        }

                        Polygon TmpPolygon = new Polygon
                        {
                            Coordonnees = ListeTmp
                        };
                        TmpPolygon.Description = openFileDialog.SafeFileName;

                        //Ajoute à la liste
                        User.Liste.Add(TmpPolygon);
                        map.Children.Add(PolygonTpm);

                        PolygonTpm = null;
                        ListeTmp   = null;
                    }
                    StatBar.Text = "Path imported"; //Affichage dans la StatusBar
                }
                catch (Exception)
                {
                    ErrorWindow error = new ErrorWindow("The file could not be read");
                    error.ShowDialog(); //bloque la page
                }
            }
        }