领胜LDS 键盘AOI检测项目
patrick.xu
2021-09-15 8bd46da0c9fbfe39a65d75b1d85692d8783f5905
src/Bro.UI.Model.Winform/UI/Canvas.cs
@@ -77,22 +77,26 @@
            set => stsStatus.Visible = value;
        }
        private void OnMouseLocationUpdated(Point screenPoint, Point imagePoint)
        private void OnMouseLocationUpdated(Point screenPoint, Point imagePoint, string colorDesc)
        {
            MouseLocationUpdated(screenPoint, imagePoint);
            //await Task.Run(() => tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y}    图片坐标X:{imagePoint.X},Y:{imagePoint.Y}   颜色:{colorDesc}");
            this.Invoke(new Action(() =>
            {
                tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y}    图片坐标X:{imagePoint.X},Y:{imagePoint.Y}   颜色:{colorDesc}";
            }));
        }
        private void MouseLocationUpdated(Point screenPoint, Point imagePoint)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<Point, Point>(MouseLocationUpdated), screenPoint, imagePoint);
            }
            else
            {
                tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y}    图片坐标X:{imagePoint.X},Y:{imagePoint.Y}";
            }
        }
        //private void MouseLocationUpdated(Point screenPoint, Point imagePoint, string colorDesc)
        //{
        //    if (InvokeRequired)
        //    {
        //        Invoke(new Action<Point, Point, string>(MouseLocationUpdated), screenPoint, imagePoint);
        //    }
        //    else
        //    {
        //        tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y}    图片坐标X:{imagePoint.X},Y:{imagePoint.Y}   颜色:{colorDesc}";
        //    }
        //}
        #endregion
        #region 属性
@@ -233,7 +237,7 @@
            {
                ele.IsEnabled = e.CheckedState;
            }
            OnElementChanged();
            OnElementChanged(null);
        }
        private void dgElements_SelectionChanged(object sender, EventArgs e)
@@ -266,7 +270,7 @@
        private void Elements_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            OnElementChanged();
            OnElementChanged(null);
            foreach (IShapeElement ele in Elements)
            {
@@ -277,14 +281,17 @@
        private void Ele_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            OnElementChanged();
            OnElementChanged(sender as IShapeElement);
        }
        private void OnElementChanged()
        private void OnElementChanged(IShapeElement ele)
        {
            if (ele != null)
                OnElementChangedHandle?.Invoke(ele);
            if (InvokeRequired)
            {
                Invoke(new Action(() => OnElementChanged()));
                Invoke(new Action(() => OnElementChanged(ele)));
            }
            else
            {
@@ -377,17 +384,17 @@
        private void tsmiUnselectElements_Click(object sender, EventArgs e)
        {
            if (MouseState == MouseState.SelectedElement)
            {
                MouseState = MouseState.Normal;
            //if (MouseState == MouseState.SelectedElement)
            //{
            //    MouseState = MouseState.Normal;
                //Elements.ForEach(ele =>
                foreach (IShapeElement ele in Elements)
                {
                    ele.State = ElementState.Normal;
                }
                //);
            }
            //    //Elements.ForEach(ele =>
            //    foreach (IShapeElement ele in Elements)
            //    {
            //        ele.State = ElementState.Normal;
            //    }
            //    //);
            //}
        }
        #endregion
@@ -539,5 +546,9 @@
            }
        }
        #endregion
        #region 事件
        public event Action<IShapeElement> OnElementChangedHandle;
        #endregion
    }
}