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());
            }
        }
        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);
            }
        }
        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());
            }
        }
예제 #4
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);
            }
        }