public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { base.Draw(canvas, rect); rect.Inflate(-10, -10); canvas.DrawRectangle(rect, Pens.Blue, null); }
/// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> /// <param name="rect">Rect.</param> public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { base.Draw(canvas, rect); canvas.DrawLine(0, rect.Height - 0.5, rect.Width, rect.Height - 0.5, NGraphics.Colors.Gray, 0.5); canvas.DrawEllipse(new Rect(-rect.Width / 3, 0, rect.Width, rect.Width), null, Brushes.Red); }
public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { if (BackgroundColor == Xamarin.Forms.Color.Transparent && BorderColor == Xamarin.Forms.Color.Transparent) { return; } CustomPainter.Paint(this, canvas, rect); }
public double DrawSegment(NGraphics.ICanvas canvas, NGraphics.Point center, double radius, double startRadian, double pullLength, NGraphics.Font font, NGraphics.Color textColor, bool isNameVisible, NGraphics.Color percentColor, bool isPercentVisible, NGraphics.Color valueColor, bool isValueVisible) { double middleRadian = startRadian + Radian / 2.0; if (IsPull) { center = new NGraphics.Point( center.X + pullLength * Math.Cos(middleRadian), center.Y + pullLength * Math.Sin(middleRadian)); } var brush = new SolidBrush((Color ?? NGraphics.Colors.Black)); var pen = new Pen(PenColor, PenWidth); canvas.DrawPath((path) => { const double shardRadian = 0.02; path.MoveTo(center); path.LineTo(center.X + Math.Cos(startRadian) * radius, center.Y + Math.Sin(startRadian) * radius); for (var addRadian = 0.0; addRadian < Radian; addRadian += shardRadian) { path.LineTo(center.X + Math.Cos(startRadian + addRadian) * radius, center.Y + Math.Sin(startRadian + addRadian) * radius); } path.LineTo(center.X + Math.Cos(startRadian + Radian) * radius, center.Y + Math.Sin(startRadian + Radian) * radius); path.Close(); }, pen, brush); if (isNameVisible) { DrawName(canvas, center, radius, font, TitleColor ?? textColor, middleRadian); } if (isValueVisible) { DrawValue(canvas, center, radius, font, ValueColor ?? valueColor, middleRadian); } if (isPercentVisible) { DrawPercent(canvas, center, radius, font, PercentColor ?? percentColor, middleRadian); } return(startRadian + Radian); }
/// <summary> /// Draw the specified canvas. /// </summary> /// <param name="canvas">Canvas.</param> /// <param name="rect">Rect.</param> public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { base.Draw(canvas, rect); var backgroundBrush = new SolidBrush(new NGraphics.Color(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A)); var curveSize = CornerRadius; var width = rect.Width; var height = rect.Height; canvas.DrawPath(new PathOp [] { new MoveTo(curveSize, 0), // Top Right corner new LineTo(width - curveSize, 0), new CurveTo( new NGraphics.Point(width - curveSize, 0), new NGraphics.Point(width, 0), new NGraphics.Point(width, curveSize) ), new LineTo(width, height - curveSize), // Bottom right corner new CurveTo( new NGraphics.Point(width, height - curveSize), new NGraphics.Point(width, height), new NGraphics.Point(width - curveSize, height) ), new LineTo(curveSize, height), // Bottom left corner new CurveTo( new NGraphics.Point(curveSize, height), new NGraphics.Point(0, height), new NGraphics.Point(0, height - curveSize) ), new LineTo(0, curveSize), new CurveTo( new NGraphics.Point(0, curveSize), new NGraphics.Point(0, 0), new NGraphics.Point(curveSize, 0) ), new ClosePath() }, null, backgroundBrush); }
public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { base.Draw(canvas, rect); const double delta = -10.0; const double yOffset = 20; var width = rect.Width; var height = rect.Height; var points = new PathOp[] { new MoveTo(0, yOffset - delta), new CurveTo(new NGraphics.Point(width / 2, yOffset + delta), new NGraphics.Point(width / 2, yOffset + delta), new NGraphics.Point(width, yOffset - delta)), new LineTo(width, height), new LineTo(0, height) }; canvas.DrawPath(points, null, new SolidBrush(new NGraphics.Color(0, 0.722, 1, 1))); }
public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { DrawBackground(canvas, rect); LastRect = rect; // 0.65 RadiusAll = Math.Min(rect.Width, rect.Height - textHeight) / 2.0; if (IsTitleOnTop) { Center = new NGraphics.Point(rect.Center.X, rect.Center.Y + textHeight); } else { Center = new NGraphics.Point(rect.Center.X, rect.Center.Y - textHeight); } double pullLength = RadiusAll.Value * PullRatio; double radius = RadiusAll.Value - (RadiusAll.Value * PullRatio); double sumRadian = StartRadian; foreach (var eachSegment in ListItems) { sumRadian = eachSegment.DrawSegment(canvas, rect.Center, radius, sumRadian, pullLength, Font, TextColor, IsNameVisible, PercentColor, IsPercentVisible, ValueColor, IsValueVisible); } Rect rectText; if (IsTitleOnTop) { rectText = new Rect(rect.Center.X, rect.Center.Y - RadiusAll.Value - textHeight / 4.0, 20, 20); } else { rectText = new Rect(rect.Center.X, rect.Center.Y + RadiusAll.Value + textHeight / 4.0, 20, 20); } canvas.DrawText(Title ?? "", rectText, new NGraphics.Font(), NGraphics.TextAlignment.Center, new Pen(TitleColor.ToCross()), new SolidBrush(TitleColor.ToCross())); }
public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { //base.Draw(canvas, rect); //canvas.DrawLine(rect.Left, rect.Top, rect.Width, rect.Height, NGraphics.Colors.Blue); //canvas.DrawLine(rect.Width, rect.Top, rect.Left, rect.Height, NGraphics.Colors.Yellow); }