private void BindCard(DeckOfCardsXF <SolitaireCard> thisGraphics, SolitaireCard thisCard)
 {
     thisGraphics.NeedsExtraSuitForSolitaire = true; //i think
     thisGraphics.SendSize(ts.TagUsed, thisCard);
     thisGraphics.DisableInput = true;               //try this too.  was originally disableone.
     //thisGraphics.InputTransparent = true; //try both this time.
 }
        private DeckOfCardsXF <HeapSolitaireCardInfo> GetNewCard(HeapSolitaireCardInfo thisCard)
        {
            var output = new DeckOfCardsXF <HeapSolitaireCardInfo>();

            output.SendSize(ts.TagUsed, thisCard);
            return(output); //hopefully this simple.
        }
        private DeckOfCardsXF <SolitaireCard> GetNewCard(SolitaireCard thisCard)
        {
            var output = new DeckOfCardsXF <SolitaireCard>();

            output.SendSize(ts.TagUsed, thisCard);
            return(output);
        }
Ejemplo n.º 4
0
        private DeckOfCardsXF <PokerCardInfo> GetNewCard(DisplayCard thisPoker)
        {
            DeckOfCardsXF <PokerCardInfo> thisCard = new DeckOfCardsXF <PokerCardInfo>();

            thisCard.SendSize(ts.TagUsed, thisPoker.CurrentCard);
            thisCard.Command = _command !;
            return(thisCard);
        }
 private void PopulateList()
 {
     _cardList !.ForEach(thisCard =>
     {
         DeckOfCardsXF <SolitaireCard> thisGraphics = new DeckOfCardsXF <SolitaireCard>();
         BindCard(thisGraphics, thisCard);
         _thisStack !.Children.Add(thisGraphics);
     });
 }
        private DeckOfCardsXF <SolitaireCard> GetGraphics(SolitaireCard thisCard)
        {
            DeckOfCardsXF <SolitaireCard> output = new DeckOfCardsXF <SolitaireCard>();

            output.SendSize(ts.TagUsed, thisCard);
            output.CommandParameter = thisCard;
            var binding = GetCommandBinding(nameof(TriangleObservable.CardCommand));

            output.SetBinding(GraphicsCommand.CommandProperty, binding);
            return(output); //hopefully this is enough (?)
        }
 private void PopulateControls()
 {
     _thisGrid !.Children.Clear();
     foreach (var thisCard in _cardList !)
     {
         DeckOfCardsXF <TR> thisGraphics = new DeckOfCardsXF <TR>();
         thisGraphics.HorizontalOptions = LayoutOptions.Start;
         thisGraphics.VerticalOptions   = LayoutOptions.Start;
         thisGraphics.Margin            = new Thickness(0, 0, 6, 0);
         thisGraphics.SendSize(ts.TagUsed, thisCard);
         var thisBind = GetCommandBinding(nameof(PlayerBoardObservable <TR> .CardCommand));
         thisGraphics.SetBinding(DeckOfCardsXF <TR> .CommandProperty, thisBind);
         thisGraphics.CommandParameter = thisCard;
         var(Row, Column) = _thisMod !.GetRowColumnData(thisCard);
         GridHelper.AddControlToGrid(_thisGrid, thisGraphics, Row - 1, Column - 1);
         Grid.SetRowSpan(thisGraphics, 2);
     }
 }
        public void Init()
        {
            CustomWaste thisWaste = Resolve <CustomWaste>(); //can't do unit testing with ui anyways.

            if (thisWaste.CardList.Count != 4)
            {
                throw new BasicBlankException("Must have 4 piles");
            }
            if (thisWaste.CardList.Any(items => items.Value != EnumCardValueList.Queen))
            {
                throw new BasicBlankException("Only Queens are supported for the special waste piles");
            }
            Grid thisGrid = new Grid();

            AddAutoColumns(thisGrid, 2);
            var thisCard = new DeckOfCardsXF <SolitaireCard>();

            thisCard.SendSize(ts.TagUsed, thisWaste.CardList.First());
            var tempSize = thisCard.ObjectSize.Height * .67f;

            thisCard.Margin = new Thickness(0, tempSize, 0, 0);
            AddControlToGrid(thisGrid, thisCard, 0, 0);
            var newCard = new DeckOfCardsXF <SolitaireCard>();

            newCard.SendSize(ts.TagUsed, thisWaste.CardList[1]);
            var tempWidth  = thisCard.ObjectSize.Width;
            var tempHeight = thisCard.ObjectSize.Height;

            newCard.Margin = new Thickness(tempWidth - 10, tempHeight + 10, 0, 0);
            AddControlToGrid(thisGrid, newCard, 0, 0);
            thisCard = new DeckOfCardsXF <SolitaireCard>();
            thisCard.SendSize(ts.TagUsed, thisWaste.CardList[2]);
            thisCard.Margin = new Thickness((tempSize / 2) * -1, tempSize, 0, 0);
            AddControlToGrid(thisGrid, thisCard, 0, 1);
            newCard = new DeckOfCardsXF <SolitaireCard>();
            newCard.SendSize(ts.TagUsed, thisWaste.CardList.Last());
            newCard.Margin = new Thickness(tempWidth * -1, 0, 0, 0);
            AddControlToGrid(thisGrid, newCard, 0, 1);
            Content = thisGrid;
        }
        public void Init(SolitairePilesCP thisMod)
        {
            _thisStack = new StackLayout();
            SolitaireCard card = new SolitaireCard();
            DeckOfCardsXF <SolitaireCard> temps = new DeckOfCardsXF <SolitaireCard>();

            temps.SendSize(ts.TagUsed, card);
            var size = temps.Measure(double.PositiveInfinity, double.PositiveInfinity);

            if (size.Request.Height == 0 || size.Request.Width == 0)
            {
                throw new BasicBlankException("Was unable to get the width or height request.  Rethink");
            }
            else
            {
                SolitaireOverlapLayoutXF.MinWidth = size.Request.Width + 9;
            }
            _thisStack.Orientation = StackOrientation.Horizontal;
            _thisStack.Spacing     = 0;
            ScrollView thisScroll = new ScrollView();

            thisScroll.Orientation = ScrollOrientation.Horizontal;
            _thisMod = thisMod;
            if (thisMod.PileList.Count == 0)
            {
                throw new BasicBlankException("Must have at least one pile.  Otherwise, not worth even using this");
            }
            thisMod.PileList.ForEach(thisPile =>
            {
                IndividualSolitairePileXF thisG = new IndividualSolitairePileXF();
                thisG.MainMod  = thisMod;
                thisG.ThisPile = thisPile;
                thisG.Margin   = new Thickness(0, 0, 0, 0); //try this
                _thisStack.Children.Add(thisG);
                thisG.Init(_needsPopulating);
            });
            _needsPopulating   = false;
            thisScroll.Content = _thisStack;
            Content            = thisScroll;
        }
        private void PopulateList()
        {
            if (_cardList !.Count == 0)
            {
                _thisGrid !.Children.Clear(); // needs to clear because no card list.  the cardlist works together with the scores
                return;
            }
            var ScoreStack = new StackLayout();

            AddControlToGrid(_thisGrid !, ScoreStack, 0, 2);
            Grid.SetRowSpan(ScoreStack, 2);
            if (_cardList.Count != 4)
            {
                throw new BasicBlankException("Must have 4 cards for this control, not " + _cardList.Count);
            }
            foreach (var ThisItem in _tempMod !.Scores)
            {
                var ThisLabel = GetDefaultLabel();
                ThisLabel.Margin = new Thickness(5, 0, 0, 0);
                ThisLabel.Text   = ThisItem.Description + " - " + ThisItem.Points;
                ScoreStack.Children.Add(ThisLabel);
            }
            int x;
            int y;
            int z = 0;

            for (y = 1; y <= 2; y++)
            {
                for (x = 1; x <= 2; x++)
                {
                    var thisCard     = _cardList[z];
                    var thisGraphics = new DeckOfCardsXF <CribbageCard>();
                    thisGraphics.SendSize(ts.TagUsed, thisCard);
                    AddControlToGrid(_thisGrid !, thisGraphics, y - 1, x - 1);
                    z += 1;
                }
            }
        }
        public BisleySolitaireMainView(IEventAggregator aggregator)
        {
            _aggregator = aggregator;
            _aggregator.Subscribe(this);

            StackLayout stack      = new StackLayout();
            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            _main         = new BasicMultiplePilesXF <SolitaireCard, ts, DeckOfCardsXF <SolitaireCard> >();
            _main.Margin  = new Thickness(2, 5, 5, 5);
            _main.Spacing = 0;

            _discard = new BasicMultiplePilesXF <SolitaireCard, ts, DeckOfCardsXF <SolitaireCard> >();
            var tempCard = new DeckOfCardsXF <SolitaireCard>();

            tempCard.SendSize(ts.TagUsed, new SolitaireCard());
            _discard.Margin = new Thickness(2, (tempCard.ObjectSize.Height * -1) - 15, 0, 0);



            stack.Children.Add(otherStack);
            var autoBut     = GetGamingButton("Auto Make Move", nameof(BisleySolitaireMainViewModel.AutoMoveAsync));
            var scoresAlone = new SimpleLabelGridXF();

            scoresAlone.AddRow("Score", nameof(BisleySolitaireMainViewModel.Score));
            var tempGrid = scoresAlone.GetContent;

            otherStack.Children.Add(autoBut);
            otherStack.Children.Add(tempGrid);
            stack.Children.Add(_main);
            stack.Children.Add(_discard);


            Content = stack; //if not doing this, rethink.
        }
        private async void CardList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            //bool wasFirst = true;
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                //object firstCard = e.NewItems[0];

                foreach (var thisItem in e.NewItems)
                {
                    var newCard = thisItem as SolitaireCard;
                    //if (wasFirst)
                    //{
                    //    if (_thisStack.HasCard(newCard!))
                    //    {
                    //        _thisStack.Children.Clear();
                    //    }
                    //    wasFirst = false;
                    //}
                    DeckOfCardsXF <SolitaireCard> thisD = new DeckOfCardsXF <SolitaireCard>();
                    thisD.NeedsExtraSuitForSolitaire = true;
                    thisD.SendSize(ts.TagUsed, newCard !);
                    if (_thisStack.HasCard(newCard !) == false)
                    {
                        _thisStack !.Children.Add(thisD);//hopefully this simple (?)
                    }
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                if (e.OldItems.Count == e.NewItems.Count)
                {
                    int x = 0;
                    foreach (var thisItem in e.OldItems)
                    {
                        var oldCard = thisItem as SolitaireCard;
                        var newCard = e.NewItems[x] as SolitaireCard;
                        var thisCon = _thisStack.FindControl(oldCard !);
                        thisCon !.BindingContext = null;    //i think this is needed too
                        thisCon.BindingContext   = newCard; //the upperright is iffy.
                        x++;
                    }
                }
                else
                {
                    throw new BasicBlankException("Not sure when the numbers don't match");
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (var thisItem in e.OldItems)
                {
                    var oldCard = thisItem as SolitaireCard;
                    var thisCon = _thisStack.FindControl(oldCard !);
                    _thisStack !.Children.Remove(thisCon !);
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                _thisStack.Children.Clear(); // needs to clear and do nothing else because no cards left
                PopulateList();
            }
            if (e.Action == NotifyCollectionChangedAction.Move)
            {
                if (e.OldStartingIndex == e.NewStartingIndex)
                {
                    RefreshItems();
                }
                else
                {
                    var firstCon = _thisStack !.Children[e.OldStartingIndex];
                    _thisStack.Children.Remove(firstCon);
                    _thisStack.Children.Insert(e.NewStartingIndex, firstCon);
                }
            }
            if (_cardList !.Count == 0)
            {
                return;
            }
            var thisCard = _cardList.Last();
            var finCo    = _thisStack.FindControl(thisCard);

            if (finCo == null)
            {
                return;
            }
            await _thisScroll.ScrollToAsync(finCo, ScrollToPosition.End, false);
        }
Ejemplo n.º 13
0
        public GalaxyCardGameMainView(IEventAggregator aggregator,
                                      TestOptions test,
                                      GalaxyCardGameVMData model,
                                      GalaxyCardGameGameContainer gameContainer
                                      )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            _gameContainer = gameContainer;
            gameContainer.SaveRoot.LoadWin(this);
            _deckGPile               = new BaseDeckXF <GalaxyCardGameCardInformation, ts, DeckOfCardsXF <GalaxyCardGameCardInformation> >();
            _score                   = new ScoreBoardXF();
            _playerHandWPF           = new BaseHandXF <GalaxyCardGameCardInformation, ts, DeckOfCardsXF <GalaxyCardGameCardInformation> >();
            _trick1                  = new TwoPlayerTrickXF <EnumSuitList, GalaxyCardGameCardInformation, ts, DeckOfCardsXF <GalaxyCardGameCardInformation> >();
            _nextCard                = new DeckOfCardsXF <GalaxyCardGameCardInformation>();
            _planetStack             = new StackLayout();
            _moonGrid                = new Grid();
            _planetStack.Orientation = StackOrientation.Horizontal;
            AddLeftOverColumn(_moonGrid, 50);
            AddLeftOverColumn(_moonGrid, 50);
            AddAutoRows(_moonGrid, 1);

            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

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

            _score.AddColumn("Cards Left", false, nameof(GalaxyCardGamePlayerItem.ObjectCount)); //very common.
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(GalaxyCardGameMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(GalaxyCardGameMainViewModel.Status));

            var endButton = GetGamingButton("End Turn", nameof(GalaxyCardGameMainViewModel.EndTurnAsync));

            endButton.HorizontalOptions = LayoutOptions.Start;
            endButton.VerticalOptions   = LayoutOptions.Start;
            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_trick1);
            otherStack.Children.Add(_nextCard);
            otherStack.Children.Add(_deckGPile);
            mainStack.Children.Add(otherStack);

            mainStack.Children.Add(_moonGrid);
            otherStack             = new StackLayout();
            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_playerHandWPF);
            //StackLayout finalStack = new StackLayout();
            //finalStack.Children.Add(firstInfo.GetContent);
            var thisBut = GetSmallerButton("Create New Moon", nameof(GalaxyCardGameMainViewModel.MoonAsync));

            thisBut.HorizontalOptions = LayoutOptions.Start;
            thisBut.VerticalOptions   = LayoutOptions.Start;
            otherStack.Children.Add(endButton);
            otherStack.Children.Add(thisBut);
            //otherStack.Children.Add(finalStack);
            mainStack.Children.Add(otherStack);
            otherStack             = new StackLayout();
            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_planetStack);
            otherStack.Children.Add(_score);
            otherStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(otherStack);
            _deckGPile.Margin          = new Thickness(5, 5, 5, 5);
            _deckGPile.VerticalOptions = LayoutOptions.Start;



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