예제 #1
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // build the randomStackPanel elements
            randomStackPanel = new StackPanel { Orientation = Orientation.Vertical };
            for (int i = 0; i < 30; i++)
                randomStackPanel.Children.Add(CreateButton(0, i, 50, 1200, true));

            // build the randomStackPanel elements
            virtualizedStackPanel = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (int i = 0; i < 30; i++)
                virtualizedStackPanel.Children.Add(CreateButton(0, i, 75, 1200));

            // build the uniform grid
            uniformGrid = new UniformGrid { Columns = 15, Rows = 20 };
            for (int c = 0; c < uniformGrid.Columns; ++c)
            {
                for (int r = 0; r < uniformGrid.Rows; ++r)
                    uniformGrid.Children.Add(CreateButton(c,r, 175, 300));
            }
                
            // build the grid
            const int gridColumns = 10;
            const int gridRows = 10;
            grid = new Grid();
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int i = 0; i < gridColumns; i++)
                grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int i = 0; i < gridRows; i++)
                grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int c = 0; c < gridColumns; ++c)
            {
                for (int r = 0; r < gridRows; ++r)
                    grid.Children.Add(CreateButton(c, r, 50 + r * 30, 100 + c * 40));
            }

            // build the scroll viewer
            scrollViewer = new TestScrollViewer { Name = "sv", Content = randomStackPanel, ScrollMode = ScrollingMode.HorizontalVertical, SnapToAnchors = true };

            // set the scroll viewer as the root
            UIComponent.RootElement = scrollViewer;
        }
예제 #2
0
        private UIElement CreateMainScene()
        {
            // the top life bar
            var topBar = CreateMainScreneTopBar();

            // Create Name label
            nameTextBlock = new TextBlock
            {
                Font = westernFont,
                TextSize = 52,
                TextColor = Color.LightGreen,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(50, 0, 50, 0)
            };
            var nameLabel = new ContentDecorator
            {
                BackgroundImage = mainScreneImages["tex_edit_inactivated_background"],
                Content = nameTextBlock,
                Padding = new Thickness(20, 15, 20, 20),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };
            nameLabel.SetGridRow(1);

            // Create Character image
            var characterImage = new ImageElement
            {
                Name = "HeroImage",
                Source = mainScreneImages["character"],
                HorizontalAlignment = HorizontalAlignment.Center,
            };
            characterImage.SetGridRow(2);

            // Create Explanation TextBlock
            var explanationLabel = new ContentDecorator
            {
                BackgroundImage = mainScreneImages["description_frame"],
                HorizontalAlignment = HorizontalAlignment.Center,
                Content = new TextBlock
                {
                    Font = LoadAsset<SpriteFont>("JapaneseFont"),
                    TextSize = 34,
                    TextColor = Color.White,
                    Text = "Pictogram-based alphabets are easily supported.\n日本語も簡単に入れることが出来ます。",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    WrapText = true
                },
                Padding = new Thickness(50, 30, 50, 40),
            };
            explanationLabel.SetGridRow(3);

            // The ship status panel
            var shipStatusPanel = CreateMainSceneShipStatusPanel();
            shipStatusPanel.SetGridRow(4);

            // Create quit button (Last element)
            var quitButton = CreateTextButton("Quit Sample");
            quitButton.HorizontalAlignment = HorizontalAlignment.Center;
            quitButton.VerticalAlignment = VerticalAlignment.Center;
            quitButton.Click += delegate { UIGame.Exit(); };
            quitButton.SetGridRow(5);

            // Put region together in the main grid
            var mainLayout = new Grid();
            mainLayout.ColumnDefinitions.Add(new StripDefinition());
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 15));
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 10));
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 20));
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 20));
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 25));
            mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 10));
            mainLayout.LayerDefinitions.Add(new StripDefinition());

            // set minimal and maximal size of rows
            mainLayout.RowDefinitions[0].MaximumSize = topBar.MaximumHeight;
            mainLayout.RowDefinitions[1].MinimumSize = 100;
            mainLayout.RowDefinitions[3].MinimumSize = 120;
            mainLayout.RowDefinitions[5].MinimumSize = 90;

            mainLayout.Children.Add(topBar);
            mainLayout.Children.Add(nameLabel);
            mainLayout.Children.Add(characterImage);
            mainLayout.Children.Add(explanationLabel);
            mainLayout.Children.Add(shipStatusPanel);
            mainLayout.Children.Add(quitButton);


            return mainLayout;
        }
예제 #3
0
        private UIElement CreateMainSceneShipStatusPanel()
        {
            // Status star bars {Power, Life, Speed}
            var powerStatusDecorator = CreateMainSceneShipStatusStars("power", powerStatusStar, 0);
            var controlStatusDecorator = CreateMainSceneShipStatusStars("control", controlStatusStar, 1);
            var speedStatusDecorator = CreateMainSceneShipStatusStars("speed", speedStatusStar, 2);
            PowerStatus = shipList[activeShipIndex].Power;
            ControlStatus = shipList[activeShipIndex].Control;
            SpeedStatus = shipList[activeShipIndex].Speed;

            // Put the stats (Stars) in 3x1 uniform grid
            var statusPanel = new UniformGrid { Rows = 3 };
            statusPanel.Children.Add(powerStatusDecorator);
            statusPanel.Children.Add(controlStatusDecorator);
            statusPanel.Children.Add(speedStatusDecorator);
            statusPanel.SetGridColumn(1);

            // SpaceShip Button
            currentShipImage = new ImageElement { Source = mainScreneImages[shipList[activeShipIndex].Name], };
            currentShipImage.SetGridRow(1);

            var shipImageSpacerGrid = new Grid { HorizontalAlignment = HorizontalAlignment.Center };
            shipImageSpacerGrid.Children.Add(currentShipImage);
            shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2));
            shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 6));
            shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2));
            shipImageSpacerGrid.ColumnDefinitions.Add(new StripDefinition());
            shipImageSpacerGrid.LayerDefinitions.Add(new StripDefinition());

            var shipButtonDesign = mainScreneImages["display_element"];
            var currentShipButton = new Button
            {
                NotPressedImage = shipButtonDesign,
                PressedImage = shipButtonDesign,
                MouseOverImage = shipButtonDesign,
                Content = shipImageSpacerGrid,
                Padding = new Thickness(45, 20, 10, 25),
                VerticalAlignment = VerticalAlignment.Center
            };
            currentShipButton.Click += delegate
            {
                // Once click, update the SpaceShip status pop-up and show it.
                UpdateShipStatus();
                ShowShipSelectionPopup();
            };
            currentShipButton.SetGridColumn(3);

            // Status upgrade buttons
            var powerUpgradeButton = CreateIncreaseStatusButton("P", 0, 0, 2, 0, () => PowerStatus, () => PowerStatus++);
            var controlUpgradeButton = CreateIncreaseStatusButton("C", 0, 1, 2, 0, () => ControlStatus, () => ControlStatus++);
            var speedUpgradeButton = CreateIncreaseStatusButton("S", 1, 0, 2, 0, () => SpeedStatus, () => SpeedStatus++);
            var lifeUpgradeButton = CreateIncreaseStatusButton("L", 1, 1, 1, 1, () => 0, () => LifeStatus++);

            // Arrange the status up buttons in a 2x2 Uniform grid.
            var statusUpgradeGridPanel = new UniformGrid
            {
                Rows = 2,
                Columns = 2,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };
            statusUpgradeGridPanel.Children.Add(powerUpgradeButton);
            statusUpgradeGridPanel.Children.Add(controlUpgradeButton);
            statusUpgradeGridPanel.Children.Add(speedUpgradeButton);
            statusUpgradeGridPanel.Children.Add(lifeUpgradeButton);
            statusUpgradeGridPanel.SetGridColumn(5);

            // Put together bottom region in horizontal Stack panel, arranging it from left to right
            var mainPanel = new Grid();
            mainPanel.RowDefinitions.Add(new StripDefinition());
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4));
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4));
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 3));
            mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space
            mainPanel.LayerDefinitions.Add(new StripDefinition());

            mainPanel.Children.Add(statusPanel);
            mainPanel.Children.Add(currentShipButton);
            mainPanel.Children.Add(statusUpgradeGridPanel);

            return mainPanel;
        }
예제 #4
0
        private UIElement CreateMainScreneTopBar()
        {
            // Create Life bar
            lifeBarGaugeImage = mainScreneImages["life_bar"];
            var lifeBarCoverImage = mainScreneImages["character_frame"];
            gaugeBarRegion = lifeBarGaugeImage.Region;

            var lifebarGauge = new ImageElement
            {
                Name = "LifeBarBackground",
                Source = lifeBarGaugeImage,
                StretchType = StretchType.Fill,
            };
            lifebarGauge.SetGridColumn(1);

            lifeBarGrid = new Grid();
            lifeBarGrid.Children.Add(lifebarGauge);
            lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, lifeBarCoverImage.Borders.X));
            lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 0));
            lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 100));
            lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, lifeBarCoverImage.Borders.Y));
            lifeBarGrid.RowDefinitions.Add(new StripDefinition());
            lifeBarGrid.LayerDefinitions.Add(new StripDefinition());
            lifeBarGrid.SetCanvasRelativePosition(new Vector3(0f, 0.185f, 0f));
            lifeBarGrid.SetCanvasRelativeSize(new Vector3(1f, 0.25f, 1f));
            lifeBarGrid.SetPanelZIndex(-1);

            var lifebarForeground = new ImageElement
            {
                Name = "LifeBarForeGround",
                Source = lifeBarCoverImage,
                StretchType = StretchType.Fill,
            };
            lifebarForeground.SetGridColumnSpan(3);
            lifebarForeground.SetGridRowSpan(3);
            lifebarForeground.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f));

            // Life count
            lifeCounter = new TextBlock
            {
                Text = CreateLifeCountText(),
                TextColor = Color.Gold,
                Font = westernFont,
                TextSize = 32,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            lifeCounter.SetCanvasAbsolutePosition(new Vector3(lifeBarCoverImage.Borders.X, float.NaN, float.NaN));
            lifeCounter.SetCanvasRelativePosition(new Vector3(float.NaN, 0.44f, 0f));
            lifeCounter.SetPanelZIndex(1);
            LifeStatus = 3;

            // Bonus items
            var bonusIcon = new ImageElement
            {
                Source = mainScreneImages["gold_icon"],
                Name = "bonus Icon",
                VerticalAlignment = VerticalAlignment.Center
            };
            bonusCounter = new TextBlock
            {
                Text = CreateBonusCountText(),
                TextColor = Color.White,
                TextSize = 27,
                Font = westernFont,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(10, 0, 0, 0)
            };

            // Money 
            var moneyIcon = new ImageElement
            {
                Source = mainScreneImages["money_icon"],
                Name = "money Icon",
                Margin = new Thickness(20, 0, 0, 0),
                VerticalAlignment = VerticalAlignment.Center
            };
            moneyCounter = new TextBlock
            {
                Text = CreateMoneyCountText(),
                TextColor = Color.White,
                TextSize = 27,
                Font = westernFont,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(10, 0, 0, 0)
            };

            // Stack panel containing the bonus and money counters
            var moneyBonusStackPanel = new StackPanel
            {
                Name = "MoneyBonusStackPanel",
                Orientation = Orientation.Horizontal,
            };
            moneyBonusStackPanel.Children.Add(bonusIcon);
            moneyBonusStackPanel.Children.Add(bonusCounter);
            moneyBonusStackPanel.Children.Add(moneyIcon);
            moneyBonusStackPanel.Children.Add(moneyCounter);
            moneyBonusStackPanel.SetCanvasRelativePosition(new Vector3(0.93f, 0.44f, 0f));
            moneyBonusStackPanel.SetCanvasRelativeSize(new Vector3(float.NaN, 0.4f, 1f));
            moneyBonusStackPanel.SetCanvasPinOrigin(new Vector3(1f, 0f, 0f));
            moneyBonusStackPanel.SetPanelZIndex(1);

            // the main grid of the top bar
            var mainLayer = new Canvas
            {
                VerticalAlignment = VerticalAlignment.Top,
                MaximumHeight = 150
            };

            mainLayer.Children.Add(lifeBarGrid);
            mainLayer.Children.Add(lifebarForeground);
            mainLayer.Children.Add(lifeCounter);
            mainLayer.Children.Add(moneyBonusStackPanel);

            return mainLayer;
        }
예제 #5
0
        private void CreateWelcomePopup()
        {
            // Create welcome text
            var welcomeText = new TextBlock
            {
                Font = westernFont,
                TextSize = 42,
                TextColor = Color.White,
                Text = "Welcome to paradox UI sample.\n" + "Please name your character",
                TextAlignment = TextAlignment.Center,
                WrapText = true,
                Margin = new Thickness(20, 0, 20, 0),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            // Create Edit text
            var nameEditText = new EditText(Services)
            {
                Font = westernFont,
                TextSize = 32,
                TextColor = Color.White,
                Text = DefaultName,
                MaxLength = 15,
                TextAlignment = TextAlignment.Center,
                ActiveImage = mainScreneImages["tex_edit_activated_background"],
                InactiveImage = mainScreneImages["tex_edit_inactivated_background"],
                MouseOverImage = mainScreneImages["tex_edit_inactivated_background"],
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                MinimumWidth = 340,
                Padding = new Thickness(30, 30, 30, 40), // Pad text (Content inside),
                Margin = new Thickness(0, 80, 0, 80), // Space around the edit
            };
            nameEditText.SetGridRow(1);

            // Create cancel and validate button
            var cancelButton = CreateTextButton("Cancel");
            cancelButton.SetGridColumn(1);

            cancelButton.Click += delegate
            {
                nameTextBlock.Text = DefaultName;
                welcomePopup.Visibility = Visibility.Collapsed;
            };

            var validateButton = CreateTextButton("Validate");
            validateButton.SetGridColumn(3);

            validateButton.Click += delegate
            {
                nameTextBlock.Text = nameEditText.Text.Trim();
                welcomePopup.Visibility = Visibility.Collapsed;
            };

            // Put cancel and validate buttons in stack panel (Left-right orientation placement)
            var buttonPanel = new Grid();
            buttonPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            buttonPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            buttonPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            buttonPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            buttonPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            buttonPanel.RowDefinitions.Add(new StripDefinition());
            buttonPanel.LayerDefinitions.Add(new StripDefinition());

            buttonPanel.Children.Add(cancelButton);
            buttonPanel.Children.Add(validateButton);
            buttonPanel.SetGridRow(2);

            // Create a stack panel to store items (Top-down orientation placement)
            var popupContentPanel = new Grid
            {
                MaximumWidth = 580,
                MaximumHeight = 900,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };

            popupContentPanel.ColumnDefinitions.Add(new StripDefinition());
            popupContentPanel.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            popupContentPanel.RowDefinitions.Add(new StripDefinition(StripType.Star));
            popupContentPanel.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            popupContentPanel.LayerDefinitions.Add(new StripDefinition());

            popupContentPanel.Children.Add(welcomeText);
            popupContentPanel.Children.Add(nameEditText);
            popupContentPanel.Children.Add(buttonPanel);

            var welcomePopupContent = new ContentDecorator
            {
                BackgroundImage = popupWindowImage,
                Content = popupContentPanel,
                Padding = new Thickness(85, 130, 85, 110)
            };

            welcomePopup = new ModalElement
            {
                Visibility = Visibility.Collapsed,
                Content = welcomePopupContent,
            };
            welcomePopup.SetPanelZIndex(1);
        }
예제 #6
0
        private UniformGrid CreateShipButtonElement(SpaceShip spaceShip)
        {
            // Put the stat text block in a vertical uniform grid
            var statusTextGrid = new UniformGrid { Rows = 3, Margin = new Thickness(5f, -6f, 0, 0)};
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Power", 0));
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Control", 1));
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Speed", 2));

            // Put the stat stars in a vertical uniform grid
            spaceShip.PowerImageElement = CreateShipStatusStar(0);
            spaceShip.ControlImageElement = CreateShipStatusStar(1);
            spaceShip.SpeedImageElement = CreateShipStatusStar(2);

            var starGrid = new UniformGrid { Rows = 3 };
            starGrid.Children.Add(spaceShip.PowerImageElement);
            starGrid.Children.Add(spaceShip.ControlImageElement);
            starGrid.Children.Add(spaceShip.SpeedImageElement);
            starGrid.SetGridColumn(2);

            // Ship image
            var shipSprite = mainScreneImages[spaceShip.Name];
            var shipImageElement = new ImageElement { Source = shipSprite };
            shipImageElement.SetGridColumn(4);

            // Create the horizontal grid with two blank stretchable columns and add the text blocks, the starts and the ship image
            var shipContent = new Grid();
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.RowDefinitions.Add(new StripDefinition());
            shipContent.LayerDefinitions.Add(new StripDefinition());

            shipContent.Children.Add(statusTextGrid);
            shipContent.Children.Add(starGrid);
            shipContent.Children.Add(shipImageElement);

            //
            var shipSelectFrameSprite = mainScreneImages["weapon_select_frame"];

            var shipButton = new Button
            {
                Name = spaceShip.Name,
                Content = shipContent,
                PressedImage = shipSelectFrameSprite,
                NotPressedImage = shipSelectFrameSprite,
                MouseOverImage = shipSelectFrameSprite,
                Padding = new Thickness(60, 20, 20, 20)
            };

            shipButton.Click += delegate
            {
                currentShipImage.Source = shipSprite;

                activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name);

                PowerStatus = spaceShip.Power;
                ControlStatus = spaceShip.Control;
                SpeedStatus = spaceShip.Speed;

                CloseShipSelectPopup();
            };

            shipButton.IsEnabled = !spaceShip.IsLocked;
            shipButton.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f));

            var buttonGrid = new UniformGrid { MaximumHeight = 100 };
            buttonGrid.Children.Add(shipButton);

            if (spaceShip.IsLocked)
            {
                var lockIconImage = mainScreneImages["lock_icon"];
                var lockIconElement = new ImageElement { Source = lockIconImage, StretchType = StretchType.Fill, };
                lockIconElement.SetPanelZIndex(1);
                buttonGrid.Children.Add(lockIconElement);
            }

            return buttonGrid;
        }
예제 #7
0
        private void CreateShipSelectionPopup()
        {
            // Create "Please select your SpaceShip" text
            var pleaseSelectText = new TextBlock
            {
                Font = westernFont,
                TextSize = 48,
                TextColor = Color.White,
                Text = "Please select your ship",
                TextAlignment = TextAlignment.Center,
                WrapText = true
            };

            // Layout elements in vertical StackPanel
            var contentStackpanel = new StackPanel { Orientation = Orientation.Vertical };

            // Create and Add SpaceShip to the stack layout
            foreach (var ship in shipList)
                contentStackpanel.Children.Add(CreateShipButtonElement(ship));

            // Uncomment those lines to have an example of stack panel item virtualization
            //var shipInitialCount = shipList.Count;
            //contentStackpanel.ItemVirtualizationEnabled = true;
            //for (int i = 0; i < 200; i++)
            //{
            //    shipList.Add(new SpaceShip { Name = shipList[i % shipInitialCount].Name });
            //    contentStackpanel.Children.Add(CreateShipButtonElement(shipList[shipList.Count - 1]));
            //}

            UpdateShipStatus();

            var contentScrollView = new ScrollViewer
            {
                MaximumHeight = 425,
                Content = contentStackpanel,
                ScrollMode = ScrollingMode.Vertical,
                Margin = new Thickness(12, 10, 7, 10),
                Padding = new Thickness(0, 0, 6, 0),
                ScrollBarColor = Color.Orange
            };

            var scrollViewerBackgroundImage = mainScreneImages["scroll_background"];
            var scrollViewerDecorator = new ContentDecorator { BackgroundImage = scrollViewerBackgroundImage, Content = contentScrollView, };
            scrollViewerDecorator.SetGridRow(2);

            var layoutGrid = new Grid();
            layoutGrid.ColumnDefinitions.Add(new StripDefinition());
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // white space
            layoutGrid.RowDefinitions.Add(new StripDefinition(StripType.Star));
            layoutGrid.LayerDefinitions.Add(new StripDefinition());
            layoutGrid.Children.Add(pleaseSelectText);
            layoutGrid.Children.Add(scrollViewerDecorator);

            var shipSelectPopupContent = new ContentDecorator
            {
                BackgroundImage = popupWindowImage,
                Content = layoutGrid,
                Padding = new Thickness(110, 120, 100, 140)
            };

            // Create SpaceShip selection popup
            shipSelectPopup = new ModalElement
            {
                Visibility = Visibility.Collapsed,
                Content = shipSelectPopupContent
            };

            shipSelectPopup.SetPanelZIndex(1);
        }
예제 #8
0
        protected override void LoadScene()
        {
            // Allow user to resize the window with the mouse.
            Game.Window.AllowUserResizing = true;

            var arial = LoadAsset<SpriteFont>("WesternFont");
            var uiImages = LoadAsset<SpriteSheet>("SplashScreenImages");

            // Create and initialize "Paradox Samples" Text
            var paradoxSampleTextBlock = new ContentDecorator
            {
                BackgroundImage = uiImages["paradox_sample_text_bg"],
                Content = new TextBlock
                {
                    Font = arial,
                    TextSize = 60,
                    Text = "Paradox Samples",
                    TextColor = Color.White,
                },
                Padding = new Thickness(35, 15, 35, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            paradoxSampleTextBlock.SetPanelZIndex(1);

            // Create and initialize "UI" Text
            var uiTextBlock = new ContentDecorator
            {
                BackgroundImage = uiImages["ui_text_bg"],
                Content = new TextBlock
                {
                    Font = arial,
                    TextSize = 60,
                    Text = "UI",
                    TextColor = Color.White,
                },
                Padding = new Thickness(15, 4, 15, 7),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            uiTextBlock.SetPanelZIndex(1);
            uiTextBlock.SetGridRow(1);

            // Create and initialize Paradox Logo
            var paradoxLogoImageElement = new ImageElement
            {
                Source = uiImages["Logo"],
                HorizontalAlignment = HorizontalAlignment.Center
            };

            paradoxLogoImageElement.SetPanelZIndex(1);
            paradoxLogoImageElement.SetGridRow(3);

            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                BackgroundImage = uiImages["touch_start_frame"],
                Content = new TextBlock
                {
                    Font = arial,
                    TextSize = 42,
                    Text = "Touch Screen to Start",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            touchStartLabel.SetPanelZIndex(1);
            touchStartLabel.SetGridRow(5);

            var grid = new Grid
            {
                MaximumWidth = 600,
                MaximumHeight = 900,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Star, 5));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(paradoxSampleTextBlock);
            grid.Children.Add(uiTextBlock);
            grid.Children.Add(paradoxLogoImageElement);
            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { Source = uiImages["background_uiimage"], StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            Entity.Get<UIComponent>().RootElement = new UniformGrid { Children = { background, grid } };
        }