public async void Register( )
        {
            _view = ViewPresenterManager.ResolveView(typeof(IStatisticView)) as IStatisticView;
            _main = MainPresenter.Get();

            var games = await DbLocal.FetchChessResults();

            var data = new StatisticViewData();

            data.TotalPlayed = games.Count();
            data.CountDraws  = games.Count(x => x.Winner == 0);
            data.CountLoses  = games.Count(x => x.Winner == 2);
            data.CountWins   = data.TotalPlayed - data.CountLoses - data.CountDraws;
            int maxLen     = 0;
            int currentMax = 0;

            foreach (var game in games)
            {
                if (game.Winner == 1)
                {
                    currentMax++;
                }
                else
                {
                    if (maxLen < currentMax)
                    {
                        maxLen = currentMax;
                    }
                }
            }
            data.LongestWins = maxLen;

            _view.Start(data);
            _main.QueryForSetupView(_view as UserControl);
        }
        public async void Register( )
        {
            _main = MainPresenter.Get();
            _view = ViewPresenterManager.ResolveView(typeof(IRemoteSetupView)) as IRemoteSetupView;

            var users = await DbLocal.FetchUsers();

            _view.Contacts  = users?.ToList();
            _view.StartGame = (addr) => {
                var gamePres = new ChessBoardPresenter();
                var canPlay  = RemoteManager.ConnectTo(new Connection {
                    Address = addr.Split(':')[0],
                    Port    = addr.Split(':')[1]
                });
                if (canPlay)
                {
                    _main.ShowInfo("Невозможно подключиться");
                    _main.ReleaseControl();
                    return;
                }
                gamePres.Register(new Model.Game.Chess.ChessSettings {
                    Type          = Model.Game.Chess.GameType.Remote,
                    IsWhite       = true,// TODO:
                    SecondLimited = -1
                });
            };
            _view.Cancel = () => {
                _main.ReleaseControl();
            };

            _view.Start();
            _main.QueryForSetupView(_view as UserControl);
        }
Esempio n. 3
0
        public AddCardPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService)
        {
            _navigationService = navigationService;

            _pageDialogService = pageDialogService;

            dbLocal = new DbLocal();

            wiFiConection = new WiFiConnection();

            firebase = new FireBaseHelper();
        }
Esempio n. 4
0
        public MainPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            carCardsData = new DbLocal();

            wiFiConection = new WiFiConnection();

            firebase = new FireBaseHelper();

            Cards = LoadCards();
        }