1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using SkiaSharp;
- namespace FlowChartV2.Libraries
- {
- public class RoundRec : Figure
- {
- private int r;
- public RoundRec(Point start, string text) : base(FigureTypes.RoundRect, text)
- {
- tsize = (int)new SKPaint().MeasureText(text) + 1;
- this.size = new Size(tsize, tsize * 2);
- int hhsize = size.h / 2, hwsize = size.w / 2;
- this.start = new Point(start.x - hwsize, start.y);
- this.left = new Point(this.start.x, this.start.y + hhsize);
- this.bottom = new Point(this.start.x + hwsize, this.start.y + size.h);
- this.right = new Point(this.start.x + size.w, this.start.y + hhsize);
- this.top = new Point(this.start.x + hwsize, this.start.y);
- this.center = new Point(this.start.x + hwsize, this.start.y + hhsize);
- r = size.h;
- }
- public override void Draw(ref SKCanvas canvas, SKPaint paint)
- {
- canvas.DrawRoundRect(start.x, start.y, size.w, size.h, r, r, paint);
- }
- public override void DrawText(ref SKCanvas canvas, SKPaint paint)
- {
- int x = start.x + (size.w - tsize) / 2, y = (size.h + start.y) - size.h / 2 + 4;
- canvas.DrawText(text, x, y, paint);
- }
- }
- }
|