示例#1
0
 /// <summary>
 /// Initializes a new instance of OptionViewModel.
 /// </summary>
 /// <param name="accessor">An object that provide access to control keys.</param>
 /// <param name="validator">An object that is used to validate control keys.</param>
 public OptionsViewModel(IHaveControlKeys accessor, IKeysValidator validator) : base("Options")
 {
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     Accessor = accessor;
     if (validator == null)
     {
         throw new ArgumentNullException(nameof(validator));
     }
     _vaidator       = validator;
     _timer          = new DispatcherTimer();
     _timer.Interval = TimeSpan.FromMilliseconds(1000);
     _timer.Tick    += (x, e) => ClearAllActiveKeysAndErrors();
 }
示例#2
0
        private Key GetKeyByName(IHaveControlKeys accessor, string name)
        {
            switch (name)
            {
            case "Left":
                return(accessor.LeftKey);

            case "Right":
                return(accessor.RightKey);

            case "Up":
                return(accessor.UpKey);

            case "Down":
                return(accessor.DownKey);

            default:
                return(Key.None);
            }
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of GameViewModel object.
 /// </summary>
 /// <param name="builder">An object that builds core game objects.</param>
 /// <param name="viewModelChanger">An object that changes views in the application.</param>
 /// <param name="accessor">An object that have access to control keys.</param>
 /// <param name="provider">An object that provides some configuration settings used in the game.</param>
 public GameViewModel(IGameBuilder builder, IViewModelChanger viewModelChanger, IHaveControlKeys accessor, ISettingsProvider provider) : base("Game")
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     _builder = builder;
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     _accessor = accessor;
     if (viewModelChanger == null)
     {
         throw new ArgumentNullException(nameof(viewModelChanger));
     }
     _viewModelChanger = viewModelChanger;
     if (provider == null)
     {
         throw new ArgumentNullException(nameof(provider));
     }
     _provider = provider;
 }