Ejemplo n.º 1
0
 public BarItemClickBinding(BarItem control, IUiCommand command)
 {
     _control = control;
     _command = command;
     _control.ItemClick += _control_ItemClick;
     Application.Idle += Application_Idle;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void ItemClickEventHandler(object sender, ItemClickEventArgs e)
        {
            var        button  = e.Item as BarButtonItem;
            IUiCommand command = GetCommand(button);

            if (command != null)
            {
                command.Execute();
            }
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
        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();
                }
            }
        }
Ejemplo n.º 6
0
 // Return is handled
 public virtual bool Handle(IUiCommand command)
 {
     return false;
 }
Ejemplo n.º 7
0
 protected void RegisterCommand(IUiCommand command)
 {
     MyUiCommands.Add(command.Key, command);
 }
Ejemplo n.º 8
0
 public bool Handle(IUiCommand command)
 {
     Log.Verbose("Handle UI Command");
     return _phase.Handle(command);
 }
Ejemplo n.º 9
0
 public CommandExecutedEventArgs(IUiCommand command)
 {
     Command = command;
 }