/// <summary> connect controllers and delegate event handlers. </summary> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> current/size/search/enter/remove fields. </param> /// <param name="click"> add to eventhandlers, null to skip. </param> public virtual void Connect(Enable enable, IAccess[] io, SetClick[] click) { // connect controllers for i/o for (int n = controller.Length; --n >= 0; ) controller[n].Connect(enable, io); // show current name and size io[0].Text = name[current]; controller[current].doSize(null, null); // delegate event handlers if (click[0] != null) click[0]((sender, e) => { // advance controller, show name and size current = (current + 1) % controller.Length; io[0].Text = name[current]; controller[current].doSize(null, null); }); if (click[1] != null) click[1]((sender, e) => controller[current].doSearch(sender, e)); if (click[2] != null) click[2]((sender, e) => controller[current].doEnter(sender, e)); if (click[3] != null) click[3]((sender, e) => controller[current].doRemove(sender, e)); if (click[4] != null) click[4]((sender, e) => controller[current].doSize(null, null)); }
/// <summary> create and connect controllers. </summary> /// <param name="enable"> controls user interaction in view. </param> /// <param name="io"> current/size/search/enter/remove fields. </param> /// <param name="click"> add to eventhandlers, null to skip. </param> /// <param name="bg"> for sequential background execution. </param> /// <param name="nameModel"> one or more name/db model pairs. </param> public Switcher(Enable enable, IAccess[] io, SetClick[] click, WorkQueue bg, params object[] nameModel) : this(bg, nameModel) { Connect(enable, io, click); }