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;

            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 #3
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);
        }