protected  Entity GetUIEntity(SpriteFont font, bool fixedSize, Vector3 position)
        {
            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                Content = new TextBlock
                {
                    Font = font,
                    TextSize = 32,
                    Text = (fixedSize) ? "Fixed Size UI" : "Regular UI",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            //touchStartLabel.SetPanelZIndex(1);

            var grid = new Grid
            {
                BackgroundColor = (fixedSize) ? new Color(255, 0, 255) : new Color(255, 255, 0),
                MaximumWidth = 100,
                MaximumHeight = 100,
                MinimumWidth = 100,
                MinimumHeight = 100,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

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

            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            var uiEntity = new Entity();

            // Create a procedural model with a diffuse material
            var uiComponent = new UIComponent
            {
                Page = new UIPage
                {
                    RootElement = new UniformGrid { Children = { background, grid } }
                },
                //IsBillboard = true,
                IsFixedSize = fixedSize,
                IsFullScreen = false,
                Resolution = new Vector3(100, 100, 100), // Same size as the inner grid
                Size = new Vector3(0.1f), // 10% of the vertical resolution
            };
            uiEntity.Add(uiComponent);

            uiEntity.Transform.Position = position;

            return uiEntity;
        }
示例#2
0
        public void TestGridDefaultState()
        {
            var grid = new Grid();

            TestDefinitionsDefaultState(grid.ColumnDefinitions);
            TestDefinitionsDefaultState(grid.RowDefinitions);
            TestDefinitionsDefaultState(grid.LayerDefinitions);
        }
示例#3
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;
        }
示例#4
0
        public void TestStarOnlyMultiSpanLayering()
        {
            // 0      30*     30     20*    50    10*    60
            // +--------------+--------------+-----------+
            // |<-c00->       |<--c01-->     |<--c02-->  |
            // +--------------+--------------+-----------+
            // |              |<----------c11----------->|
            // +--------------+--------------+-----------+
            // |<---------------c20---------------->     |
            // +--------------+--------------+-----------+

            var grid = new Grid();
            var ratios = new List<float> { 30, 20, 10 };

            grid.ColumnDefinitions.Clear();
            foreach (var ratio in ratios)
                grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, ratio));

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(20, 0, 0), ExpectedArrangeValue = new Vector3(60, 0, 0) };
            var c01 = new ArrangeValidator { Name = "c01", ReturnedMeasuredValue = new Vector3(15, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0) };
            var c02 = new ArrangeValidator { Name = "c02", ReturnedMeasuredValue = new Vector3( 8, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0) };
            var c11 = new ArrangeValidator { Name = "c11", ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(60, 0, 0) };
            var c20 = new ArrangeValidator { Name = "c20", ReturnedMeasuredValue = new Vector3(55, 0, 0), ExpectedArrangeValue = new Vector3(120, 0, 0) };
            
            c11.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            c20.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);

            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c02.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            c11.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c11.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c20.DependencyProperties.Set(GridBase.RowPropertyKey, 2);

            grid.Children.Add(c00);
            grid.Children.Add(c01);
            grid.Children.Add(c02);
            grid.Children.Add(c11);
            grid.Children.Add(c20);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(60, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(2 * grid.DesiredSizeWithMargins, false);

            for (int i = 0; i < ratios.Count; i++)
                Assert.AreEqual(2 * ratios[i], grid.ColumnDefinitions[i].ActualSize);
        }
示例#5
0
        public void TestFixedOnlyBasicLayering()
        {
            var grid = new Grid();

            var columnSizes = new List<float>();
            var rowSizes = new List<float>();
            var layerSizes = new List<float>();

            for (int i = 0; i < 4; i++)
                columnSizes.Add((float)rand.NextDouble());
            for (int i = 0; i < 5; i++)
                rowSizes.Add((float)rand.NextDouble());
            for (int i = 0; i < 6; i++)
                layerSizes.Add((float)rand.NextDouble());

            CreateFixedSizeDefinition(grid.ColumnDefinitions, columnSizes);
            CreateFixedSizeDefinition(grid.RowDefinitions, rowSizes);
            CreateFixedSizeDefinition(grid.LayerDefinitions, layerSizes);

            var size = rand.NextVector3();
            grid.Measure(size);
            grid.Arrange(size, false);

            CheckFixedSizeStripSize(grid.ColumnDefinitions, columnSizes);
        }
示例#6
0
        /// <summary>
        /// Creates UI showing parameters of Fault formation algorithm
        /// </summary>
        private void CreateUI()
        {
            var virtualResolution = new Vector3(GraphicsDevice.Presenter.BackBuffer.Width, GraphicsDevice.Presenter.BackBuffer.Height, 1);

            loadingModal = new ModalElement { Visibility = Visibility.Collapsed };

            loadingTextBlock = new TextBlock { Font = Font, Text = "Loading a model...", Visibility = Visibility.Collapsed, TextColor = Color.White, TextSize = 22 };

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

            // Parameters Grid
            var parametersGrid = new Grid();
            parametersGrid.LayerDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            parametersGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            parametersGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 30));
            parametersGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 30));

            // Terrain Size
            var terrainSizeText = new TextBlock
            {
                Font = Font,
                Text = "" + (int)Math.Pow(2, terrainSizePowerFactor),
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                MinimumWidth = 60
            };
            terrainSizeText.SetGridRow(0);
            terrainSizeText.SetGridColumn(1);

            var terrainSizeIncButton = new Button { Content = new TextBlock { Text = "+", Font = Font, TextAlignment = TextAlignment.Center } };
            terrainSizeIncButton.SetGridRow(0);
            terrainSizeIncButton.SetGridColumn(3);

            var terrainSizeDecButton = new Button { Content = new TextBlock { Text = "-", Font = Font, TextAlignment = TextAlignment.Center } };
            terrainSizeDecButton.SetGridRow(0);
            terrainSizeDecButton.SetGridColumn(2);

            terrainSizeIncButton.Click += (s, e) =>
            {
                TerrainSizePowerFactor++;
                terrainSizeText.Text = "" + (int)Math.Pow(2, TerrainSizePowerFactor);
            };

            terrainSizeDecButton.Click += (s, e) =>
            {
                TerrainSizePowerFactor--;
                terrainSizeText.Text = "" + (int)Math.Pow(2, TerrainSizePowerFactor);
            };

            var terrainSizeDescription = new TextBlock
            {
                Font = Font,
                Text = "Terrain Size:",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            terrainSizeDescription.SetGridRow(0);
            terrainSizeDescription.SetGridColumn(0);

            parametersGrid.Children.Add(terrainSizeDescription);
            parametersGrid.Children.Add(terrainSizeText);
            parametersGrid.Children.Add(terrainSizeDecButton);
            parametersGrid.Children.Add(terrainSizeIncButton);

            // Iteration
            var iterationText = new TextBlock
            {
                Font = Font,
                Text = "" + (int)Math.Pow(2, IterationPowerFactor),
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            iterationText.SetGridRow(1);
            iterationText.SetGridColumn(1);

            var iterationIncButton = new Button { Content = new TextBlock { Text = "+", Font = Font, TextAlignment = TextAlignment.Center } };
            iterationIncButton.SetGridRow(1);
            iterationIncButton.SetGridColumn(3);

            var iterationDecButton = new Button { Content = new TextBlock { Text = "-", Font = Font, TextAlignment = TextAlignment.Center } };
            iterationDecButton.SetGridRow(1);
            iterationDecButton.SetGridColumn(2);

            iterationIncButton.Click += (s, e) =>
            {
                IterationPowerFactor++;
                iterationText.Text = "" + (int)Math.Pow(2, IterationPowerFactor);
            };

            iterationDecButton.Click += (s, e) =>
            {
                IterationPowerFactor--;
                iterationText.Text = "" + (int)Math.Pow(2, IterationPowerFactor);
            };

            var iterationDescription = new TextBlock
            {
                Font = Font,
                Text = "Iteration:",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            iterationDescription.SetGridRow(1);
            iterationDescription.SetGridColumn(0);

            parametersGrid.Children.Add(iterationDescription);
            parametersGrid.Children.Add(iterationText);
            parametersGrid.Children.Add(iterationDecButton);
            parametersGrid.Children.Add(iterationIncButton);

            // Filter Intensity
            var filterIntensityText = new TextBlock
            {
                Font = Font,
                Text = "" + FilterHeightBandStrength,
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            filterIntensityText.SetGridRow(2);
            filterIntensityText.SetGridColumn(1);

            var filterIncButton = new Button { Content = new TextBlock { Text = "+", Font = Font, TextAlignment = TextAlignment.Center } };
            filterIncButton.SetGridRow(2);
            filterIncButton.SetGridColumn(3);

            var filterDecButton = new Button { Content = new TextBlock { Text = "-", Font = Font, TextAlignment = TextAlignment.Center } };
            filterDecButton.SetGridRow(2);
            filterDecButton.SetGridColumn(2);

            filterIncButton.Click += (s, e) =>
            {
                FilterHeightBandStrength += 0.1f;
                filterIntensityText.Text = "" + FilterHeightBandStrength;
            };

            filterDecButton.Click += (s, e) =>
            {
                FilterHeightBandStrength -= 0.1f;
                filterIntensityText.Text = "" + FilterHeightBandStrength;
            };

            var filterIntensityDescription = new TextBlock
            {
                Font = Font,
                Text = "Filter Intensity:",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            filterIntensityDescription.SetGridRow(2);
            filterIntensityDescription.SetGridColumn(0);

            parametersGrid.Children.Add(filterIntensityDescription);
            parametersGrid.Children.Add(filterIntensityText);
            parametersGrid.Children.Add(filterDecButton);
            parametersGrid.Children.Add(filterIncButton);

            // Height Scale
            var heightScaleText = new TextBlock
            {
                Font = Font,
                Text = "" + TerrainHeightScale,
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            heightScaleText.SetGridRow(3);
            heightScaleText.SetGridColumn(1);

            var heightScaleIncButton = new Button { Content = new TextBlock { Text = "+", Font = Font, TextAlignment = TextAlignment.Center } };
            heightScaleIncButton.SetGridRow(3);
            heightScaleIncButton.SetGridColumn(3);

            var heightScaleDecButton = new Button { Content = new TextBlock { Text = "-", Font = Font, TextAlignment = TextAlignment.Center } };
            heightScaleDecButton.SetGridRow(3);
            heightScaleDecButton.SetGridColumn(2);

            heightScaleIncButton.Click += (s, e) =>
            {
                TerrainHeightScale++;
                heightScaleText.Text = "" + TerrainHeightScale;
            };

            heightScaleDecButton.Click += (s, e) =>
            {
                TerrainHeightScale--;
                heightScaleText.Text = "" + TerrainHeightScale;
            };

            var heightScaleDescription = new TextBlock
            {
                Font = Font,
                Text = "Height Scale:",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            heightScaleDescription.SetGridRow(3);
            heightScaleDescription.SetGridColumn(0);

            parametersGrid.Children.Add(heightScaleDescription);
            parametersGrid.Children.Add(heightScaleText);
            parametersGrid.Children.Add(heightScaleDecButton);
            parametersGrid.Children.Add(heightScaleIncButton);

            // Zoom
            var zoomFactorIncButton = new Button { Content = new TextBlock { Text = "+", Font = Font, TextAlignment = TextAlignment.Center } };
            zoomFactorIncButton.SetGridRow(4);
            zoomFactorIncButton.SetGridColumn(3);

            var zoomFactorDecButton = new Button { Content = new TextBlock { Text = "-", Font = Font, TextAlignment = TextAlignment.Center } };
            zoomFactorDecButton.SetGridRow(4);
            zoomFactorDecButton.SetGridColumn(2);

            zoomFactorIncButton.Click += (s, e) =>
            {
                zoomFactor -= 0.1f;
                UpdateCamera();
            };

            zoomFactorDecButton.Click += (s, e) =>
            {
                zoomFactor += 0.1f;
                UpdateCamera();
            };

            var zoomDescription = new TextBlock
            {
                Font = Font,
                Text = "Zoom",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            zoomDescription.SetGridRow(4);
            zoomDescription.SetGridColumn(0);

            parametersGrid.Children.Add(zoomDescription);
            parametersGrid.Children.Add(zoomFactorDecButton);
            parametersGrid.Children.Add(zoomFactorIncButton);

            // Light toggle button
            var lightToggleButton = new Button { Content = new TextBlock { Text = "Directional Light Off", Font = Font }, HorizontalAlignment = HorizontalAlignment.Left };

            lightToggleButton.Click += (s, e) =>
            {
                var ligh0 = DirectionalLight0.Get<LightComponent>();
                var ligh1 = DirectionalLight1.Get<LightComponent>();

                ligh0.Enabled = !ligh0.Enabled;
                ligh1.Enabled = !ligh1.Enabled;
                ((TextBlock)lightToggleButton.Content).Text = ligh0.Enabled ? "Directional Light Off" : "Directional Light On";
            };

            // Re-create terrain
            var reCreateTerrainButton = new Button { Content = new TextBlock { Text = "Recreate terrain", Font = Font }, HorizontalAlignment = HorizontalAlignment.Left };

            reCreateTerrainButton.Click += (s, e) => GenerateTerrain();

            var descriptionCanvas = new StackPanel
            {
                Children =
                {
                    new TextBlock { Font = Font, Text = "Fault formation parameters", TextSize = 19},
                    parametersGrid,
                    lightToggleButton,
                    reCreateTerrainButton
                }
            };

            var activeButton = new Button
            {
                Content = new TextBlock { Text = "Description Off", Font = Font },
                Padding = new Thickness(10, 10, 10, 10),
                Margin = new Thickness(0, 0, 0, 20),
                HorizontalAlignment = HorizontalAlignment.Left
            };

            var isDescriptionOn = true;

            activeButton.Click += (s, e) =>
            {
                isDescriptionOn = !isDescriptionOn;
                ((TextBlock)activeButton.Content).Text = isDescriptionOn ? "Description Off" : "Description On";
                descriptionCanvas.Visibility = isDescriptionOn ? Visibility.Visible : Visibility.Collapsed;
            };

            var buttonDescription = new StackPanel { Orientation = Orientation.Vertical, Children = { activeButton, descriptionCanvas } };

            var uiComponent = UIEntity.Get<UIComponent>();
            uiComponent.RootElement = new Canvas { Children = { buttonDescription, loadingModal, loadingTextBlock } };
            uiComponent.Resolution = virtualResolution;
        }
示例#7
0
        public void TestAutoOnlyMinMaxLayering()
        {
            //  min = 20                                                      min = 20
            //                                 max = 20             max = 20  max = 20
            // 0         20        40         60        80        100        120      140
            // +---------+---------+----------+---------+---------+----------+--------+
            // |<-c00->  |<--c01-->|                    |<-c04->  |<----c05--|-->     |
            // +---------+---------+----------+---------+---------+----------+--------+
            // |<-------c10------->|                    |         |          |<-c16-> |
            // +---------+---------+----------+---------+---------+----------+--------+
            // |         |<----------c21-------->       |         |          |<---c26-|-->
            // +---------+---------+----------+---------+---------+----------+--------|
            // |         |         |<-------c32-------->|         |          |        |
            // +---------+---------+----------+---------+---------+----------+--------+
            // |         |         |          |         |<------------c44------------>|
            // +---------+---------+----------+---------+---------+----------+--------+

            var grid = new Grid();

            // set the grid definition
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MinimumSize = 20 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 20 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 20 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 20, MinimumSize = 20 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            // create the children
            var c00 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c00" };
            var c01 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(20, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c01" };
            var c04 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c03" };
            var c05 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c04" };
            var c10 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(40, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0), Name = "c10" };
            var c16 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c15" };
            var c21 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(50, 0, 0), ExpectedArrangeValue = new Vector3(60, 0, 0), Name = "c21" };
            var c26 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0), Name = "c25" };
            var c32 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(40, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0), Name = "c32" };
            var c44 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(60, 0, 0), ExpectedArrangeValue = new Vector3(60, 0, 0), Name = "c44" };

            // set the spans 
            c10.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            c21.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            c32.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            c44.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);

            // set the positions
            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c04.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);
            c05.DependencyProperties.Set(GridBase.ColumnPropertyKey, 5);
            c10.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c16.DependencyProperties.Set(GridBase.ColumnPropertyKey, 6);
            c16.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c21.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c21.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            c26.DependencyProperties.Set(GridBase.ColumnPropertyKey, 6);
            c26.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            c32.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            c32.DependencyProperties.Set(GridBase.RowPropertyKey, 3);
            c44.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);
            c44.DependencyProperties.Set(GridBase.RowPropertyKey, 4);

            // add the children
            grid.Children.Add(c00);
            grid.Children.Add(c01);
            grid.Children.Add(c04);
            grid.Children.Add(c05);
            grid.Children.Add(c10);
            grid.Children.Add(c16);
            grid.Children.Add(c21);
            grid.Children.Add(c26);
            grid.Children.Add(c32);
            grid.Children.Add(c44);

            grid.Measure(30 * rand.NextVector3());
            Assert.AreEqual(new Vector3(140, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(100 * rand.NextVector3(), false);

            Assert.AreEqual(20, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[3].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[4].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[5].ActualSize);
            Assert.AreEqual(20, grid.ColumnDefinitions[6].ActualSize);
        }
示例#8
0
        public void TestAutoOnlyBasicLayering()
        {
            // 0       10          40            80
            // +-------+-----------+-------------+
            // |<-c00->|<--c01-->  |             |
            // +-------+-----------+-------------+
            // |       |<---c11--->|<----c12---->|
            // +-------+-----------+-------------+

            var grid = new Grid();

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            var c00 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(10, 0, 0) };
            var c01 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(20, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c11 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c12 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(40, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0) };

            c00.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            c00.DependencyProperties.Set(GridBase.RowPropertyKey, 0);

            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c01.DependencyProperties.Set(GridBase.RowPropertyKey, 0);

            c11.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c11.DependencyProperties.Set(GridBase.RowPropertyKey, 1);

            c12.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            c12.DependencyProperties.Set(GridBase.RowPropertyKey, 1);

            grid.Children.Add(c00);
            grid.Children.Add(c01);
            grid.Children.Add(c11);
            grid.Children.Add(c12);

            grid.Measure(30 * rand.NextVector3());
            Assert.AreEqual(new Vector3(80,0,0), grid.DesiredSizeWithMargins);

            grid.Arrange(30 * rand.NextVector3(), false);

            Assert.AreEqual(10, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(40, grid.ColumnDefinitions[2].ActualSize);
        }
示例#9
0
        protected override void LoadScene()
        {
            // Allow user to resize the window with the mouse.
            Game.Window.AllowUserResizing = true;

            // Create and initialize "Xenko Samples" Text
            var xenkoSampleTextBlock = new ContentDecorator
            {
                BackgroundImage = SpriteFromSheet.Create(SplashScreenImages, "xenko_sample_text_bg"),
                Content = new TextBlock
                {
                    Font = WesternFont,
                    TextSize = 60,
                    Text = "Xenko UI Particles",
                    TextColor = Color.White,
                },
                Padding = new Thickness(35, 15, 35, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            xenkoSampleTextBlock.SetPanelZIndex(1);
            

            //*********************************
            // Confetti button
            var buttonImage = SpriteFromSheet.Create(SplashScreenImages, "button_long");

            var xenkoButtonConfetti = new Button
            {
                NotPressedImage = buttonImage,
                PressedImage = buttonImage,
                MouseOverImage = buttonImage,

                Content = new TextBlock
                {
                    Font = WesternFont,
                    TextColor = Color.White,
                    Text = "Click here to start the game over",
                    TextSize = 24
                },

                HorizontalAlignment = HorizontalAlignment.Right,
                Padding = new Thickness(90, 22, 25, 35),
//                BackgroundColor = Color.DarkOrchid
            };

            xenkoButtonConfetti.SetPanelZIndex(1);
            xenkoButtonConfetti.SetGridRow(1);

            xenkoButtonConfetti.Click += delegate
            {
                fusePercentage = 1f;
                desiredState = GameState.NewGame;
                var effectOffset = new Vector3(45 - xenkoButtonConfetti.RenderSize.X / 2, -5, 0);
                SpawnParticles(xenkoButtonConfetti.WorldMatrix.TranslationVector + effectOffset, Prefab, 2f);
            };
            //*********************************

            //*********************************
            // Stars button
            var buttonStars = SpriteFromSheet.Create(SplashScreenImages, "button_short");

            var xenkoButtonStars = new Button
            {
                NotPressedImage = buttonStars,
                PressedImage = buttonStars,
                MouseOverImage = buttonStars,

                Content = new TextBlock
                {
                    Font = WesternFont,
                    TextColor = Color.White,
                    Text = "Congratulations",
                    TextSize = 24
                },

                HorizontalAlignment = HorizontalAlignment.Right,
                Padding = new Thickness(90, 22, 25, 35),
//                BackgroundColor = Color.DarkOrchid

            };

            xenkoButtonStars.SetPanelZIndex(1);
            xenkoButtonStars.SetGridRow(4);

            xenkoButtonStars.Click += delegate
            {
                desiredState = GameState.EndGame;
                var effectOffset = new Vector3(45 - xenkoButtonStars.RenderSize.X / 2, -5, 0);
                SpawnParticles(xenkoButtonStars.WorldMatrix.TranslationVector + effectOffset, Prefab, 2f);
            };
            //*********************************

            var bottomBar = CreateBottomBar();
            bottomBar.SetPanelZIndex(1);
            bottomBar.SetGridRow(6);

            var grid = new Grid
            {
                MaximumWidth = virtualWidth,
                MaximumHeight = virtualHeight,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto)); // 0
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto)); // 1
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto)); // 2
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto)); // 3
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto)); // 4
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 100)); // 5
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 50)); // 5
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(xenkoSampleTextBlock);
            grid.Children.Add(xenkoButtonConfetti);
            grid.Children.Add(xenkoButtonStars);
            grid.Children.Add(bottomBar);

            // Add the background
            var background = new ImageElement { Source = SpriteFromSheet.Create(SplashScreenImages, "background_uiimage"), StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            Entity.Get<UIComponent>().Page = new UIPage { RootElement = new UniformGrid { Children = { background, grid } } };
        }
示例#10
0
        public void TestStarOnlyMultiMinLayering1()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10) { MinimumSize = 20 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 20) { MinimumSize = 30 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 30) { MinimumSize = 40 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 40) { MinimumSize = 50 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            //    min = 20    min = 30  min = 40  min = 50
            // 0    10*    20   20*   50        90       140
            // +-----------+----------+---------+--------+
            // |<---------------c00--------------->      |
            // +---- ------+----------+---------+--------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(25, 0, 0), ExpectedArrangeValue = new Vector3(140, 0, 0) };
            c00.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 4);
            grid.Children.Add(c00);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(140, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(50 * Vector3.One, false);
            Assert.AreEqual(20, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(40, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(50, grid.ColumnDefinitions[3].ActualSize);
        }
示例#11
0
        public void TestMeasureProvidedSizeAuto0()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));

            var child0 = new MeasureValidator { Name = "0", ReturnedMeasuredValue = providedSize, ExpectedMeasureValue = providedSize };
            var child1 = new MeasureValidator { Name = "1", ReturnedMeasuredValue = providedSize, ExpectedMeasureValue = new Vector3(10, providedSize.Y, providedSize.Z) };
            var child2 = new MeasureValidator { Name = "2", ReturnedMeasuredValue = providedSize, ExpectedMeasureValue = providedSize };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);

            grid.Measure(providedSize);
        }
示例#12
0
        public void TestMeasureProvidedSizeStar1()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10) { MinimumSize = 50 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 40) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 50));

            var child0 = new MeasureReflector { Name = "0" };
            var child1 = new MeasureReflector { Name = "1" };
            var child2 = new MeasureReflector { Name = "2" };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(50, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(40, child2.DesiredSize.X);
        }
示例#13
0
        public void TestMeasureProvidedSizeStar0()
        {
            var grid = new Grid();

            var providedSize = 1000 * rand.NextVector3();

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 40));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 50));

            var child0 = new MeasureReflector { Name = "0" };
            var child1 = new MeasureReflector { Name = "1" };
            var child2 = new MeasureReflector { Name = "2" };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(0.1f * providedSize.X, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(0.4f * providedSize.X, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(0.5f * providedSize.X, child2.DesiredSize.X);
        }
示例#14
0
        public void TestMeasureProvidedSizeFixedMulti()
        {
            var grid = new Grid();

            var providedSize = 1000 * rand.NextVector3();

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed) { MinimumSize = 5 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed) { MaximumSize = 0.5f });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 2));

            var child2 = new MeasureValidator { Name = "2", ExpectedMeasureValue = new Vector3(3f, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = providedSize };
            var child4 = new MeasureValidator { Name = "4", ExpectedMeasureValue = new Vector3(8.5f, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = providedSize };

            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);

            child2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child4.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 4);

            grid.Children.Add(child2);
            grid.Children.Add(child4);

            grid.Measure(providedSize);
        }
示例#15
0
        public void TestDefaultGridLayering()
        {
            var grid = new Grid();

            var child0 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 200, 0), ExpectedArrangeValue = new Vector3(200, 200, 0), ReturnedMeasuredValue = new Vector3(100, 400, 0), DepthAlignment = DepthAlignment.Stretch };
            //var child1 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 200, 0), ExpectedArrangeValue = new Vector3(200, 200, 0), ReturnedMeasuredValue = new Vector3(100, 400, 0), Width = 100, Height = 400, DepthAlignment = DepthAlignment.Stretch };

            grid.Children.Add(child0);
            //grid.Children.Add(child1);

            grid.Measure(new Vector3(200, 200, 0));
            grid.Arrange(new Vector3(200, 200, 0), false);

            // Try again with strips (it should behave the same)
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.RowDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Measure(new Vector3(200, 200, 0));
            grid.Arrange(new Vector3(200, 200, 0), false);
        }
示例#16
0
        public void TestMeasureProvidedSizeMix()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 6));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 15));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));

            var child0 = new MeasureReflector { Name = "0", };
            var child1 = new MeasureReflector { Name = "1", };
            var child2 = new MeasureReflector { Name = "2", };
            var child3 = new ArrangeValidator { Name = "3", ReturnedMeasuredValue = new Vector3(5, providedSize.Y, providedSize.Z) };
            var child4 = new MeasureReflector { Name = "4", };
            var child5 = new ArrangeValidator { Name = "5", ReturnedMeasuredValue = new Vector3(20, providedSize.Y, providedSize.Z)};

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child3.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);
            child4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);
            child5.DependencyProperties.Set(GridBase.ColumnPropertyKey, 5);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);
            grid.Children.Add(child3);
            grid.Children.Add(child4);
            grid.Children.Add(child5);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(20, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(30, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child2.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(5, child3.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(15, child4.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(20, child5.DesiredSize.X);
        }
示例#17
0
        public void TestStarOnlyMax1EltLayering()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10) { MaximumSize = 20 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            //    max = 20
            // 0    10*   20   
            // +----------+
            // |<----c00--|-->
            // +----------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0) };
            grid.Children.Add(c00);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(20, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(40 * Vector3.One, false);
            Assert.AreEqual(20, grid.ColumnDefinitions[0].ActualSize);
        }
示例#18
0
        public void TestStarOnlyMultiMaxLayering2()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MaximumSize = 20 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MaximumSize = 50 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MaximumSize = 40 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MaximumSize = 30 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            // |<---max 20-->|<---max 50----|<->---max 40-|<->-max 30-->|
            // 0      1*     20     1*      75     1*     115    1*     140
            // +-------------+--------------+-------------+-------------+
            // |<-------------------------c00-------------------------->|
            // +-------------+--------------+-------------+-------------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(110, 0, 0), ExpectedArrangeValue = new Vector3(110, 0, 0) };
            c00.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 4);
            grid.Children.Add(c00);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(110, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(110 * Vector3.One, false);
            Assert.AreEqual(20, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[3].ActualSize);
        }
示例#19
0
        public void TestStarOnlyMax2EltsLayering3()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10) { MaximumSize = 40 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 20) { MaximumSize = 50 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            //    max = 40   max = 50
            // 0    10*    20   20*   50
            // +-----------+----------+
            // |<---c00--->|<--c01--> |           
            // +-----------+----------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(15, 0, 0), ExpectedArrangeValue = new Vector3(20, 0, 0) };
            var c01 = new ArrangeValidator { Name = "c01", ReturnedMeasuredValue = new Vector3(25, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0) };

            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);

            grid.Children.Add(c00);
            grid.Children.Add(c01);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(45, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(60 * Vector3.One, false);
            Assert.AreEqual(20, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(40, grid.ColumnDefinitions[1].ActualSize);
        }
示例#20
0
        public void TestBasicMultiTypeLayering()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 30));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            // 0     30     30     auto     60     1*     100
            // +-------------+--------------+-------------+
            // |<---c00--->  |<----c01----->|             |
            // +-------------+--------------+-------------+
            // |             |<-------------c11---------->|
            // +-------------+--------------+-------------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(20, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c01 = new ArrangeValidator { Name = "c01", ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c11 = new ArrangeValidator { Name = "c11", ReturnedMeasuredValue = new Vector3(70, 0, 0), ExpectedArrangeValue = new Vector3(80, 0, 0) };

            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c11.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c11.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c11.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);

            grid.Children.Add(c00);
            grid.Children.Add(c01);
            grid.Children.Add(c11);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(100, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(110 * Vector3.One, false);
            Assert.AreEqual(30, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(50, grid.ColumnDefinitions[2].ActualSize);
        }
示例#21
0
        public void TestMeasureProvidedSizeAuto1()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 15 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MinimumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 20));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));

            var child0 = new MeasureReflector { Name = "0", };
            var child1 = new MeasureReflector { Name = "1", };
            var child2 = new MeasureReflector { Name = "2", };
            var child3 = new MeasureReflector { Name = "3", };
            var child4 = new MeasureReflector { Name = "4", };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child3.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);
            child4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);
            grid.Children.Add(child3);
            grid.Children.Add(child4);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(15, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(65, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(20, child2.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child3.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(55, child4.DesiredSize.X);
        }
示例#22
0
        private UIElement CreateBottomBar()
        {
            // Create Life bar
            lifeBarGaugeImage = ButtonsImages["rope_small"];
            gaugeBarRegion = lifeBarGaugeImage.Region;

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

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


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

            mainLayer.Children.Add(lifeBarGrid);

            return mainLayer;
        }
示例#23
0
        public void TestStarOnlyMinMaxLayering2()
        {
            var grid = new Grid();
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 10, MaximumSize = 70 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 20, MaximumSize = 35 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 30, MaximumSize = 55 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 40, MaximumSize = 45 });
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            // |<--min 10->  |<---min 20->  |<---min 30-> |<--min 40->|
            // |<---max 70---|<-->-max 35-->|<---max 55-->|<---max 45-->|
            // 0      1*     20     1*      55     1*     95     1*     145
            // +-------------+--------------+-------------+-------------+
            // |<-------------------------c00-------------------------->|
            // +-------------+--------------+-------------+-------------+

            var c00 = new ArrangeValidator { Name = "c00", ReturnedMeasuredValue = new Vector3(195, 0, 0), ExpectedArrangeValue = new Vector3(195, 0, 0) };
            c00.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 4);
            grid.Children.Add(c00);

            grid.Measure(50 * rand.NextVector3());
            Assert.AreEqual(new Vector3(195, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(195 * Vector3.One, false);
            Assert.AreEqual(60, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(35, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(55, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(45, grid.ColumnDefinitions[3].ActualSize);
        }
示例#24
0
        public void TestMeasureProvidedSizeAutoMix()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 20));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 30) { MaximumSize = 25 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MinimumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 15 });

            var child2 = new MeasureValidator { Name = "2", ExpectedMeasureValue = new Vector3(030, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = new Vector3(030, 100, 100) };
            var child3 = new MeasureValidator { Name = "3", ExpectedMeasureValue = new Vector3(050, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = new Vector3(050, 100, 100) };
            var child4 = new MeasureValidator { Name = "4", ExpectedMeasureValue = new Vector3(075, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = new Vector3(075, 100, 100) };
            var child5 = new MeasureValidator { Name = "5", ExpectedMeasureValue = new Vector3(085, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = new Vector3(085, 100, 100) };
            var child6 = new MeasureValidator { Name = "6", ExpectedMeasureValue = new Vector3(100, providedSize.Y, providedSize.Z), ReturnedMeasuredValue = new Vector3(100, 100, 100) };

            child2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child3.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            child4.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 4);
            child5.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 5);
            child6.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 6);

            grid.Children.Add(child2);
            grid.Children.Add(child3);
            grid.Children.Add(child4);
            grid.Children.Add(child5);
            grid.Children.Add(child6);

            grid.Measure(providedSize);
        }
示例#25
0
        public void TestDefinitionNoCompletion()
        {
            var grid = new Grid();

            var c1 = new Canvas();
            c1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            c1.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            c1.DependencyProperties.Set(GridBase.RowPropertyKey, 5);
            c1.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);

            var c2 = new Canvas();
            c2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);
            c2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            c2.DependencyProperties.Set(GridBase.LayerPropertyKey, 1);
            c2.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 4);

            grid.Children.Add(c1);
            grid.Children.Add(c2);

            grid.Measure(Vector3.Zero);
            grid.Arrange(Vector3.Zero, false);

            Assert.AreEqual(grid.ColumnDefinitions.Count, 0);
            Assert.AreEqual(grid.RowDefinitions.Count, 0);
            Assert.AreEqual(grid.LayerDefinitions.Count, 0);
        }
示例#26
0
        public void TestBasicInvalidations()
        {
            var grid = new Grid();

            var rowDefinition = new StripDefinition();
            grid.RowDefinitions.Add(rowDefinition);

            // ReSharper disable ImplicitlyCapturedClosure

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => grid.RowDefinitions.Add(new StripDefinition()));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => grid.ColumnDefinitions.Add(new StripDefinition()));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => grid.LayerDefinitions.Add(new StripDefinition()));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => rowDefinition.MinimumSize = 37);
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => rowDefinition.MaximumSize = 38);
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => rowDefinition.Type = StripType.Fixed);
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => rowDefinition.SizeValue = 39);
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => grid.RowDefinitions.Remove(rowDefinition));

            // ReSharper restore ImplicitlyCapturedClosure
        }
示例#27
0
        public void TestAutoOnlyMultiSpanLayering()
        {
            // 0       10          40                70
            // +-------+-----------+-----------------+
            // |<-c00->|<--c01-->  |                 |
            // +-------+-----------+-----------------+
            // |<-------c10------->|<---c12--->      |
            // +-------+-----------+-----------------+
            // |       |<-----------c21---------->   |
            // +-------+-----------+-----------------+
            // |<-----------------c30--------------->|
            // +-------+-----------+-----------------+

            var grid = new Grid();

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));

            var c00 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(10, 0, 0) };
            var c01 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(20, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c10 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(40, 0, 0), ExpectedArrangeValue = new Vector3(40, 0, 0) };
            var c12 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(10, 0, 0), ExpectedArrangeValue = new Vector3(30, 0, 0) };
            var c21 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(30, 0, 0), ExpectedArrangeValue = new Vector3(60, 0, 0) };
            var c30 = new ArrangeValidator { ReturnedMeasuredValue = new Vector3(70, 0, 0), ExpectedArrangeValue = new Vector3(70, 0, 0) };

            // set the spans 
            c10.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            c21.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            c30.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);

            // set the positions
            c01.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c10.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c12.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            c12.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            c21.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            c21.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            c30.DependencyProperties.Set(GridBase.RowPropertyKey, 3);

            // add the children
            grid.Children.Add(c00);
            grid.Children.Add(c01);
            grid.Children.Add(c10);
            grid.Children.Add(c12);
            grid.Children.Add(c21);
            grid.Children.Add(c30);

            grid.Measure(30 * rand.NextVector3());
            Assert.AreEqual(new Vector3(70, 0, 0), grid.DesiredSizeWithMargins);

            grid.Arrange(50 * rand.NextVector3(), false);

            Assert.AreEqual(10, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(30, grid.ColumnDefinitions[2].ActualSize);
        }
示例#28
0
        public void TestSurroudingAnchor()
        {
            var childSize1 = new Vector3(50, 150, 250);
            var childSize2 = new Vector3(100, 200, 300);

            var grid = new Grid { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 100));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 200));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Star));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Star));

            var child1 = new UniformGrid { Size = childSize1 };
            var child2 = new UniformGrid { Size = childSize2 };
            child2.DependencyProperties.Set(GridBase.RowPropertyKey, 1);

            grid.Children.Add(child1);
            grid.Children.Add(child2);

            grid.Measure(1000 * Vector3.One);
            grid.Arrange(1000 * Vector3.One, false);
            
            Assert.AreEqual(new Vector2(   0, 100), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, -1));
            Assert.AreEqual(new Vector2(   0, 100), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 0));
            Assert.AreEqual(new Vector2( -50,  50), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 50));
            Assert.AreEqual(new Vector2( -80,  20), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 80));
            Assert.AreEqual(new Vector2(   0, 200), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 100));
            Assert.AreEqual(new Vector2( -10, 190), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 110));
            Assert.AreEqual(new Vector2(-200,   0), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 300));
            Assert.AreEqual(new Vector2(-200,   0), grid.GetSurroudingAnchorDistances(Orientation.Horizontal, 500));
            
            Assert.AreEqual(new Vector2(   0, 150), grid.GetSurroudingAnchorDistances(Orientation.Vertical, -1));
            Assert.AreEqual(new Vector2(   0, 150), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 0));
            Assert.AreEqual(new Vector2( -50, 100), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 50));
            Assert.AreEqual(new Vector2( -80,  70), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 80));
            Assert.AreEqual(new Vector2(   0, 200), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 150));
            Assert.AreEqual(new Vector2( -10, 190), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 160));
            Assert.AreEqual(new Vector2(-200,   0), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 350));
            Assert.AreEqual(new Vector2(-200,   0), grid.GetSurroudingAnchorDistances(Orientation.Vertical, 500));
            
            Assert.AreEqual(new Vector2(   0, 300), grid.GetSurroudingAnchorDistances(Orientation.InDepth, -1));
            Assert.AreEqual(new Vector2(   0, 300), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 0));
            Assert.AreEqual(new Vector2( -50, 250), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 50));
            Assert.AreEqual(new Vector2( -80, 220), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 80));
            Assert.AreEqual(new Vector2(   0, 300), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 300));
            Assert.AreEqual(new Vector2( -10, 290), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 310));
            Assert.AreEqual(new Vector2(-300,   0), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 600));
            Assert.AreEqual(new Vector2(-300,   0), grid.GetSurroudingAnchorDistances(Orientation.InDepth, 900));
        }
示例#29
0
        private void InitializeMainPage()
        {
            var rootElement = page.RootElement;

            // counters
            bonusCounter = rootElement.FindVisualChildOfType<TextBlock>("bonusCounter");
            lifeCounter = rootElement.FindVisualChildOfType<TextBlock>("lifeCounter");
            moneyCounter = rootElement.FindVisualChildOfType<TextBlock>("moneyCounter");
            Bonus = 30;
            LifeStatus = 3;
            Money = 30;

            // lifebar
            lifebarGaugeImage = MainSceneImages["life_bar"];
            lifebarGrid = rootElement.FindVisualChildOfType<Grid>("lifebarGrid");
            gaugeBarRegion = lifebarGaugeImage.Region;

            // character name
            nameTextBlock = rootElement.FindVisualChildOfType<TextBlock>("nameTextBlock");

            // explanation
            // FIXME: UI asset should support multiline text
            var explanationText = rootElement.FindVisualChildOfType<TextBlock>("explanationText");
            explanationText.Text = "Pictogram-based alphabets are easily supported.\n日本語も簡単に入れることが出来ます。";

            // status stars
            var statusPanel = rootElement.FindVisualChildOfType<UniformGrid>("statusPanel");
            powerStatusStar = statusPanel.FindVisualChildOfType<ImageElement>("powerStatusStar");
            controlStatusStar = statusPanel.FindVisualChildOfType<ImageElement>("controlStatusStar");
            speedStatusStar = statusPanel.FindVisualChildOfType<ImageElement>("speedStatusStar");
            PowerStatus = shipList[activeShipIndex].Power;
            ControlStatus = shipList[activeShipIndex].Control;
            SpeedStatus = shipList[activeShipIndex].Speed;

            // ship selection
            var currentShipButton = rootElement.FindVisualChildOfType<Button>("currentShipButton");
            currentShipButton.Click += delegate
            {
                // Once click, update the SpaceShip status pop-up and show it.
                UpdateShipStatus();
                ShowShipSelectionPopup();
            };
            currentShipImage = currentShipButton.FindVisualChildOfType<ImageElement>("currentShipImage");

            // upgrade buttons
            var statusUpgradePanel = rootElement.FindVisualChildOfType<UniformGrid>("statusUpgradePanel");
            SetupStatusButton(statusUpgradePanel.FindVisualChildOfType<ButtonBase>("powerStatusButton"), 2, 0, () => PowerStatus, () => PowerStatus++);
            SetupStatusButton(statusUpgradePanel.FindVisualChildOfType<ButtonBase>("controlStatusButton"), 2, 0, () => ControlStatus, () => ControlStatus++);
            SetupStatusButton(statusUpgradePanel.FindVisualChildOfType<ButtonBase>("speedStatusButton"), 2, 0, () => SpeedStatus, () => SpeedStatus++);
            SetupStatusButton(statusUpgradePanel.FindVisualChildOfType<ButtonBase>("lifeStatusButton"), 1, 1, () => 0, () => LifeStatus++);

            // quit button
            var quitButton = rootElement.FindVisualChildOfType<Button>("quitButton");
            quitButton.Click += delegate { UIGame.Exit(); };
        }
示例#30
0
        public void TestFixedOnlyComplexLayering()
        {
            // create a 3x3 grid with elements of every every different span and too small/big size
            var grid = new Grid();

            // the grid definition
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 100));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 200));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 300));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 400));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 500));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 600));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 700));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 800));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 900));

            // the simple cells children
            var child000 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 700), ExpectedArrangeValue = new Vector3(100, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child100 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 400, 700), ExpectedArrangeValue = new Vector3(200, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child200 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(300, 400, 700), ExpectedArrangeValue = new Vector3(300, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child010 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 500, 700), ExpectedArrangeValue = new Vector3(100, 500, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child020 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 600, 700), ExpectedArrangeValue = new Vector3(100, 600, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child001 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 800), ExpectedArrangeValue = new Vector3(100, 400, 800), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child002 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 900), ExpectedArrangeValue = new Vector3(100, 400, 900), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };

            // two cells children
            var child000C2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(300, 400, 700), ExpectedArrangeValue = new Vector3(300, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child100C2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(500, 400, 700), ExpectedArrangeValue = new Vector3(500, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000C3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(600, 400, 700), ExpectedArrangeValue = new Vector3(600, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000R2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 900, 700), ExpectedArrangeValue = new Vector3(100, 900, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child010R2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 1100, 700), ExpectedArrangeValue = new Vector3(100, 1100, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000R3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 1500, 700), ExpectedArrangeValue = new Vector3(100, 1500, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000L2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 1500), ExpectedArrangeValue = new Vector3(100, 400, 1500), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child001L2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 1700), ExpectedArrangeValue = new Vector3(100, 400, 1700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000L3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 2400), ExpectedArrangeValue = new Vector3(100, 400, 2400), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };

            // set the span of the children
            child000C2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child100C2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child000C3.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            child000R2.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);
            child010R2.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);
            child000R3.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 3);
            child000L2.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 2);
            child001L2.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 2);
            child000L3.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 3);

            // place the children in the grid
            child100.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child200.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child010.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            child020.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            child001.DependencyProperties.Set(GridBase.LayerPropertyKey, 1);
            child002.DependencyProperties.Set(GridBase.LayerPropertyKey, 2);
            child100C2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child010R2.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            child001L2.DependencyProperties.Set(GridBase.LayerPropertyKey, 1);

            // add the children to the grid
            grid.Children.Add(child000);
            grid.Children.Add(child100);
            grid.Children.Add(child200);
            grid.Children.Add(child010);
            grid.Children.Add(child020);
            grid.Children.Add(child001);
            grid.Children.Add(child002);
            grid.Children.Add(child000C2);
            grid.Children.Add(child100C2);
            grid.Children.Add(child000C3);
            grid.Children.Add(child000R2);
            grid.Children.Add(child010R2);
            grid.Children.Add(child000R3);
            grid.Children.Add(child000L2);
            grid.Children.Add(child001L2);
            grid.Children.Add(child000L3);

            //measure with too small size
            grid.Measure(Vector3.Zero);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.DesiredSizeWithMargins);
            // measure with too big size
            grid.Measure(float.PositiveInfinity * Vector3.One);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.DesiredSizeWithMargins);

            // arrange with too small size
            grid.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.RenderSize);
            // arrange with too big size
            grid.Arrange(float.PositiveInfinity * Vector3.One, false);

            // test the strip actual size
            Assert.AreEqual(100, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(200, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(300, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(400, grid.RowDefinitions[0].ActualSize);
            Assert.AreEqual(500, grid.RowDefinitions[1].ActualSize);
            Assert.AreEqual(600, grid.RowDefinitions[2].ActualSize);
            Assert.AreEqual(700, grid.LayerDefinitions[0].ActualSize);
            Assert.AreEqual(800, grid.LayerDefinitions[1].ActualSize);
            Assert.AreEqual(900, grid.LayerDefinitions[2].ActualSize);
        }