protected override void FirstSetUp() { var thisScore = new ScoringGuideClassCP(); ThisFrame.Text = "Scoring Guide"; Grid firstGrid = new Grid(); firstGrid.Children.Add(ThisDraw); var thisRect = ThisFrame.GetControlArea(); Grid otherGrid = new Grid(); otherGrid.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 3, 3, 5); GridHelper.AddLeftOverColumn(otherGrid, 2); GridHelper.AddLeftOverColumn(otherGrid, 2); StackPanel thisStack = new StackPanel(); AddLabel(thisScore.OffenseText, true, thisStack); GridHelper.AddControlToGrid(otherGrid, thisStack, 0, 0); var thisList = thisScore.OffenseList(); thisList.ForEach(item => AddLabel(item, false, thisStack)); thisStack = new StackPanel(); GridHelper.AddControlToGrid(otherGrid, thisStack, 0, 1); thisList = thisScore.DefenseList(); AddLabel(thisScore.DefenseText, true, thisStack); thisList.ForEach(item => AddLabel(item, false, thisStack)); firstGrid.Children.Add(otherGrid); Content = firstGrid; }
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. } }
private void PopulateControls() { _thisGrid !.Children.Clear(); // i think if (_thisList !.Count == 0) { return; } if (_thisList.Count != 5) { throw new BasicBlankException("Must have 5 cards for poker hand."); } int x = 0; foreach (var display in GlobalClass.PokerList) { var graphics = GetNewCard(display); graphics.CommandParameter = display; //var button = new Button() //{ // Name = nameof(PokerMainViewModel.HoldUnhold), // Content = "Test" //}; //GridHelper.AddControlToGrid(_thisGrid, button, 0, x); GridHelper.AddControlToGrid(_thisGrid, graphics, 0, x); var label = SharedUIFunctions.GetDefaultLabel(); label.FontSize = 20; // can always be adjusted as needed label.HorizontalAlignment = HorizontalAlignment.Center; label.FontWeight = FontWeights.Bold; label.DataContext = display; label.SetBinding(TextBlock.TextProperty, new Binding(nameof(DisplayCard.Text))); GridHelper.AddControlToGrid(_thisGrid, label, 1, x); x += 1; } }
private void PopulateControls() { _thisGrid !.Children.Clear(); // i think if (_thisList !.Count == 0) { return; } if (_thisList.Count != 5) { throw new BasicBlankException("Must have 5 cards for poker hand."); } int x = 0; foreach (var display in _thisList) { var graphics = GetNewCard(display); graphics.CommandParameter = display; GridHelper.AddControlToGrid(_thisGrid, graphics, 0, x); var thisLabel = SharedUIFunctions.GetDefaultLabel(); if (ScreenUsed != EnumScreen.SmallPhone) { thisLabel.FontSize = 20; // can always be adjusted as needed } else { thisLabel.FontSize = 12; } thisLabel.HorizontalOptions = LayoutOptions.Center; thisLabel.FontAttributes = FontAttributes.Bold; thisLabel.BindingContext = display; thisLabel.SetBinding(Label.TextProperty, new Binding(nameof(DisplayCard.Text))); GridHelper.AddControlToGrid(_thisGrid, thisLabel, 1, x); x += 1; } }
private void PopulateList() { int x; int y; int z = 0; _mainGrid !.Children.Clear(); // clear and redo var loopTo = _thisMod !.Rows; for (x = 1; x <= loopTo; x++) { var loopTo1 = _thisMod.Columns; for (y = 1; y <= loopTo1; y++) { if (z + 1 <= _objectList !.Count) { var thisCard = _objectList[z]; var thisGraphics = new GW(); CardBindings(thisGraphics, thisCard); GridHelper.AddControlToGrid(_mainGrid, thisGraphics, x - 1, y - 1); z += 1; } } } }
public void LoadFrame(FrameInfoCP thisFrame) { if (thisFrame.SectionList.Count != 3) { throw new BasicBlankException("Must have 3 sections, not " + thisFrame.SectionList.Count); } _thisGrid = new Grid(); int x; for (x = 1; x <= 3; x++) { GridHelper.AddLeftOverColumn(_thisGrid, 1); if (x < 3) { GridHelper.AddLeftOverRow(_thisGrid, 1);// for equal } } BlankBowlingBorderXF mainOne = new BlankBowlingBorderXF(); _thisGrid.Children.Add(mainOne); Grid.SetRowSpan(mainOne, 2); Grid.SetColumnSpan(mainOne, 3); Label thisLabel = new Label(); thisLabel.BindingContext = thisFrame; Binding thisBind = new Binding(nameof(FrameInfoCP.Score)); var thisCon = new BowlingConverterXF(); thisBind.Converter = thisCon; thisLabel.TextColor = Color.White; thisLabel.SetBinding(Label.TextProperty, thisBind); thisLabel.FontSize = 10; GridHelper.AddControlToGrid(_thisGrid, thisLabel, 1, 0); Grid.SetColumnSpan(thisLabel, 3); // use all 3 columns thisLabel.HorizontalOptions = LayoutOptions.Center; int SectionSize = 20; // trial and error for (x = 1; x <= 3; x++) { BlankBowlingBorderXF thisBlank = new BlankBowlingBorderXF(); thisBlank.WidthRequest = SectionSize; thisBlank.HeightRequest = 13; GridHelper.AddControlToGrid(_thisGrid, thisBlank, 0, x - 1); thisLabel = new Label(); thisLabel.TextColor = Color.White; thisLabel.HorizontalOptions = LayoutOptions.Center; thisLabel.FontSize = 10; thisLabel.HeightRequest = 13; thisLabel.SetBinding(Label.TextProperty, new Binding(nameof(SectionInfoCP.Score))); thisLabel.BindingContext = thisFrame.SectionList[x]; // not 0 based because of dictionary. the key starts with 1 GridHelper.AddControlToGrid(_thisGrid, thisLabel, 0, x - 1); } Content = _thisGrid; }
private void AddBackroundLabel(Grid otherGrid, RowInfo thisRow, int row) { TextBlock thisText = new TextBlock(); { var withBlock = thisText; withBlock.DataContext = thisRow; YahtzeeColorConverter converter = new YahtzeeColorConverter(); Binding ThisBind = new Binding(nameof(thisRow.IsRecent)); ThisBind.Converter = converter; withBlock.SetBinding(TextBlock.BackgroundProperty, ThisBind); GridHelper.AddControlToGrid(otherGrid, thisText, row, 0); Grid.SetColumnSpan(thisText, 3); } }
private void AddBackroundLabel(Grid otherGrid, RowInfo thisRow, int row) { Label thisText = new Label(); { var withBlock = thisText; withBlock.BindingContext = thisRow; YahtzeeColorConverter converter = new YahtzeeColorConverter(); Binding ThisBind = new Binding(nameof(thisRow.IsRecent)); ThisBind.Converter = converter; withBlock.SetBinding(BackgroundColorProperty, ThisBind); GridHelper.AddControlToGrid(otherGrid, thisText, row, 0); Grid.SetColumnSpan(thisText, 3); thisText.InputTransparent = true; } }
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; }
private void PopulateControls() { _thisGrid !.Children.Clear(); foreach (var thisCard in _cardList !) { DeckOfCardsWPF <TR> thisGraphics = new DeckOfCardsWPF <TR>(); thisGraphics.Margin = new Thickness(0, 0, 6, 0); thisGraphics.SendSize(ts.TagUsed, thisCard); var thisBind = GetCommandBinding(nameof(PlayerBoardObservable <TR> .CardCommand)); thisGraphics.SetBinding(GraphicsCommand.CommandProperty, thisBind); thisGraphics.CommandParameter = thisCard; var(Row, Column) = _thisMod !.GetRowColumnData(thisCard); GridHelper.AddControlToGrid(_thisGrid, thisGraphics, Row - 1, Column - 1); Grid.SetRowSpan(thisGraphics, 2); } }
public void Init() { var thisList = _gameBoard.GetSquares(); _thisGrid.Children.Clear(); GamePackageViewModelBinder.ManuelElements.Clear(); foreach (var thisSquare in thisList) { MineSquareWPF thisGraphics = new MineSquareWPF(thisSquare); _mines.Add(thisGraphics); GamePackageViewModelBinder.ManuelElements.Add(thisGraphics); GridHelper.AddControlToGrid(_thisGrid, thisGraphics, thisSquare.Row - 1, thisSquare.Column - 1); } //probably after all is done recheck the bindings. }
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); } }
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; }
public void CreateControls(IBoardCollection <T> itemsSource) // has to be at least this view model { if (itemsSource == null) { throw new BasicBlankException("The list is null. Therefore, can't create controls"); } if (itemsSource.Count() == 0) { throw new Exception("Must have at least one item from the list. Otherwise, it will show nothing. If there are exceptions, then can take out"); } PieceList = itemsSource; LoadGridColumnRows(); //maybe we need this now (?) int x; int y; int z = 0; var loopTo = itemsSource.GetTotalRows(); for (x = 1; x <= loopTo; x++) { var loopTo1 = itemsSource.GetTotalColumns(); for (y = 1; y <= loopTo1; y++) { if (z < itemsSource.Count()) { if (CanAddControl(itemsSource, x, y) == true) { var thisItem = itemsSource[x, y]; var thisControl = GetControl(thisItem, z); // needs to get in the habit of using 0 based //_thisGrid.Children.Add(thisControl); if (_hasHeaders == false) { GridHelper.AddControlToGrid(_thisGrid, thisControl, x - 1, y - 1); } else { GridHelper.AddControlToGrid(_thisGrid, thisControl, x, y); // because of the headers and footers. } z += 1; // 0 based } } } } }
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); } }
public void Init() { var thisList = _gameBoard.GetSquares(); _thisGrid.Children.Clear(); GamePackageViewModelBinder.ManuelElements.Clear(); //most likely has to do manually here too foreach (var thisSquare in thisList) { MineSquareXF thisGraphics = new MineSquareXF(thisSquare); thisGraphics.HorizontalOptions = LayoutOptions.Fill; thisGraphics.VerticalOptions = LayoutOptions.Fill; _mines.Add(thisGraphics); GamePackageViewModelBinder.ManuelElements.Add(thisGraphics); GridHelper.AddControlToGrid(_thisGrid, thisGraphics, thisSquare.Row - 1, thisSquare.Column - 1); } //probably after all is done recheck the bindings. }
private readonly DiceListControlXF <D> _diceControl; //hopefully still okay (?) public YahtzeeMainView(IEventAggregator aggregator, YahtzeeVMData <D> model) { _aggregator = aggregator; _aggregator.Publish(this); _model = model; _aggregator.Subscribe(this); _diceControl = new DiceListControlXF <D>(); Grid eGrid = new Grid(); GridHelper.AddLeftOverColumn(eGrid, 50); GridHelper.AddLeftOverColumn(eGrid, 50); ParentSingleUIContainer sheetGrid = new ParentSingleUIContainer(nameof(YahtzeeMainViewModel <D> .CurrentScoresheet)); StackLayout stack = new StackLayout(); stack.Children.Add(sheetGrid); SimpleLabelGridXF firstInfo = new SimpleLabelGridXF(); 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 ScoreBoardXF(); _score.AddColumn("Points", false, nameof(YahtzeePlayerItem <D> .Points)); _score.HorizontalOptions = LayoutOptions.Start; _score.VerticalOptions = LayoutOptions.Start; var thisRoll = GetGamingButton("Roll Dice", nameof(YahtzeeMainViewModel <D> .RollDiceAsync)); stack.Children.Add(_diceControl); stack.Children.Add(eGrid); StackLayout finalStack = new StackLayout(); GridHelper.AddControlToGrid(eGrid, finalStack, 0, 0); //try this too. finalStack.Children.Add(thisRoll); finalStack.Children.Add(_score); GridHelper.AddControlToGrid(eGrid, firstInfo.GetContent, 0, 1); Content = stack; }
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 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. } }
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; }
protected void AddControlToGrid(Control thisCon, int row, int column) { GridHelper.AddControlToGrid(_thisGrid, thisCon, row, column); // so the inherited versions still don't have to know about it. }
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; }
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; }
//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; }