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 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;
        }
        private void PopulateControls(RackoGameContainer gameContainer)
        {
            _thisStack !.Children.Clear();
            int starts   = gameContainer.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.DataContext = thisCard; // i think
                GridHelper.AddPixelColumn(thisGrid, 100);
                GridHelper.AddAutoColumns(thisGrid, 1);
                var thisLabel = SharedUIFunctions.GetDefaultLabel();
                thisLabel.HorizontalAlignment = HorizontalAlignment.Center;
                thisLabel.VerticalAlignment   = VerticalAlignment.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);
                CardGraphicsWPF graphics = new CardGraphicsWPF();
                graphics.SendSize("", thisCard); //hopefully this simple.
                GridHelper.AddControlToGrid(thisGrid, graphics, 0, 1);
                RowClickerWPF custom = new RowClickerWPF();
                custom.Command          = _thisCommand !;
                custom.CommandParameter = thisCard;
                //custom.Name = nameof(RackoMainViewModel.PlayOnPileAsync);
                //custom.Command = mainGame.ThisMod!.PlayOnPileCommand;
                GridHelper.AddControlToGrid(thisGrid, custom, 0, 0);
                Grid.SetColumnSpan(custom, 2); // so it spans the entire control.
                _thisStack.Children.Add(thisGrid);
            }
        }
        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);
            }
        }
示例#5
0
        public void CreateShip(ShipInfoCP thisShip, BattleshipMainViewModel model)
        {
            DataContext = thisShip;
            Grid  thisGrid = new Grid();
            float labelSize;

            labelSize = 40; // can try 40.  can experiment though.
            Button thisBut = new Button();

            GridHelper.AddAutoRows(thisGrid, 1);
            int x;

            for (x = 1; x <= 5; x++)
            {
                GridHelper.AddPixelColumn(thisGrid, (int)labelSize);
            }
            GridHelper.AddPixelColumn(thisGrid, 100); // not sure
            thisBut.BorderBrush     = Brushes.White;
            thisBut.BorderThickness = new Thickness(2, 2, 2, 2);
            thisBut.FontWeight      = FontWeights.Bold;
            thisBut.FontSize        = 14;
            thisBut.Content         = thisShip.ShipName;
            IValueConverter thisConv;

            thisConv = new BooleanToVisibilityConverter();
            var thisBind = new Binding(nameof(ShipInfoCP.Visible));

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

            thisBut.Name = 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; //try this for now.  otherwise, i have to create custom button control.
            thisConv                    = new ChooseShipConverter();
            thisBind.Converter          = thisConv;
            thisBind.ConverterParameter = thisShip.ShipCategory;
            thisBut.SetBinding(Button.BackgroundProperty, thisBind);
            GridHelper.AddControlToGrid(thisGrid, thisBut, 0, 5);
            x = 0;
            foreach (var thisPiece in thisShip.PieceList !.Values)
            {
                TextBlock thisText   = new TextBlock();
                Border    thisBorder = new Border();
                thisBorder.BorderBrush     = Brushes.Black;
                thisBorder.BorderThickness = new Thickness(2, 2, 2, 2);
                GridHelper.AddControlToGrid(thisGrid, thisBorder, 0, x);
                thisText.DataContext   = thisPiece;
                thisBorder.DataContext = thisPiece; // has to put here as well
                thisConv           = new ShipLabelConverter();
                thisBind           = new Binding(nameof(PieceInfoCP.DidHit));
                thisBind.Converter = thisConv;
                thisBorder.SetBinding(Border.BackgroundProperty, thisBind);
                thisText.FontWeight = FontWeights.Bold;
                thisText.FontSize   = 14;
                thisText.SetBinding(TextBlock.TextProperty, new Binding(nameof(PieceInfoCP.Location)));
                thisText.HorizontalAlignment = HorizontalAlignment.Center;
                thisText.VerticalAlignment   = VerticalAlignment.Center;
                GridHelper.AddControlToGrid(thisGrid, thisText, 0, x);
                x += 1;
            }
            Content = thisGrid;
        }
        //something else has to do messagebox.
        public YahtzeeScoresheetView(ScoreContainer scoreContainer)
        {
            Grid grid = new Grid();

            GridHelper.AddAutoColumns(grid, 2);
            // there are 2 groupboxes
            CrossPlatformBorderWPF thisBorder;
            GroupBox thisGroup = new GroupBox();

            thisGroup.VerticalAlignment = VerticalAlignment.Top;
            GridHelper.AddControlToGrid(grid, thisGroup, 0, 0);
            thisGroup.Header          = "Top Portion";
            thisGroup.BorderThickness = new Thickness(2, 2, 2, 2);
            thisGroup.Foreground      = Brushes.White;
            thisGroup.BorderBrush     = Brushes.Black;
            Grid otherGrid = new Grid();

            thisGroup.Content    = otherGrid;
            otherGrid.Background = Brushes.White;
            otherGrid.Margin     = new Thickness(4, 4, 4, 4);
            GridHelper.AddAutoColumns(otherGrid, 1);
            GridHelper.AddPixelColumn(otherGrid, 75);
            GridHelper.AddPixelColumn(otherGrid, 75);
            GridHelper.AddAutoRows(otherGrid, 9);
            var thisLabel = GetHeaderLabel("Description");

            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 0);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 0);
            thisLabel = GetHeaderLabel("Possible Points");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 1);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 1);
            thisLabel = GetHeaderLabel("Points Obtained");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 2);
            var thisList = (from Items in scoreContainer.RowList
                            where Items.IsTop == true && Items.RowSection == EnumRow.Regular
                            select Items).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);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
                thisLabel = GetPossibleText(thisRow);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 1);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 1);
                thisLabel = GetScoreText(thisRow);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
                RowClickerWPF temprow = new RowClickerWPF();
                GridHelper.AddControlToGrid(otherGrid, temprow, x, 0);
                temprow.DataContext      = thisRow; //i think.
                temprow.Name             = nameof(IScoresheetAction.RowAsync);
                temprow.CommandParameter = thisRow;
                GamePackageViewModelBinder.ManuelElements.Add(temprow);
                Grid.SetColumnSpan(temprow, 3);
            }
            RowInfo bonus = (from y in scoreContainer.RowList
                             where y.IsTop == true && y.RowSection == EnumRow.Bonus
                             select y).Single();

            x        += 1;
            thisLabel = GetDescriptionText(bonus.Description);
            GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
            thisLabel            = new TextBlock();
            thisLabel.Background = Brushes.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("Total Top Portion");
            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);
            thisGroup = new GroupBox();
            GridHelper.AddControlToGrid(grid, thisGroup, 0, 1);
            thisGroup.Header          = "Bottom Portion";
            thisGroup.BorderThickness = new Thickness(2, 2, 2, 2);
            thisGroup.Foreground      = Brushes.White;
            thisGroup.BorderBrush     = Brushes.Black;
            otherGrid            = new Grid();
            thisGroup.Content    = otherGrid;
            otherGrid.Background = Brushes.White;
            otherGrid.Margin     = new Thickness(4, 4, 4, 4);
            GridHelper.AddAutoColumns(otherGrid, 1);
            GridHelper.AddPixelColumn(otherGrid, 75);
            GridHelper.AddPixelColumn(otherGrid, 75);
            thisList = (from Items in scoreContainer.RowList
                        where Items.IsTop == false && Items.RowSection == EnumRow.Regular
                        select Items).ToCustomBasicList();
            GridHelper.AddAutoRows(otherGrid, thisList.Count + 2); // because needs header and footer
            thisLabel = GetHeaderLabel("Description");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 0);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 0);
            thisLabel = GetHeaderLabel("Possible Points");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 1);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 1);
            thisLabel = GetHeaderLabel("Points Obtained");
            GridHelper.AddControlToGrid(otherGrid, thisLabel, 0, 2);
            thisBorder = GetBorder();
            GridHelper.AddControlToGrid(otherGrid, thisBorder, 0, 2);
            x = 0;
            foreach (var thisRow in thisList)
            {
                RowClickerWPF tempRow = new RowClickerWPF();
                x += 1;
                AddBackroundLabel(otherGrid, thisRow, x);
                thisLabel  = GetDescriptionText(thisRow.Description);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 0);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 0);
                thisLabel = GetPossibleText(thisRow);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 1);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 1);
                thisLabel = GetScoreText(thisRow);
                GridHelper.AddControlToGrid(otherGrid, thisLabel, x, 2);
                thisBorder = GetBorder();
                GridHelper.AddControlToGrid(otherGrid, thisBorder, x, 2);
                GridHelper.AddControlToGrid(otherGrid, tempRow, x, 0);
                tempRow.Name             = nameof(IScoresheetAction.RowAsync);
                tempRow.DataContext      = thisRow;
                tempRow.CommandParameter = thisRow;
                GamePackageViewModelBinder.ManuelElements.Add(tempRow);
                Grid.SetColumnSpan(tempRow, 3);
            }
            RowInfo bottomTotal = (from y in scoreContainer.RowList
                                   where y.IsTop == false && y.RowSection == EnumRow.Totals
                                   select y).Single();

            x        += 1;
            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);
            // Dim TopTotal = (From Items In ThisMod.RowList Where Items.IsTop = True AndAlso Items.RowSection = RowInfo.EnumRowEnum.Totals).Single
            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;
        }