Ejemplo n.º 1
0
        private void PopulateControls(RackoGameContainer mainGame)
        {
            _thisStack !.Children.Clear();
            int starts   = mainGame.PlayerList.Count() + 2;
            int diffs    = starts;
            var tempList = _cardList !.ToRegularDeckDict();

            tempList.Reverse();
            int x;
            CustomBasicList <int> otherList = new CustomBasicList <int>();

            for (x = 1; x <= 10; x++)
            {
                otherList.Add(starts);
                starts += diffs;
            }
            otherList.Reverse();
            foreach (var thisCard in tempList)
            {
                Grid thisGrid = new Grid();
                thisGrid.BindingContext = thisCard; // i think
                GridHelper.AddPixelColumn(thisGrid, 100);
                GridHelper.AddAutoColumns(thisGrid, 1);
                var thisLabel = GetDefaultLabel();
                thisLabel.HorizontalOptions = LayoutOptions.Center;
                thisLabel.VerticalOptions   = LayoutOptions.Center;
                thisLabel.Text     = otherList[tempList.IndexOf(thisCard)].ToString();
                thisLabel.FontSize = 40;
                thisLabel.Margin   = new Thickness(0, 3, 0, 0);
                GridHelper.AddControlToGrid(thisGrid, thisLabel, 0, 0);
                CardGraphicsXF ThisGraphics = new CardGraphicsXF();
                ThisGraphics.SendSize("", thisCard); //hopefully this simple.
                GridHelper.AddControlToGrid(thisGrid, ThisGraphics, 0, 1);
                RowClickerXF custom = new RowClickerXF();
                custom.Command          = _thisCommand !;
                custom.CommandParameter = thisCard;
                GridHelper.AddControlToGrid(thisGrid, custom, 0, 0);
                Grid.SetColumnSpan(custom, 2); // so it spans the entire control.
                _thisStack.Children.Add(thisGrid);
            }
        }
        //public void Dispose()
        //{
        //    _thisStack.Children.Clear();
        //}
        public void Init(bool NeedsPopulating)
        {
            if (ThisPile == null)
            {
                throw new BasicBlankException("Must send in the pile being used for this");
            }
            if (MainMod == null)
            {
                throw new BasicBlankException("There was no main viewmodel sent for this");
            }
            _cardList                    = ThisPile.CardList;
            BindingContext               = ThisPile;
            VerticalOptions              = LayoutOptions.StartAndExpand; // had to actually expand.
            _thisStack.IsKlondike        = MainMod.IsKlondike;           // needed this as well.
            _cardList.CollectionChanged += CardList_CollectionChanged;
            Grid thisGrid = new Grid();

            thisGrid.Children.Add(_thisStack);
            RowClickerXF thisBlank = new RowClickerXF();

            thisBlank.Command           = MainMod.ColumnCommand;
            thisBlank.CommandParameter  = ThisPile; //hopefully this simple (?)
            thisBlank.HorizontalOptions = LayoutOptions.Fill;
            thisBlank.VerticalOptions   = LayoutOptions.Fill;
            thisGrid.Children.Add(thisBlank);
            //another choice is to let the events handle the populating.
            _thisScroll                  = new ScrollView();
            _thisScroll.Orientation      = ScrollOrientation.Vertical;
            _thisScroll.InputTransparent = true;
            _thisScroll.Content          = thisGrid;
            if (NeedsPopulating)
            {
                PopulateList();
            }
            Content = _thisScroll;
            SetBinding(IsSelectedProperty, new Binding(nameof(PileInfoCP.IsSelected)));
        }
        public YahtzeeScoresheetView(ScoreContainer scoreContainer,
                                     IYahtzeeLayout layout,
                                     IStandardScreen screen
                                     )
        {
            _layout = layout;
            _screen = screen;


            Grid grid = new Grid();

            2.Times(x => GridHelper.AddLeftOverColumn(grid, 50));
            grid.RowSpacing = 2;
            CrossPlatformBorderXF thisBorder; //no groupboxes.
            Grid otherGrid = new Grid();

            otherGrid.BackgroundColor = Color.White;
            if (_screen.IsSmallest)
            {
                otherGrid.HorizontalOptions = LayoutOptions.Start;
                otherGrid.VerticalOptions   = LayoutOptions.Start;
            }
            otherGrid.Margin        = new Thickness(4, 4, 4, 4);
            otherGrid.RowSpacing    = 0;
            otherGrid.ColumnSpacing = 0;
            GridHelper.AddControlToGrid(grid, otherGrid, 0, 0); //i think
            GridHelper.AddLeftOverColumn(otherGrid, 20);
            GridHelper.AddLeftOverColumn(otherGrid, 15);
            GridHelper.AddLeftOverColumn(otherGrid, 15);
            int pixelHeight = _layout.GetPixelHeight;

            8.Times(y => GridHelper.AddPixelRow(otherGrid, pixelHeight));
            Label thisLabel;
            var   thisList = (from item in scoreContainer.RowList
                              where item.IsTop == true && item.RowSection == EnumRow.Regular
                              select item).ToCustomBasicList();

            if (thisList.Count != 6)
            {
                throw new BasicBlankException("All yahtzee games must have 6 sections total, not " + thisList.Count);
            }
            int x = 0;

            foreach (var thisRow in thisList)
            {
                x += 1;
                AddBackroundLabel(otherGrid, thisRow, x);
                thisLabel = GetDescriptionText(thisRow.Description);
                thisLabel.InputTransparent = true;
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
                thisLabel = GetPossibleText(thisRow);
                thisLabel.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 1);
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 1);
                thisLabel = GetScoreText(thisRow);
                thisLabel.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
                RowClickerXF tempRow = new RowClickerXF();
                GridHelper.AddControlToGrid(otherGrid, tempRow, x, 0);
                tempRow.BindingContext = thisRow; //i think.
                tempRow.SetName(nameof(IScoresheetAction.RowAsync));
                tempRow.CommandParameter = thisRow;
                //GamePackageViewModelBinder.ManuelElements.Add(tempRow);
                Grid.SetColumnSpan(tempRow, 3);
            }
            RowInfo bonus = (from Items in scoreContainer.RowList
                             where Items.IsTop == true && Items.RowSection == EnumRow.Bonus
                             select Items).Single();

            x        += 1;
            thisLabel = GetDescriptionText(bonus.Description);
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
            thisLabel = new Label();
            thisLabel.BackgroundColor = Color.Aqua;
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 1);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 1);
            thisLabel = GetScoreText(bonus);
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
            x        += 1; //total score last
            thisLabel = GetFooterText("Upper Total");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
            Grid.SetColumnSpan(thisLabel, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
            Grid.SetColumnSpan(thisBorder, 2);
            RowInfo topTotal = (from Items in scoreContainer.RowList
                                where Items.IsTop == true && Items.RowSection == EnumRow.Totals
                                select Items).Single();

            thisLabel = GetScoreText(topTotal);
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
            otherGrid = new Grid();
            GridHelper.AddControlToGrid(grid, otherGrid, 0, 1); //i think
            otherGrid.BackgroundColor = Color.White;
            otherGrid.RowSpacing      = 0;
            otherGrid.ColumnSpacing   = 0;
            otherGrid.Margin          = new Thickness(4, 4, 4, 4);
            if (_screen.IsSmallest)
            {
                otherGrid.HorizontalOptions = LayoutOptions.Start;
                otherGrid.VerticalOptions   = LayoutOptions.Start;
            }
            GridHelper.AddLeftOverColumn(otherGrid, 20);
            GridHelper.AddLeftOverColumn(otherGrid, 15);
            GridHelper.AddLeftOverColumn(otherGrid, 15);
            thisList = (from Items in scoreContainer.RowList
                        where Items.IsTop == false && Items.RowSection == EnumRow.Regular
                        select Items).ToCustomBasicList();
            int maxs = thisList.Count + 1;

            maxs.Times(x => GridHelper.AddPixelRow(otherGrid, pixelHeight));
            x = 0;
            foreach (var thisRow in thisList)
            {
                RowClickerXF tempRow = new RowClickerXF();
                AddBackroundLabel(otherGrid, thisRow, x);
                thisLabel = GetDescriptionText(thisRow.Description);
                thisLabel.InputTransparent = true;
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
                thisLabel = GetPossibleText(thisRow);
                thisLabel.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 1);
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 1);
                thisLabel = GetScoreText(thisRow);
                thisLabel.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
                thisBorder = GetBorder();
                thisBorder.InputTransparent = true;
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
                GridHelper.AddControlToGrid(otherGrid, tempRow, x, 0);
                tempRow.BindingContext = thisRow;
                tempRow.SetName(nameof(IScoresheetAction.RowAsync));
                tempRow.CommandParameter = thisRow;
                //GamePackageViewModelBinder.ManuelElements.Add(tempRow);
                Grid.SetColumnSpan(tempRow, 3);
                x += 1; //risking here.
            }
            RowInfo bottomTotal = (from Items in scoreContainer.RowList
                                   where Items.IsTop == false && Items.RowSection == EnumRow.Totals
                                   select Items).Single();

            thisLabel = GetFooterText("Total Bottom Portion");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
            Grid.SetColumnSpan(thisLabel, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
            Grid.SetColumnSpan(thisBorder, 2);
            thisLabel = GetScoreText(bottomTotal);
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
            Content = grid;
        }