public CandylandMainView(IEventAggregator aggregator, TestOptions test, IGamePackageRegister register //unless i extend the contract, will be done this way. ) { Background = Brushes.White; _aggregator = aggregator; _aggregator.Subscribe(this); StackPanel mainStack = new StackPanel(); ParentSingleUIContainer?restoreP = null; if (test.SaveOption == EnumTestSaveCategory.RestoreOnly) { restoreP = new ParentSingleUIContainer() { Name = nameof(CandylandMainViewModel.RestoreScreen) }; } StackPanel otherStack = new StackPanel(); _ourBoard = new GameboardWPF(); register.RegisterControl(_ourBoard.Element1, "main"); //register!.RegisterSingleton(_ourBoard.Element1, "main"); //i think _ourCard = new CardGraphicsWPF(); // bindings are finished _ourCard.SendSize("main", new CandylandCardData()); otherStack.Margin = new Thickness(5, 5, 5, 5); otherStack.Orientation = Orientation.Horizontal; StackPanel firstStack = new StackPanel(); otherStack.Children.Add(firstStack); firstStack.Children.Add(_ourCard); //you already subscribed. just hook up another event for this. _ourPiece = new PieceWPF(); _ourPiece.Margin = new Thickness(0, 5, 0, 0); _ourPiece.SetSizes(); BaseLabelGrid firstInfo = new BaseLabelGrid(); firstInfo.AddRow("Turn", nameof(CandylandMainViewModel.NormalTurn)); firstInfo.AddRow("Status", nameof(CandylandMainViewModel.Status)); firstStack.Children.Add(firstInfo.GetContent); firstStack.Children.Add(_ourPiece); _ourBoard.HorizontalAlignment = HorizontalAlignment.Left; _ourBoard.VerticalAlignment = VerticalAlignment.Top; _ourBoard.Margin = new Thickness(5, 0, 0, 0); otherStack.Children.Add(_ourBoard); 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; }
private async Task PrepareToAnimateAsync(AnimateCardInPileEventModel <FlinchCardInformation> data) // don't need index ever for this. { var thisPile = FindControl(data.ThisPile !); var topLocation = GetStartLocation(); var bottomLocaton = GetBottomLocation(); var cardLocation = GetCardLocation(thisPile !); switch (data.Direction) { case EnumAnimcationDirection.StartCardToDown: { _animates !.LocationFrom = cardLocation; _animates.LocationTo = bottomLocaton; break; } case EnumAnimcationDirection.StartCardToUp: { _animates !.LocationFrom = cardLocation; _animates.LocationTo = topLocation; break; } case EnumAnimcationDirection.StartDownToCard: { _animates !.LocationFrom = bottomLocaton; _animates.LocationTo = cardLocation; break; } case EnumAnimcationDirection.StartUpToCard: { _animates !.LocationFrom = topLocation; _animates.LocationTo = cardLocation; break; } } CardGraphicsWPF thisControl = new CardGraphicsWPF(); thisControl.SendSize("", data.ThisCard !); thisControl.Drew = false; thisControl.IsSelected = false; thisControl.DoInvalidate(); await _animates !.DoAnimateAsync(thisControl); // i think thisControl.Visibility = Visibility.Collapsed; _thisCanvas !.Children.Clear(); //try this too. }
private readonly ThreeLetterFunCardData _tempCard; //not sure. public ThreeLetterFunMainView(IEventAggregator aggregator, TestOptions test, ThreeLetterFunMainGameClass mainGame, ThreeLetterFunVMData model, GameBoard gameBoard ) { _aggregator = aggregator; _mainGame = mainGame; _model = model; _gameBoard = gameBoard; model.NewUI = this; _aggregator.Subscribe(this); StackPanel mainStack = new StackPanel(); ParentSingleUIContainer?restoreP = null; if (test.SaveOption == EnumTestSaveCategory.RestoreOnly) { restoreP = new ParentSingleUIContainer() { Name = nameof(ThreeLetterFunMainViewModel.RestoreScreen) }; } _tempCard = new ThreeLetterFunCardData(); _tempCard.Visible = false; _currentCard = new CardGraphicsWPF(); _currentCard.SendSize(ThreeLetterFunCardGraphicsCP.TagUsed, _tempCard); //i think. var winLabel = GetDefaultLabel(); winLabel.SetBinding(TextBlock.TextProperty, new Binding(nameof(ThreeLetterFunMainViewModel.PlayerWon))); _score = new ScoreBoardWPF(); _score.AddColumn("Cards Won", true, nameof(ThreeLetterFunPlayerItem.CardsWon)); StackPanel otherStack = new StackPanel(); otherStack.Orientation = Orientation.Horizontal; mainStack.Children.Add(_currentCard); mainStack.Children.Add(winLabel); mainStack.Children.Add(_gameBoard1); mainStack.Children.Add(_tileBoard1); var thisBut = GetGamingButton("Play", nameof(ThreeLetterFunMainViewModel.PlayAsync)); otherStack.Children.Add(thisBut); thisBut = GetGamingButton("Give Up", nameof(ThreeLetterFunMainViewModel.GiveUpAsync)); otherStack.Children.Add(thisBut); thisBut = GetGamingButton("Take Back", nameof(ThreeLetterFunMainViewModel.TakeBack)); otherStack.Children.Add(thisBut); mainStack.Children.Add(otherStack); mainStack.Children.Add(_score); if (restoreP != null) { 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.BasicData.MultiPlayer) { _score.LoadLists(_mainGame.PlayerList); //hopefully no need for the other controls since something else handles it now. } else { _score.Visibility = Visibility.Collapsed; } _tileBoard1.Init(_model); _gameBoard1.LoadList(_gameBoard, ThreeLetterFunCardGraphicsCP.TagUsed); Content = mainStack; }