public void LoadList(PlayerBoardObservable <TR> thisMod)
        {
            _thisMod  = thisMod;
            _cardList = thisMod.CardList;
            _cardList.CollectionChanged += CardList_CollectionChanged;
            if (thisMod.Game == PlayerBoardObservable <TR> .EnumGameList.None)
            {
                throw new BasicBlankException("Must choose Skuck or Horseshoes");
            }
            if (_cardList.Count == 0)
            {
                throw new BasicBlankException("Must have cardlist already");
            }
            _thisGrid = new Grid();
            GamePackageDIContainer thisC     = Resolve <GamePackageDIContainer>();
            IProportionImage       thisImage = thisC.Resolve <IProportionImage>(ts.TagUsed);
            SKSize thisSize = _cardList.First().DefaultSize;
            SKSize usedSize = thisSize.GetSizeUsed(thisImage.Proportion);
            var    pixels   = usedSize.Height / 2;
            int    x;
            var    loopTo = _cardList.Count;

            for (x = 1; x <= loopTo; x++)
            {
                GridHelper.AddPixelRow(_thisGrid, (int)pixels);
            }
            GridHelper.AddPixelRow(_thisGrid, (int)pixels);
            pixels = usedSize.Width + 6;
            for (x = 1; x <= 4; x++)
            {
                GridHelper.AddPixelColumn(_thisGrid, (int)pixels);
            }
            PopulateControls();
            Content = _thisGrid;
        }
示例#2
0
        public void LoadList(RummyDiceHandVM thisMod, RummyDiceMainGameClass mainGame)
        {
            _thisMod    = thisMod;
            _mainGame   = mainGame;
            DataContext = thisMod;
            _handList   = thisMod.HandList;
            _handList.CollectionChanged += HandList_CollectionChanged;
            Text = $"Temp Set {thisMod.Index}";
            SetBinding(IsEnabledProperty, nameof(RummyDiceHandVM.IsEnabled));
            RummyDiceInfo firstDice = new RummyDiceInfo();

            if (firstDice.HeightWidth == 0)
            {
                throw new BasicBlankException("You must specify the height/width of the dice");
            }
            IProportionImage thisI     = new CustomProportionWPF();
            SKSize           firstSize = new SKSize(firstDice.HeightWidth, firstDice.HeightWidth);
            var  sizeUsed  = firstSize.GetSizeUsed(thisI.Proportion);
            Grid firstGrid = new Grid();

            GridHelper.AddPixelRow(firstGrid, (int)sizeUsed.Height + 50);
            GridHelper.AddLeftOverRow(firstGrid, 1);
            Margin                 = new Thickness(3, 3, 3, 3);
            _thisStack             = new StackPanel();
            _thisStack.Orientation = Orientation.Horizontal;
            Button thisBut = GetGamingButton("Place Tiles", nameof(RummyDiceHandVM.BoardCommand));

            //i think since its a different view model, has to do manually.
            thisBut.Name    = "";
            thisBut.Command = thisMod.BoardCommand;
            thisBut.Margin  = new Thickness(5, 5, 5, 5);
            GridHelper.AddControlToGrid(firstGrid, _thisStack, 0, 0);
            GridHelper.AddControlToGrid(firstGrid, thisBut, 1, 0);
            _thisGrid = new Grid();
            //hopefully does not need visible.  if we need visible, rethink.


            //SetBinding(VisibilityProperty, GetVisibleBinding(nameof(RummyDiceHandVM.Visible)));
            _thisGrid.Children.Add(ThisDraw);
            _thisGrid.Children.Add(firstGrid);
            var thisRect = ThisFrame.GetControlArea();

            _thisStack.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3);
            Width             = 1520; //different on xamarin forms.
            Height            = 250;
            PopulateControls();       //just in case there is something to start with.
            Content = _thisGrid;
        }
示例#3
0
        public void Init(BasicMultiplePilesCP <CA> mod, string tagUsed)
        {
            _thisGrid   = new Grid();
            _parentGrid = new Grid();
            _parentGrid.Children.Add(_thisGrid);
            _thisMod       = mod;
            BindingContext = mod; // i think needs this as well.
            _tagUsed       = tagUsed;
            GW tempCard = new GW();

            tempCard.SendSize(tagUsed, new CA()); //for testing.
            SKSize size = tempCard.ObjectSize;

            if (_thisMod.PileList !.Count == 0)
            {
                throw new Exception("Must have at least one pile.  Otherwise, not worth even using this");
            }
            if (_thisMod.HasFrame)
            {
                GridHelper.AddAutoColumns(_thisGrid, _thisMod.Columns);
                GridHelper.AddAutoRows(_thisGrid, _thisMod.Rows);
            }
            else
            {
                _thisMod.Columns.Times(x =>
                {
                    GridHelper.AddPixelColumn(_thisGrid, size.Width);
                });
                _thisMod.Rows.Times(x =>
                {
                    GridHelper.AddPixelRow(_thisGrid, size.Height);
                });
            }
            _thisGrid.RowSpacing    = Spacing;
            _thisGrid.ColumnSpacing = Spacing;
            foreach (var pileMod in _thisMod.PileList)
            {
                PrivateBasicIndividualPileXF <CA, GC, GW> pileG = new PrivateBasicIndividualPileXF <CA, GC, GW>();
                pileG.MainMod  = _thisMod;
                pileG.ThisPile = pileMod;
                GridHelper.AddControlToGrid(_thisGrid, pileG, pileMod.Row - 1, pileMod.Column - 1);
                pileG.Init(tagUsed);
            }
            Content = _parentGrid;
        }
        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;
        }
        public void CreateShip(ShipInfoCP thisShip, BattleshipMainViewModel model)
        {
            BindingContext = thisShip;
            Grid  thisGrid = new Grid();
            float labelSize;

            labelSize              = 40; // can try 40.  can experiment though.
            thisGrid.RowSpacing    = 0;
            thisGrid.ColumnSpacing = 0;
            Button thisBut = new Button();

            GridHelper.AddPixelRow(thisGrid, 50);
            int x;

            for (x = 1; x <= 5; x++)
            {
                GridHelper.AddPixelColumn(thisGrid, (int)labelSize);
            }
            GridHelper.AddPixelColumn(thisGrid, 120); // not sure
            thisBut.BorderColor    = Color.White;
            thisBut.BorderWidth    = 2;
            thisBut.FontAttributes = FontAttributes.Bold;
            thisBut.FontSize       = 14;
            thisBut.Text           = thisShip.ShipName;
            var thisBind = new Binding(nameof(ShipInfoCP.Visible));

            thisBut.SetBinding(IsVisibleProperty, thisBind);
            if (thisShip.ShipCategory == EnumShipList.None)
            {
                throw new BasicBlankException("Can't be none");
            }

            thisBut.SetName(nameof(BattleshipMainViewModel.ChooseShip));
            GamePackageViewModelBinder.ManuelElements.Add(thisBut); //try this one as well.
            thisBut.CommandParameter = thisShip.ShipCategory;
            thisBut.Margin           = new Thickness(5, 0, 0, 0);
            thisBind        = new Binding(nameof(BattleshipMainViewModel.ShipSelected));
            thisBind.Source = model;
            IValueConverter thisConv = new ChooseShipConverter();

            thisBind.Converter          = thisConv;
            thisBind.ConverterParameter = thisShip.ShipCategory;
            thisBut.SetBinding(BackgroundColorProperty, thisBind);
            GridHelper.AddControlToGrid(thisGrid, thisBut, 0, 5);
            x = 0;
            foreach (var thisPiece in thisShip.PieceList !.Values)
            {
                Label thisText = new Label();
                thisText.BindingContext = thisPiece;
                thisConv           = new ShipLabelConverter();
                thisBind           = new Binding(nameof(PieceInfoCP.DidHit));
                thisBind.Converter = thisConv;
                thisText.SetBinding(BackgroundColorProperty, thisBind);
                thisText.FontAttributes = FontAttributes.Bold;
                thisText.FontSize       = 14;
                thisText.TextColor      = Color.Black;
                thisText.SetBinding(Label.TextProperty, new Binding(nameof(PieceInfoCP.Location)));
                thisText.HorizontalTextAlignment = TextAlignment.Center;
                thisText.VerticalTextAlignment   = TextAlignment.Center;
                GridHelper.AddControlToGrid(thisGrid, thisText, 0, x);
                x += 1;
            }
            Content = thisGrid;
        }