public override void DrawRect(NSRect aRect) { float left = Bounds.MinX + iPadding; float right = Bounds.MaxX - iPadding; float top = Bounds.MaxY - iPadding - iAnchorHeight; float bottom = Bounds.MinY + iPadding + iAnchorHeight; NSBezierPath path = new NSBezierPath(); // start the path in the bottom left corner, just past the arc of the corner and go clockwise path.MoveToPoint(new NSPoint(left, bottom + iCornerRadius)); path.LineToPoint(new NSPoint(left, top - iCornerRadius)); path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(left, top), new NSPoint(left + iCornerRadius, top), iCornerRadius); if (iAnchorOnTop) { path.LineToPoint(new NSPoint(iAnchorApex - iAnchorWidth * 0.5f, top)); path.LineToPoint(new NSPoint(iAnchorApex, top + iAnchorHeight)); path.LineToPoint(new NSPoint(iAnchorApex + iAnchorWidth * 0.5f, top)); } path.LineToPoint(new NSPoint(right - iCornerRadius, top)); path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(right, top), new NSPoint(right, top - iCornerRadius), iCornerRadius); path.LineToPoint(new NSPoint(right, bottom + iCornerRadius)); path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(right, bottom), new NSPoint(right - iCornerRadius, bottom), iCornerRadius); if (!iAnchorOnTop) { path.LineToPoint(new NSPoint(iAnchorApex + iAnchorWidth * 0.5f, bottom)); path.LineToPoint(new NSPoint(iAnchorApex, bottom - iAnchorHeight)); path.LineToPoint(new NSPoint(iAnchorApex - iAnchorWidth * 0.5f, bottom)); } path.LineToPoint(new NSPoint(left + iCornerRadius, bottom)); path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(left, bottom), new NSPoint(left, bottom + iCornerRadius), iCornerRadius); path.ClosePath(); NSColor.WhiteColor.SetStroke(); path.LineWidth = 4.0f; path.Stroke(); NSColor.ColorWithCalibratedWhiteAlpha(0.0f, 0.9f).SetFill(); path.Fill(); path.Release(); }