1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using SkiaSharp;
- namespace FlowChartV2.Libraries
- {
- public class Rhombus : Figure
- {
- public Rhombus(Point start, string text) : base(FigureTypes.Rhombus, text)
- {
- tsize = (int)new SKPaint().MeasureText(text) + 1;
- this.size = new Size(Convert.ToInt32(tsize * 1.3), Convert.ToInt32(tsize * 1.3));
- 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)
- {
- SKPoint[] points =
- {
- new SKPoint(top.x,top.y),
- new SKPoint(right.x,right.y),
- new SKPoint(right.x,right.y),
- new SKPoint(bottom.x,bottom.y),
- new SKPoint(bottom.x,bottom.y),
- new SKPoint(left.x,left.y),
- new SKPoint(left.x,left.y),
- new SKPoint(top.x,top.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);
- }
- }
- }
|