public void UpdateDiceViewModel(RummyDiceMainGameClass mainGame) { _thisMod = mainGame.MainBoard1; DataContext = _thisMod; _diceList !.CollectionChanged -= DiceList_CollectionChanged; _diceList = mainGame.SaveRoot !.DiceList; _diceList.CollectionChanged += DiceList_CollectionChanged; _thisStack !.Children.Clear(); PopulateList(); }
public RummyDiceHandVM(CommandContainer command, RummyDiceMainGameClass mainGame) : base(command) { //Visible = true; //needs to be true this time. _mainGame = mainGame; MethodInfo method = this.GetPrivateMethod(nameof(PrivateSetChosenAsync)); BoardCommand = new ControlCommand(this, method, command); method = this.GetPrivateMethod(nameof(DiceChosenAsync)); DiceCommand = new ControlCommand(this, method, command); }
public RummyDiceMainViewModel(CommandContainer commandContainer, RummyDiceMainGameClass mainGame, IViewModelData viewModel, BasicData basicData, TestOptions test, IGamePackageResolver resolver ) : base(commandContainer, mainGame, viewModel, basicData, test, resolver) { _mainGame = mainGame; _basicData = basicData; }
public void LoadDiceViewModel(RummyDiceMainGameClass mainGame) { _thisMod = mainGame.MainBoard1; _board = mainGame.MainBoard1; Margin = new Thickness(3, 3, 3, 3); BindingContext = _thisMod; _diceList = mainGame.SaveRoot !.DiceList; _diceList.CollectionChanged += DiceList_CollectionChanged; _thisStack = new StackLayout(); _thisStack.Orientation = StackOrientation.Horizontal; // will always be horizontal for this one. PopulateList(); Content = _thisStack; }
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; }
public void LoadList(RummyDiceHandVM thisMod, RummyDiceMainGameClass mainGame) { _thisMod = thisMod; _mainGame = mainGame; BindingContext = thisMod; HorizontalOptions = LayoutOptions.FillAndExpand; //hopefully this works too. _handList = thisMod.HandList; _handList.CollectionChanged += HandList_CollectionChanged; Text = $"Temp Set {thisMod.Index}"; SetBinding(IsEnabledProperty, new Binding(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 CustomProportionXF(); SKSize firstSize = new SKSize(firstDice.HeightWidth, firstDice.HeightWidth); var sizeUsed = firstSize.GetSizeUsed(thisI.Proportion); Margin = new Thickness(3, 3, 3, 3); _thisStack = new StackLayout(); _thisStack.Orientation = StackOrientation.Horizontal; _thisStack.Spacing = 0; Button thisBut = GetSmallerButton("Place Tiles", ""); thisBut.Command = thisMod.BoardCommand; //i think this way this time. StackLayout finalStack = new StackLayout(); finalStack.Orientation = StackOrientation.Horizontal; finalStack.Children.Add(thisBut); finalStack.Spacing = 2; finalStack.Children.Add(_thisStack); thisBut.HorizontalOptions = LayoutOptions.Start; thisBut.VerticalOptions = LayoutOptions.Start; _thisStack.HorizontalOptions = LayoutOptions.FillAndExpand; thisBut.FontSize *= .7f; _thisGrid = new Grid(); _thisGrid.Children.Add(ThisDraw); _thisGrid.Children.Add(finalStack); var thisRect = ThisFrame.GetControlArea(); thisBut.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3); _thisStack.Margin = new Thickness(thisRect.Left + 3, thisRect.Top + 10, 3, 3); PopulateControls(); //just in case there is something to start with. Content = _thisGrid; }
public RummyDiceMainView(IEventAggregator aggregator, TestOptions test, RummyDiceMainGameClass mainGame ) { _aggregator = aggregator; _mainGame = mainGame; _aggregator.Subscribe(this); StackPanel mainStack = new StackPanel(); ParentSingleUIContainer?restoreP = null; if (test.SaveOption == EnumTestSaveCategory.RestoreOnly) { restoreP = new ParentSingleUIContainer() { Name = nameof(RummyDiceMainViewModel.RestoreScreen) }; } StackPanel tempSets = new StackPanel(); RummyDiceHandWPF thisTemp = new RummyDiceHandWPF(); thisTemp.Index = 1; tempSets.Children.Add(thisTemp); _tempList !.Add(thisTemp); //forgot this too. thisTemp = new RummyDiceHandWPF(); thisTemp.Index = 2; tempSets.Children.Add(thisTemp); _tempList.Add(thisTemp); StackPanel otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; otherStack.Children.Add(tempSets); _thisScore = new ScoreBoardWPF(); otherStack.Children.Add(_thisScore); mainStack.Children.Add(otherStack); SimpleLabelGrid otherScore = new SimpleLabelGrid(); otherScore.AddRow("Roll", nameof(RummyDiceMainViewModel.RollNumber), new RollConverter()); otherScore.AddRow("Score", nameof(RummyDiceMainViewModel.Score)); var tempGrid = otherScore.GetContent; tempGrid.VerticalAlignment = VerticalAlignment.Bottom; // try this way otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; otherStack.Children.Add(tempGrid); Button thisBut; thisBut = GetGamingButton("Put Back", nameof(RummyDiceMainViewModel.BoardAsync)); thisBut.Margin = new Thickness(5, 0, 0, 0); otherStack.Children.Add(thisBut); mainStack.Children.Add(otherStack); otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; _thisScore.AddColumn("Score Round", false, nameof(RummyDicePlayerItem.ScoreRound)); _thisScore.AddColumn("Score Game", false, nameof(RummyDicePlayerItem.ScoreGame)); _thisScore.AddColumn("Phase", false, nameof(RummyDicePlayerItem.Phase)); _thisScore.VerticalAlignment = VerticalAlignment.Top; otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; mainStack.Children.Add(otherStack); _diceControl = new RummyDiceListWPF(); thisBut = GetGamingButton("Roll", nameof(RummyDiceMainViewModel.RollAsync)); thisBut.HorizontalAlignment = HorizontalAlignment.Left; otherStack.Children.Add(thisBut); otherStack.Children.Add(_diceControl); SimpleLabelGrid firstInfo = new SimpleLabelGrid(); firstInfo.AddRow("Turn", nameof(RummyDiceMainViewModel.NormalTurn)); firstInfo.AddRow("Status", nameof(RummyDiceMainViewModel.Status)); firstInfo.AddRow("Phase", nameof(RummyDiceMainViewModel.CurrentPhase)); otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; StackPanel bottomStack = new StackPanel(); otherStack.Children.Add(bottomStack); var endButton = GetGamingButton("End Turn", nameof(RummyDiceMainViewModel.EndTurnAsync)); endButton.HorizontalAlignment = HorizontalAlignment.Left; endButton.Margin = new Thickness(5, 0, 0, 20); bottomStack.Children.Add(endButton); thisBut = GetGamingButton("Score Hand", nameof(RummyDiceMainViewModel.CheckAsync)); thisBut.Margin = new Thickness(5, 0, 0, 0); bottomStack.Children.Add(thisBut); otherStack.Children.Add(firstInfo.GetContent); mainStack.Children.Add(otherStack); if (restoreP != null) { //todo: figure out where to place the restore ui if there is a restore option. mainStack.Children.Add(restoreP); //default add to grid but does not have to. } Content = mainStack; }
public RummyDiceMainView(IEventAggregator aggregator, TestOptions test, RummyDiceMainGameClass mainGame ) { _aggregator = aggregator; _aggregator.Subscribe(this); _mainGame = mainGame; StackLayout mainStack = new StackLayout(); ParentSingleUIContainer?restoreP = null; if (test.SaveOption == EnumTestSaveCategory.RestoreOnly) { restoreP = new ParentSingleUIContainer(nameof(RummyDiceMainViewModel.RestoreScreen)); } Grid tempGrid = new Grid(); AddLeftOverRow(tempGrid, 50); AddLeftOverRow(tempGrid, 50); AddAutoRows(tempGrid, 1); AddLeftOverColumn(tempGrid, 1); AddAutoColumns(tempGrid, 1); RummyDiceHandXF thisTemp = new RummyDiceHandXF(); thisTemp.Index = 1; AddControlToGrid(tempGrid, thisTemp, 0, 0); _tempList !.Add(thisTemp); //forgot this too. thisTemp = new RummyDiceHandXF(); thisTemp.Index = 2; AddControlToGrid(tempGrid, thisTemp, 1, 0); _tempList.Add(thisTemp); _thisScore = new ScoreBoardXF(); AddControlToGrid(tempGrid, _thisScore, 0, 1); Grid.SetRowSpan(_thisScore, 3); mainStack.Children.Add(tempGrid); SimpleLabelGridXF otherScore = new SimpleLabelGridXF(); otherScore.AddRow("Roll", nameof(RummyDiceMainViewModel.RollNumber), new RollConverter()); otherScore.AddRow("Score", nameof(RummyDiceMainViewModel.Score)); tempGrid = otherScore.GetContent; tempGrid.VerticalOptions = LayoutOptions.End; // try this way var otherStack = new StackLayout(); otherStack.Orientation = StackOrientation.Horizontal; otherStack.Children.Add(tempGrid); Button thisBut; thisBut = GetGamingButton("Put Back", nameof(RummyDiceMainViewModel.BoardAsync)); thisBut.Margin = new Thickness(5, 0, 0, 0); otherStack.Children.Add(thisBut); mainStack.Children.Add(otherStack); otherStack = new StackLayout(); otherStack.Orientation = StackOrientation.Horizontal; _thisScore.AddColumn("Score Round", false, nameof(RummyDicePlayerItem.ScoreRound)); _thisScore.AddColumn("Score Game", false, nameof(RummyDicePlayerItem.ScoreGame)); _thisScore.AddColumn("Phase", false, nameof(RummyDicePlayerItem.Phase)); _thisScore.VerticalOptions = LayoutOptions.Start; otherStack = new StackLayout(); otherStack.Orientation = StackOrientation.Horizontal; mainStack.Children.Add(otherStack); _diceControl = new RummyDiceListXF(); thisBut = GetGamingButton("Roll", nameof(RummyDiceMainViewModel.RollAsync)); thisBut.HorizontalOptions = LayoutOptions.Start; otherStack.Children.Add(thisBut); otherStack.Children.Add(_diceControl); SimpleLabelGridXF firstInfo = new SimpleLabelGridXF(); firstInfo.AddRow("Turn", nameof(RummyDiceMainViewModel.NormalTurn)); firstInfo.AddRow("Status", nameof(RummyDiceMainViewModel.Status)); firstInfo.AddRow("Phase", nameof(RummyDiceMainViewModel.CurrentPhase)); otherStack = new StackLayout(); otherStack.Orientation = StackOrientation.Horizontal; StackLayout bottomStack = new StackLayout(); otherStack.Children.Add(bottomStack); var endButton = GetGamingButton("End Turn", nameof(RummyDiceMainViewModel.EndTurnAsync)); endButton.HorizontalOptions = LayoutOptions.Start; endButton.Margin = new Thickness(5, 0, 0, 20); bottomStack.Children.Add(endButton); thisBut = GetGamingButton("Score Hand", nameof(RummyDiceMainViewModel.CheckAsync)); thisBut.Margin = new Thickness(5, 0, 0, 0); bottomStack.Children.Add(thisBut); otherStack.Children.Add(firstInfo.GetContent); mainStack.Children.Add(otherStack); if (restoreP != null) { //todo: figure out where to place the restore ui if there is a restore option. mainStack.Children.Add(restoreP); //default add to grid but does not have to. } GamePackageViewModelBinder.ManuelElements.Clear(); //often times i have to add manually. if (_mainGame !.TempSets !.Count == 0) { throw new BasicBlankException("You need to have 2 sets, not none for tempsets"); } _mainGame.TempSets.ForEach(tempCP => { RummyDiceHandXF thisTemp = _tempList.Single(items => items.Index == tempCP.Index); thisTemp.LoadList(tempCP, _mainGame); }); _diceControl !.LoadDiceViewModel(_mainGame); _thisScore !.LoadLists(_mainGame.PlayerList !); // i think Content = mainStack; }