Skip to content

Instantly share code, notes, and snippets.

@Clancey
Created February 6, 2011 03:39
Show Gist options
  • Save Clancey/813102 to your computer and use it in GitHub Desktop.
Save Clancey/813102 to your computer and use it in GitHub Desktop.
using System;
using System.Drawing;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
namespace BundlerCrash
{
public partial class AppDelegate : NSApplicationDelegate
{
MainWindowController mainWindowController;
public AppDelegate ()
{
}
MyView view;
public override void FinishedLaunching (NSObject notification)
{
mainWindowController = new MainWindowController ();
view = new MyView(mainWindowController.Window.Frame);
mainWindowController.Window.ContentView.AddSubview(view);
mainWindowController.Window.MakeKeyAndOrderFront (this);
}
}
public class MyView : NSView
{
public MyView(RectangleF rect) : base (rect)
{
}
public override void DrawRect (RectangleF dirtyRect)
{
using(var G = Graphics.FromHwnd(this.Handle))
{
Pen pen = new Pen(Color.Green, 2.0f);
Brush brush = new SolidBrush(Color.Blue);
G.DrawRectangle(pen,Rectangle.Round(dirtyRect));
G.FillRectangle(brush,Rectangle.Round(dirtyRect));
}
base.DrawRect (dirtyRect);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment