kingno
2025-06-17 007782bf44e49b4e3d5166ef361ac9fd03cad9c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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);
        }
 
    }
}