private void CreateNewLocation(Type_Emplacement type, int x = 30, int y = 30) { LoginTools.CheckConnection(); Emplacement newLocation = new Emplacement(); _db.Emplacement.Add(newLocation); newLocation.Taille_X = 10; newLocation.Taille_Y = 10; int i = _locationsList.Count; while (_db.Emplacement.Any(a => a.Nom_Emplacement.Equals("Emplacement " + i))) { i++; } foreach (GraphicLocation graphicLocation in _locationsList) { if (graphicLocation.Location.Nom_Emplacement.Equals("Emplacement " + i)) { i++; } } newLocation.Nom_Emplacement = "Emplacement " + i; newLocation.Type_Emplacement = type; GraphicLocation newGraphicLocation = new GraphicLocation(newLocation); newGraphicLocation.Move(new Point(x, y), pictureBox); _locationsList.Add(newGraphicLocation); SelectedLocation = newGraphicLocation; Refresh(); }
public void MoveTest() { var e1 = new PT_Camping.Model.Emplacement { Nom_Emplacement = "e1", Cordonnee_X = 5, Coordonnee_Y = 5 }; var graphicLocation = new GraphicLocation(e1); //Check position before Assert.AreEqual(graphicLocation.Location.Cordonnee_X, 5); Assert.AreEqual(graphicLocation.Location.Coordonnee_Y, 5); PictureBox pb = new PictureBox { Width = 100, Height = 100 }; graphicLocation.Move(new System.Drawing.PointF( (float)(graphicLocation.Location.Cordonnee_X + 10), (float)(graphicLocation.Location.Coordonnee_Y + 25)), pb); //Check position after Assert.AreEqual(graphicLocation.Location.Cordonnee_X, 15); Assert.AreEqual(graphicLocation.Location.Coordonnee_Y, 30); }