How to draw something (line, circle, etc.) in a Gtk # window?

I use Mono and C #. I would like to create a “graphical” application.

In WinForms and .NET, I can use System.Drawing. What can I use with GTK #?

How does GTK # performance work under Windows?

+4
source share
1 answer

This is done using Mono.Cairo, which is a wrapper around its own drawing library (like GDI +), so it works pretty well.

Example (draw a line):

using (Cairo.Context g = CairoHelper.Create (myWindow.GdkWindow)) { g.MoveTo (0, 0); g.LineTo (10, 10); g.Color = new Color (1, 1, 1); g.Stroke (); } 

Cairo lacks higher-level features such as DrawRectangle and FillRectangle. Pinta has many extension methods that add these features that you can see:

https://github.com/jpobst/Pinta/blob/master/Pinta.Core/Extensions/CairoExtensions.cs

+4
source

All Articles