public override void DrawRect(CGRect dirtyRect)
{
Graphics g = Graphics.FromCurrentContext();
g.Clear(Color.Wheat);
var mainBundle = NSBundle.MainBundle;
var filePath = mainBundle.PathForResource("CocoaMono","png");
var bitmap = Image.FromFile(filePath);
filePath = mainBundle.PathForResource("tiger-Q300","png");
var tiger = Image.FromFile(filePath);
using (var ig = Graphics.FromImage(bitmap))
{
//ig.Clear(Color.Red);
var pen = new Pen (Brushes.Yellow, 20);
var rec = new SizeF (200, 200);
var recp = new PointF (bitmap.Width - rec.Width - pen.Width / 2, bitmap.Height - rec.Height - pen.Width / 2);
ig.DrawEllipse (pen, new RectangleF (recp, rec));
}
g.DrawImage(bitmap, new Point(50,50));
g.DrawImage(tiger, new Point(200,200));
// To test Save uncomment the following lines
// var destopDirectory = Environment.GetFolderPath (Environment.SpecialFolder.DesktopDirectory);
// var finalPath = System.IO.Path.Combine (destopDirectory, "cocoa-monowithcircle.jpg");
//
// bitmap.Save(finalPath);
using (SolidBrush brush = new SolidBrush(BACKCOLOR))
{
Image pic = GetCircleImage(); //get circle image
Size newSize = new Size(pic.Size.Width * _scale, pic.Size.Height * _scale);//calculate new size of circle
g.FillEllipse(brush, new Rectangle(_circleLocation, newSize));//draw the shape background
g.DrawImage(pic, new Rectangle(_circleLocation, newSize));//draw the hatch style
}
g.Dispose();
}