Example #1
0
    public CurveWidget(Curve _curve)
        : base()
    {
        PixelsPerUnit = 300;

        CanvasRect rect = new CanvasRect(Root());
        rect.X1 = 0;
        rect.Y1 = 0;
        rect.X2 = 1;
        rect.Y2 = 1;
        rect.FillColor = "white";
        rect.OutlineColor = null;
        rect.WidthUnits = 0.0;

        CenterScrollRegion = true;
        SetScrollRegion(0.0, 0.0, 1.0, 1.0);

        curve = _curve;

        bpath = new MyBPath(Root());
        bpath.WidthPixels = 0;
        bpath.OutlineColor = "blue";

        MakeLine(0,0.25, 1,0.25);
        MakeLine(0,0.5, 1,0.5);
        MakeLine(0,0.75, 1,0.75);

        MakeLine(0.25,0, 0.25,1);
        MakeLine(0.5,0, 0.5,1);
        MakeLine(0.75,0, 0.75,1);

        points = new ArrayList();

        for (uint i = 0; i < curve.NumPoints(); ++i) {
            float x, y;
            curve.GetPoint (i, out x, out y);
            points.Add (new CurvePoint(x, y, this));
        }

        bpath.SetPathDef(MakePathDef());

        marker = new CurveMarker(0, 0, this, "dark grey");
        marker.Active = false;

        ButtonPressEvent += new ButtonPressEventHandler(OnButtonPress);
    }