public override void DrawWithFrame(RectangleF cellFrame, NSView inView) { //Assert (!_deallocCalled, "DrawWithFrame: Dealloc was called on object"); //Assert (!_disposeCalled, "DrawWithFrame: Dispose was called on object"); if (_image != null) { RectangleF imageFrame; cellFrame.Divide(3 + _image.Size.Width, CGRectEdge.MinXEdge, out imageFrame, out cellFrame); if (DrawsBackground) { BackgroundColor.Set(); NSGraphics.RectFill(imageFrame); } imageFrame.X += 3; imageFrame.Size = _image.Size; //if (inView.IsFlipped) { // imageFrame.Y += (float)Math.Ceiling((cellFrame.Height + imageFrame.Height) / 2); //} //else { imageFrame.Y += (float)Math.Ceiling((cellFrame.Height - imageFrame.Height) / 2); //} _image.Draw(imageFrame, new RectangleF(PointF.Empty, _image.Size), NSCompositingOperation.SourceOver, 1f, true, null); } base.DrawWithFrame(cellFrame, inView); }
public override void DrawWithFrame(CGRect cellFrame, NSView inView) { if (DrawsBackground && BackgroundColor != null && BackgroundColor.AlphaComponent > 0) { BackgroundColor.Set(); NSGraphics.RectFill(cellFrame); } base.DrawWithFrame(cellFrame, inView); var progress = FloatValue; if (float.IsNaN((float)progress)) { return; } string progressText = (int)(progress * 100f) + "%"; var str = new NSMutableAttributedString(progressText, NSDictionary.FromObjectAndKey(TextColor, NSStringAttributeKey.ForegroundColor)); var range = new NSRange(0, str.Length); if (Font != null) { str.AddAttributes(NSDictionary.FromObjectAndKey(Font, NSStringAttributeKey.Font), range); } var h = Handler; if (h == null) { return; } var size = h._fontUtility.MeasureString(str, cellFrame.Size.ToEto()); var rect = cellFrame.ToEto(); var offset = (rect.Size - size) / 2; if (!NSGraphicsContext.CurrentContext.IsFlipped) { offset.Height = -offset.Height; } rect.Offset(offset); str.DrawString(rect.ToNS()); }