public void SetLegendImage(KSeries series) { NSImage nsImage; int thickness = (series.lineStyle == KLineStyle.Thick) ? 3 : (series.lineMode == KLineMode.Line) ? 1 : 8; const int height = 16; const int width = 50; const int padding = 1; const int frame = 3; const int left = 0; int framedH = thickness + 2 * frame; int framedY = (height - 2 * padding - framedH) / 2; int framedW = width - 2 * padding; int framedX = left + padding; using (CGBitmapContext bitmap = CG.Bitmap(left + width, height)) { CG.DrawRect(bitmap, new CGRect(0, 0, left + width, height), CG.Color(new SKColor(0, 0, 0, 0))); // transparent if (series.visible) { CG.DrawRect(bitmap, new CGRect(framedX, framedY, framedW, framedH), CG.Color(SKColors.White)); CG.DrawRect(bitmap, new CGRect(framedX + frame, framedY + frame, framedW - 2 * frame, thickness), CG.Color(series.color)); } using (CGImage cgImage = bitmap.ToImage()) { nsImage = new NSImage(cgImage, new CGSize(cgImage.Width, cgImage.Height)); } } this.imageDM = nsImage; this.imageLM = nsImage; this.button.Image = nsImage; }
public /*interface Painter*/ void DrawRect(SKRect rect, SKPaint paint) { CG.DrawRect(canvas, CG.Rect(rect), paint); }