private void RunAction(TextBoxAction action) { if (!action.WillDoNothing() && !AskClientsToProcessAction(action)) { action.Execute(); } }
/// <summary> /// Sends an event to clients telling them an action is ready /// to be executed. If they process the action, the textbox /// doesn't have to execute the action itself, /// so AskClientsToProcessAction returns true. /// If noone cares about the action, the textbox should /// execute the action itself, so the default value is false. /// </summary> /// <param name="action">An action which was just recorded and /// is about to be executed either by the clients /// or by the textbox itself.</param> /// <returns>true if the action has already been processed, /// false otherwise (the textbox needs to process the action itself)</returns> private bool AskClientsToProcessAction(TextBoxAction action) { if (TextBoxChangePending != null) { TextBoxChangeEventArgs e = new TextBoxChangeEventArgs(); e.Action = action; e.Handled = false; e.Textbox = this; TextBoxChangePending(this, e); return(e.Handled); } return(false); }
/// <summary> /// Sends an event to clients telling them an action is ready /// to be executed. If they process the action, the textbox /// doesn't have to execute the action itself, /// so AskClientsToProcessAction returns true. /// If noone cares about the action, the textbox should /// execute the action itself, so the default value is false. /// </summary> /// <param name="action">An action which was just recorded and /// is about to be executed either by the clients /// or by the textbox itself.</param> /// <returns>true if the action has already been processed, /// false otherwise (the textbox needs to process the action itself)</returns> private bool AskClientsToProcessAction(TextBoxAction action) { if (TextBoxChangePending != null) { TextBoxChangeEventArgs e = new TextBoxChangeEventArgs(); e.Action = action; e.Handled = false; e.Textbox = this; TextBoxChangePending(this, e); return e.Handled; } return false; }