// If multiple nodes are selected and the method does not have the AllowMultiSelectionAttribute // attribute, disable the command. protected override void CommandUpdate(object target, CommandArrayInfo cinfo) { NodeCommandHandler nc = (NodeCommandHandler)target; base.CommandUpdate(target, cinfo); if (nc.MultipleSelectedNodes) { bool allowMultiArray = false; ICommandArrayUpdateHandler h = ((ICommandArrayUpdateHandler)this).Next; while (h != null) { if (h is AllowMultiSelectionAttribute) { allowMultiArray = true; break; } h = h.Next; } if (!allowMultiArray) { cinfo.Clear(); } } }
public void AddCustomHandlers (ICommandUpdateHandler handlerChain, ICommandArrayUpdateHandler arrayHandlerChain) { this.customHandlerChain = handlerChain; this.customArrayHandlerChain = arrayHandlerChain; }
ICommandArrayUpdateHandler ChainHandler (ICommandArrayUpdateHandler chain, object attr) { ICommandArrayUpdateHandler h = attr as ICommandArrayUpdateHandler; if (h == null) return chain; h.Next = chain ?? DefaultCommandHandler.Instance; return h; }