Example #1
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            // Create a transform matrix for the graphics path
            NMatrix matrix = NMatrix.CreateRotationMatrix(m_PathAngle * NAngle.Degree2Rad, NPoint.Zero);

            matrix.Translate(m_PathPositionX, m_PathPositionY);

            // Create a graphics path containing a rectangle and transform it
            NGraphicsPath path = new NGraphicsPath();

            path.AddRectangle(0, 0, RectWidth, RectHeight);
            path.Transform(matrix);

            // Paint the graphics path
            NPaintVisitor pv = args.PaintVisitor;

            pv.SetStroke(m_Stroke);
            pv.SetFill(m_ImageFill);
            pv.PaintPath(path);

            // Paint a border around the canvas
            pv.ClearFill();
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }
Example #2
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor pv = args.PaintVisitor;

            pv.ClearStyles();

            if (m_PaintImageInRectangle)
            {
                pv.PaintImage(NResources.Image_JpegSuite_q080_jpg.ImageSource, new NRectangle(m_PosX, m_PosY, m_Width, m_Height));
            }
            else
            {
                pv.PaintImage(NResources.Image_JpegSuite_q080_jpg.ImageSource, new NPoint(m_PosX, m_PosY));
            }

            // paint a border around the canvas
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }
            public void Paint(NPaintVisitor visitor)
            {
                NColor color;

                switch (State)
                {
                case ENTouchDeviceState.Down:
                    color = NColor.Blue;
                    break;

                case ENTouchDeviceState.Unknown:
                    color = NColor.Green;
                    break;

                case ENTouchDeviceState.Up:
                    color = NColor.Red;
                    break;

                default:
                    throw new Exception("New ENTouchDeviceState?");
                }

                NSize size = Size;

                if (size.Width == 0 || size.Height == 0)
                {
                    size = new NSize(5, 5);
                }

                visitor.SetStroke(new NStroke(color));
                visitor.PaintEllipse(NRectangle.FromCenterAndSize(Location, size));
            }
Example #4
0
        void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NStroke stroke = (NStroke)canvas.Tag;

            NPaintVisitor visitor = args.PaintVisitor;

            visitor.SetStroke(stroke);
            visitor.SetFill(null);

            double strokeWidth   = stroke.Width;
            double rectWidth     = 300;
            double ellipseWidth  = 150;
            double polylineWidth = 180;
            double dist          = 20;

            double x1 = 10 + strokeWidth / 2;
            double x2 = x1 + rectWidth + dist + strokeWidth;
            double x3 = x2 + ellipseWidth;
            double x4 = x3 + dist + strokeWidth;
            double x5 = x4 + polylineWidth + dist + strokeWidth / 2;
            double y1 = 10 + strokeWidth / 2;
            double y2 = y1 + strokeWidth + 10;
            double y3 = y1 + 50;

            // draw a horizontal line
            visitor.PaintLine(x1, y1, x3, y1);

            // draw a rectangle
            visitor.PaintRectangle(x1, y2, rectWidth, 100);

            // draw an ellipse
            visitor.PaintEllipse(x2, y2, ellipseWidth, 100);

            // draw a polyline
            NPolyline polyLine = new NPolyline(4);

            polyLine.Add(new NPoint(x4, y2 + 90));
            polyLine.Add(new NPoint(x4 + 60, y2));
            polyLine.Add(new NPoint(x4 + 120, y2 + 90));
            polyLine.Add(new NPoint(x4 + 180, y2));
            visitor.PaintPolyline(polyLine);

            // draw text
            string dashStyleName = stroke.DashStyle.ToString();

            visitor.ClearStroke();
            visitor.SetFont(m_LabelFont);
            visitor.SetFill(m_LabelFill);

            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            visitor.PaintString(new NRectangle(x5, y3, 200, 50), dashStyleName, ref settings);
        }
Example #5
0
        void PaintTriangle(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(NColor.Black, 2);
            paintVisitor.SetFill(NColor.Crimson);

            NPoint p1 = new NPoint(0.5 * w, 0.2 * h);
            NPoint p2 = new NPoint(0.8 * w, 0.8 * h);
            NPoint p3 = new NPoint(0.2 * w, 0.7 * h);

            paintVisitor.PaintTriangle(p1, p2, p3);
        }
Example #6
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor pv = args.PaintVisitor;

            int count = m_Values.Length;

            // calculate total value
            double total = 0;

            for (int i = 0; i < count; i++)
            {
                total += m_Values[i];
            }

            // paint the pie slices
            double beginAngle = 0;

            pv.ClearStyles();

            for (int i = 0; i < count; i++)
            {
                double sweepAngle = NMath.PI2 * (m_Values[i] / total);

                NGraphicsPath path = new NGraphicsPath();
                path.AddPie(0.1 * W, 0.1 * H, 0.8 * W, 0.8 * H, beginAngle, sweepAngle);

                if (i == 0)
                {
                    const double detachment = 20;
                    double       midAngle   = beginAngle + sweepAngle / 2;
                    double       dx         = Math.Cos(midAngle) * detachment;
                    double       dy         = Math.Sin(midAngle) * detachment;
                    path.Translate(dx, dy);
                }

                pv.SetFill(m_ColorFills[i]);
                pv.PaintPath(path);

                beginAngle += sweepAngle;
            }

            // paint a border around the canvas
            pv.ClearFill();
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }
Example #7
0
        void PaintQuadrangle(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(NColor.Black, 2);
            paintVisitor.SetFill(new NColor(NColor.Crimson, 128));

            NPoint p1 = new NPoint(0.3 * w, 0.2 * h);
            NPoint p2 = new NPoint(0.6 * w, 0.2 * h);
            NPoint p3 = new NPoint(0.8 * w, 0.8 * h);
            NPoint p4 = new NPoint(0.2 * w, 0.6 * h);

            paintVisitor.PaintQuadrangle(p1, p2, p3, p4);
        }
Example #8
0
        void PaintEllipse(NPaintVisitor paintVisitor, double w, double h)
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0, NColor.Indigo));
            rgf.GradientStops.Add(new NGradientStop(0.6f, NColor.SlateBlue));
            rgf.GradientStops.Add(new NGradientStop(1, new NColor(NColor.Crimson, 30)));

            paintVisitor.SetStroke(NColor.Black, 1);
            paintVisitor.SetFill(rgf);

            paintVisitor.PaintEllipse(0.2 * w, 0.3 * h, 0.6 * w, 0.4 * h);
        }
Example #9
0
        void PaintRectangle(NPaintVisitor paintVisitor, double w, double h)
        {
            NLinearGradientFill lgf = new NLinearGradientFill();

            lgf.GradientStops.Add(new NGradientStop(0, NColor.Indigo));
            lgf.GradientStops.Add(new NGradientStop(0.5f, NColor.SlateBlue));
            lgf.GradientStops.Add(new NGradientStop(1, new NColor(NColor.Crimson, 30)));

            paintVisitor.SetStroke(NColor.Black, 1);
            paintVisitor.SetFill(lgf);

            paintVisitor.PaintRectangle(0.2 * w, 0.3 * h, 0.6 * w, 0.4 * h);
        }
Example #10
0
        void PaintPolyline(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(NColor.Black, 2);

            NPolyline polyline = new NPolyline(5);

            polyline.Add(0.2 * w, 0.2 * h);
            polyline.Add(0.4 * w, 0.3 * h);
            polyline.Add(0.3 * w, 0.5 * h);
            polyline.Add(0.4 * w, 0.7 * h);
            polyline.Add(0.8 * w, 0.8 * h);
            paintVisitor.PaintPolyline(polyline);
        }
Example #11
0
        void PaintPath(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(new NColor(0, 0, 0, 160), 6);
            paintVisitor.SetFill(new NColor(NColor.GreenYellow, 128));

            NGraphicsPath path = new NGraphicsPath();

            path.StartFigure(0.2 * w, 0.2 * h);
            path.LineTo(0.7 * w, 0.3 * h);
            path.CubicBezierTo(0.8 * w, 0.8 * h, 1 * w, 0.4 * h, 0.5 * w, 0.7 * h);
            path.LineTo(0.3 * w, 0.7 * h);
            path.CubicBezierTo(0.2 * w, 0.2 * h, 0.3 * w, 0.7 * h, 0.4 * w, 0.6 * h);
            path.CloseFigure();

            paintVisitor.PaintPath(path);
        }
Example #12
0
        void PaintPolygon(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(new NColor(0, 0, 0, 160), 6);
            paintVisitor.SetFill(NColor.GreenYellow);

            NPolygon polygon = new NPolygon(6);

            polygon.Add(0.3 * w, 0.2 * h);
            polygon.Add(0.6 * w, 0.2 * h);
            polygon.Add(0.5 * w, 0.4 * h);
            polygon.Add(0.8 * w, 0.8 * h);
            polygon.Add(0.3 * w, 0.7 * h);
            polygon.Add(0.2 * w, 0.4 * h);

            paintVisitor.PaintPolygon(polygon, ENFillRule.EvenOdd);
        }
Example #13
0
        void PaintLine(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(NColor.Black, 2);

            paintVisitor.PaintLine(0.2 * w, 0.8 * h, 0.7 * w, 0.2 * h);
        }
Example #14
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            canvas.HorizontalPlacement = ENHorizontalPlacement.Center;
            canvas.VerticalPlacement   = ENVerticalPlacement.Center;

            NPaintVisitor pv = args.PaintVisitor;

            pv.ClearStyles();
            pv.SetStroke(NColor.MidnightBlue, 1);
            pv.SetFill(NColor.LightSteelBlue);

            NMatrix m1 = NMatrix.Identity;

            m1.Rotate(NAngle.Degree2Rad * m_Angle1);

            NMatrix m2 = NMatrix.Identity;

            m2.Rotate(NAngle.Degree2Rad * m_Angle2);
            m2.Translate(100, 0);

            NMatrix m3 = NMatrix.Identity;

            m3.Rotate(NAngle.Degree2Rad * m_Angle3);
            m3.Translate(100, 0);

            NRegion clipRegion = NRegion.FromRectangle(m_ClipRect);

            pv.PushClip(clipRegion);

            pv.PushTransform(new NMatrix(m_PositionX, 0));
            PaintVerticalBar(pv);

            pv.PushTransform(new NMatrix(0, m_PositionY));
            PaintBase(pv);

            pv.PushTransform(m1);
            PaintLink(pv, 20);
            PaintJoint(pv, 20);

            pv.PushSnapToPixels(false);
            pv.PushTransform(m2);
            PaintLink(pv, 16);
            PaintJoint(pv, 16);

            pv.PushTransform(m3);
            PaintGripper(pv);
            PaintJoint(pv, 12);

            pv.PopTransform();            // m3
            pv.PopTransform();            // m2
            pv.PopTransform();            // m1
            pv.PopTransform();            // mTY
            pv.PopTransform();            // mTX
            pv.PopSnapToPixels();
            pv.PopClip();

            // paint a border around the clip rectangle
            pv.ClearFill();
            pv.SetStroke(NColor.Red, 1);
            pv.PaintRectangle(m_ClipRect);

            // paint a border around the canvas
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }