void attachToSingleControl(Control control, IStandardEventListener listener, bool isAttach) { Button button = control as Button; if (null != button) { if (isAttach) { button.Click += listener.OnButtonClick; } else { button.Click -= listener.OnButtonClick; } return; } CheckBox checkBox = control as CheckBox; if (null != checkBox) { if (isAttach) { checkBox.CheckedChanged += listener.OnCheckedChanged; } else { checkBox.CheckedChanged -= listener.OnCheckedChanged; } return; } }
public void ReplaceStandardEventListener(IStandardEventListener newValue) { var index = TestComponentsLookup.StandardEventListener; var component = CreateComponent <StandardEventListenerComponent>(index); component.value = newValue; ReplaceComponent(index, component); }
public void AddStandardEventListener(IStandardEventListener value) { var listeners = hasStandardEventListener ? standardEventListener.value : new System.Collections.Generic.List <IStandardEventListener>(); listeners.Add(value); ReplaceStandardEventListener(listeners); }
public void RemoveStandardEventListener(IStandardEventListener value) { var listeners = standardEventListener.value; listeners.Remove(value); if (listeners.Count == 0) { RemoveStandardEventListener(); } else { ReplaceStandardEventListener(listeners); } }
void attachToSingleControl(ToolStripItem control, IStandardEventListener listener, bool isAttach) { ToolStripButton button = control as ToolStripButton; if (null != button) { if (isAttach) { button.Click += listener.OnButtonClick; } else { button.Click -= listener.OnButtonClick; } return; } }
void doAttachEvents(Control control, IStandardEventListener listener, bool isAttach) { attachToSingleControl(control, listener, isAttach); var strip = control as ToolStrip; if (strip != null) { foreach (ToolStripItem child in strip.Items) { attachToSingleControl(child, listener, isAttach); } } else { foreach (Control child in control.Controls) { doAttachEvents(child, listener, isAttach); } } }
public void DetachEvents(Control control, IStandardEventListener listener) { doAttachEvents(control, listener, false); }
public void AttachEvents(Control control, IStandardEventListener listener) { doAttachEvents(control, listener, true); }