private readonly ThreeLetterFunCardData _tempCard; //not sure.

        public ThreeLetterFunMainView(IEventAggregator aggregator,
                                      TestOptions test,
                                      ThreeLetterFunMainGameClass mainGame,
                                      ThreeLetterFunVMData model,
                                      GameBoard gameBoard
                                      )
        {
            _aggregator = aggregator;
            _mainGame   = mainGame;
            _model      = model;
            _gameBoard  = gameBoard;
            model.NewUI = this;
            _aggregator.Subscribe(this);
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(ThreeLetterFunMainViewModel.RestoreScreen));
            }

            _tempCard         = new ThreeLetterFunCardData();
            _tempCard.Visible = false;
            _currentCard      = new CardGraphicsXF();
            _currentCard.SendSize(ThreeLetterFunCardGraphicsCP.TagUsed, _tempCard); //i think.

            var winLabel = GetDefaultLabel();

            winLabel.SetBinding(Label.TextProperty, new Binding(nameof(ThreeLetterFunMainViewModel.PlayerWon)));
            _score = new ScoreBoardXF();
            _score.AddColumn("Cards Won", true, nameof(ThreeLetterFunPlayerItem.CardsWon));
            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            mainStack.Children.Add(_currentCard);
            mainStack.Children.Add(winLabel);
            mainStack.Children.Add(_gameBoard1);
            mainStack.Children.Add(_tileBoard1);
            var thisBut = GetGamingButton("Play", nameof(ThreeLetterFunMainViewModel.PlayAsync));

            otherStack.Children.Add(thisBut);
            thisBut = GetGamingButton("Give Up", nameof(ThreeLetterFunMainViewModel.GiveUpAsync));
            otherStack.Children.Add(thisBut);
            thisBut = GetGamingButton("Take Back", nameof(ThreeLetterFunMainViewModel.TakeBack));
            otherStack.Children.Add(thisBut);
            mainStack.Children.Add(otherStack);
            mainStack.Children.Add(_score);

            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }



            Content = mainStack;
        }
Example #2
0
        public CandylandMainView(IEventAggregator aggregator,
                                 TestOptions test,
                                 IGamePackageRegister register
                                 )
        {
            BackgroundColor = Color.White;
            _aggregator     = aggregator;
            _aggregator.Subscribe(this);
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(CandylandMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            _ourBoard = new GameBoardXF();
            register.RegisterControl(_ourBoard.Element, "main");
            _ourCard = new CardGraphicsXF(); // bindings are finished
            _ourCard.SendSize("main", new CandylandCardData());
            otherStack.Margin      = new Thickness(5, 5, 5, 5);
            otherStack.Orientation = StackOrientation.Horizontal;
            StackLayout firstStack = new StackLayout();

            otherStack.Children.Add(firstStack);
            firstStack.Children.Add(_ourCard); //you already subscribed.  just hook up another event for this.
            _ourPiece        = new PieceXF();
            _ourPiece.Margin = new Thickness(0, 5, 0, 0);
            _ourPiece.SetSizes();
            BaseLabelGrid firstInfo = new BaseLabelGrid();

            firstInfo.AddRow("Turn", nameof(CandylandMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(CandylandMainViewModel.Status));
            firstStack.Children.Add(firstInfo.GetContent);
            firstStack.Children.Add(_ourPiece);
            _ourBoard.HorizontalOptions = LayoutOptions.Start;
            _ourBoard.VerticalOptions   = LayoutOptions.Start;
            _ourBoard.Margin            = new Thickness(5, 0, 0, 0);
            otherStack.Children.Add(_ourBoard);
            mainStack.Children.Add(otherStack);


            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
Example #3
0
        private async Task PrepareToAnimateAsync(AnimateCardInPileEventModel <FlinchCardInformation> data) // don't need index ever for this.
        {
            var thisPile      = FindControl(data.ThisPile !);
            var topLocation   = GetStartLocation();
            var bottomLocaton = GetBottomLocation();
            var cardLocation  = GetCardLocation(thisPile !);

            switch (data.Direction)
            {
            case EnumAnimcationDirection.StartCardToDown:
            {
                _animates !.LocationFrom = cardLocation;
                _animates.LocationTo     = bottomLocaton;
                break;
            }

            case EnumAnimcationDirection.StartCardToUp:
            {
                _animates !.LocationFrom = cardLocation;
                _animates.LocationTo     = topLocation;
                break;
            }

            case EnumAnimcationDirection.StartDownToCard:
            {
                _animates !.LocationFrom = bottomLocaton;
                _animates.LocationTo     = cardLocation;
                break;
            }

            case EnumAnimcationDirection.StartUpToCard:
            {
                _animates !.LocationFrom = topLocation;
                _animates.LocationTo     = cardLocation;
                break;
            }
            }
            CardGraphicsXF thisControl = new CardGraphicsXF();

            thisControl.SendSize("", data.ThisCard !);
            thisControl.Drew       = false;
            thisControl.IsSelected = false;
            thisControl.DoInvalidate();
            await _animates !.DoAnimateAsync(thisControl); // i think

            thisControl.IsVisible = false;
            _thisCanvas !.Children.Clear(); //try this too.
        }