コード例 #1
0
ファイル: ClickTests.cs プロジェクト: robterrell/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var element1 = new Button { Name = "1", Width = 800, Height = 400, Content = new TextBlock { Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true } };
            element1.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(100, 50, 0));
            element1.DependencyProperties.Set(Panel.ZIndexPropertyKey, -1);

            var element2 = new Button { Name = "2", Width = 400, Height = 200, Content = new TextBlock { Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true } };
            element2.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(300, 150, 0));
            element2.DependencyProperties.Set(Panel.ZIndexPropertyKey, 1);

            var element3 = new Button { Name = "3", Width = 400, Height = 200, Content = new TextBlock { Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true } };
            element3.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(150, 225, 0));
            element3.DependencyProperties.Set(Panel.ZIndexPropertyKey, 2);

            var element4 = new Button { Name = "4", Width = 400, Height = 200, Content = new TextBlock { Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true } };
            element4.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(450, 75, 0));
            element4.DependencyProperties.Set(Panel.ZIndexPropertyKey, 0);

            var canvas = new Canvas();
            canvas.Children.Add(element1);
            canvas.Children.Add(element2);
            canvas.Children.Add(element3);
            canvas.Children.Add(new Canvas { Children = { element4 } });

            elements = new List<Button> { element1, element2, element3, element4 };

            UIComponent.RootElement = canvas;
        }
コード例 #2
0
ファイル: ModalElementTest.cs プロジェクト: releed/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            Sprites = Asset.Load<SpriteSheet>("UIImages");

            var lifeBar = new ImageElement { Source = Sprites["Logo"], HorizontalAlignment = HorizontalAlignment.Center };
            lifeBar.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);

            var quitGameButton = new Button
                {
                    Content = new TextBlock { Text = "Quit Game", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") },
                    VerticalAlignment = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Padding = Thickness.UniformRectangle(10),
                };
            quitGameButton.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            quitGameButton.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            quitGameButton.Click += (sender, args) => Exit();

            modalButton1Text = new TextBlock { Text = "Close Modal window 1", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") };
            var modalButton1 = new Button
            {
                Name = "Button Modal 1",
                Content = modalButton1Text,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Padding = Thickness.UniformRectangle(10),
            };
            modalButton1.Click += ModalButton1OnClick;
            modal1 = new ModalElement { Content = modalButton1, Name = "Modal 1"};
            modal1.DependencyProperties.Set(Panel.ZIndexPropertyKey, 1);
            modal1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            modal1.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            modal1.OutsideClick += Modal1OnOutsideClick;

            modalButton2Text = new TextBlock { Text = "Close Modal window 2", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") };
            var modalButton2 = new Button
            {
                Name = "Button Modal 2",
                Content = modalButton2Text,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Padding = Thickness.UniformRectangle(10),
            };
            modalButton2.Click += ModalButton2OnClick;
            modal2 = new ModalElement { Content = modalButton2, Name = "Modal 2" };
            modal2.DependencyProperties.Set(Panel.ZIndexPropertyKey, 2);
            modal2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            modal2.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            modal2.OutsideClick += Modal2OnOutsideClick;

            uniformGrid = new UniformGrid { Columns = 3, Rows = 3 };
            uniformGrid.Children.Add(modal1);
            uniformGrid.Children.Add(modal2);
            uniformGrid.Children.Add(lifeBar);
            uniformGrid.Children.Add(quitGameButton);
            
            UIComponent.RootElement = uniformGrid;
        }
コード例 #3
0
ファイル: ButtonTests.cs プロジェクト: Powerino73/paradox
        public void TestProperties()
        {
            var control = new Button();

            // test properties default values
            Assert.AreEqual(new Thickness(10, 5, 10, 7), control.Padding);
        }
コード例 #4
0
 //Button configuration
 Button SetupButton(string name, float location)
 {
     Button button = new Button
     {
         Height = 25,
         Width = 100
     };
     button.Click += delegate { ((MenuScript)Entity.Get<ScriptComponent>().Scripts[1]).Menu(name); };
     TextBlock text = new TextBlock
     {
         Height = 20,
         Width = 80,
         Font = Asset.Load<SpriteFont>("Font"),
         Text = name,
         TextAlignment = TextAlignment.Center
     };
     text.SetCanvasRelativePosition(new Vector3(0, 0, 0));
     button.Content = new Canvas
     {
         Children =
         {
             text
         }
     };
     button.SetCanvasRelativePosition(new Vector3(0, location, 0));
     return button;
 }
コード例 #5
0
ファイル: LeaveEnterTest.cs プロジェクト: RainsSoft/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();
            
            buttonLeftTop2 = new Button { Padding = new Thickness(50, 50, 0, 50) };
            buttonLeftTop1 = new Button { Padding = new Thickness(50, 50, 0, 50), Content = buttonLeftTop2 };
            buttonLeftTop0 = new Button { Padding = new Thickness(50, 50, 0, 50), Content = buttonLeftTop1};

            var bottomGrid = new UniformGrid { Rows = 1, Columns = 2 };
            bottomButton = new Button { Content = bottomGrid };
            bottomButton.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            bottomButton.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);

            buttonBottomLeft1 = new Button { Margin = new Thickness(50, 50, 0, 50) };
            buttonBottomLeft0 = new Button { Margin = new Thickness(50, 0, 0, 100), Content = buttonBottomLeft1 };

            bottonBottomRight1 = new Button { Margin = new Thickness(0, 0, 50, 100) };
            buttomBottonRight0 = new Button { Margin = new Thickness(0, 0, 50, 50), Content = bottonBottomRight1 };
            buttomBottonRight0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);

            bottomGrid.Children.Add(buttonBottomLeft0);
            bottomGrid.Children.Add(buttomBottonRight0);

            var mainGrid = new UniformGrid { Rows = 2, Columns = 2 };
            mainGrid.Children.Add(buttonLeftTop0);
            mainGrid.Children.Add(bottomButton);

            UIComponent.RootElement = mainGrid;
        }
コード例 #6
0
ファイル: ButtonTest.cs プロジェクト: RainsSoft/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            button = new Button();

            UIComponent.RootElement = button;
        }
コード例 #7
0
        public void TestBasicInvalidations()
        {
            var newButton = new Button();

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Content = newButton);

            var sameButton = newButton;

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => Content = sameButton);
        }
コード例 #8
0
ファイル: UIScript.cs プロジェクト: vanhapara/paradox-samples
        /// <summary>
        /// Create a button and link the click action to the corresponding animation.
        /// </summary>
        private Button CreateButton(string animationName)
        {
            var font = Asset.Load<SpriteFont>("Font");

            var idleButton = new Button
            {
                Content = new TextBlock
                {
                    Text = "Play " + animationName,
                    Font = font,
                },
                Padding = new Thickness(10, 10, 10, 10),
                Margin = new Thickness(0, 0, 0, 10),
            };
            idleButton.Click += (s, e) => Knight.Get<AnimationComponent>().Crossfade(animationName, TimeSpan.FromSeconds(0.1));

            return idleButton;
        }
コード例 #9
0
        public void TestUpdateWorldMatrixInvalidation()
        {
            var children = new Button();
            Content = children;

            var worldMatrix = Matrix.Zero;
            var localMatrix = Matrix.Identity;

            Measure(Vector3.Zero);
            Arrange(Vector3.Zero, false);
            UpdateWorldMatrix(ref worldMatrix, false);

            worldMatrix.M11 = 2;
            UpdateWorldMatrix(ref worldMatrix, true);
            Assert.AreEqual(worldMatrix.M11, children.WorldMatrix.M11);

            worldMatrix.M11 = 3;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(2, children.WorldMatrix.M11);

            worldMatrix.M11 = 1;
            localMatrix.M11 = 4;
            LocalMatrix = localMatrix;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(localMatrix.M11, children.WorldMatrix.M11);

            localMatrix.M11 = 1;
            LocalMatrix = localMatrix;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(localMatrix.M11, children.WorldMatrix.M11);

            InvalidateArrange();
            Arrange(Vector3.Zero, false);

            worldMatrix.M11 = 5;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(worldMatrix.M11, children.WorldMatrix.M11);
        }
コード例 #10
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var Sprites = Asset.Load<SpriteSheet>("UIImages");
            element1 = new Button { Name = "1", Width = 300, Height = 150 };
            element1.PressedImage = Sprites["Logo"];
            element1.NotPressedImage = Sprites["BorderButton"];
            element1.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(350, 300, 0));
            element1.DependencyProperties.Set(Panel.ZIndexPropertyKey, 1);

            element2 = new Button { Name = "2", Width = 600, Height = 300 };
            element2.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(200, 100, -50));
            element2.DependencyProperties.Set(Panel.ZIndexPropertyKey, 0);
            element2.PressedImage = new Sprite(Asset.Load<Texture>("ImageButtonPressed"));
            element2.NotPressedImage = new Sprite(Asset.Load<Texture>("ImageButtonNotPressed"));

            var canvas = new Canvas();
            canvas.Children.Add(element1);
            canvas.Children.Add(element2);

            UIComponent.RootElement = canvas;
        }
コード例 #11
0
ファイル: MouseOverTest.cs プロジェクト: Powerino73/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var background = new Entity { new BackgroundComponent { Texture = Asset.Load<Texture>("ParadoxBackground") } };
            Scene.AddChild(background);

            button1 = new Button { Content = new TextBlock { Text = "text block button 1", Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true } };
            button1.SetCanvasRelativePosition(new Vector3(0.025f, 0.05f, 0f));

            edit1 = new EditText(Services) { Text = "Edit text 1", Font = Asset.Load<SpriteFont>("CourierNew12"), SynchronousCharacterGeneration = true, };
            edit1.SetCanvasRelativePosition(new Vector3(0.025f, 0.15f, 0f));

            button2 = new Button { Content = new TextBlock { Text = "text block button 2", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), SynchronousCharacterGeneration = true } };
            edit2 = new EditText(Services) { Text = "Edit text 2", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), };

            stackPanel = new StackPanel
            {
                Children = { button2, edit2 }, 
                HorizontalAlignment = HorizontalAlignment.Center, 
                VerticalAlignment = VerticalAlignment.Center, 
                Orientation = Orientation.Horizontal
            };
            stackPanel.SetCanvasRelativePosition(new Vector3(0.5f, 0.5f, 0f));
            stackPanel.SetCanvasPinOrigin(new Vector3(.5f));

            canvas = new Canvas { Children = {button1, edit1, stackPanel}, CanBeHitByUser = true };

            button1.MouseOverStateChanged += (sender, args) => { triggeredButton1 = true; oldValueButton1 = args.OldValue; newValueButton1 = args.NewValue;};
            button2.MouseOverStateChanged += (sender, args) => { triggeredButton2 = true;};
            edit1.MouseOverStateChanged += (sender, args) => { triggeredEdit1 = true;};
            edit2.MouseOverStateChanged += (sender, args) => { triggeredEdit2 = true;};
            canvas.MouseOverStateChanged += (sender, args) => { triggeredCanvas = true;};
            stackPanel.MouseOverStateChanged += (sender, args) => { triggeredStackPanel = true;};

            UIComponent.RootElement = canvas;
        }
コード例 #12
0
ファイル: UniformGridTest.cs プロジェクト: robterrell/paradox
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var imgElt = new ImageElement { Source = new Sprite(Asset.Load<Texture>("uv")), StretchType = StretchType.Fill };
            imgElt.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);
            imgElt.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            imgElt.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            imgElt.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);

            var button1 = new Button();
            button1.DependencyProperties.Set(GridBase.RowPropertyKey, 3);
            button1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);

            var button2 = new Button();
            button2.DependencyProperties.Set(GridBase.RowPropertyKey, 3);
            button2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);

            var text = new TextBlock
            {
                Text = "Test Uniform Grid", 
                Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), 
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };
            text.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            text.DependencyProperties.Set(GridBase.RowPropertyKey, 0);
            text.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);

            var grid = new UniformGrid { Rows = 4, Columns = 4};
            grid.Children.Add(imgElt);
            grid.Children.Add(button1);
            grid.Children.Add(button2);
            grid.Children.Add(text);

            UIComponent.RootElement = grid;
        }
コード例 #13
0
ファイル: UIScript.cs プロジェクト: vanhapara/paradox-samples
        private void CreateMainMenuUI()
        {
            var paradoxLogo = new ImageElement { Source = uiImages["pdx_logo"] };

            paradoxLogo.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            paradoxLogo.SetCanvasRelativeSize(new Vector3(0.5f, 0.5f, 1f));
            paradoxLogo.SetCanvasRelativePosition(new Vector3(0.5f, 0.3f, 1f));

            StartButton = new Button
            {
                Content = new TextBlock { Font = spriteFont, Text = "Touch to Start", TextColor = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center},
                NotPressedImage = buttonImage,
                PressedImage = buttonImage,
                MouseOverImage = buttonImage,
                Padding = new Thickness(80, 27, 25, 35),
                MinimumWidth = 250f,
            };

            StartButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            StartButton.SetCanvasRelativePosition(new Vector3(0.5f, 0.7f, 0f));

            var mainMenuCanvas = new Canvas();
            mainMenuCanvas.Children.Add(paradoxLogo);
            mainMenuCanvas.Children.Add(StartButton);

            mainMenuRoot = new ModalElement
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Content = mainMenuCanvas
            };
        }
コード例 #14
0
        private Button CreateButton(string text, SpriteFont font, int offset)
        {
            var button = new Button
            {
                Name = text,
                Padding = Thickness.UniformRectangle(15),
                HorizontalAlignment = HorizontalAlignment.Left,
                Content = new TextBlock { Text = text, Font = font, TextSize = 35, TextColor = new Color(200, 200, 200, 255) },
            };
            button.Click += (sender, args) => ChangeConstraint(offset);
            button.SetCanvasPinOrigin(new Vector3(offset > 0 ? 1 : 0, 0.5f, 0));
            button.SetCanvasRelativePosition(new Vector3(offset > 0 ? 0.97f : 0.03f, 0.93f, 0));

            return button;
        }
コード例 #15
0
ファイル: CanvasTests.cs プロジェクト: Powerino73/paradox
        public void TestComputeAbsolutePinPosition()
        {
            var child = new Button();

            // directly set the values
            var parentSize = new Vector3(2);
            child.SetCanvasRelativePosition(new Vector3(float.NaN));
            child.SetCanvasAbsolutePosition(new Vector3(-1.5f, 0, 1.5f));
            Assert.AreEqual(child.GetCanvasAbsolutePosition(), ComputeAbsolutePinPosition(child, ref parentSize));
            child.SetCanvasAbsolutePosition(new Vector3(float.NaN));
            child.SetCanvasRelativePosition(new Vector3(-1.5f, 0, 1.5f));
            Assert.AreEqual(2*child.GetCanvasRelativePosition(), ComputeAbsolutePinPosition(child, ref parentSize));

            // indirectly set the value
            child.SetCanvasAbsolutePosition(new Vector3(-1.5f, 0, 1.5f));
            child.SetCanvasRelativePosition(new Vector3(float.NaN));
            Assert.AreEqual(child.GetCanvasAbsolutePosition(), ComputeAbsolutePinPosition(child, ref parentSize));
            child.SetCanvasRelativePosition(new Vector3(-1.5f, 0, 1.5f));
            child.SetCanvasAbsolutePosition(new Vector3(float.NaN));
            Assert.AreEqual(2*child.GetCanvasRelativePosition(), ComputeAbsolutePinPosition(child, ref parentSize));

            // indirect/direct mix
            child.SetCanvasAbsolutePosition(new Vector3(-1.5f, float.NaN, 1.5f));
            child.SetCanvasRelativePosition(new Vector3(float.NaN, 1, float.NaN));
            Assert.AreEqual(new Vector3(-1.5f, 2, 1.5f), ComputeAbsolutePinPosition(child, ref parentSize));
            child.SetCanvasRelativePosition(new Vector3(-1.5f, float.NaN, 1.5f));
            child.SetCanvasAbsolutePosition(new Vector3(float.NaN, 1, float.NaN));
            Assert.AreEqual(new Vector3(-3f, 1, 3f), ComputeAbsolutePinPosition(child, ref parentSize));

            // infinite values
            parentSize = new Vector3(float.PositiveInfinity);
            child.SetCanvasRelativePosition(new Vector3(-1.5f, 0, 1.5f));
            Utilities.AreExactlyEqual(new Vector3(float.NegativeInfinity, 0f, float.PositiveInfinity), ComputeAbsolutePinPosition(child, ref parentSize));
        }
コード例 #16
0
ファイル: UIScript.cs プロジェクト: vanhapara/paradox-samples
        private void CreateGameOverUI()
        {
            MenuButton = new Button
            {
                Content = new TextBlock { Font = spriteFont, Text = "Menu", TextColor = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center},
                PressedImage = buttonImage,
                NotPressedImage = buttonImage,
                MouseOverImage = buttonImage,
                Padding = new Thickness(77, 29, 25, 35),
                MinimumWidth = 190f,
            };

            MenuButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            MenuButton.SetCanvasRelativePosition(new Vector3(0.70f, 0.7f, 0f));

            RetryButton = new Button
            {
                Content = new TextBlock { Font = spriteFont, Text = "Retry", TextColor = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center},
                Padding = new Thickness(74, 29, 25, 35),
                MinimumWidth = 190f,
                PressedImage = buttonImage,
                MouseOverImage = buttonImage,
                NotPressedImage = buttonImage
            };

            RetryButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f));
            RetryButton.SetCanvasRelativePosition(new Vector3(0.3f, 0.7f, 0f));

            var gameOverCanvas = new Canvas();
            gameOverCanvas.Children.Add(MenuButton);
            gameOverCanvas.Children.Add(RetryButton);

            gameOverRoot = new ModalElement
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Content = gameOverCanvas,
                MinimumWidth = 200f,
            };
        }
コード例 #17
0
ファイル: CanvasTests.cs プロジェクト: Powerino73/paradox
        public void TestComputeAvailableSize()
        {
            var child = new Button();
            child.SetCanvasPinOrigin(new Vector3(0, 0.5f, 1));

            // tests in the cases position is absolute
            var availableSize = new Vector3(100, 150, 200);
            child.SetCanvasAbsolutePosition(new Vector3(-1, -2, -3));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasAbsolutePosition(new Vector3(0, 0, 0));
            Utilities.AreExactlyEqual(new Vector3(100, 0, 0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasAbsolutePosition(new Vector3(1, 2, 3));
            Utilities.AreExactlyEqual(new Vector3(99, 4, 3), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasAbsolutePosition(availableSize);
            Utilities.AreExactlyEqual(new Vector3(0, 0, 200), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasAbsolutePosition(availableSize + new Vector3(1, 2, 3));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));

            // tests in the cases position is relative
            child.SetCanvasRelativePosition(new Vector3(-1, -2, -3));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(0, 0, 0));
            Utilities.AreExactlyEqual(new Vector3(100, 0, 0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(0.1f, 0.2f, 0.4f));
            Utilities.AreExactlyEqual(new Vector3(90, 60, 80), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(1f));
            Utilities.AreExactlyEqual(new Vector3(0, 0, 200), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(1.1f, 2f, 3f));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));

            // tests in the case available size are infinite
            availableSize = new Vector3(float.PositiveInfinity);
            child.SetCanvasAbsolutePosition(new Vector3(-1, -2, -3));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasAbsolutePosition(new Vector3(1, 2, 3));
            Utilities.AreExactlyEqual(new Vector3(float.PositiveInfinity, 4, 3), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(-1f, -2f, -3f));
            Utilities.AreExactlyEqual(new Vector3(0), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativePosition(new Vector3(1f, 2f, 3f));
            Utilities.AreExactlyEqual(new Vector3(float.PositiveInfinity), ComputeAvailableSize(child, availableSize, false));
            child.SetCanvasRelativeSize(new Vector3(0, 0.5f, 1.5f));
            Utilities.AreExactlyEqual(new Vector3(0, float.PositiveInfinity, float.PositiveInfinity), ComputeAvailableSize(child, availableSize, false));
        }
コード例 #18
0
ファイル: CanvasGridTest.cs プロジェクト: Powerino73/paradox
 private void CreateAndInsertButton(UniformGrid grid, int c, int r)
 {
     var button = new Button();
     button.DependencyProperties.Set(GridBase.RowPropertyKey, r);
     button.DependencyProperties.Set(GridBase.ColumnPropertyKey, c);
     grid.Children.Add(button);
 }
コード例 #19
0
        private void CreateUI()
        {
            VirtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height, 1);

            var font = Asset.Load<SpriteFont>("Font");
            var canvas = new Canvas();
            var stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Left,
                MinimumWidth = 200
            };

            var buttonLightDirect = CreateButton("direct", GetButtonTextOnOff("Direct light: ", directionalLight.Enabled), font, Thickness.UniformRectangle(5));
            buttonLightDirect.Click += ToggleLight;

            var buttonLightPoint = CreateButton("point", GetButtonTextOnOff("Point lights: ", pointLights[0].Enabled), font, Thickness.UniformRectangle(5));
            buttonLightPoint.Click += ToggleLight;

            var buttonLightSpot = CreateButton("spot", GetButtonTextOnOff("Spot light: ", spotLight.Enabled), font, Thickness.UniformRectangle(5));
            buttonLightSpot.Click += ToggleLight;

            buttonShadow = CreateButton("direct", GetButtonTextOnOff("Shadow: ", directionalLight.ShadowMap), font, new Thickness(20, 5, 5, 5));
            buttonShadow.Opacity = directionalLight.Enabled ? 1.0f : 0.3f;
            buttonShadow.CanBeHitByUser = directionalLight.Enabled;
            buttonShadow.Click += ToggleShadowMap;

            buttonSpotShadow = CreateButton("spot", GetButtonTextOnOff("Shadow: ", spotLight.ShadowMap), font, new Thickness(20, 5, 5, 5));
            buttonSpotShadow.Opacity = spotLight.Enabled ? 1.0f : 0.3f;
            buttonSpotShadow.CanBeHitByUser = spotLight.Enabled;
            buttonSpotShadow.Click += ToggleShadowMap;

            buttonLightRotate = CreateButton("rotate", GetButtonTextOnOff("Lights rotation: ", rotateLights), font, new Thickness(20, 5, 5, 5));
            var enabled = pointLights.Count > 0 && pointLights[0].Enabled;
            buttonLightRotate.Opacity = enabled ? 1.0f : 0.3f;
            buttonLightRotate.CanBeHitByUser = enabled;
            buttonLightRotate.Click += ToogleRotation;

            stackPanel.Children.Add(buttonLightDirect);
            stackPanel.Children.Add(buttonShadow);
            stackPanel.Children.Add(buttonLightPoint);
            stackPanel.Children.Add(buttonLightRotate);
            stackPanel.Children.Add(buttonLightSpot);
            stackPanel.Children.Add(buttonSpotShadow);
            canvas.Children.Add(stackPanel);
            UI.RootElement = canvas;
        }
コード例 #20
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;
        }
コード例 #21
0
        public void TestHandlerRaiseOrder()
        {
            lastHandlerCalledId = 0;

            var button = new Button();
            button.Click += TestHandlerRaiseOrderOnClick1;
            button.Click += TestHandlerRaiseOrderOnClick2;
            button.Click += TestHandlerRaiseOrderOnClick3;
            button.Click += TestHandlerRaiseOrderOnClick4;

            button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));

            Assert.AreEqual(4, lastHandlerCalledId);
        }
コード例 #22
0
        public void TestUnregisterHandlerInsideHandler()
        {
            testUnregisterHandlerCallCount = 0;

            var button = new Button();
            button.Click += TestUnregisterHandlerOnClick;
            button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));

            Assert.AreEqual(1, testUnregisterHandlerCallCount);
        }
コード例 #23
0
ファイル: PanelTests.cs プロジェクト: Powerino73/paradox
        public void TestUpdateWorldMatrixInvalidation()
        {
            ResetState();

            var child = new Button();
            Children.Add(child);

            var worldMatrix = Matrix.Zero;
            var localMatrix = Matrix.Identity;
            
            Measure(Vector3.Zero);
            Arrange(Vector3.Zero, false);
            UpdateWorldMatrix(ref worldMatrix, false);
            
            worldMatrix.M11 = 2;
            UpdateWorldMatrix(ref worldMatrix, true);
            Assert.AreEqual(worldMatrix.M11, child.WorldMatrix.M11);
            
            worldMatrix.M11 = 3;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(2, child.WorldMatrix.M11);
            
            worldMatrix.M11 = 1;
            localMatrix.M11 = 4;
            LocalMatrix = localMatrix;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(localMatrix.M11, child.WorldMatrix.M11);
            
            localMatrix.M11 = 1;
            LocalMatrix = localMatrix;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(localMatrix.M11, child.WorldMatrix.M11);
            
            InvalidateArrange();
            Arrange(Vector3.Zero, false);
            
            worldMatrix.M11 = 5;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(worldMatrix.M11, child.WorldMatrix.M11);

            var secondButton = new Button();
            Children.Add(secondButton);
            Measure(Vector3.Zero);
            Arrange(Vector3.Zero, false);
            worldMatrix.M11 = 7;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(worldMatrix.M11, child.WorldMatrix.M11);

            Children.Remove(secondButton);
            Measure(Vector3.Zero);
            Arrange(Vector3.Zero, false);
            worldMatrix.M11 = 9;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(worldMatrix.M11, child.WorldMatrix.M11);

            worldMatrix.M11 = 1;
            UpdateWorldMatrix(ref worldMatrix, true);
            Assert.AreEqual(worldMatrix.M11, child.WorldMatrix.M11);

            var childArrangeMatrix = 10 * Matrix.Identity;
            child.DependencyProperties.Set(PanelArrangeMatrixPropertyKey, childArrangeMatrix);
            worldMatrix.M11 = 1;
            UpdateWorldMatrix(ref worldMatrix, false);
            Assert.AreEqual(childArrangeMatrix.M11, child.WorldMatrix.M11);
        }
コード例 #24
0
        public void TestReccursiveRaise()
        {
            clickCount = 0;

            var button = new Button();
            button.Click += TestReccursiveRaiseOnClick;
            button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));

            Assert.AreEqual(10, clickCount);
        }
コード例 #25
0
ファイル: SensorGameTest.cs プロジェクト: releed/paradox
        private void BuildUI()
        {
            var width = 400;
            var bufferRatio = GraphicsDevice.Presenter.BackBuffer.Width / (float)GraphicsDevice.Presenter.BackBuffer.Height;
            var ui = new UIComponent { VirtualResolution = new Vector3(width, width / bufferRatio, 500) };
            SceneSystem.SceneInstance.Scene.Entities.Add(new Entity { ui });

            currentText = new TextBlock { Font = font, TextColor = Color.White, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center };

            var buttonBack = new Button { Content = new TextBlock { Font = font, Text = "Previous" }, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left };
            var buttonNext = new Button { Content = new TextBlock { Font = font, Text = "Next" }, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Right };

            currentText.SetGridColumn(1);
            buttonNext.SetGridColumn(2);

            buttonBack.Click += (o, _) => ChangeScene(-1);
            buttonNext.Click += (o, _) => ChangeScene(+1);

            ui.RootElement = new UniformGrid { Columns = 3, Children = { buttonBack, currentText, buttonNext } };
        }
コード例 #26
0
        private Button CreateButton(int col, int row, float minimumHeight = 0, float minimumWidth = 0, bool randomMinHeight = false, bool randowMinWidth = false)
        {
            var button =  new Button
            {
                Name = "Button at col " + col + " - row " + row,
                MinimumHeight = minimumHeight,
                MinimumWidth = minimumWidth,
                Content = new TextBlock { Text = "Col " + col + " - Row " + row, Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center}
            };

            if (randomMinHeight)
                button.MinimumHeight = minimumHeight + 3 * (float)random.NextDouble() * minimumHeight;

            if (randowMinWidth)
                button.MinimumWidth = minimumWidth + 3 * (float)random.NextDouble() * minimumWidth;

            button.DependencyProperties.Set(GridBase.ColumnPropertyKey, col);
            button.DependencyProperties.Set(GridBase.RowPropertyKey, row);

            return button;
        }
コード例 #27
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var resolution = (Vector3)UIComponent.VirtualResolution;

            var canvas = new Canvas();
            var imgElt = new ImageElement { Name = "UV image", Source = new Sprite(Asset.Load<Texture>("uv")), Width = resolution.X / 5, Height = resolution.Y / 5, StretchType = StretchType.Fill };
            imgElt.DependencyProperties.Set(Canvas.PinOriginPropertyKey, 0.5f * Vector3.One);
            imgElt.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(resolution.X / 10, resolution.Y / 10, 0));
            imgElt.DependencyProperties.Set(Panel.ZIndexPropertyKey, -1);

            stackPanel = new StackPanel { Orientation = Orientation.Vertical };

            scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.Vertical };
            scrollViewer.DependencyProperties.Set(Canvas.AbsolutePositionPropertyKey, new Vector3(resolution.X / 4, resolution.Y / 10, 0));
            scrollViewer.Content = stackPanel;

            var button1 = new Button { Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5), LocalMatrix = Matrix.Scaling(2, 2, 2) };
            var textOnly = new TextBlock { Text = "Text only button", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextColor = new Color(1f, 0, 0, 0.5f) };
            button1.Content = textOnly;

            var button2 = new Button { Name = "Button2", Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5) };
            var imageContent = new ImageElement { Name = "Image Button2", Source = new Sprite(Asset.Load<Texture>("uv")), StretchType = StretchType.FillOnStretch, MaximumHeight = 50 };
            button2.Content = imageContent;

            var button3 = new Button { Margin = Thickness.UniformRectangle(5), Padding = Thickness.UniformRectangle(5) };
            var stackContent = new StackPanel { Orientation = Orientation.Horizontal };
            var stackImage = new ImageElement { Name = "Image stack panel", Source = new Sprite(Asset.Load<Texture>("uv")), MaximumHeight = 50 };
            var stackText = new TextBlock { Text = "button text", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), Margin = Thickness.UniformRectangle(5) };
            stackContent.Children.Add(stackImage);
            stackContent.Children.Add(stackText);
            button3.Content = stackContent;

            var button4 = new Button { Margin = Thickness.UniformRectangle(5), HorizontalAlignment = HorizontalAlignment.Right, Padding = Thickness.UniformRectangle(5) };
            var imageContent2 = new ImageElement { Name = "button 4 uv image", Source = new Sprite(Asset.Load<Texture>("uv")), StretchType = StretchType.FillOnStretch, MaximumHeight = 40, Opacity = 0.5f };
            button4.Content = imageContent2;

            var button5 = new Button { Margin = Thickness.UniformRectangle(5), HorizontalAlignment = HorizontalAlignment.Left, Padding = Thickness.UniformRectangle(5) };
            var textOnly2 = new TextBlock { Text = "Left aligned", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") };
            button5.Content = textOnly2;

            var button6 = new ImageButton
            {
                Height = 50,
                Margin = Thickness.UniformRectangle(5),
                HorizontalAlignment = HorizontalAlignment.Center,
                PressedImage = new Sprite(Asset.Load<Texture>("ImageButtonPressed")),
                NotPressedImage = new Sprite(Asset.Load<Texture>("ImageButtonNotPressed")),
            };

            toggle = new ToggleButton
            {
                Content = new TextBlock { Text = "Toggle button test", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15") },
                IsThreeState = true
            };

            scrollingText = new ScrollingText { Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), Text = "<<<--- Scrolling text in a button ", IsEnabled = IsUpdateAutomatic };
            var button7 = new Button { Margin = Thickness.UniformRectangle(5), Content = scrollingText };

            var uniformGrid = new UniformGrid { Rows = 2, Columns = 2 };
            var gridText = new TextBlock { Text = "Uniform grid", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center};
            gridText.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            var buttonLeft = new Button { Content = new TextBlock { Text = "unif-grid left", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center } };
            buttonLeft.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            var buttonRight = new Button { Content = new TextBlock { Text = "unif-grid right", Font = Asset.Load<SpriteFont>("MicrosoftSansSerif15"), TextAlignment = TextAlignment.Center } };
            buttonRight.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            buttonRight.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            uniformGrid.Children.Add(gridText);
            uniformGrid.Children.Add(buttonLeft);
            uniformGrid.Children.Add(buttonRight);

            stackPanel.Children.Add(button1);
            stackPanel.Children.Add(button2);
            stackPanel.Children.Add(button3);
            stackPanel.Children.Add(button4);
            stackPanel.Children.Add(button5);
            stackPanel.Children.Add(button6);
            stackPanel.Children.Add(toggle);
            stackPanel.Children.Add(button7);
            stackPanel.Children.Add(uniformGrid);

            canvas.Children.Add(imgElt);
            canvas.Children.Add(scrollViewer);

            UIComponent.RootElement = canvas;
        }
コード例 #28
0
        private Button CreateIncreaseStatusButton(string text, int rowIndex, int columnIndex, int moneyCost, int bonuscost, Func<int> getProperty, Action setProperty)
        {
            var button = new Button
            {
                NotPressedImage = mainScreneImages["small_display_element"],
                MouseOverImage = mainScreneImages["small_display_element"],
                PressedImage = mainScreneImages["small_display_element_pressed"],
                MinimumWidth = 80,
                Name = text,
                Content = new TextBlock
                {
                    Font = westernFont,
                    TextColor = Color.Black,
                    Text = text,
                    TextSize = 54,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                },
                Padding = new Thickness(22, 11, 22, 15)
            };

            button.SetGridColumn(columnIndex);
            button.SetGridRow(rowIndex);

            button.Click += delegate
            {
                if (!CanPurchase(moneyCost, bonuscost) || getProperty() >= MaximumStar)
                    return;

                setProperty();
                PurchaseWithBonus(bonuscost);
                PurchaseWithMoney(moneyCost);
            };

            return button;
        }
コード例 #29
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;
        }