public override void Draw(Graphics graphics, RectangleInt region)
        {
            this.region = region;

            graphics.FillRectangle(GetBrush(node), region.ToDrawingRect());
            graphics.DrawRectangle(GetPen(node), region.ToDrawingRect());

            // Draw path to parent
            if (node.TreeNode.Parent != null)
            {
                RootPathElement parent = owner[node.TreeNode.Parent.Data];
                if (parent != null)
                {
                    if (onPath)
                    {
                        graphics.DrawLine(new Pen(Color.Black, 3f), region.TopMiddle.ToPoint(), owner.GetDrawRegion(parent).BottomMiddle.ToPoint());
                    }
                    else
                    {
                        graphics.DrawLine(new Pen(Color.LightGray), region.TopMiddle.ToPoint(), owner.GetDrawRegion(parent).BottomMiddle.ToPoint() );
                    }
                }
            }

            if (owner.Selected == this)
            {
                graphics.DrawRectangle(new Pen(Color.Yellow, 2f), region.ToDrawingRect());
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Strong Construction
 /// </summary>
 /// <param name="aGameUI"></param>
 public GameCoords(GameUI aGameUI)
 {
     GameUI = aGameUI;
     GlobalOffset = new VectorInt(10, 30);
     GlobalTileSize = new SizeInt(16, 16);
     windowRegion =  new RectangleInt(new VectorInt(0, 0), new SizeInt(400, 300));
 }
        public NodeListVisualisation(List<SolverNode> nodes, SizeInt cellSize)
        {
            this.nodes = nodes;
            this.cellSize = cellSize;

            int maxH = ((nodes.Count + 1)/maxCellWidth)*cellSize.Height;
            renderCanvas = new RectangleInt(0,0, cellSize.Width*maxCellWidth, maxH);
            windowRegion = renderCanvas;
        }
        /// <summary>
        /// Strong COnstructoin
        /// </summary>
        /// <param name="sourceTree"></param>
        public TreeVisualisation(Tree<SolverNode> sourceTree, RectangleInt renderSize, SizeInt cellSize)
        {
            // this.controller = controller;
            this.tree = sourceTree;

            // Calculate the render size
            RenderCanvas = renderSize;
            CellSize = cellSize;
        }
        /// <summary>
        /// Strong constructor
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="cellSize"></param>
        public NodeListVisualisation(SolverController controller, List<SolverNode> nodes, SizeInt cellSize)
        {
            Display = new CommonDisplay(controller);
            this.nodes = nodes;
            this.cellSize = cellSize;

            int maxH = ((nodes.Count + 1)/maxCellWidth+1)*cellSize.Height;
            renderCanvas = new RectangleInt(0,0, cellSize.Width*maxCellWidth, maxH);
            windowRegion = renderCanvas;
        }
        public override void Draw(Graphics graphics, RectangleInt region)
        {
            this.region = region;

            graphics.FillEllipse(owner.Display.GetBrush(node.TreeNode), region.ToDrawingRect());
            graphics.DrawEllipse(owner.Display.GetPen(node.TreeNode), region.ToDrawingRect());

            // Draw path to parent
            if (node.TreeNode.Parent != null)
            {
                RootPathElement parent = owner[node.TreeNode.Parent.Data];
                if (parent != null)
                {
                    if (onPath)
                    {
                        graphics.DrawLine(new Pen(Color.Black, 2f), region.TopMiddle.ToDrawingPoint(),
                                          owner.GetDrawRegion(parent).BottomMiddle.ToDrawingPoint());
                    }
                    else
                    {
                        graphics.DrawLine(new Pen(Color.Black), region.TopMiddle.ToDrawingPoint(),
                                          owner.GetDrawRegion(parent).BottomMiddle.ToDrawingPoint());
                    }
                }
            }

            if (owner.Selected == this)
            {
                graphics.DrawRectangle(new Pen(Color.Yellow, 2f), region.ToDrawingRect());
            }

            // ID and Weighting text
            graphics.DrawString(node.Weighting.ToString("0"), font, brushShaddow, region.TopLeft.Add(1, 1).ToDrawingPoint());
            graphics.DrawString(node.Weighting.ToString("0"), font, brush, region.TopLeft.ToDrawingPoint());

            if (false)
            {
                // Show ID below
                graphics.DrawString(node.NodeID, font, brushShaddow, region.TopLeft.X + 1, region.TopLeft.Y + 9);
                graphics.DrawString(node.NodeID, font, brush, region.TopLeft.X, region.TopLeft.Y + 8);
            }
        }
Esempio n. 7
0
 public abstract void Draw(Graphics graphics, RectangleInt region);
        public override void Draw(Graphics graphics, RectangleInt region)
        {
            graphics.FillRectangle(owner.Display.GetBrush(node.TreeNode), region.ToDrawingRect());
            graphics.DrawRectangle(owner.Display.GetPen(node.TreeNode), region.ToDrawingRect());

            if (owner.Selected == this)
            {
                graphics.DrawRectangle(new Pen(Color.Yellow, 2f), region.ToDrawingRect());
            }
        }
Esempio n. 9
0
 private static void DrawBitmapCentered(Graphics Graphics, RectangleInt Target, Image image)
 {
     VectorInt pos = Target.Center.Subtract(image.Width/2, image.Height/2);
     Graphics.DrawImage(image, pos.X, pos.Y);
 }
Esempio n. 10
0
        public override void Render()
        {
            if (imageBack != null)
            {
                VectorInt pos = CurrentRect.Center.Subtract(imageBack.Width / 2 + 2, imageBack.Height / 2 + 2);
                GameUI.Graphics.DrawImage(imageBack, pos.X, pos.Y);
            }

            if (imageNormal != null)
            {
                DrawBitmapCentered(GameUI.Graphics, CurrentRect, imageNormal);
            }

            if (isMouseOver)
            {
                if (mouseOverBrush != null)
                {
                    RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(1, 1), CurrentRect.BottomRight.Add(1, 1));
                    GameUI.Graphics.FillEllipse(mouseOverBrush, over.ToDrawingRect());
                }

                if (toolTip != null)
                {
                    Font ttFont = new Font("Arial", 10f);
                    SizeF ffSizeF = GameUI.Graphics.MeasureString(toolTip, ttFont);
                    SizeInt ffSize = new SizeInt((int) ffSizeF.Width, (int) ffSizeF.Height);

                    RectangleInt posTT = new RectangleInt(CurrentRect.BottomLeft.Subtract(ffSize.Width/2, -5 ), ffSize);

                    if (posTT.TopLeft.X < GameUI.GameCoords.WindowRegion.TopLeft.X)
                        posTT.TopLeft.X = GameUI.GameCoords.WindowRegion.TopLeft.X;
                    if (posTT.TopLeft.Y < GameUI.GameCoords.WindowRegion.TopLeft.Y)
                        posTT.TopLeft.Y = GameUI.GameCoords.WindowRegion.TopLeft.Y;

                    if (posTT.BottomRight.X > GameUI.GameCoords.WindowRegion.BottomRight.X)
                        posTT.BottomRight.X = GameUI.GameCoords.WindowRegion.BottomRight.X;
                    if (posTT.BottomRight.Y < GameUI.GameCoords.WindowRegion.BottomRight.Y)
                        posTT.BottomRight.Y = GameUI.GameCoords.WindowRegion.BottomRight.Y;

                    Brush ttBrush = new SolidBrush(Color.Cyan);
                    Brush ttBrushShadow = new SolidBrush(Color.DarkCyan);

                    NodeEffectText nodeTT = new NodeEffectText(GameUI, 10000, toolTip, ttFont, ttBrush, ttBrushShadow, posTT.TopLeft);
                    nodeTT.BrushBackGround = new SolidBrush(Color.DarkSlateGray);
                    nodeTT.Path = new Paths.StaticPath(posTT.TopLeft, 1);
                    GameUI.Add(nodeTT);
                }
            }

            if (maskEffect != null)
            {
                RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(5, 5), CurrentRect.BottomRight.Add(10, 10));
                GameUI.Graphics.FillEllipse(maskEffect, over.ToDrawingRect());
            }
        }
        public override void Draw(Graphics graphics, RectangleInt region)
        {
            int slice = owner.CellSize.Width;

            List<BitmapViewer.Layer> slices = GetTrueValues();
            if (slices != null && slices.Count > 0)
            {
                slice = owner.CellSize.Width / slices.Count;
            }

            foreach (BitmapViewer.Layer current in owner.DrawLayers)
            {
                if (!current.IsVisible) continue;

                if (current.Bitmap != null)
                {
                    if (slices.Contains(current))
                    {
                        if (current.Map != null)
                        {
                            Image tile = DrawingHelper.Images.GetImage(current.Map[logicalPosition]);
                            graphics.DrawImage(tile, region.ToDrawingRect());
                        }
                        else if (current.CellImage != null)
                        {
                            graphics.DrawImage(current.CellImage, region.ToDrawingRect());
                        }
                        else
                        {
                            //Bitmap
                            int idx = slices.IndexOf(current);
                            graphics.FillRectangle(current.Brush, region.TopLeft.X + idx*slice, region.TopLeft.Y, slice, region.Height);
                        }
                    }
                }
                else
                {
                    if (current.Map != null)
                    {
                        Image tile = DrawingHelper.Images.GetImage(current.Map[logicalPosition]);
                        graphics.DrawImage(tile, region.ToDrawingRect());
                    }
                }

            }

            if (this == owner.Selected)
            {
                // Draw Selected cursor
                graphics.DrawRectangle(new Pen(Color.Yellow, 3f), region.TopLeft.X - 2, region.TopLeft.Y - 2, region.Size.Width + 4, region.Size.Height + 4);
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Fill a box, not the insides with a CellState
 /// </summary>
 /// <param name="R"></param>
 /// <param name="C"></param>
 public void FillBox(RectangleInt R, CellStates C)
 {
     for (int px = R.TopLeft.X; px <= R.BottomRight.X; px++)
         for (int py = R.TopLeft.Y; py <= R.BottomRight.Y; py++)
         {
             if (px == R.TopLeft.X || py == R.TopLeft.Y || px == R.BottomRight.X || py == R.BottomRight.Y)
             {
                 this[new VectorInt(px, py)] = C;
             }
         }
 }
Esempio n. 13
0
        /// <summary>
        /// Moving in each direction try to find another non-goal corner
        /// </summary>
        private void CheckRecessFromCorner(StaticAnalysis staticAnalysis,  List<Recess> outRecesses, Bitmap outRecessMap, VectorInt CheckPos, Direction CheckDirection)
        {
            RectangleInt region = new RectangleInt(new VectorInt(0, 0), outRecessMap.Size.Subtract(1, 1));
            VectorInt pos = CheckPos;

            Direction sideA;
            Direction sideB;
            // Check Recess wall side
            if (CheckDirection == Direction.Up || CheckDirection == Direction.Down)
            {
                sideA = Direction.Left;
                sideB = Direction.Right;
            }
            else
            {
                sideA = Direction.Up;
                sideB = Direction.Down;
            }

            bool hasSideA = true;
            bool hasSideB = true;

            // Try to find another corner with SideA or SideB
            while (region.Contains(pos))
            {
                // Check Fail

                if (staticAnalysis.WallMap[pos]) return; // Wall in way- Fail

                if (hasSideA)
                {
                    if (!staticAnalysis.WallMap[pos.Offset(sideA)]) hasSideA = false;
                }

                if (hasSideB)
                {
                    if (!staticAnalysis.WallMap[pos.Offset(sideB)]) hasSideB = false;
                }

                if (!hasSideA && !hasSideB) return;

                // Check success
                // Don't check the first time
                if (pos != CheckPos)
                {
                    if (staticAnalysis.CornerMap[pos])
                    {
                        Recess newRecess = new Recess("Recess #"+(outRecesses.Count+1).ToString(), outRecessMap.Size);
                        outRecesses.Add(newRecess);
                        // Winner
                        // Mark all in path as corner
                        VectorInt setTrue = CheckPos;
                        while (setTrue != pos)
                        {
                            // Individual
                            newRecess[setTrue] = true;
                            // Master (all recesses)
                            outRecessMap[setTrue] = true;

                            // Next
                            setTrue = setTrue.Offset(CheckDirection);
                        }

                        // Do the final node
                        newRecess[pos] = true;
                        outRecessMap[pos] = true;

                        newRecess.GoalCount = newRecess.BitwiseAND(staticAnalysis.GoalMap).Count;
                        return;
                    }
                }

                // Next
                pos = pos.Offset(CheckDirection);
            }
        }