using Bro.Common.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace Bro.UI.Model.Winform
|
{
|
public class PointIndicator : ElementBase
|
{
|
public CustomizedPoint Center { get; set; } = new CustomizedPoint();
|
|
public float Radius { get; set; } = 25;
|
|
public override int FontDistance { get; set; } = 25;
|
|
public PointIndicator() { }
|
|
public PointIndicator(float x, float y)
|
{
|
Center = new CustomizedPoint();
|
Center.X = x;
|
Center.Y = y;
|
}
|
|
public PointIndicator(CustomizedPoint point)
|
{
|
Center = new CustomizedPoint(point.X, point.Y);
|
}
|
|
public static List<PointIndicator> GetPointList<T>(List<T> points) where T : CustomizedPoint
|
{
|
return points.ConvertAll(p =>
|
{
|
return new PointIndicator(p);
|
}).ToList();
|
}
|
|
#region ElementBase
|
|
public override object Clone()
|
{
|
PointIndicator clone = new PointIndicator();
|
clone.Center = new CustomizedPoint(Center.X, Center.Y);
|
return clone;
|
}
|
|
protected override void SetNormalPen()
|
{
|
Pen = new Pen(Color.Green, 5);
|
}
|
|
public override void Draw(Graphics g)
|
{
|
g.DrawEllipse(Pen, new RectangleF((float)Center.X - Radius, (float)Center.Y - Radius, Radius * 2, Radius * 2));
|
g.DrawLine(Pen, (float)Center.X, (float)Center.Y - Radius, (float)Center.X, (float)Center.Y + Radius);
|
g.DrawLine(Pen, (float)Center.X - Radius, (float)Center.Y, (float)Center.X + Radius, (float)Center.Y);
|
|
string info = GetDisplayText();
|
g.DrawString(info, Font, new SolidBrush(Pen.Color), new PointF((float)Center.X - Radius - FontDistance, (float)Center.Y - Radius - FontDistance));
|
}
|
|
public override string GetDisplayText()
|
{
|
return $"X:{Center.X};Y:{Center.Y}";
|
}
|
|
public override bool IsIntersect(Rectangle rect)
|
{
|
return false;
|
}
|
|
public override bool IsMouseHover(Point p)
|
{
|
return false;
|
}
|
|
public override bool IsMouseInSide(Point p)
|
{
|
return false;
|
}
|
|
public override void OnKeyDown(object sender, KeyEventArgs e)
|
{
|
}
|
|
public override void OnKeyUp(object sender, KeyEventArgs e)
|
{
|
}
|
|
public override void OnMouseDownWhenNew(Point p)
|
{
|
}
|
|
public override void OnMouseMoveWhenNew(Point p)
|
{
|
}
|
|
public override void OnMouseUpWhenNew(Point p)
|
{
|
}
|
|
public override void Translate(int x, int y)
|
{
|
}
|
|
protected override void DrawResult(Graphics g)
|
{
|
}
|
#endregion
|
}
|
}
|