Skip to content

Instantly share code, notes, and snippets.

@chamons
Last active March 31, 2017 19:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chamons/c9c17978e620848dc402e97c1ebf258b to your computer and use it in GitHub Desktop.
public partial class DrawingView : AppKit.NSView
{
public DrawingView (CGRect r) : base (r)
{
}
public override void DrawRect (CGRect dirtyRect)
{
using (var g = Graphics.FromCurrentContext ()) {
g.Clear (Color.White);
CGRect ClientRectangle = dirtyRect;
g.PageUnit = GraphicsUnit.Inch;
g.TranslateTransform (((float)ClientRectangle.Width / g.DpiX) / 2, ((float)ClientRectangle.Height / g.DpiY) / 2);
Pen greenPen = new Pen (Color.Green, 1 / g.DpiX);
g.DrawLine (greenPen, 0, 0, 1, 1);
g.Dispose ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment