private void ProcessPieceSelected(PieceCP piece) { PieceList.ForEach(tempPiece => { if (tempPiece.Equals(piece)) { tempPiece.IsSelected = true; } else { tempPiece.IsSelected = false; } }); HowMany = piece.HowMany; ShapeChosen = piece.ShapeUsed; }
private void PieceBindings(XactikaPieceXF thisGraphics, PieceCP thisPiece) { thisGraphics.WidthRequest = _sizeUsed.Width; thisGraphics.HeightRequest = _sizeUsed.Height; thisGraphics.Margin = new Thickness(5, 0, 5, 5); // i do like the idea of margins this time as well. thisGraphics.IsVisible = true; // has to manually be set thisGraphics.BindingContext = thisPiece; var thisBind = GetCommandBinding(nameof(ChooseShapeObservable.ShapeSelectedCommand)); thisGraphics.SetBinding(GraphicsCommand.CommandProperty, thisBind); thisGraphics.CommandParameter = thisPiece; // i think thisGraphics.SetBinding(XactikaPieceXF.ShapeUsedProperty, nameof(PieceCP.ShapeUsed)); thisGraphics.SetBinding(XactikaPieceXF.HowManyProperty, nameof(PieceCP.HowMany)); thisGraphics.SetBinding(XactikaPieceXF.IsSelectedProperty, nameof(PieceCP.IsSelected)); thisGraphics.SetBinding(IsEnabledProperty, nameof(PieceCP.IsEnabled)); thisGraphics.SendPiece(thisPiece); // i think }
private void PieceBindings(XactikaPieceWPF thisGraphics, PieceCP thisPiece) { thisGraphics.Width = 90; thisGraphics.Height = 207; // use proportions (decided the aspect ratio as 1.5) thisGraphics.Margin = new Thickness(5, 0, 5, 5); // i do like the idea of margins this time as well. thisGraphics.Visibility = Visibility.Visible; // has to manually be set thisGraphics.DataContext = thisPiece; var thisBind = GetCommandBinding(nameof(ChooseShapeObservable.ShapeSelectedCommand)); thisGraphics.SetBinding(GraphicsCommand.CommandProperty, thisBind); thisGraphics.CommandParameter = thisPiece; // i think thisGraphics.SetBinding(XactikaPieceWPF.ShapeUsedProperty, nameof(PieceCP.ShapeUsed)); thisGraphics.SetBinding(XactikaPieceWPF.HowManyProperty, nameof(PieceCP.HowMany)); thisGraphics.SetBinding(XactikaPieceWPF.IsSelectedProperty, nameof(PieceCP.IsSelected)); thisGraphics.SetBinding(IsEnabledProperty, nameof(PieceCP.IsEnabled)); thisGraphics.SendPiece(thisPiece); // i think }
public void ChoosePiece(EnumShapes shape) { if (PieceList.Count > 0) { var piece = (from x in PieceList where (int)x.ShapeUsed == (int)shape select x).Single(); piece.IsSelected = false; // its obvious now. PieceList.ReplaceAllWithGivenItem(piece); // this will become the new list } else { PieceCP newPiece = new PieceCP(); newPiece.ShapeUsed = shape; newPiece.HowMany = _gameContainer.SaveRoot !.Value; PieceList.ReplaceAllWithGivenItem(newPiece); } Visible = true; // obviously }
public void LoadPieceList(XactikaCardInformation card) // has to be loaded with the card chosen { CustomBasicCollection <PieceCP> tempList = new CustomBasicCollection <PieceCP>(); PieceCP thisPiece = new PieceCP(); thisPiece.HowMany = card.HowManyBalls; thisPiece.ShapeUsed = EnumShapes.Balls; tempList.Add(thisPiece); thisPiece = new PieceCP(); thisPiece.HowMany = card.HowManyCones; thisPiece.ShapeUsed = EnumShapes.Cones; tempList.Add(thisPiece); thisPiece = new PieceCP(); thisPiece.HowMany = card.HowManyCubes; thisPiece.ShapeUsed = EnumShapes.Cubes; tempList.Add(thisPiece); thisPiece = new PieceCP(); thisPiece.HowMany = card.HowManyStars; thisPiece.ShapeUsed = EnumShapes.Stars; tempList.Add(thisPiece); PieceList.ReplaceRange(tempList); Visible = true; }