using Bro.Common.Interface;
|
using Bro.UI.Model.Winform;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing.Design;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms.Design;
|
|
namespace Bro.M135.Common
|
{
|
|
public class DefectRectangleIndicator : UIIndicator
|
{
|
public string DefectName { get; set; }
|
public RectangleF DisplayRect { get; set; } = new RectangleF();
|
protected int FontSize = 15;
|
public override object Clone()
|
{
|
DefectRectangleIndicator dri = new DefectRectangleIndicator();
|
dri.DefectName = this.DefectName;
|
dri.DisplayRect = this.DisplayRect;
|
return dri;
|
}
|
|
public override void Draw(Graphics g)
|
{
|
g.FillRectangle(new SolidBrush(Color.FromArgb(100, BaseColor)), DisplayRect.X, DisplayRect.Y, DisplayRect.Width, DisplayRect.Height);
|
Font font = new Font("Tahoma", FontSize);
|
var txtSize = g.MeasureString(DefectName, font);
|
g.DrawString(DefectName, font, new SolidBrush(Color.FromArgb(100, Color.Red)), (float)(DisplayRect.X + DisplayRect.Width / 2.0 - txtSize.Width / 2.0), DisplayRect.Y + DisplayRect.Height + 5);
|
}
|
|
public override string GetDisplayText()
|
{
|
return $"{DefectName}:{DisplayRect.X} {DisplayRect.Y} {DisplayRect.Width} {DisplayRect.Height}";
|
}
|
}
|
|
public class DefectRectangleIndicatorEditor : UITypeEditor
|
{
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
{
|
return UITypeEditorEditStyle.Modal;
|
}
|
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
{
|
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
|
if (edSvc != null)
|
{
|
if (context.Instance is IProcessConfig config)
|
{
|
FrmDefectRectangleIndicatorEditor frm = new FrmDefectRectangleIndicatorEditor();
|
|
if (frm.ShowDialog() == DialogResult.OK)
|
{
|
|
}
|
}
|
}
|
|
return base.EditValue(context, provider, value);
|
}
|
|
}
|
}
|