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
        protected override void FirstSetUp()
        {
            HorizontalOptions = LayoutOptions.Start;
            VerticalOptions   = LayoutOptions.Start;
            Grid firstGrid = new Grid();

            firstGrid.Children.Add(ThisDraw);
            ScrollView thisScroll = new ScrollView();

            Text = "Score Details";
            var thisRect = ThisFrame.GetControlArea();

            thisScroll.Margin       = new Thickness(thisRect.Left, thisRect.Top, 3, 2);
            _mainGrid               = new Grid();
            _mainGrid.RowSpacing    = 0;
            _mainGrid.ColumnSpacing = 4;
            thisScroll.Orientation  = ScrollOrientation.Both;
            thisScroll.Content      = _mainGrid;
            firstGrid.Children.Add(thisScroll);
            Content = firstGrid;
            GridHelper.AddAutoRows(_mainGrid, 1);
            _rowList = new CustomBasicList <BindData>();
            AddColumn("Nick Name", true, "NickName", rightMargin: 8);
            firstGrid.HorizontalOptions = LayoutOptions.Start;
            firstGrid.VerticalOptions   = LayoutOptions.Start;
        }
Пример #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 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);
     }
 }
Пример #5
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;
        }
Пример #6
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.
            }
        }
Пример #7
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();
        }
        protected override void FirstSetUp()
        {
            HorizontalAlignment = HorizontalAlignment.Left;
            VerticalAlignment   = VerticalAlignment.Top; // sometimes has to manually do though.
            base.FirstSetUp();
            Grid firstGrid = new Grid();

            firstGrid.Children.Add(ThisDraw);
            ScrollViewer thisScroll = new ScrollViewer();

            Text = "Score Details";
            var thisRect = ThisFrame.GetControlArea();

            thisScroll.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 3, 3, 5); // try this way.
            _mainGrid         = new Grid();
            thisScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            thisScroll.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            thisScroll.Content = _mainGrid;
            firstGrid.Children.Add(thisScroll);
            Content = firstGrid;
            GridHelper.AddAutoRows(_mainGrid, 1);
            _rowList = new CustomBasicList <BindData>();
            AddColumn("Nick Name", true, "NickName", rightMargin: 10);
        }
Пример #9
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;
        }
Пример #10
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;
        }