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;
        }
Ejemplo n.º 2
0
        public CandylandMainView(IEventAggregator aggregator,
                                 TestOptions test,
                                 IGamePackageRegister register
                                 )
        {
            BackgroundColor = Color.White;
            _aggregator     = aggregator;
            _aggregator.Subscribe(this);
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(CandylandMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            _ourBoard = new GameBoardXF();
            register.RegisterControl(_ourBoard.Element, "main");
            _ourCard = new CardGraphicsXF(); // bindings are finished
            _ourCard.SendSize("main", new CandylandCardData());
            otherStack.Margin      = new Thickness(5, 5, 5, 5);
            otherStack.Orientation = StackOrientation.Horizontal;
            StackLayout firstStack = new StackLayout();

            otherStack.Children.Add(firstStack);
            firstStack.Children.Add(_ourCard); //you already subscribed.  just hook up another event for this.
            _ourPiece        = new PieceXF();
            _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.HorizontalOptions = LayoutOptions.Start;
            _ourBoard.VerticalOptions   = LayoutOptions.Start;
            _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;
        }