示例#1
0
            protected override void Paint(PPaintContext paintContext)
            {
                // make sure grid gets drawn on snap to grid boundaries. And
                // expand a little to make sure that entire view is filled.
                float bx           = (X - (X % gridSpacing)) - gridSpacing;
                float by           = (Y - (Y % gridSpacing)) - gridSpacing;
                float rightBorder  = X + Width + gridSpacing;
                float bottomBorder = Y + Height + gridSpacing;

                XnaGraphics g    = paintContext.Graphics;
                RectangleFx clip = paintContext.LocalClip;

                for (float x = bx; x < rightBorder; x += gridSpacing)
                {
                    gridLine.Reset();
                    gridLine.AddLine(x, by, x, bottomBorder);
                    if (PUtil.RectIntersectsPerpLine(clip, x, by, x, bottomBorder))
                    {
                        g.DrawPath(gridPen, gridLine);
                    }
                }

                for (float y = by; y < bottomBorder; y += gridSpacing)
                {
                    gridLine.Reset();
                    gridLine.AddLine(bx, y, rightBorder, y);
                    if (PUtil.RectIntersectsPerpLine(clip, bx, y, rightBorder, y))
                    {
                        g.DrawPath(gridPen, gridLine);
                    }
                }
            }
            protected override void Paint(PPaintContext paintContext)
            {
                float bx           = X;
                float by           = Y;
                float rightBorder  = bx + Width;
                float bottomBorder = by + Height;

                XnaGraphicsPath line = new XnaGraphicsPath();
                XnaGraphics     g    = paintContext.Graphics;

                System.Drawing.Color penColor = System.Drawing.Color.FromArgb(this.Brush.A, this.Brush.R, this.Brush.G, this.Brush.B);
                System.Drawing.Pen   pen      = new System.Drawing.Pen(penColor, 0);

                // draw vertical lines
                for (float x = bx; x < rightBorder; x += 5)
                {
                    line.Reset();
                    line.AddLine(x, by, x, bottomBorder);
                    g.DrawPath(pen, line);
                }

                for (float y = by; y < bottomBorder; y += 5)
                {
                    line.Reset();
                    line.AddLine(bx, y, rightBorder, y);
                    g.DrawPath(pen, line);
                }
            }
示例#3
0
 /// <summary>
 /// Overridden.  Pops the clip from the paint context and then renders the outline
 /// of this node.
 /// </summary>
 /// <param name="paintContext">
 /// The paint context to use for painting this node.
 /// </param>
 protected override void PaintAfterChildren(PPaintContext paintContext)
 {
     paintContext.PopClip();
     if (Pen != null)
     {
         XnaGraphics g = paintContext.Graphics;
         g.DrawPath(Pen, PathReference);
     }
 }
示例#4
0
        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(PPaintContext paintContext)
        {
            XnaGraphics g = paintContext.Graphics;

            float  x         = X;
            float  y         = Y;
            float  width     = Width;
            float  height    = Height;
            Matrix transform = g.Transform;

            float[] elements = MatrixExtensions.GetElements(transform);
            float   magX     = elements[0];
            float   magY     = elements[3];
            float   dx       = (float)(1.0 / magX);
            float   dy       = (float)(1.0 / magY);

            g.FillRectangle(Brush, Bounds);

            path.Reset();
            path.AddLine((float)(x + width), (float)y, (float)x, (float)y);
            path.AddLine((float)x, (float)y, (float)x, (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(topLeftOuterColor.A, topLeftOuterColor.R, topLeftOuterColor.G, topLeftOuterColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width), (float)(y + dy), (float)(x + dx), (float)(y + dy));
            path.AddLine((float)(x + dx), (float)(y + dy), (float)(x + dx), (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(topLeftInnerColor.A, topLeftInnerColor.R, topLeftInnerColor.G, topLeftInnerColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width), (float)(y), (float)(x + width), (float)(y + height));
            path.AddLine((float)(x + width), (float)(y + height), (float)(x), (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(bottomRightOuterColor.A, bottomRightOuterColor.R, bottomRightOuterColor.G, bottomRightOuterColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width - dx), (float)(y + dy), (float)(x + width - dx), (float)(y + height - dy));
            path.AddLine((float)(x + width - dx), (float)(y + height - dy), (float)(x), (float)(y + height - dy));
            pen.Color = System.Drawing.Color.FromArgb(bottomRightInnerColor.A, bottomRightInnerColor.R, bottomRightInnerColor.G, bottomRightInnerColor.B);
            g.DrawPath(pen, path);
        }
示例#5
0
        //****************************************************************
        // Painting - Methods for painting a PPath.
        //****************************************************************

        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(PPaintContext paintContext)
        {
            //System.Drawing.Brush b = this.Brush;
            XnaGraphics g = paintContext.Graphics;

            if (this.Brush != Color.Transparent)
            {
                //PointFx transformedPosition = MatrixExtensions.Transform(this.Matrix, new PointFx(1.0f, 1.0f));
                g.FillPath(this.Matrix, this.Brush, path);
            }

            if (pen != null)
            {
                g.DrawPath(pen, path);
            }
        }