using Bro.Common.Model;
|
using System;
|
using System.Windows;
|
using System.Windows.Media;
|
|
namespace Bro.Common.ImageCanvas.Shapes
|
{
|
public class ComplexPointIndicator : ShapeElementBase
|
{
|
public ComplexPoint PointInfo { get; set; }
|
|
public float Angle { get; set; }
|
|
readonly int halfRectSize = 20;
|
readonly int halfLength = 100;
|
|
public override void SetNormalPen()
|
{
|
if (PointInfo.PlatPoint.IsAvailable)
|
{
|
Pen = new Pen(new SolidColorBrush(Colors.Green), 3);
|
}
|
else
|
{
|
Pen = new Pen(new SolidColorBrush(Colors.Red), 3);
|
}
|
}
|
|
protected override void DrawShape(DrawingContext dc)
|
{
|
Text = $"{Index} 图像坐标:{PointInfo.ImagePoint.X},{PointInfo.ImagePoint.Y}\r\n机台坐标:{PointInfo.PlatPoint.X},{PointInfo.PlatPoint.Y}\r\n角度:{Angle}";
|
dc.DrawText(new FormattedText(Text, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Typeface, FontSize, Pen.Brush), new Point(PointInfo.ImagePoint.X + FontDistance, PointInfo.ImagePoint.Y - FontDistance));
|
|
dc.PushTransform(new RotateTransform(0 - Angle, PointInfo.ImagePoint.X, PointInfo.ImagePoint.Y));
|
|
dc.DrawRectangle(null, Pen, new Rect(PointInfo.ImagePoint.X - halfRectSize, PointInfo.ImagePoint.Y - halfRectSize, halfRectSize * 2, halfRectSize * 2));
|
dc.DrawLine(Pen, new Point(PointInfo.ImagePoint.X, PointInfo.ImagePoint.Y - halfLength), new Point(PointInfo.ImagePoint.X, PointInfo.ImagePoint.Y + halfLength));
|
dc.DrawLine(Pen, new Point(PointInfo.ImagePoint.X - halfLength, PointInfo.ImagePoint.Y), new Point(PointInfo.ImagePoint.X + halfLength, PointInfo.ImagePoint.Y));
|
}
|
|
protected override bool IsMouseInSide(Point point)
|
{
|
return Math.Sqrt(Math.Pow(PointInfo.ImagePoint.X - point.X, 2) + Math.Pow(PointInfo.ImagePoint.Y - point.Y, 2)) < halfLength;
|
}
|
|
protected override bool IsMouseHover(Point point)
|
{
|
return false;
|
}
|
}
|
}
|