Ejemplo n.º 1
0
        protected CommandBindingManagerBase(ICommandManager commandManager, InputCommandBinder inputCommandBinder, Game game)
        {
            mInputCommandBinder = inputCommandBinder;

            commandManager.Add(ESCAPE, game.Exit);
            commandManager.Add(TAKE_SCREENSHOT, game.TakeScreenshot);

            mInputCommandBinder.Bind(Button.Escape, ESCAPE);
            mInputCommandBinder.Bind(Button.PrintScreen, TAKE_SCREENSHOT);
        }
Ejemplo n.º 2
0
 public ToolDemo(ICommandManager commandManager, IKeyboard keyboard, IConfig <Config> config)
 {
     token = commandManager.Add(keyboard.Down(Caps + A),
                                e => { Logger.LogInformation($"{nameof(ToolDemo)}: Caps+A triggered!!!!!!!"); });
     Logger.LogInformation(config.CurrentValue.Option1);
     Logger.LogInformation(config.CurrentValue.Option2.ToString());
 }
Ejemplo n.º 3
0
        public ToolDemo(ICommandManager commandManager, IKeyboard keyboard, IConfig <Config> config)
        {
            CommandA = commandManager.Add(keyboard.OnDown(AK + A),
                                          e => { Logger.LogInformation($"{nameof(ToolDemo)}: Caps+A triggered!!!!!!!"); });
            CommandB = (Caps + B).OnDown(e => Logger.LogWarning("Caps+B pressed!!!"));

            Logger.LogInformation(config.CurrentValue.Option1);
            Logger.LogInformation(config.CurrentValue.Option2.ToString());
            RegisterCommands();
        }
        /// <summary>
        /// Build command.
        /// </summary>
        /// <returns></returns>
        public ICommand Build()
        {
            var executeAction = new Action <object>(async _ => await navigationService.PopViewModel());

            if (commandManager != null)
            {
                return(commandManager.Add(executeAction));
            }

            return(new Command(executeAction));
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serviceContainer"></param>
        public ThemeViewModel(IUnityContainer serviceContainer)
        {
            // Resolve themes.
            themeService = serviceContainer.Resolve <IThemeService>();
            popupService = serviceContainer.Resolve <IPopupService>();

            // Setup commands.
            ItemTappedCommand = commandManager.Add(OnItemTapped);

            // Refresh IsActive state of each theme.
            RefreshThemesActivity();
        }
        /// <summary>
        /// Build command.
        /// </summary>
        /// <returns></returns>
        public ICommand Build()
        {
            if (viewModelType == null)
            {
                throw new ArgumentNullException(nameof(viewModelType));
            }

            var executeAction = new Action <object>(async _ => await modalService.Push(viewModelType));

            if (commandManager != null)
            {
                return(commandManager.Add(executeAction));
            }

            return(new Command(executeAction));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="navigationService"></param>
        /// <remarks>
        /// Require: <see cref="INavigationService"/>
        /// </remarks>
        public WelcomeViewModel(IUnityContainer unityContainer)
        {
            // Resolve services.
            modalService = unityContainer.Resolve <IModalService>();
            unityContainer.TryResolve <IThemeService>(out themeService);

            // Setup commands.
            ContinueCommand = commandManager.Add(async _ =>
            {
                commandManager.DisableAll();

                await Task.Delay(200);
                await modalService.Pop();

                commandManager.EnableAll();
            });
        }
Ejemplo n.º 8
0
        public CameraCommandManager(ICommandManager commandManager, InputCommandBinder inputCommandBinder, Stand stand)
        {
            commandManager.Add(MOVE_FORWARD, () => stand.Position += stand.Direction * mFrameTime * mSpeedFactor);
            commandManager.Add(MOVE_BACKWARD, () => stand.Position -= stand.Direction* mFrameTime * mSpeedFactor);
            commandManager.Add(STRAFE_RIGHT, () => stand.Position += stand.Direction.Cross(stand.Up) * mFrameTime * mSpeedFactor);
            commandManager.Add(STRAFE_LEFT, () => stand.Position -= stand.Direction.Cross(stand.Up) * mFrameTime * mSpeedFactor);
            commandManager.Add(UP, () => stand.Position += stand.Up * mFrameTime * mSpeedFactor);
            commandManager.Add(DOWN, () => stand.Position -= stand.Up* mFrameTime * mSpeedFactor);
            commandManager.Add(SPEEDFACTOR, () => mSpeedFactor = 20);

            inputCommandBinder.Bind(Button.LeftShift, SPEEDFACTOR);
            inputCommandBinder.Bind(Button.W, MOVE_FORWARD);
            inputCommandBinder.Bind(Button.S, MOVE_BACKWARD);
            inputCommandBinder.Bind(Button.D, STRAFE_RIGHT);
            inputCommandBinder.Bind(Button.A, STRAFE_LEFT);
            inputCommandBinder.Bind(Button.R, UP);
            inputCommandBinder.Bind(Button.F, DOWN);
        }
        public FirstPersonCameraCommandBindingManager(ICommandManager commandManager, InputCommandBinder inputCommandBinder, FirstPersonStand stand, Game game)
            : base(commandManager, inputCommandBinder, stand, game)
        {
            commandManager.Add(TURN_LEFT, () => stand.Yaw(-FrameTime));
            commandManager.Add(TURN_RIGHT, () => stand.Yaw(FrameTime));
            commandManager.Add(TURN_UP, () => stand.Pitch(-FrameTime));
            commandManager.Add(TURN_DOWN, () => stand.Pitch(FrameTime));
            commandManager.Add(ROLL_LEFT, () => stand.Roll(FrameTime));
            commandManager.Add(ROLL_RIGHT, () => stand.Roll(-FrameTime));

            inputCommandBinder.Bind(Button.J, TURN_LEFT);
            inputCommandBinder.Bind(Button.L, TURN_RIGHT);
            inputCommandBinder.Bind(Button.I, TURN_UP);
            inputCommandBinder.Bind(Button.K, TURN_DOWN);
            inputCommandBinder.Bind(Button.U, ROLL_LEFT);
            inputCommandBinder.Bind(Button.O, ROLL_RIGHT);
        }
        public OrbitingCameraCommandBindingManager(ICommandManager commandManager, InputCommandBinder inputCommandBinder, OrbitingStand stand, Game game)
            : base(commandManager, inputCommandBinder, game)
        {
            commandManager.Add(MOVE_BACKWARD, () => stand.Radius += FrameTime);
            commandManager.Add(MOVE_FORWARD, () => stand.Radius -= FrameTime);
            commandManager.Add(STRAFE_RIGHT, () => stand.Azimuth -= FrameTime);
            commandManager.Add(STRAFE_LEFT, () => stand.Azimuth += FrameTime);
            commandManager.Add(UP, () => stand.Declination += FrameTime);
            commandManager.Add(DOWN, () => stand.Declination -= FrameTime);

            inputCommandBinder.Bind(Button.W, MOVE_FORWARD);
            inputCommandBinder.Bind(Button.S, MOVE_BACKWARD);
            inputCommandBinder.Bind(Button.D, STRAFE_RIGHT);
            inputCommandBinder.Bind(Button.A, STRAFE_LEFT);
            inputCommandBinder.Bind(Button.R, UP);
            inputCommandBinder.Bind(Button.F, DOWN);
        }
Ejemplo n.º 11
0
        private void Add(ICommandManager commandManager, IPlugin plugin, AliasData unparsedAlias, 
            IExpression alias, bool store)
        {
            ushort arity = alias.Arity;
            QualifiedNameTypes qualifiedName =
                QualifiedAliasName(plugin.Name, unparsedAlias.Name, arity);

            if(_aliases.ContainsKey(qualifiedName) || _commands.ContainsKey(qualifiedName))
                throw new InvalidOperationException("Alias with name " + unparsedAlias.Name + " and arity " + arity
                    + " already exists.");

            AliasCommand command = new AliasCommand(plugin, unparsedAlias.Name,
                "Alias for (" + ControlCodes.Bold(unparsedAlias.Expression) + ")", false, alias);
            commandManager.Add(command);

            _unqualifiedAliases.Add(unparsedAlias.Name, arity);
            _commands.Add(qualifiedName, command);
            _aliases.Add(qualifiedName, unparsedAlias);
            if(store)
                Aliases.Add(unparsedAlias);
        }