예제 #1
0
        private void InitializeWelcomePopup()
        {
            welcomePopup = UILibrary.InstantiateElement<ModalElement>("WelcomePopup");
            welcomePopup.SetPanelZIndex(1);

            // FIXME: UI asset should support multiline text
            var welcomeText = welcomePopup.FindVisualChildOfType<TextBlock>("welcomeText");
            welcomeText.Text = "Welcome to xenko UI sample.\nPlease name your character";
            
            var cancelButton = welcomePopup.FindVisualChildOfType<Button>("cancelButton");
            cancelButton.Click += delegate
            {
                nameTextBlock.Text = DefaultName;
                CloseWelcomePopup();
            };

            var nameEditText = welcomePopup.FindVisualChildOfType<EditText>("nameEditText");
            nameEditText.Text = DefaultName;
            var validateButton = welcomePopup.FindVisualChildOfType<Button>("validateButton");
            validateButton.Click += delegate
            {
                nameTextBlock.Text = nameEditText.Text.Trim();
                CloseWelcomePopup();
            };
        }
예제 #2
0
        private void InitializeShipSelectionPopup()
        {
            shipSelectPopup = UILibrary.InstantiateElement<ModalElement>("ShipSelectPopup");
            shipSelectPopup.SetPanelZIndex(1);

            // Layout elements in vertical StackPanel
            var contentStackpanel = shipSelectPopup.FindVisualChildOfType<StackPanel>("contentStackPanel");

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

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

            UpdateShipStatus();
            CloseShipSelectPopup();
        }