public void CreateHeadersColumnsRows(CustomBasicList <string> rowSource, CustomBasicList <string> columnSource, string veryFirstHeader = "")
        {
            GridHelper.AddAutoColumns(_thisGrid, 1);
            GridHelper.AddAutoRows(_thisGrid, 1);
            _hasHeaders = true;
            int x = 0;

            foreach (var thisRow in rowSource)
            {
                x += 1;
                var thisLabel = CreateLabel(thisRow.ToString()); // can always use this
                if (LeftRightMargins > 0)
                {
                    thisLabel.Margin = new Thickness(LeftRightMargins, 0, LeftRightMargins, 0);
                }
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, x, 0); // i think 0 is fine here.
            }
            x = 0;
            foreach (var thisColumn in columnSource)
            {
                x += 1;
                var thisLabel = CreateLabel(thisColumn.ToString());
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, 0, x);
            }
            if (veryFirstHeader != "")
            {
                var thisLabel = CreateLabel(veryFirstHeader);
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, 0, 0); // this has a header for both.  to support bowling dice game.
            }
        }
예제 #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;
        }
 public void UpdateLists(BasicMultiplePilesCP <CA> mod)
 {
     _thisMod    = mod;
     DataContext = null;
     DataContext = _thisMod;
     _thisGrid !.Children.Clear(); //i think this is best.
     GridHelper.AddAutoColumns(_thisGrid, _thisMod.Columns);
     GridHelper.AddAutoRows(_thisGrid, _thisMod.Rows);
     foreach (var pileMod in _thisMod.PileList !)
     {
         PrivateBasicIndividualPileWPF <CA, GC, GW> PileG = new PrivateBasicIndividualPileWPF <CA, GC, GW>();
         PileG.MainMod  = _thisMod;
         PileG.ThisPile = pileMod;
         GridHelper.AddControlToGrid(_thisGrid, PileG, pileMod.Row - 1, pileMod.Column - 1);
         PileG.Margin = new Thickness(Spacing, Spacing, Spacing, Spacing);
         PileG.Init(_tagUsed);
     }
 }
예제 #4
0
        private readonly DiceListControlWPF <D> _diceControl; //hopefully still okay (?)

        public YahtzeeMainView(IEventAggregator aggregator, YahtzeeVMData <D> model)
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Publish(this);
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _diceControl = new DiceListControlWPF <D>();

            Grid eGrid = new Grid();

            GridHelper.AddAutoColumns(eGrid, 2);
            GridHelper.AddAutoRows(eGrid, 2);
            ParentSingleUIContainer sheetGrid = new ParentSingleUIContainer()
            {
                Name = nameof(YahtzeeMainViewModel <D> .CurrentScoresheet)
            };
            StackPanel stack = new StackPanel();

            GridHelper.AddControlToGrid(eGrid, sheetGrid, 0, 0);
            GridHelper.AddControlToGrid(eGrid, stack, 0, 1);
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(YahtzeeMainViewModel <D> .NormalTurn));
            firstInfo.AddRow("Roll", nameof(YahtzeeMainViewModel <D> .RollNumber)); // its bound now.
            firstInfo.AddRow("Status", nameof(YahtzeeMainViewModel <D> .Status));
            firstInfo.AddRow("Turn #", nameof(YahtzeeMainViewModel <D> .Round));    // i think
            stack.Children.Add(firstInfo.GetContent);
            _score = new ScoreBoardWPF();
            _score.AddColumn("Points", false, nameof(YahtzeePlayerItem <D> .Points));
            stack.Children.Add(_score);
            var        thisRoll   = GetGamingButton("Roll Dice", nameof(YahtzeeMainViewModel <D> .RollDiceAsync));
            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            _diceControl           = new DiceListControlWPF <D>();
            otherStack.Children.Add(_diceControl);
            otherStack.Children.Add(thisRoll);
            GridHelper.AddControlToGrid(eGrid, otherStack, 1, 0);
            Grid.SetColumnSpan(otherStack, 2);
            Content = eGrid;
        }
        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);
            }
        }
예제 #7
0
        public void CreateHeadersColumnsRows(CustomBasicList <string> rowSource, CustomBasicList <string> columnSource, string veryFirstHeader = "")
        {
            GridHelper.AddAutoColumns(_thisGrid, 1);
            GridHelper.AddAutoRows(_thisGrid, 1);
            if (rowSource.Count != HowManyRows)
            {
                throw new BasicBlankException("The row headers must equal the row count");
            }
            if (columnSource.Count != HowManyColumns)
            {
                throw new BasicBlankException("The column headers must equal the column count");
            }
            int x = 0;

            foreach (var thisRow in rowSource)
            {
                x += 1;
                var thisLabel = CreateLabel(thisRow); // can always use this
                if (LeftRightMargins > 0)
                {
                    thisLabel.Margin = new Thickness(LeftRightMargins, 0, LeftRightMargins, 0);
                }
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, x, 0); // i think 0 is fine here.
            }
            x = 0;
            foreach (var thisColumn in columnSource)
            {
                x += 1;
                var thisLabel = CreateLabel(thisColumn);
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, 0, x);
            }
            if (veryFirstHeader != "")
            {
                var thisLabel = CreateLabel(veryFirstHeader);
                GridHelper.AddControlToGrid(_thisGrid, thisLabel, 0, 0); // this has a header for both.  to support bowling dice game.
            }
        }
예제 #8
0
        public void Init(PokerMainViewModel thisMod)
        {
            _thisMod = thisMod;
            Type         type   = _thisMod !.GetType();
            MethodInfo?  method = type.GetMethod(nameof(PokerMainViewModel.HoldUnhold));
            PropertyInfo?fun    = type.GetProperty(nameof(PokerMainViewModel.CanHoldUnhold));

            if (method == null)
            {
                throw new BasicBlankException("Method not found for hand.  Rethink");
            }
            if (fun == null)
            {
                throw new BasicBlankException("Function not found for hand.  Rethink");
            }
            _command  = new PlainCommand(_thisMod, method, fun, _thisMod.CommandContainer);
            _thisGrid = new Grid();
            GridHelper.AddAutoColumns(_thisGrid, 5);
            GridHelper.AddAutoRows(_thisGrid, 2);
            _thisList = thisMod.PokerList;
            _thisList.CollectionChanged += ThisList_CollectionChanged;
            Content = _thisGrid;
            PopulateControls();
        }
예제 #9
0
 protected virtual void LoadGridColumnRows() // may have to override this because for bowling dice game, we don't know for a while how many columns
 {
     GridHelper.AddAutoRows(_thisGrid, HowManyRows);
     GridHelper.AddAutoColumns(_thisGrid, HowManyColumns);
 }
        //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;
        }
 protected void LoadGridColumnRows() // may not have to override because bowling dice game is using a different one that behaves a little differently.
 {
     GridHelper.AddAutoRows(_thisGrid, PieceList !.GetTotalRows());
     GridHelper.AddAutoColumns(_thisGrid, PieceList.GetTotalColumns());
 }