将十字线以及点点距ROI实现迁移到XP.ImageProcessing.RoiControl中
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace XP.ImageProcessing.RoiControl.Models
|
||||
{
|
||||
/// <summary>一次点点距测量的所有视觉元素</summary>
|
||||
public class MeasureGroup
|
||||
{
|
||||
public Ellipse Dot1 { get; set; }
|
||||
public Ellipse Dot2 { get; set; }
|
||||
public Line Line { get; set; }
|
||||
public TextBlock Label { get; set; }
|
||||
public Point P1 { get; set; }
|
||||
public Point P2 { get; set; }
|
||||
|
||||
public double Distance
|
||||
{
|
||||
get
|
||||
{
|
||||
double dx = P2.X - P1.X, dy = P2.Y - P1.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLine()
|
||||
{
|
||||
Line.X1 = P1.X; Line.Y1 = P1.Y;
|
||||
Line.X2 = P2.X; Line.Y2 = P2.Y;
|
||||
Line.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void UpdateLabel(string unit = "px")
|
||||
{
|
||||
Label.Text = $"{Distance:F2} {unit}";
|
||||
Canvas.SetLeft(Label, (P1.X + P2.X) / 2 + 8);
|
||||
Canvas.SetTop(Label, (P1.Y + P2.Y) / 2 - 18);
|
||||
Label.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user