Пример #1
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);
        }