Beispiel #1
0
        private async Task ClearStatisticsHelper()
        {
            var playerTodelete = Players.FirstOrDefault(m => m.Id == PlayerDetails.Id);

            await _statisticsRepository.DeleteByPlayerId(PlayerDetails.Id);

            CheckForChangedPlayer();

            MessageBus.Current.SendMessage(new List <Player> {
                new Player(0)
                {
                    PlayerDetails = playerTodelete
                }
            });

            ShowStatsCommand.Execute(false);
        }
Beispiel #2
0
 private void ShowDetail(object arg)
 {
     ShowStatsCommand.Execute(false);
     ShowPlayerView = false;
 }
Beispiel #3
0
        private void LoadCommands()
        {
            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                var imageDefinition = await _imageLoadTask.PickThumbnailImage();

                return(imageDefinition);
            });

            LoadCommand.Subscribe(LoadThumbnailImage);

            SnapCommand = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                var camera = new CameraCaptureUI();

                var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);

                return(await _imageLoadTask.GetImageDefinitionFromFile(file));
            });

            SnapCommand.Subscribe(LoadThumbnailImage);

            SaveCommand =
                ReactiveCommand.Create(this.WhenAny(x => x.PlayerDetails.IsDirty, x => x.PlayerDetails.Name,
                                                    x => x.PlayerDetails.NickName,
                                                    (isDirty, name, nickName) =>
                                                    isDirty.Value && !string.IsNullOrWhiteSpace(name.Value) &&
                                                    !string.IsNullOrWhiteSpace(nickName.Value)));

            SaveCommand.Subscribe(arg => SaveCommandHandler());

            SaveCommand.CanExecuteObservable.Subscribe(HandleSaveCanExecuteChangedHandler);

            DeleteCommand = ReactiveCommand.Create(this.WhenAny(x => x.PlayerDetails.Id,
                                                                id => id.Value != Guid.Empty));

            DeleteCommand.Subscribe(async arg => await DeleteCommandHandler());

            DeleteCommand.CanExecuteObservable.Subscribe(HandleDeleteCanExecuteChangedHandler);

            CreateNewCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.PlayerDetails.IsDirty)
                                                      .Select(x => !x).Skip(1));

            CreateNewCommand.Subscribe(arg => CreateCommandHandler());

            CreateNewCommand.CanExecuteObservable.Subscribe(HandleNewCanExecuteChangedHandler);

            ShowStatsCommand = ReactiveCommand.Create();

            ShowStatsCommand.Subscribe(arg =>
            {
                var newId = arg is Guid ? (Guid?)arg : null;

                if (newId.HasValue)
                {
                    ClickedPlayerId = newId.Value;
                }
            });

            ShowStatsCommand.CanExecuteObservable.Subscribe(HandleShowStatsCommandChangedHandler);

            PlayerSummaryCommand = ReactiveCommand.Create();

            PlayerSummaryCommand.Subscribe(ShowSummary);

            PlayerDetailCommand = ReactiveCommand.Create();

            PlayerDetailCommand.Subscribe(ShowDetail);
        }
Beispiel #4
0
 private void ShowSummary(object arg)
 {
     ShowStatsCommand.Execute(false);
     ShowPlayerView = true;
 }