1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using SkiaSharp;
- namespace FlowChartV2.Libraries
- {
- public class CurvRect : Figure
- {
- public CurvRect(Point start, string text) : base(FigureTypes.CurvRect, text)
- {
- tsize = (int)new SKPaint().MeasureText(text) + 1;
- this.size = new Size(hfont * hfont, tsize);
- 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 - size.h / 4, 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 + size.h / 4, 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);
- }
- public override void Draw(ref SKCanvas canvas, SKPaint paint)
- {
- SKPoint[] points =
- {
- new SKPoint(start.x,start.y),
- new SKPoint(start.x + size.w + size.h / 2,start.y),
- new SKPoint(start.x + size.w + size.h / 2,start.y),
- new SKPoint(start.x + size.w,start.y + size.h),
- new SKPoint(start.x + size.w,start.y + size.h),
- new SKPoint(start.x - size.h / 2, start.y + size.h),
- new SKPoint(start.x - size.h / 2, start.y + size.h),
- new SKPoint(start.x,start.y),
- };
- canvas.DrawPoints(SKPointMode.Lines, points, 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);
- }
- }
- }
|