领胜LDS 键盘AOI检测项目
wells.liu
2020-06-28 19a9489aef9b3353171eca5e6b583aadb2828593
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using Bro.Common.Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
 
namespace Bro.UI.Model.Winform
{
    public class PointIndicator : ElementBase
    {
        public CustomizedPoint Center { get; set; } = new CustomizedPoint();
 
        public float Radius { get; set; } = 25;
 
        public override int FontDistance { get; set; } = 25;
 
        public PointIndicator() { }
 
        public PointIndicator(float x, float y)
        {
            Center = new CustomizedPoint();
            Center.X = x;
            Center.Y = y;
        }
 
        public PointIndicator(CustomizedPoint point)
        {
            Center = new CustomizedPoint(point.X, point.Y);
        }
 
        public static List<PointIndicator> GetPointList<T>(List<T> points) where T : CustomizedPoint
        {
            return points.ConvertAll(p =>
             {
                 return new PointIndicator(p);
             }).ToList();
        }
 
        #region ElementBase
        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()
        {
            PointIndicator clone = new PointIndicator();
            clone.Center = new CustomizedPoint(Center.X, Center.Y);
            return clone;
        }
 
        protected override void SetNormalPen()
        {
            Pen = new Pen(Color.Green, 5);
        }
 
        public override void Draw(Graphics g)
        {
            g.DrawEllipse(Pen, new RectangleF((float)Center.X - Radius, (float)Center.Y - Radius, Radius * 2, Radius * 2));
            g.DrawLine(Pen, (float)Center.X, (float)Center.Y - Radius, (float)Center.X, (float)Center.Y + Radius);
            g.DrawLine(Pen, (float)Center.X - Radius, (float)Center.Y, (float)Center.X + Radius, (float)Center.Y);
 
            string info = GetDisplayText();
            g.DrawString(info, new Font("NewRoman", FontSize), new SolidBrush(Pen.Color), new PointF((float)Center.X - Radius - FontDistance, (float)Center.Y - Radius - FontDistance));
        }
 
        public override string GetDisplayText()
        {
            return $"X:{Center.X};Y:{Center.Y}";
        }
 
        public override bool IsIntersect(Rectangle rect)
        {
            return false;
        }
 
        public override bool IsMouseHover(Point p)
        {
            return false;
        }
 
        public override bool IsMouseInSide(Point p)
        {
            return false;
        }
 
        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
    }
}