/// <summary> /// Called when removing a delegate from an event, see the /// GroundPlane.Changed event for an example. /// </summary> /// <param name="type"> /// The event watcher type index /// </param> /// <param name="value"> /// Delegate to remove /// </param> public static void Remove(UnsafeNativeMethods.EventSyncDocumentSettingsChangedFlag type, EventHandler <RenderPropertyChangedEvent> value) { // Remove from the dictionary if (g_event_dictionary.ContainsKey(type)) { g_event_dictionary[type] -= value; } // If there are still event hooks set then bail if (!IsEmpty) { return; } // There are no event hooks set so call into rhcmnrdk_c to set the // callback hook to null. UnsafeNativeMethods.CRdkCmnEventWatcher_SetDocumentSettingsChangedEventCallback(null, Rhino.Runtime.HostUtils.m_rdk_ew_report); g_settings_changed_hook = null; }
/// <summary> /// Called when adding a delegate to a event, see the GroundPlane.Changed /// event for an example. /// </summary> /// <param name="type"> /// The event watcher type index /// </param> /// <param name="value"> /// Delegate to add /// </param> public static void Add(UnsafeNativeMethods.EventSyncDocumentSettingsChangedFlag type, EventHandler <RenderPropertyChangedEvent> value) { // If the callback hook has not been set then set it now if (g_settings_changed_hook == null) { // Call into rhcmnrdk_c to set the callback hook g_settings_changed_hook = OnSettingsChanged; UnsafeNativeMethods.CRdkCmnEventWatcher_SetDocumentSettingsChangedEventCallback(g_settings_changed_hook, Rhino.Runtime.HostUtils.m_rdk_ew_report); } if (!g_event_dictionary.ContainsKey(type)) { g_event_dictionary.Add(type, null); } // Need to do this to ensure the delegate does not get added twice g_event_dictionary[type] -= value; // Add the new delegate to the event list g_event_dictionary[type] += value; }