From 5241a8f6377dfd1618610dd15fd05ed6f51c8ba2 Mon Sep 17 00:00:00 2001
From: patrick.xu <patrick.xu@broconcentric.com>
Date: 星期三, 16 十二月 2020 11:19:45 +0800
Subject: [PATCH] 1. 添加默认流程和默认产品功能 2. 修改批量建立检测项功能

---
 src/Bro.M071.Process/M071Models.cs |  102 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 97 insertions(+), 5 deletions(-)

diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs
index beb5008..ed4c138 100644
--- a/src/Bro.M071.Process/M071Models.cs
+++ b/src/Bro.M071.Process/M071Models.cs
@@ -17,6 +17,42 @@
 
 namespace Bro.M071.Process
 {
+    public class KeyLocation : IComplexDisplay
+    {
+        [Category("閿悕閰嶇疆")]
+        [Description("鍗曢敭閿悕")]
+        [TypeConverter(typeof(KeyNameDictConverter))]
+        public string Key { get; set; }
+
+        [Category("榛樿閰嶇疆")]
+        [Description("鏄惁榛樿灏哄閰嶇疆")]
+        public bool IsDefault { get; set; } = false;
+
+        //[Category("浣嶇疆閰嶇疆")]
+        //[Description("鍗曢敭鍦ㄩ敭鐩樺钩闈㈠浘涓婄殑浣嶇疆鏄剧ず")]
+        //public RectangleF KeyRect { get; set; } = new RectangleF(0, 0, 0, 0);
+
+        [Category("浣嶇疆閰嶇疆")]
+        [Description("鍗曢敭宸︿笂瑙掑潗鏍�")]
+        [TypeConverter(typeof(ComplexObjectConvert))]
+        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
+        public CustomizedPoint KeyPosition { get; set; } = new CustomizedPoint();
+
+        [Category("浣嶇疆閰嶇疆")]
+        [Description("鍗曢敭灏哄")]
+        public SizeF KeySize { get; set; } = new SizeF();
+
+        [Category("浣嶇疆閰嶇疆")]
+        [Description("鍗曢敭涔嬪悗闂撮殭浣嶇疆")]
+        public SizeF IntervalSize { get; set; } = new SizeF();
+
+        public string GetDisplayText()
+        {
+            return $"{(IsDefault ? "Default" : Key)}:{KeyPosition.X},{KeyPosition.Y},{KeySize.Width},{KeySize.Height}";
+        }
+    }
+
+
     public class KeyAlgorithem : IComplexDisplay
     {
         [Browsable(false)]
@@ -48,6 +84,11 @@
         [Description("妫�娴嬬畻娉曡矾寰�")]
         [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
         public string AlgorithemPath { get; set; }
+
+        [Category("鏄剧ず閰嶇疆")]
+        [Description("鏄剧ず鍖哄煙澶у皬")]
+        [DisplayName("鏍囩澶у皬")]
+        public Size DisplayRect { get; set; }
     }
 
     public class KeyResult : IComplexDisplay
@@ -235,7 +276,7 @@
         {
             Measurements?.ForEach(m => m?.Dispose());
             Measurements = null;
-
+            ElementList = null;
             Barcode = null;
             GC.Collect();
         }
@@ -282,7 +323,7 @@
 
         #region 鏄剧ず
         [Browsable(false)]
-        public Rectangle DisplayLocation { get; set; } = new Rectangle();
+        public Rectangle DisplayLocation { get; set; } = new Rectangle(10, 10, 100, 100);
         #endregion
 
         #region 妫�娴嬬粨鏋�
@@ -319,6 +360,44 @@
         private void K_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("KeyUnitCollection"));
+        }
+
+        public MeasurementUnit Copy()
+        {
+            MeasurementUnit mUnit = new MeasurementUnit();
+
+            mUnit.Id = this.Id;
+            mUnit.Name = this.Name;
+            if (string.IsNullOrWhiteSpace(mUnit.Name))
+            {
+                mUnit.Name = string.Join("-", KeyUnitCollection.Select(u => u.GetDisplayText()));
+            }
+
+            mUnit.IsEnabled = this.IsEnabled;
+            mUnit.MeasureType = this.MeasureType;
+
+            mUnit.DisplayLocation = new Rectangle(this.DisplayLocation.Location, this.DisplayLocation.Size);
+
+            if (this.Spec == null)
+            {
+                mUnit.Spec = null;
+            }
+            else
+            {
+                mUnit.Spec = new MeasureType();
+                mUnit.Spec.Code = this.Spec.Code;
+                mUnit.Spec.AlgorithemPath = this.Spec.AlgorithemPath;
+                mUnit.Spec.StandardValue = this.Spec.StandardValue;
+                mUnit.Spec.Tolrenance_Positive = this.Spec.Tolrenance_Positive;
+                mUnit.Spec.Tolrenance_Negative = this.Spec.Tolrenance_Negative;
+            }
+
+            this.KeyUnitCollection.ForEach(k =>
+            {
+                mUnit.KeyUnitCollection.Add(k.Copy());
+            });
+
+            return mUnit;
         }
     }
 
@@ -369,10 +448,9 @@
 
         public void Dispose()
         {
-            SpinWait wait = new SpinWait();
             while (ImageSaveStatus != 0)
             {
-                wait.SpinOnce();
+                Thread.Sleep(10);
             }
 
             KeyImages?.ForEach(i =>
@@ -391,7 +469,7 @@
             {
                 if (valuePairs == null || valuePairs.Count == 0)
                 {
-                    IsDone = false; 
+                    IsDone = false;
                     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone"));
                     return;
                 }
@@ -415,6 +493,20 @@
                 }
             }
         }
+
+        public KeyUnitBind Copy()
+        {
+            KeyUnitBind clone = new KeyUnitBind();
+            clone.Key = this.Key;
+            clone.KeyResultId = this.KeyResultId;
+
+            this.MeasureValueDict.Keys.ToList().ForEach(k =>
+            {
+                clone.MeasureValueDict[k] = null;
+            });
+
+            return clone;
+        }
     }
 
     //public class NoticedDictionary<T1, T2> : Dictionary<T1, T2>, INotifyPropertyChanged

--
Gitblit v1.8.0