领胜LDS 键盘AOI检测项目
patrick.xu
2021-02-20 b3aa95bab5796caaf28a06922abf111ae55e37df
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using Autofac;
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
 
namespace Bro.M071.Process
{
    internal class KeyNameDictConverter : StringConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
 
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }
 
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    return new StandardValuesCollection(config.KeyNameCollection);
                }
            }
 
            return base.GetStandardValues(context); ;
        }
    }
 
    internal class SnapshotPointConverter : ComboBoxItemTypeConvert
    {
        public override Hashtable GetConvertHash(ITypeDescriptorContext context)
        {
            Hashtable table = new Hashtable();
 
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s =>
                      {
                          table[s.Id] = s.Name;
                      });
                }
            }
 
            return table;
        }
    }
 
    internal class KeyAlgorithemConverter : ComboBoxItemTypeConvert
    {
        public override Hashtable GetConvertHash(ITypeDescriptorContext context)
        {
            Hashtable table = new Hashtable();
 
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    config.KeyAlgorithemCollection.ForEach(s =>
                    {
                        table[s.Id] = s.Name;
                    });
                }
            }
 
            return table;
        }
    }
 
    internal class KeyResultConverter : ComboBoxItemTypeConvert
    {
        public override Hashtable GetConvertHash(ITypeDescriptorContext context)
        {
            Hashtable table = new Hashtable();
 
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    config.KeyResultCollection.ForEach(s =>
                    {
                        table[s.Id] = s.Name;
                    });
                }
            }
 
            return table;
        }
    }
 
    //internal class KeyUnitConverter : ComboBoxItemTypeConvert
    //{
    //    public override Hashtable GetConvertHash(ITypeDescriptorContext context)
    //    {
    //        Hashtable table = new Hashtable();
 
    //        using (var scope = GlobalVar.Container.BeginLifetimeScope())
    //        {
    //            IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
    //            if (iConfig is M071Config config)
    //            {
    //                config.KeyUnitCollection.ForEach(s =>
    //                {
    //                    table[s.Id] = s.Key;
    //                });
    //            }
    //        }
 
    //        return table;
    //    }
    //}
 
    internal class KeyUnitResultConverter : ComboBoxItemTypeConvert
    {
        public override Hashtable GetConvertHash(ITypeDescriptorContext context)
        {
            Hashtable table = new Hashtable();
 
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    var resultIds = config.KeyUnitCollection.Where(u => u.IsEnabled && u.Key == (context.Instance as KeyUnitBind).Key).Select(u => u.KeyResultId).ToList();
 
                    var result = config.KeyResultCollection.Where(u => resultIds.Contains(u.Id)).SelectMany(u => u.Results).ToList();
 
                    if (result != null && result.Count > 0)
                    {
                        result.ForEach(r =>
                        {
                            table.Add(r, r);
                        });
 
                        table.Add("All", "All");
                    }
                }
            }
 
            return table;
        }
    }
 
    internal class MeasureTypeConverter : StringConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
 
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }
 
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            using (var scope = GlobalVar.Container.BeginLifetimeScope())
            {
                IProcessConfig iConfig = scope.Resolve<IProcessConfig>();
 
                if (iConfig is M071Config config)
                {
                    return new StandardValuesCollection(config.MeasureTypeCollection.Select(u => u.Code).ToList());
                }
            }
 
            return base.GetStandardValues(context); ;
        }
    }
}