public MainWindow(string Nom, string Prenom, string Mail) { currentUser.Nom = Nom; currentUser.Prenom = Prenom; currentUser.Mail = Mail; currentUser.Load(""); foreach (ICartoObj obj in currentUser.OcICartoObj) { if (obj is POI) { temppoi = obj as POI; Pushpin newPin = new Pushpin(); newPin.Location = new Location(temppoi.Latitude, temppoi.Longitude); bingmap.Children.Add(newPin); } if (obj is Polyline) { temppl = obj as Polyline; MapPolyline newMPL = new MapPolyline(); newMPL.Stroke = new SolidColorBrush(temppl.Couleur); newMPL.StrokeThickness = temppl.Epaisseur; newMPL.Opacity = 1; newMPL.Locations = new LocationCollection(); foreach (Coordonnees cd in temppl.ListeCoord) { newMPL.Locations.Add(new Location(cd.Latitude, cd.Longitude)); } bingmap.Children.Add(newMPL); } if (obj is Polygon) { temppg = obj as Polygon; MapPolygon newMPG = new MapPolygon(); newMPG.Fill = new SolidColorBrush(temppg.Remplissage); newMPG.Stroke = new SolidColorBrush(temppg.Contour); newMPG.Opacity = temppg.Opacite; newMPG.Locations = new LocationCollection(); foreach (Coordonnees cd in temppg.ListeCoord) { newMPG.Locations.Add(new Location(cd.Latitude, cd.Longitude)); } bingmap.Children.Add(newMPG); } } InitializeComponent(); //MessageBox.Show(currentUser.ToString()); lb_objects.ItemsSource = currentUser.OcICartoObj; }
private void Open_Click(object sender, RoutedEventArgs e) { if (_user.ObservableCollection == null || _user.ObservableCollection.Count < 1) { MessageBox.Show("la liste est vide,rien à charger"); } else { MessageBox.Show("Vos données ont été chargé avec succès"); _user.Load(); foreach (ICartoObj item in _user.ObservableCollection) { if (item is Polyline) { ListBox1.Items.Add("Polyline:"); ListBox1.Items.Add(item); //On ajoute polyline dans la listbox } else if (item is Polygone) { Console.WriteLine("Polygone: \n"); ListBox1.Items.Add(item); } else if (item is POI) { ListBox1.Items.Add(item); } } } }
private void SeConnecter_Click(object sender, RoutedEventArgs e) { MyPersonalMapData temp = new MyPersonalMapData(); if (temp.Load(Prenom, Nom)) { TextBoxInfo.Text = "Ce compte n'existe pas!"; return; } ((MainWindow)Owner).myPersonalMapData = temp; Close(); }
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 } }
static void Main(string[] args) { /*List<CartoObj> list = new List<CartoObj> { }; * POI poi1 = new POI(); * POI poi2 = new POI(); * Polyline polyline1 = new Polyline(); * Polyline polyline2 = new Polyline(); * Polygon polygon1 = new Polygon(); * Polygon polygon2 = new Polygon(); * * list.Add(poi1); * list.Add(poi2); * list.Add(polyline1); * list.Add(polyline2); * list.Add(polygon1); * list.Add(polygon2); * * Console.WriteLine("Afficher cette liste en utilisant le mot clé foreach"); * foreach(CartoObj c in list) * { * c.Draw(); * } * * Console.WriteLine("\nAfficher la liste des objets implémentant l’interface IPointy"); * foreach(CartoObj c in list) * { * if(c is IPointy) * { * c.Draw(); * } * } * * Console.WriteLine("\nAfficher la liste des objets n’implémentant pas l’interface IPointy"); * foreach(CartoObj c in list) * { * if(!(c is IPointy)) * { * c.Draw(); * } * } * * Console.WriteLine("\nCréer une liste générique de 5 Polyline, l’afficher"); * List<Polyline> listePoli = new List<Polyline> { }; * listePoli.Add(new Polyline(new List<Coordonnees>{new Coordonnees(0,0),new Coordonnees(1,1) },Colors.Black,0)); * listePoli.Add(new Polyline(new List<Coordonnees>{new Coordonnees(0,0),new Coordonnees(4,5) },Colors.Black,0)); * listePoli.Add(new Polyline(new List<Coordonnees>{new Coordonnees(0,0),new Coordonnees(1,1) },Colors.Black,0)); * listePoli.Add(new Polyline(new List<Coordonnees>{new Coordonnees(0,0),new Coordonnees(10,-1) },Colors.Black,0)); * listePoli.Add(new Polyline(new List<Coordonnees>{new Coordonnees(0,0),new Coordonnees(0,10) },Colors.Black,0)); * * foreach(Polyline p in listePoli) * { * p.Draw(); * } * * Console.WriteLine("\nla trier par ordre de longueur croissante"); * listePoli.Sort(); * * Console.WriteLine("\nl’afficher à nouveau"); * foreach (Polyline p in listePoli) * { * p.Draw(); * } * * Console.WriteLine("\ntrier la liste par ordre croissant de taille de surface de la bounding box englobant la polyline"); * MyPolylineBoundingBoxComparer triSurface = new MyPolylineBoundingBoxComparer(); * listePoli.Sort(triSurface); * foreach (Polyline p in listePoli) * { * p.Draw(); * } * * Console.WriteLine("\nRechercher, parmi les polyline de la liste, celles qui présentent la même taille qu’une polyline de référence"); * Polyline polyline3 = new Polyline(new List<Coordonnees> { new Coordonnees(0, 0), new Coordonnees(1, 1) }, Colors.Black, 0); * Console.WriteLine("Find : {0}", listePoli.Find(x => x.longeur().Equals(polyline3.longeur()))); * * Console.WriteLine("\nRechercher, parmi les polyline de la liste, celles qui sont proches d’un point passé en paramètre"); * Coordonnees coordonnees1 = new Coordonnees(0, 2); * Console.WriteLine("Coordonnees1: " + coordonnees1 + " Precision: 0.5"); * foreach(Polyline p in listePoli) * { * if(p.IsPointClose(coordonnees1,0.5)) * { * Console.WriteLine("Le point " + coordonnees1 + " est proche de la listePoli!"); * } * else * { * Console.WriteLine("Le point " + coordonnees1 + " n'est pas proche de la listePoli!"); * } * } * Coordonnees coordonnees2 = new Coordonnees(0, 0); * Console.WriteLine("Coordonnees1: " + coordonnees2 + " Precision: 1"); * foreach (Polyline p in listePoli) * { * if (p.IsPointClose(coordonnees2, 1)) * { * Console.WriteLine("Le point " + coordonnees2 + " est proche de la listePoli!"); * } * else * { * Console.WriteLine("Le point " + coordonnees2 + " n'est pas proche de la listePoli!"); * } * } * * Console.WriteLine("\nMettre en place et tester un mécanisme qui permet de classer une liste d’objets CartoObj sur base du nombre d’objets Coordonnees qui le compose via un …Comparer."); * MyNbCoordonneesComparer triNbCoordonnees = new MyNbCoordonneesComparer(); * List < CartoObj > list1 = new List<CartoObj> { }; * list1.Add(new Polyline(new List<Coordonnees> { new Coordonnees(0, 0), new Coordonnees(1, 1),new Coordonnees(2,2) }, Colors.Black, 1)); * list1.Add(new Polyline(new List<Coordonnees> {new Coordonnees(0,0)},Colors.Black,1)); * list1.Add(new Polyline(new List<Coordonnees> {new Coordonnees(0,0),new Coordonnees(1,1)},Colors.Black,1)); * Console.WriteLine("Voici la liste:"); * foreach(CartoObj c in list1) * { * if(c is Polyline) * { * Polyline p1 = c as Polyline; * p1.Draw(); * } * if(c is Polygon) * { * Polygon p1 = c as Polygon; * p1.Draw(); * } * } * * list1.Sort(triNbCoordonnees); * * Console.WriteLine("Voici la liste triee:"); * foreach (CartoObj c in list1) * { * if (c is Polyline) * { * Polyline p1 = c as Polyline; * p1.Draw(); * } * if (c is Polygon) * { * Polygon p1 = c as Polygon; * p1.Draw(); * } * }*/ //Tester MyPersonalMapData /*MyPersonalMapData mapData = new MyPersonalMapData("Gerard","Vincent","*****@*****.**",new ObservableCollection<ICartoObj> { }); * Polyline poly = new Polyline(new List<Coordonnees> { new Coordonnees(0,0),new Coordonnees(1,1)},Colors.Black,1); * Polygon polygon = new Polygon(new List<Coordonnees> { new Coordonnees(3,3)},Colors.Black,Colors.Black,1); * mapData.ObservableCollection.Add(poly); * mapData.ObservableCollection.Add(polygon); * mapData.Draw(); * mapData.Save();*/ MyPersonalMapData mapdata = new MyPersonalMapData(); mapdata.Load("Vincent", "Gerard"); Console.WriteLine(mapdata); foreach (ICartoObj i in mapdata.ObservableCollection) { if (i is POI) { POI p = i as POI; Console.Write("POI: "); Console.WriteLine(p); } if (i is Polyline) { Polyline p = i as Polyline; Console.Write("POLYLINE: "); Console.WriteLine(p); foreach (Coordonnees c in p.Collection) { Console.Write("\t\t -"); Console.WriteLine(c); } } if (i is Polygon) { Polygon p = i as Polygon; Console.Write("POLYGON: "); Console.WriteLine(p); foreach (Coordonnees c in p.Collection) { Console.Write("\t\t-"); Console.WriteLine(c); } } } Console.ReadLine(); }
static void Main(string[] args) { #region DECLARATION Coordonnees c = new Coordonnees(150, 120); Coordonnees cDef = new Coordonnees(); POI poi = new POI(125, 38, "Test"); POI poiDef = new POI(); List <Coordonnees> maliste = new List <Coordonnees>(); { maliste.Add(c); maliste.Add(cDef); } Polyline pl = new Polyline(maliste, Color.FromRgb(255, 0, 0), 17); Polyline plDef = new Polyline(); Polygon pg = new Polygon("", Colors.Red, Colors.Blue, 0, maliste); Polygon pgDef = new Polygon(); List <CartoObj> listeCO = new List <CartoObj>() { c, cDef, poi, poiDef, pl, plDef, pg, pgDef }; // Polyline List <Coordonnees> listCD2 = new List <Coordonnees>(); { listCD2.Add(new Coordonnees(6, 9)); listCD2.Add(new Coordonnees(7, 2)); } List <Coordonnees> listCD4 = new List <Coordonnees>(); { listCD4.Add(new Coordonnees(8, 4)); listCD4.Add(new Coordonnees(3, 0)); listCD4.Add(new Coordonnees(2, 9)); } List <Coordonnees> listCD5 = new List <Coordonnees>(); { listCD5.Add(new Coordonnees(8, 3)); listCD5.Add(new Coordonnees(3, 3)); listCD5.Add(new Coordonnees(5, 7)); } Polyline pl1 = new Polyline(); Polyline pl2 = new Polyline(listCD2, Colors.Aqua, 5); Polyline pl3 = new Polyline(); Polyline pl4 = new Polyline(listCD4, Colors.Red, 7); Polyline pl5 = new Polyline(listCD5, Colors.Green, 9); List <Polyline> listePL = new List <Polyline>() { pl1, pl2, pl3, pl4, pl5 }; MyPersonalMapData mdataDef = new MyPersonalMapData(); mdataDef.OcICartoObj.Add(poiDef); // plante mdataDef.OcICartoObj.Add(pgDef); mdataDef.OcICartoObj.Add(plDef); Polygon prout = new Polygon("", Colors.RosyBrown, Colors.Teal, 15, listCD4); ObservableCollection <ICartoObj> OCtest = new ObservableCollection <ICartoObj>(); { OCtest.Add(prout); OCtest.Add(pl2); OCtest.Add(poiDef); } MyPersonalMapData mdata = new MyPersonalMapData("Jooris", "Yannick", "*****@*****.**", OCtest); // test depuis le 15/04 Polyline pl10 = new Polyline(Colors.White, 10); Polyline pl11 = new Polyline(Colors.Blue, 11); #endregion #region TESTS bool exit = false; ConsoleKeyInfo choix; while (!exit) { PrintMenu(); choix = Console.ReadKey(); Console.Clear(); switch (choix.Key) { case ConsoleKey.D1: #region TEST 01 Console.WriteLine("Test Coordonnées: "); Console.WriteLine(c.ToString()); Console.WriteLine(cDef.ToString()); Console.ReadKey(); Console.Clear(); Console.WriteLine("Test POI: "); Console.WriteLine(poi.ToString()); Console.WriteLine(poiDef.ToString()); Console.ReadKey(); Console.Clear(); Console.WriteLine("Test Polyline: "); pl.Draw(); plDef.Draw(); Console.ReadKey(); Console.Clear(); Console.WriteLine("Test Polygon: "); pg.Draw(); pgDef.Draw(); Console.ReadKey(); Console.Clear(); #endregion break; case ConsoleKey.D2: #region TEST 02 Console.WriteLine("Liste générique d'objets CartoObjs: "); foreach (CartoObj co in listeCO) { co.Draw(); } Console.ReadKey(); Console.Clear(); Console.WriteLine("Objets implémentant IPointy: "); foreach (CartoObj co in listeCO) { if (co is IPointy) { Console.WriteLine(co.ToString() + "\n"); } } Console.ReadKey(); Console.Clear(); Console.WriteLine("Objets n'implémentant pas IPointy: "); foreach (CartoObj co in listeCO) { if (!(co is IPointy)) { Console.WriteLine(co.ToString() + "\n"); } } Console.ReadKey(); Console.Clear(); #endregion break; case ConsoleKey.D3: #region TEST 03 Console.WriteLine("Liste générique de 5 objets Polyline: "); foreach (Polyline polyline in listePL) { polyline.Draw(); } Console.ReadKey(); Console.Clear(); Console.WriteLine("Tri par ordre croissant de longueur:"); listePL.Sort(); foreach (Polyline polyline in listePL) { polyline.Draw(); } Console.ReadKey(); Console.Clear(); Console.WriteLine("Tri par ordre croissant de surface:"); MyPolylineBoundingBoxComparer polylineCmp = new MyPolylineBoundingBoxComparer(); listePL.Sort(polylineCmp); foreach (Polyline polyline in listePL) { polyline.Draw(); } Console.ReadKey(); Console.Clear(); #endregion break; case ConsoleKey.D4: #region TEST 04 Console.WriteLine("Comparaison à un Polyline de référence:"); listePL.Add(pl2); foreach (Polyline polyline in listePL.FindAll(cmp => cmp.Equals(pl1))) { Console.WriteLine(polyline.ToString()); } listePL.Remove(pl2); Console.ReadKey(); Console.Clear(); Console.WriteLine("Polylines proches d'un point passé en paramètre:"); foreach (Polyline polyline in listePL) { if (polyline.IsPointClose(5, 5, 2)) { Console.WriteLine(polyline.ToString()); } } Console.ReadKey(); Console.Clear(); #endregion break; case ConsoleKey.D5: #region TEST 05 Console.WriteLine("Mécanisme qui trie une liste de CartoObjs selon le nombre de coordonnées:"); foreach (CartoObj co in listeCO) { Console.WriteLine(co.ToString() + "\n"); } Console.ReadKey(); Console.Clear(); MyNombreCoordonneesComparer ncComparer = new MyNombreCoordonneesComparer(); listeCO.Sort(ncComparer); foreach (CartoObj co in listeCO) { Console.WriteLine(co.ToString() + "\n"); } #endregion break; case ConsoleKey.D6: #region TEST 06 Console.WriteLine("Test d'objets MyPersonalMapData et de leurs méthodes"); Console.WriteLine(mdataDef.ToString() + "\n"); Console.WriteLine(mdata.ToString()); Console.ReadKey(); //Console.Clear(); Console.WriteLine("Test BinaryFormatter (save)"); Console.WriteLine("Saving..."); mdata.Save(@"C:\Users\Yannick\OneDrive\Prog\mapdata.dat"); Console.WriteLine("Done!"); Console.ReadKey(); //Console.Clear(); Console.WriteLine("Test BinaryFormatter (load)"); MyPersonalMapData fromfile = new MyPersonalMapData("Jooris", "Yannick", "3"); Console.WriteLine("Loading..."); fromfile.Load(@"C:\Users\Yannick\OneDrive\Prog\mapdata.dat"); Console.WriteLine("Done!"); Console.WriteLine(fromfile.ToString()); Console.ReadKey(); #endregion break; case ConsoleKey.D7: #region TEST 07 Console.WriteLine("Resultat CompareTo: " + pl10.CompareTo(pl11)); Console.ReadKey(); #endregion break; case ConsoleKey.D8: #region TEST 08 Console.ReadKey(); #endregion break; case ConsoleKey.Escape: exit = true; break; } } #endregion }