예제 #1
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
            }
        }
예제 #3
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
            }
        }
예제 #4
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;
 }
예제 #5
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
                }
            }
        }