using Bro.Common.Helper;
|
using Bro.Common.Model;
|
using System;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.Drawing.Design;
|
using System.Windows.Forms;
|
|
namespace Bro.UI.Model.Winform
|
{
|
[Element("圆形ROI", "")]
|
public class ROI_Circle : ElementBase
|
{
|
#region ElementBase
|
//默认不在列表中显示
|
[Browsable(false)]
|
public override bool ShowList { get; set; } = false;
|
|
public override void Calculate(Bitmap image)
|
{
|
}
|
|
public override void Calculate(IntPtr imagePtr, int ptrSize, int imageWidth, int imageHeight)
|
{
|
}
|
|
public override void Calculate(string imagePath)
|
{
|
}
|
|
public override void CalculateBaseRectangle()
|
{
|
}
|
|
public override object Clone()
|
{
|
ROI_Circle circle = new ROI_Circle();
|
|
circle.Center = Center;
|
circle.Radius = Radius;
|
circle.ROI_Index = ROI_Index + "_Clone";
|
|
return circle;
|
}
|
|
public override void Draw(Graphics g)
|
{
|
g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Center.X, Center.Y, 1.0f, 1.0f));
|
|
Pen pen = null;
|
if (ROI_Index == "1")
|
{
|
pen = new Pen(new SolidBrush(Color.Red), 6.0f);
|
|
g.DrawString(
|
"P1",
|
new Font(new FontFamily("宋体"), 40.0f),
|
new SolidBrush(Color.Red),
|
new PointF(Center.X - Radius - 80, Center.Y - Radius - 40)
|
);
|
}
|
else
|
{
|
pen = new Pen(new SolidBrush(Color.Green), 3.0f);
|
}
|
|
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
|
g.DrawEllipse(pen, Center.X - Radius, Center.Y - Radius, Radius * 2, Radius * 2);
|
|
if (ROI_Index == "1")
|
{
|
g.DrawEllipse(pen, Center.X - Radius - 15, Center.Y - Radius - 15, Radius * 2 + 30, Radius * 2 + 30);
|
}
|
}
|
|
public override bool IsIntersect(Rectangle rect)
|
{
|
return false;
|
}
|
|
public override bool IsMouseHover(Point p)
|
{
|
return false;
|
}
|
|
public override bool IsMouseInSide(Point p)
|
{
|
double dist = Math.Sqrt((Math.Pow((p.X - Center.X), 2) + Math.Pow((p.Y - Center.Y), 2)));
|
return dist <= Radius;
|
}
|
|
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
|
|
#region IComplexDisplay
|
public override string GetDisplayText()
|
{
|
return $"X:{Center.X},Y:{Center.Y},R:{Radius}";
|
}
|
#endregion
|
|
#region Properties
|
[Category("专有配置")]
|
[Description("中心点")]
|
[TypeConverter(typeof(ComplexObjectConvert))]
|
[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
|
public CustomizedPoint Center { get; set; } = new CustomizedPoint();
|
|
[Category("专有配置")]
|
[Description("ROI半径")]
|
public float Radius { get; set; }
|
|
[Category("专有配置")]
|
[Description("ROI编号")]
|
public string ROI_Index { get; set; }
|
#endregion
|
}
|
}
|