public BarItemClickBinding(BarItem control, IUiCommand command) { _control = control; _command = command; _control.ItemClick += _control_ItemClick; Application.Idle += Application_Idle; }
public static void BindClick(this BarItem control, IUiCommand command) { if (CommandsBinder.Bindings.ContainsKey(control)) CommandsBinder.Bindings[control].Dispose(); CommandsBinder.Bindings[control] = new BarItemClickBinding(control, command); }
private void ItemClickEventHandler(object sender, ItemClickEventArgs e) { var button = e.Item as BarButtonItem; IUiCommand command = GetCommand(button); if (command != null) { command.Execute(); } }
public override bool Handle(IUiCommand command) { Log.Verbose("Main Phase Handle: IUiCommand"); if (Owner != Game.User.You) return false; var dragCommand = command as DragCommand; if (dragCommand == null) return false; var id = dragCommand.Source.name; var card =_game.GetCardById(id); if (!card.Owner.IsPlayable(card)) return false; _game.GameController.RpcPlayCard(id); return true; }
public void Start() { while (!app.IsQuitting) { ConsoleKeyInfo key; if (Console.KeyAvailable) { key = Console.ReadKey(true); } else { continue; } if (current != null && current.IsFinished()) { this.current = null; this.state = State.AwaitingCommand; } switch (this.state) { case State.AwaitingCommand: if (bindings.ContainsKey(key.KeyChar)) { this.current = Activator.CreateInstance(bindings[key.KeyChar], this.app) as IUiCommand; if (this.current == null) { throw new Exception(); } this.state = State.Command; this.current.Start(); } break; case State.Command: current.TakeKey(key); break; default: throw new Exception(); } } }
// Return is handled public virtual bool Handle(IUiCommand command) { return false; }
protected void RegisterCommand(IUiCommand command) { MyUiCommands.Add(command.Key, command); }
public bool Handle(IUiCommand command) { Log.Verbose("Handle UI Command"); return _phase.Handle(command); }
public CommandExecutedEventArgs(IUiCommand command) { Command = command; }