using System; using System.Drawing; 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 System.Windows.Point(X, Y), Radius, Radius); dc.DrawEllipse(null, Pen, new System.Windows.Point(X, Y), Radius * 0.8, Radius * 0.8); dc.DrawLine(Pen, new System.Windows.Point(X, Y - Radius), new System.Windows.Point(X, Y + Radius)); dc.DrawLine(Pen, new System.Windows.Point(X - Radius, Y), new System.Windows.Point(X + Radius, Y)); FormattedText fTxt = new FormattedText(Text, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Typeface, FontSize, Pen.Brush); dc.DrawText(fTxt, new System.Windows.Point(X - fTxt.WidthIncludingTrailingWhitespace / 2, Y - Radius / 2 - fTxt.MaxTextHeight)); } public override void Draw(Graphics g) { throw new NotImplementedException(); } protected override bool IsMouseInSide(System.Windows.Point point) { return Math.Sqrt(Math.Pow(X - point.X, 2) + Math.Pow(Y - point.Y, 2)) < Radius; } protected override bool IsMouseHover(System.Windows.Point point) { return false; } public override void SetNormalPen() { Pen = new System.Windows.Media.Pen(new SolidColorBrush(Colors.GreenYellow), 3); } } }