Screenshots (SVG) - Documentation - Python - C# - Download - Project Page - Feedback

DiaCanvas#

DiaCanvas# is a C# wrapper for DiaCanvas2 written by Martin Willemoes Hansen. It has been developed using Mono.

It is still young and it has just started to crawl, but hopefully it will be up and running in the next few months.

Installation

There has yet to be a stable release of DiaCanvas#, the only way to obtain the code right now, is to get it from the Mono CVS repository.

The CVS module is named diacanvas-sharp.

Sample

A screendump of a DiaCanvas2 C# sample program:

What do the C# code look like then, take a look at this?

using System;

using Dia;
using Gtk;
using GtkSharp;
using Glade;

public class Sample {

	[Glade.Widget] Window main;
	[Glade.Widget] ScrolledWindow scrolledwindow;

	CanvasView view;

	public Sample() 
	{
		XML gui = new XML ("glade/gui.glade", "main", null);
		gui.Autoconnect (this);

		Dia.Canvas canvas = new Dia.Canvas();
		view = new CanvasView (canvas, true);
		scrolledwindow.Add (view);
		SetupTools();

		main.ShowAll();
	}

	[Glade.Widget] Image image1, image2, image3, image4;
	void SetupTools()
	{
		image1.Pixbuf = new Gdk.Pixbuf (null, "pixmaps/selection.png");
		image2.Pixbuf = new Gdk.Pixbuf (null, "pixmaps/line.png");
		image3.Pixbuf = new Gdk.Pixbuf (null, "pixmaps/box.png");
	}

	void SelectionTool (object sender, EventArgs args)
	{
		view.Tool = new StackTool();
	}

	void LineTool (object sender, EventArgs args)
	{
		view.Tool = new PlacementTool (Dia.CanvasLine.GType);
		view.Tool.ButtonReleaseEvent += new DiaSharp.ButtonReleaseEventHandler (UnsetTool);
	}

	void BoxTool (object sender, EventArgs args)
	{
		view.Tool = new PlacementTool (Dia.CanvasBox.GType);
		view.Tool.ButtonReleaseEvent += new DiaSharp.ButtonReleaseEventHandler (UnsetTool);
	}

	void TextTool (object sender, EventArgs args)
	{
		view.Tool = new PlacementTool (Dia.CanvasText.GType);
		view.Tool.ButtonReleaseEvent += new DiaSharp.ButtonReleaseEventHandler (UnsetTool);
	}

	void UnsetTool (object sender, DiaSharp.ButtonReleaseEventArgs args)
	{
		args.View.Tool = new StackTool();
	}

	void Quit (object sender, EventArgs args)
	{
		Application.Quit();
	}

	static void Main()
	{
		Application.Init();
		new Sample();
		Application.Run();
	}
}

demo.cs

This example depends on some other resources, such as pixmaps and the glade GUI files. To run it get the latest version of DiaCanvas# it includes the example and all the resources needed.

Credits

Author: Martin Willemoes Hansen.