示例#1
0
    void CreateItemsProgramatically()
    {
        // Adding image
        CanvasImage image = new CanvasImage (new Pixbuf (null, "logo.png"));
        image.Move (50, 50);
        canvas.Root.Add (image);

        // Adding textbox
        CanvasTextBox textbox = new CanvasTextBox();
        textbox.Move (50, 150);
        canvas.Root.Add (textbox);

        // Adding line
        Dia.CanvasLine line = new Dia.CanvasLine();
        line.LineWidth = 10;
        line.Color = 8327327;

        // Broke between 0.13 and 0.14
        // line.Dash = new double [] { 2, 4, 8, 16, 32 };

        line.HeadPos = new Dia.Point (50, 70);;
        line.TailPos = new Dia.Point (200, 250);
        line.Cap = Dia.CapStyle.Butt;
        line.Move (50, 150);
        canvas.Root.Add (line);

        // Adding box
        CanvasBox box = new CanvasBox();
        box.BorderWidth = 8.5;
        box.Color = 2134231;
        box.Move (250, 225);
        canvas.Root.Add (box);

        // Adding custom clock
        CanvasClock clock = new CanvasClock ();
        clock.Width = 100;
        clock.Height = 100;
        clock.Move (450, 225);
        canvas.Root.Add (clock);

        // Adding custom figure
        CanvasFigure figure = new CanvasFigure();
        figure.Move (50, 325);
        canvas.Root.Add (figure);

        view.UnselectAll();
        CanvasViewItem vitem = view.FindViewItem (image);
        view.Focus (vitem);
    }