コード例 #1
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);
        }
コード例 #2
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);
        }