123456789101112131415161718192021222324252627282930313233 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using SkiaSharp;
- namespace FlowChartV2.Libraries
- {
- public class Rect : Figure
- {
- public Rect(Point start, string text) : base(FigureTypes.Rectengle, text)
- {
- tsize = (int)new SKPaint().MeasureText(text) + 1;
- this.size = new Size(tsize - tsize / 100 * 50, Convert.ToInt32(tsize * 1.5));
- 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);
- }
- public override void Draw(ref SKCanvas canvas, SKPaint paint)
- {
- canvas.DrawRect(start.x, start.y, size.w, size.h, 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);
- }
- }
- }
|