/// <summary> /// Displays the chosen event's parameters in the parameter panel. /// </summary> /// <param name="constructor">The event's constructor.</param> /// <param name="chooserMap">A mapping between a type to a function that instantiates a new chooser-control.</param> private void HandleEventChosen(Constructor constructor, Dictionary<Type, Func<IParamChooser>> chooserMap) { parameterPanel.ClearAllParameters(); chosenEventConstructor = constructor; AddParameters(constructor.Parameters, chooserMap); }
/// <summary> /// Posts an event. /// If the parameter-panel does not contain the event selected, it will display the event's /// parameters and not post the event. /// If the parameter-panel already displays this event's parameters of if the event does not require /// any parameters, posts the event immediatly using the launcher's own PostEvent method. /// </summary> /// <param name="constructor"></param> /// <param name="chooserMap"></param> /// <returns></returns> private bool PostEvent(Constructor constructor, Dictionary<Type, Func<IParamChooser>> chooserMap) { if (chosenEventConstructor == null) return false; else if (chosenEventConstructor != constructor) { HandleEventChosen(constructor, chooserMap); if (constructor.Parameters.Length == 0) return true; return false; } else return true; }
/// <summary> /// Creates a new dynamic event item. /// </summary> /// <param name="text">The label associated with this event-item.</param> /// <param name="constructor">The event's constructor.</param> public DynamicEventItem(string text, Constructor constructor) { Text = text; Constructor = constructor; }