public override void DrawRect(NSRect aRect) { // draw bars if (iMaxValue > 0) { // draw the current value bar NSColor colour = NSColor.ColorWithCalibratedRedGreenBlueAlpha(71.0f / 255.0f, 172.0f / 255.0f, 220.0f / 255.0f, 1.0f); colour.SetStroke(); DrawArc(0, iValue, true); // draw the preview bar if (iPreviewEnabled) { colour = NSColor.ColorWithCalibratedRedGreenBlueAlpha(187.0f / 255.0f, 187.0f / 255.0f, 0.0f / 255.0f, 1.0f); colour.SetStroke(); DrawArc(iValue, iPreviewValue, (iPreviewValue > iValue)); } } // draw text if (iText != null) { NSMutableParagraphStyle style = new NSMutableParagraphStyle(); style.SetParagraphStyle(NSParagraphStyle.DefaultParagraphStyle); style.SetAlignment(NSTextAlignment.NSCenterTextAlignment); NSDictionary dict = NSDictionary.DictionaryWithObjectsAndKeys(FontManager.FontMedium, NSAttributedString.NSFontAttributeName, style, NSAttributedString.NSParagraphStyleAttributeName, NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName, null); style.Release(); NSSize size = iText.SizeWithAttributes(dict); NSRect rect = new NSRect((Bounds.Width - size.width) * 0.5f, (Bounds.Height - size.height) * 0.5f, size.width, size.height); iText.DrawInRectWithAttributes(rect, dict); } }