From a383b2288dcfb90e9aa1dcf796e41d9c6be1e429 Mon Sep 17 00:00:00 2001 From: patrick.xu <patrick.xu@broconcentric.com> Date: 星期一, 02 八月 2021 17:26:56 +0800 Subject: [PATCH] 1. 部分修改 --- src/Bro.UI.Model.Winform/UI/Canvas.cs | 67 +++++++++++++++++++-------------- 1 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/Bro.UI.Model.Winform/UI/Canvas.cs b/src/Bro.UI.Model.Winform/UI/Canvas.cs index feb020d..9b7102f 100644 --- a/src/Bro.UI.Model.Winform/UI/Canvas.cs +++ b/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}锛孻锛歿screenPoint.Y} 鍥剧墖鍧愭爣X锛歿imagePoint.X}锛孻锛歿imagePoint.Y} 棰滆壊锛歿colorDesc}"); + this.Invoke(new Action(() => + { + tsslLocation.Text = $"灞忓箷鍧愭爣X锛歿screenPoint.X}锛孻锛歿screenPoint.Y} 鍥剧墖鍧愭爣X锛歿imagePoint.X}锛孻锛歿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}锛孻锛歿screenPoint.Y} 鍥剧墖鍧愭爣X锛歿imagePoint.X}锛孻锛歿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}锛孻锛歿screenPoint.Y} 鍥剧墖鍧愭爣X锛歿imagePoint.X}锛孻锛歿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 } } -- Gitblit v1.8.0