Пример #1
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);
        }
        void PaintPolyline(NPaintVisitor paintVisitor, double w, double h)
        {
            NPolyline polyline = new NPolyline(5);

            polyline.Add(0.1 * w, 0.1 * h);
            polyline.Add(0.4 * w, 0.2 * h);
            polyline.Add(0.2 * w, 0.5 * h);
            polyline.Add(0.3 * w, 0.8 * h);
            polyline.Add(0.9 * w, 0.9 * h);
            paintVisitor.PaintPolyline(polyline);
        }
Пример #3
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);
        }