Exemple #1
0
        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();
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public void ResizeTest()
        {
            var e1 = new PT_Camping.Model.Emplacement
            {
                Nom_Emplacement = "e1",
                Cordonnee_X     = 5,
                Coordonnee_Y    = 5,
                Taille_X        = 50,
                Taille_Y        = 50
            };
            var graphicLocation = new GraphicLocation(e1);


            //Check position before
            Assert.AreEqual(graphicLocation.Location.Taille_X, 50);
            Assert.AreEqual(graphicLocation.Location.Taille_Y, 50);

            PictureBox pb = new PictureBox
            {
                Width  = 100,
                Height = 50
            };

            graphicLocation.Resize(new System.Drawing.SizeF(15, 10), pb);

            //Check position after
            Assert.AreEqual(graphicLocation.Location.Taille_X, 15);
            Assert.AreEqual(graphicLocation.Location.Taille_Y, 20); //picture box height is half sized
        }
Exemple #4
0
        public void InstanceTest()
        {
            var e1 = new PT_Camping.Model.Emplacement {
                Nom_Emplacement = "e1"
            };
            var graphicLocation = new GraphicLocation(e1);

            Assert.AreEqual(e1, graphicLocation.Location);
            Assert.IsFalse(graphicLocation.Booked);
        }