diff --git a/WireEventImplementor/WireInstances.cs b/WireEventImplementor/WireInstances.cs index ebe1c5a..85d3fc3 100644 --- a/WireEventImplementor/WireInstances.cs +++ b/WireEventImplementor/WireInstances.cs @@ -1,4 +1,5 @@ -using Grasshopper.GUI.Canvas; +using Grasshopper; +using Grasshopper.GUI.Canvas; using Grasshopper.GUI.Canvas.Interaction; using Grasshopper.Kernel; using System; @@ -33,6 +34,23 @@ public static class WireInstances private static TaskCompletionSource m_source = new TaskCompletionSource(); + public static void OnWiring(WireStatus wireStatus) + { + Wiring?.Invoke(wireStatus); + } + + public static void OnPreWired(WireStatus wireStatus) + { + PreWired?.Invoke(wireStatus); + } + + public static void OnPostWired(WireStatus wireStatus) + { + PostWired?.Invoke(wireStatus); + if (Instances.ActiveCanvas.ActiveInteraction is GH_WireInteraction) + Instances.ActiveCanvas.ActiveInteraction = null; + } + /// /// Call when canvas created. /// @@ -54,10 +72,10 @@ private static void Canvas_MouseMove(object sender, MouseEventArgs e) m_source = new TaskCompletionSource(); if (status.WireTarget == null) - Wiring?.Invoke(status); + OnWiring(status); else { - PreWired?.Invoke(status); + OnPreWired(status); m_source.SetResult(status); } } @@ -71,7 +89,7 @@ private static async void Canvas_MouseUp(object sender, MouseEventArgs e) WireStatus status = await m_source.Task; m_source = new TaskCompletionSource(); - PostWired?.Invoke(status); + OnPostWired(status); (sender as GH_Canvas).Refresh(); }