예제 #1
0
        public WallEntity WallToEntity(Wall toConvert, BlueprintEntity bearer)
        {
            WallEntity conversion = new WallEntity()
            {
                BeginningX      = toConvert.Beginning().CoordX,
                BeginningY      = toConvert.Beginning().CoordY,
                EndX            = toConvert.End().CoordX,
                EndY            = toConvert.End().CoordY,
                Height          = toConvert.Height(),
                Width           = toConvert.Width(),
                BearerBlueprint = bearer
            };

            return(conversion);
        }
        private void PaintOpenings()
        {
            drawer.CreateOrRecreateLayer(ref drawer.layers.openingLayer);
            ICollection <Opening> openings = selectedBluePrint.GetOpenings();

            foreach (Opening opening in openings.Where(x => x.GetComponentType() == ComponentType.DOOR))
            {
                Wall wall = selectedBluePrint.GetWalls().First(x => x.DoesContainPoint(opening.GetPosition()));
                if (wall.Beginning().CoordX == wall.End().CoordX)
                {
                    drawer.PaintVerticalDoor(opening);
                }
                else
                {
                    drawer.PaintHorizontalDoor(opening);
                }
            }
            foreach (Opening opening in openings.Where(x => x.GetComponentType() == ComponentType.WINDOW))
            {
                Wall wall = selectedBluePrint.GetWalls().First(x => x.DoesContainPoint(opening.GetPosition()));
                if (wall.Beginning().CoordX == wall.End().CoordX)
                {
                    drawer.PaintVerticalWindow(opening);
                }
                else
                {
                    drawer.PaintHorizontalWindow(opening);
                }
            }
            drawer.drawSurface.Invalidate();
        }
예제 #3
0
        public void GetBeginningTest()
        {
            int   expectedXResult = 0;
            int   expectedYResult = 0;
            Point actualResult    = instance.Beginning();

            Assert.IsTrue((actualResult.CoordX == expectedXResult) && (actualResult.CoordY == expectedYResult));
        }
예제 #4
0
        public void ConstructorSortedPointsTest()
        {
            Wall testWall    = new Wall(new Point(3, 2), new Point(1, 1));
            bool beginningOk = testWall.Beginning().Equals(new Point(1, 1));
            bool endOk       = testWall.End().Equals(new Point(3, 2));

            Assert.IsTrue(beginningOk && endOk);
        }
        //Erase events
        private void drawSurface_MouseClickErase(object sender, MouseEventArgs e)
        {
            System.Drawing.Point point = drawer.AdjustPointToGrid(drawer.drawSurface.PointToClient(Cursor.Position));
            Logic.Domain.Point   deletionPointPrecise = drawer.pointConverter.DrawablePointIntoLogicPoint(point);
            Logic.Domain.Point   closestDeletionPointToGridIntersection = drawer.pointConverter.DrawablePointIntoLogicPoint(drawer.AdjustPointToGridIntersection(point));

            try
            {
                bool existOpeningInPoint = selectedBluePrint.GetOpenings().Any(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection));
                bool existWallInPoint    = selectedBluePrint.GetWalls().Any(x => x.DoesContainPoint(deletionPointPrecise));
                bool existColumnInPoint  = selectedBluePrint.GetColumns().Any(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection));
                if (existOpeningInPoint)
                {
                    Opening openingToRemove = selectedBluePrint.GetOpenings().FirstOrDefault(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection));
                    editor.RemoveOpening(openingToRemove);
                }
                else if (existWallInPoint && !existOpeningInPoint)
                {
                    Wall wallToDelete = selectedBluePrint.GetWalls().First(x => x.DoesContainPoint(deletionPointPrecise));
                    editor.RemoveWall(wallToDelete.Beginning(), wallToDelete.End());
                }
                else if (existColumnInPoint)
                {
                    editor.RemoveColumn(closestDeletionPointToGridIntersection);
                }
            }
            catch (Exception)
            {
                //error message
            }

            PaintWalls();
            PaintBeams();
            PaintOpenings();
            PaintColumns();
            calulateCostsAndPrices();
        }
 private void PaintWall(Wall wall)
 {
     using (Graphics graphics = Graphics.FromImage(wallsLayer)) {
         graphics.DrawLine(wallPen, LogicPointIntoDrawablePoint(wall.Beginning()), LogicPointIntoDrawablePoint(wall.End()));
     }
 }
 public void PaintWall(Wall wall)
 {
     using (Graphics graphics = Graphics.FromImage(layers.wallsLayer))
     {
         graphics.DrawLine(pencilcase.WallPen, pointConverter.LogicPointIntoDrawablePoint(wall.Beginning()), pointConverter.LogicPointIntoDrawablePoint(wall.End()));
     }
 }