using System; using System.Windows; using System.Windows.Media; namespace Bro.Common.ImageCanvas.Shapes { public class PointIndicator : ShapeElementBase { public float X { get; set; } public float Y { get; set; } public float Radius { get; set; } public PointIndicator(float x, float y, float radius = 35.0f) { X = x; Y = y; Radius = radius; Text = $"{X.ToString("f2")},{Y.ToString("f2")}"; } protected override void DrawShape(DrawingContext dc) { dc.DrawEllipse(null, Pen, new Point(X, Y), Radius, Radius); dc.DrawEllipse(null, Pen, new Point(X, Y), Radius * 0.8, Radius * 0.8); dc.DrawLine(Pen, new Point(X, Y - Radius), new Point(X, Y + Radius)); dc.DrawLine(Pen, new Point(X - Radius, Y), new Point(X + Radius, Y)); FormattedText fTxt = new FormattedText(Text, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Typeface, FontSize, Pen.Brush); dc.DrawText(fTxt, new Point(X - fTxt.WidthIncludingTrailingWhitespace / 2, Y - Radius / 2 - fTxt.MaxTextHeight)); } protected override bool IsMouseInSide(Point point) { return Math.Sqrt(Math.Pow(X - point.X, 2) + Math.Pow(Y - point.Y, 2)) < Radius; } protected override bool IsMouseHover(Point point) { return false; } public override void SetNormalPen() { Pen = new Pen(new SolidColorBrush(Colors.GreenYellow), 3); } } }