public NewRoundBoardPage()
        {
            this.InitializeComponent();
            _uiClasses.Board                 = _board;
            _uiClasses.GridDeck              = _gridDeck;
            _uiClasses.LayoutRoot            = LayoutRoot;
            _uiClasses.CenterGrid            = PlayGrid;
            _uiClasses.Dispatcher            = Dispatcher;
            _uiClasses.GridPlayer            = _gridPlayer;
            _uiClasses.GridComputer          = _gridComputer;
            _uiClasses.GridPlayedCards       = _gridPlayedCards;
            _uiClasses.GridCrib              = _gridCrib;
            _uiClasses.CountControl          = _ctrlCount;
            _uiClasses.ShowInstructionsUi    = _hintWindow;
            _uiClasses.PlayerSetScoreControl = _board;
            _uiClasses.ViewCallback          = this;
            _uiClasses.FriendlyName          = "RoundPage";

            _view = new CribbageView(_uiClasses);
            _view.Initialize();

            _initTimer.Interval = TimeSpan.FromMilliseconds(100);
            _initTimer.Tick    += InitOnceAsyc;
            _initTimer.Start();



            _board.HideAsync();
        }
Example #2
0
        private async Task Init()
        {
            LogTrace = new LogTrace();
            await LogTrace.Init(true);

            Current = this;

            AnimationSpeeds = new AnimationSpeedsClass(AnimationSpeedSetting.Regular);
            _deck           = new Deck();

            InitializeSettings();
            _windowBounds = Window.Current.Bounds;
            Window.Current.SizeChanged += OnWindowSizeChanged;
            _settingsPopup              = new Popup();
            CurrentBoardType            = BoardType.Uninitialized;

            _frame.Navigate(typeof(NewRoundBoardPage));
            CurrentBoardType = BoardType.Round;

            CribbageView view = GetCribbageView();

            view.InitializeAsync(_deck, _stateMachine);



            if (_stateMachine != null)
            {
                _stateMachine.TransferState();
            }


            _appBarBottom.IsOpen = true;
        }
Example #3
0
        private async void OnNewGame(object sender, RoutedEventArgs e)
        {
            _btnNewGame.IsEnabled = false;
            _appBarBottom.IsOpen  = false;
            CribbageView view = GetCribbageView();

            _stateMachine = new ClientStateMachine();
            _stateMachine.Init(false, view);
            await view.OnNewGame(_stateMachine);

            _btnNewGame.IsEnabled = true;
        }
 public void Init(bool wantCallback, CribbageView view)
 {
     _boardUi = new UIState(view.Board);
     _view    = view;
     if (wantCallback)
     {
         _initTimer.Tick    += AysnInit;
         _initTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
         _initTimer.Start();
     }
     _asyncStateTimer.Interval = TimeSpan.FromMilliseconds(500);
     _asyncStateTimer.Tick    += OnSetStateAsync;
 }
Example #5
0
        private async void OnOpenGame(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            b.IsEnabled           = false;
            _btnNewGame.IsEnabled = false;
            _appBarBottom.IsOpen  = false;
            try
            {
                var filePicker = new FileOpenPicker();
                filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                filePicker.ViewMode = PickerViewMode.List;
                filePicker.FileTypeFilter.Add(".crib");
                StorageFile file = await filePicker.PickSingleFileAsync();

                if (file == null)
                {
                    return;
                }



                using (var stream = await file.OpenStreamForReadAsync())
                {
                    using (var streamReader = new StreamReader(stream))
                    {
                        string savedGame = streamReader.ReadToEnd();

                        CribbageView view = GetCribbageView();
                        _stateMachine = new ClientStateMachine();
                        _stateMachine.Init(false, view);
                        await view.OnLoadGame(_stateMachine);

                        await _stateMachine.Load(savedGame);
                    }
                }
            }

            finally
            {
                b.IsEnabled           = true;
                _btnNewGame.IsEnabled = true;
            }
        }
 public void TransfertoNewUI(CribbageView view)
 {
     _view = view;
 }