예제 #1
0
        private void loadTest(int testType)
        {
            testContainer.Clear();

            Triangle triangle;

            switch (testType)
            {
            case 0:
                Container box;

                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new[]
                {
                    new DraggableTriangle
                    {
                        //chameleon = true,
                        Position = new Vector2(0, 0),
                        Size     = new Vector2(25, 25),
                        Origin   = Anchor.Centre,
                        Anchor   = Anchor.Centre,
                        Colour   = Color4.Blue,
                    },
                    triangle = new DraggableTriangle
                    {
                        Size   = new Vector2(250, 250),
                        Alpha  = 0.5f,
                        Origin = Anchor.Centre,
                        Anchor = Anchor.Centre,
                        Colour = Color4.DarkSeaGreen,
                    }
                });

                triangle.OnUpdate += delegate { triangle.Rotation += 0.05f; };
                break;
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }
예제 #2
0
        private void loadTest(int testType)
        {
            testContainer.Clear();

            Container box;

            switch (testType)
            {
            case 0:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Position = new Vector2(0, 0),
                    Size     = new Vector2(25, 25),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });

                box.Add(box = new InfofulBox
                {
                    Size   = new Vector2(250, 250),
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre,
                    Colour = Color4.DarkSeaGreen,
                });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;

            case 1:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 5);


                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour = Color4.DarkSeaGreen,
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                Drawable localBox = box;
                box.OnUpdate += delegate { localBox.Rotation += 0.05f; };

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size     = new Vector2(100, 100),
                    Position = new Vector2(50, 50),
                    Alpha    = 0.5f,
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });
                break;

            case 2:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 50; i++)
                {
                    box.Add(box = new InfofulBoxAutoSize
                    {
                        Colour   = new Color4(253, 253, 253, 255),
                        Position = new Vector2(-3, -3),
                        Origin   = Anchor.BottomRight,
                        Anchor   = Anchor.BottomRight,
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.BottomRight,
                    Anchor = Anchor.BottomRight,
                    Colour = Color4.SeaGreen,
                });
                break;

            case 3:
                testContainer.Add(box = new InfofulBox
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Size   = new Vector2(250, 250)
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 100; i++)
                {
                    box.Add(box = new InfofulBox
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = new Color4(253, 253, 253, 255),
                        Origin           = Anchor.BottomRight,
                        Anchor           = Anchor.BottomRight,
                        Size             = new Vector2(0.99f, 0.99f)
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.BottomRight,
                    Anchor = Anchor.BottomRight,
                    Colour = Color4.SeaGreen,
                });
                break;

            case 4:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "Test CentreLeft line 1",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "Test CentreLeft line 2",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 5:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "123,456,789=",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft,
                    Scale    = new Vector2(2f)
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "123,456,789ms",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 6:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour   = Color4.OrangeRed,
                    Position = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(100, 100),
                    Size     = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });
                break;

            case 7:
                Container            shrinkContainer;
                Container <Drawable> boxes;

                testContainer.Add(shrinkContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.5f, 1),
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Color4.AliceBlue,
                            Alpha            = 0.2f
                        },
                        boxes = new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Vertical,
                            Spacing          = new Vector2(0, 10),
                        }
                    }
                });

                for (int i = 0; i < 10; i++)
                {
                    boxes.Add(new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Anchor           = Anchor.TopCentre,
                        Origin           = Anchor.TopCentre,
                        Size             = new Vector2(0.9f, 40),
                        Colour           = Color4.AliceBlue,
                        Alpha            = 0.2f
                    });
                }

                shrinkContainer.ScaleTo(new Vector2(1.5f, 1), 1000);
                using (shrinkContainer.BeginDelayedSequence(1000))
                {
                    shrinkContainer.ScaleTo(new Vector2(1f, 1), 1000);
                    using (shrinkContainer.BeginDelayedSequence(1000))
                    {
                        shrinkContainer.Loop();
                    }
                }
                break;

            case 8:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    using (b.BeginDelayedSequence(1000))
                    {
                        b.ScaleTo(new Vector2(1, 1), 1000);
                        using (b.BeginDelayedSequence(1000))
                        {
                            b.Loop();
                        }
                    }
                }

                break;
            }

            case 9:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    using (b.BeginDelayedSequence(1000))
                    {
                        b.ScaleTo(new Vector2(1, 1), 1000);
                        using (b.BeginDelayedSequence(1000))
                        {
                            b.Loop();
                        }
                    }
                }

                break;
            }

            case 10:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    using (b.BeginDelayedSequence(1000))
                    {
                        b.ScaleTo(new Vector2(1, 1), 1000);
                        using (b.BeginDelayedSequence(1000))
                        {
                            b.Loop();
                        }
                    }
                }

                break;
            }

            case 11:
            {
                Drawable box1;
                Drawable box2;
                Drawable box3;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box1 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box2 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = -1,
                                                Children     = new[]
                                                {
                                                    box3 = new Box
                                                    {
                                                        Margin = new MarginPadding(50),
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Drawable b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    using (b.BeginDelayedSequence(1000))
                    {
                        b.ScaleTo(new Vector2(1, 1), 1000);
                        using (b.BeginDelayedSequence(1000))
                            b.Loop();
                    }
                }

                break;
            }

            case 12:
            {
                // demonstrates how relativeaxes drawables act inside an autosize parent
                Drawable sizedBox;

                testContainer.Add(new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            new Container
                            {
                                Size     = new Vector2(300),
                                Anchor   = Anchor.Centre,
                                Origin   = Anchor.Centre,
                                Children = new Drawable[]
                                {
                                    new Box {
                                        Colour = Color4.Gray, RelativeSizeAxes = Axes.Both
                                    },
                                    new Container
                                    {
                                        AutoSizeAxes = Axes.Both,
                                        Anchor       = Anchor.Centre,
                                        Origin       = Anchor.Centre,
                                        Children     = new[]
                                        {
                                            // defines the size of autosize
                                            sizedBox = new Box
                                            {
                                                Colour = Color4.Red,
                                                Anchor = Anchor.Centre,
                                                Origin = Anchor.Centre,
                                                Size   = new Vector2(100f)
                                            },
                                            // gets relative size based on autosize
                                            new Box
                                            {
                                                Colour           = Color4.Black,
                                                RelativeSizeAxes = Axes.Both,
                                                Size             = new Vector2(0.5f)
                                            },
                                        }
                                    }
                                }
                            }
                        }
                    });

                sizedBox.ScaleTo(new Vector2(2, 2), 1000, EasingTypes.Out);
                using (sizedBox.BeginDelayedSequence(1000))
                {
                    sizedBox.ScaleTo(new Vector2(1, 1), 1000, EasingTypes.In);
                    using (sizedBox.BeginDelayedSequence(1000))
                        sizedBox.Loop();
                }

                break;
            }
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }
예제 #3
0
        private void loadTest(int testType)
        {
            TestContainer.Clear();

            switch (testType)
            {
            default:
            {
                Color4 glowColour = Color4.Aquamarine;
                glowColour.A = 0.5f;

                Container box;
                TestContainer.Add(box = new InfofulBoxAutoSize
                    {
                        Anchor          = Anchor.Centre,
                        Origin          = Anchor.Centre,
                        Masking         = true,
                        CornerRadius    = 100,
                        BorderColour    = Color4.Aquamarine,
                        BorderThickness = 3,
                        EdgeEffect      = new EdgeEffect
                        {
                            Type   = EdgeEffectType.Shadow,
                            Radius = 100,
                            Colour = new Color4(0, 50, 100, 200),
                        },
                    });

                box.Add(box = new InfofulBox
                    {
                        Size   = new Vector2(250, 250),
                        Alpha  = 0.5f,
                        Origin = Anchor.Centre,
                        Anchor = Anchor.Centre,
                        Colour = Color4.DarkSeaGreen,
                    });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;
            }

            case 1:
            {
                Color4 glowColour = Color4.Aquamarine;
                glowColour.A = 0.5f;

                Container box;
                TestContainer.Add(new InfofulBoxAutoSize
                    {
                        Anchor   = Anchor.Centre,
                        Origin   = Anchor.Centre,
                        Children = new[]
                        {
                            box = new InfofulBox
                            {
                                Masking      = true,
                                CornerRadius = 100,
                                Size         = new Vector2(400, 400),
                                Alpha        = 0.5f,
                                Origin       = Anchor.Centre,
                                Anchor       = Anchor.Centre,
                                Colour       = Color4.DarkSeaGreen,
                            }
                        }
                    });

                box.OnUpdate += delegate { box.Rotation += 0.05f; box.CornerRadius = 100 + 100 * (float)Math.Sin(box.Rotation * 0.01); };
                break;
            }

            case 2:
            {
                Color4 glowColour = Color4.Aquamarine;
                glowColour.A = 0.5f;

                Container box;
                TestContainer.Add(new InfofulBoxAutoSize
                    {
                        Anchor   = Anchor.Centre,
                        Origin   = Anchor.Centre,
                        Children = new[]
                        {
                            box = new InfofulBox
                            {
                                Masking      = true,
                                CornerRadius = 25,
                                Shear        = new Vector2(0.5f, 0),
                                Size         = new Vector2(150, 150),
                                Scale        = new Vector2(2.5f, 1.5f),
                                Alpha        = 0.5f,
                                Origin       = Anchor.Centre,
                                Anchor       = Anchor.Centre,
                                Colour       = Color4.DarkSeaGreen,
                            }
                        }
                    });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;
            }

            case 3:
            {
                Color4 glowColour = Color4.Aquamarine;
                glowColour.A = 0.5f;

                Container box1;
                Container box2;

                TestContainer.Add(new InfofulBoxAutoSize
                    {
                        Anchor     = Anchor.Centre,
                        Origin     = Anchor.Centre,
                        EdgeEffect = new EdgeEffect
                        {
                            Type      = EdgeEffectType.Glow,
                            Radius    = 100,
                            Roundness = 50,
                            Colour    = glowColour,
                        },
                        BorderColour    = Color4.Aquamarine,
                        BorderThickness = 3,
                        Children        = new[]
                        {
                            box1 = new InfofulBoxAutoSize
                            {
                                Masking      = true,
                                CornerRadius = 25,
                                Shear        = new Vector2(0.5f, 0),
                                Alpha        = 0.5f,
                                Origin       = Anchor.Centre,
                                Anchor       = Anchor.Centre,
                                Colour       = Color4.DarkSeaGreen,
                                Children     = new[]
                                {
                                    box2 = new InfofulBox
                                    {
                                        Masking      = true,
                                        CornerRadius = 25,
                                        Shear        = new Vector2(0.25f, 0.25f),
                                        Size         = new Vector2(100, 200),
                                        Alpha        = 0.5f,
                                        Origin       = Anchor.Centre,
                                        Anchor       = Anchor.Centre,
                                        Colour       = Color4.Blue,
                                    }
                                }
                            }
                        }
                    });

                box1.OnUpdate += delegate { box1.Rotation += 0.07f; };
                box2.OnUpdate += delegate { box2.Rotation -= 0.15f; };
                break;
            }

            case 4:
            {
                Func <float, Drawable> createMaskingBox = delegate(float scale)
                {
                    float size = 200 / scale;
                    return(new Container
                        {
                            Masking = true,
                            CornerRadius = 25 / scale,
                            BorderThickness = 12.5f / scale,
                            BorderColour = Color4.Red,
                            Size = new Vector2(size),
                            Scale = new Vector2(scale),
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre,
                            Children = new Drawable[]
                            {
                                new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour = Color4.White,
                                    Anchor = Anchor.Centre,
                                    Origin = Anchor.Centre,
                                },
                                new SpriteText
                                {
                                    Text = @"Size: " + size + ", Scale: " + scale,
                                    TextSize = 20 / scale,
                                    Colour = Color4.Blue,
                                    Anchor = Anchor.Centre,
                                    Origin = Anchor.Centre,
                                },
                            }
                        });
                };

                TestContainer.Add(new FlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new[]
                        {
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.5f),
                                Masking          = true,
                                Children         = new[] { createMaskingBox(100) }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.5f),
                                Masking          = true,
                                Children         = new[] { createMaskingBox(10) }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.5f),
                                Masking          = true,
                                Children         = new[] { createMaskingBox(1) }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.5f),
                                Masking          = true,
                                Children         = new[] { createMaskingBox(0.1f) }
                            },
                        }
                    });

                break;
            }

            case 5:
            {
                TestContainer.Add(new Container
                    {
                        Masking          = true,
                        Size             = new Vector2(0.5f),
                        RelativeSizeAxes = Axes.Both,
                        Children         = new[]
                        {
                            new Container
                            {
                                Masking          = true,
                                CornerRadius     = 100f,
                                BorderThickness  = 50f,
                                BorderColour     = Color4.Red,
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(1.5f),
                                Anchor           = Anchor.BottomRight,
                                Origin           = Anchor.Centre,
                                Children         = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.White,
                                    },
                                }
                            }
                        }
                    });
                break;
            }
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }
예제 #4
0
        private void loadTest(int testType)
        {
            testContainer.Clear();

            Container box;

            switch (testType)
            {
            case 0:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Position = new Vector2(0, 0),
                    Size     = new Vector2(25, 25),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });

                box.Add(box = new InfofulBox
                {
                    Size   = new Vector2(250, 250),
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre,
                    Colour = Color4.DarkSeaGreen,
                });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;

            case 1:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 5);


                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour = Color4.DarkSeaGreen,
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                Drawable localBox = box;
                box.OnUpdate += delegate { localBox.Rotation += 0.05f; };

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size     = new Vector2(100, 100),
                    Position = new Vector2(50, 50),
                    Alpha    = 0.5f,
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre,
                    Colour   = Color4.Blue,
                });
                break;

            case 2:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 100; i++)
                {
                    box.Add(box = new InfofulBoxAutoSize
                    {
                        Colour   = new Color4(253, 253, 253, 255),
                        Position = new Vector2(3, 3),
                        Origin   = Anchor.BottomRight,
                        Anchor   = Anchor.BottomRight
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.TopLeft,
                    Anchor = Anchor.TopLeft,
                    Colour = Color4.SeaGreen,
                });
                break;

            case 3:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "Test CentreLeft line 1",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "Test CentreLeft line 2",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 4:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "123,456,789=",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft,
                    Scale    = new Vector2(2f)
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "123,456,789ms",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 5:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour   = Color4.OrangeRed,
                    Position = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new InfofulBox
                {
                    Position = new Vector2(100, 100),
                    Size     = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft,
                    Colour   = Color4.OrangeRed,
                });
                break;

            case 6:
                Container            shrinkContainer;
                Container <Drawable> boxes;

                testContainer.Add(shrinkContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.5f, 1),
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Color4.AliceBlue,
                            Alpha            = 0.2f
                        },
                        boxes = new FlowContainer {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Spacing          = new Vector2(0, 10),
                            Direction        = FlowDirection.VerticalOnly,
                        }
                    }
                });

                for (int i = 0; i < 10; i++)
                {
                    boxes.Add(new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Anchor           = Anchor.TopCentre,
                        Origin           = Anchor.TopCentre,
                        Size             = new Vector2(0.9f, 40),
                        Colour           = Color4.AliceBlue,
                        Alpha            = 0.2f
                    });
                }

                shrinkContainer.ScaleTo(new Vector2(1.5f, 1), 1000);
                shrinkContainer.Delay(1000);
                shrinkContainer.ScaleTo(new Vector2(1f, 1), 1000);
                shrinkContainer.Delay(1000);
                shrinkContainer.Loop();
                break;

            case 7:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Padding      = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    b.Delay(1000);
                    b.ScaleTo(new Vector2(1, 1), 1000);
                    b.Delay(1000);
                    b.Loop();
                }

                break;
            }

            case 8:
            {
                Container box1;
                Container box2;
                Container box3;

                testContainer.Add(new FlowContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children         = new Drawable[]
                        {
                            // This first guy is used for spacing.
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.125f, 1),
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box1 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.TopLeft,
                                                        Origin = Anchor.TopLeft,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box2 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.Centre,
                                                        Origin = Anchor.Centre,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Size             = new Vector2(0.25f, 1),
                                Children         = new[]
                                {
                                    new InfofulBoxAutoSize
                                    {
                                        Anchor   = Anchor.Centre,
                                        Origin   = Anchor.Centre,
                                        Children = new[]
                                        {
                                            new Container
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Depth        = 1,
                                                Margin       = new MarginPadding(50),
                                                Children     = new Drawable[]
                                                {
                                                    box3 = new InfofulBox
                                                    {
                                                        Anchor = Anchor.BottomRight,
                                                        Origin = Anchor.BottomRight,
                                                        Size   = new Vector2(50),
                                                        Colour = Color4.Blue,
                                                    },
                                                }
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    });

                foreach (Container b in new[] { box1, box2, box3 })
                {
                    b.ScaleTo(new Vector2(2, 2), 1000);
                    b.Delay(1000);
                    b.ScaleTo(new Vector2(1, 1), 1000);
                    b.Delay(1000);
                    b.Loop();
                }

                break;
            }
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }
예제 #5
0
        private void loadTest(int testType)
        {
            currentTest = testType;

            testContainer.Clear();

            Container box = null;

            switch (currentTest)
            {
            case 1:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.Blue)
                {
                    //chameleon = true,
                    Position = new Vector2(0, 0),
                    Size     = new Vector2(25, 25),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre
                });

                box.Add(box = new InfofulBox(RectangleF.Empty, 0, Color4.DarkSeaGreen)
                {
                    Size   = new Vector2(250, 250),
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                box.OnUpdate += delegate
                {
                    box.Rotation += 0.05f;
                };
                break;

            case 2:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 5);


                box.Add(box = new InfofulBoxAutoSize()
                {
                    Colour = Color4.DarkSeaGreen,
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                Drawable localBox = box;
                box.OnUpdate += delegate
                {
                    localBox.Rotation += 0.05f;
                };

                box.Add(box = new InfofulBox(RectangleF.Empty, 0, Color4.Blue)
                {
                    //chameleon = true,
                    Size     = new Vector2(100, 100),
                    Position = new Vector2(50, 50),
                    Alpha    = 0.5f,
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre
                });
                break;

            case 3:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 100; i++)
                {
                    box.Add(box = new InfofulBoxAutoSize()
                    {
                        Colour   = new Color4(253, 253, 253, 255),
                        Position = new Vector2(3, 3),
                        Origin   = Anchor.BottomRight,
                        Anchor   = Anchor.BottomRight
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox(RectangleF.Empty, 1, Color4.SeaGreen)
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.TopLeft,
                    Anchor = Anchor.TopLeft
                });
                break;

            case 4:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new SpriteText()
                {
                    Position = new Vector2(5, -20),
                    Text     = "Test CentreLeft line 1",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });

                box.Add(new SpriteText()
                {
                    Position = new Vector2(5, 20),
                    Text     = "Test CentreLeft line 2",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 5:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new SpriteText()
                {
                    Position = new Vector2(5, -20),
                    Text     = "123,456,789=",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft,
                    Scale    = new Vector2(2f)
                });

                box.Add(new SpriteText()
                {
                    Position = new Vector2(5, 20),
                    Text     = "123,456,789ms",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 6:
                testContainer.Add(box = new InfofulBoxAutoSize()
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                box.Add(box = new InfofulBoxAutoSize()
                {
                    Colour   = Color4.OrangeRed,
                    Position = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(box = new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(100, 100),
                    Size     = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });
                break;
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }
예제 #6
0
        private void loadTest(int testType)
        {
            currentTest = testType;

            testContainer.Clear();

            Container box;

            switch (currentTest)
            {
            case 1:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box);

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.Blue)
                {
                    //chameleon = true,
                    Position = new Vector2(0, 0),
                    Size     = new Vector2(25, 25),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre
                });

                box.Add(box = new InfofulBox(RectangleF.Empty, 0, Color4.DarkSeaGreen)
                {
                    Size   = new Vector2(250, 250),
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                box.OnUpdate += delegate { box.Rotation += 0.05f; };
                break;

            case 2:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 5);


                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour = Color4.DarkSeaGreen,
                    Alpha  = 0.5f,
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre
                });

                Drawable localBox = box;
                box.OnUpdate += delegate { localBox.Rotation += 0.05f; };

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.Blue)
                {
                    //chameleon = true,
                    Size     = new Vector2(100, 100),
                    Position = new Vector2(50, 50),
                    Alpha    = 0.5f,
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.Centre
                });
                break;

            case 3:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                addCornerMarkers(box, 10, Color4.YellowGreen);

                for (int i = 0; i < 100; i++)
                {
                    box.Add(box = new InfofulBoxAutoSize
                    {
                        Colour   = new Color4(253, 253, 253, 255),
                        Position = new Vector2(3, 3),
                        Origin   = Anchor.BottomRight,
                        Anchor   = Anchor.BottomRight
                    });
                }

                addCornerMarkers(box, 2);

                box.Add(new InfofulBox(RectangleF.Empty, 1, Color4.SeaGreen)
                {
                    //chameleon = true,
                    Size   = new Vector2(50, 50),
                    Origin = Anchor.TopLeft,
                    Anchor = Anchor.TopLeft
                });
                break;

            case 4:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "Test CentreLeft line 1",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "Test CentreLeft line 2",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 5:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.CentreLeft
                });

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(5, 0),
                    Size     = new Vector2(300, 80),
                    Origin   = Anchor.TopLeft,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, -20),
                    Text     = "123,456,789=",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft,
                    Scale    = new Vector2(2f)
                });

                box.Add(new SpriteText
                {
                    Position = new Vector2(5, 20),
                    Text     = "123,456,789ms",
                    Origin   = Anchor.CentreLeft,
                    Anchor   = Anchor.CentreLeft
                });
                break;

            case 6:
                testContainer.Add(box = new InfofulBoxAutoSize
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre
                });

                box.Add(box = new InfofulBoxAutoSize
                {
                    Colour   = Color4.OrangeRed,
                    Position = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });

                box.Add(new InfofulBox(RectangleF.Empty, 0, Color4.OrangeRed)
                {
                    Position = new Vector2(100, 100),
                    Size     = new Vector2(100, 100),
                    Origin   = Anchor.Centre,
                    Anchor   = Anchor.TopLeft
                });
                break;

            case 7:
                Container shrinkContainer;
                Container boxes;

                testContainer.Add(shrinkContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Size             = new Vector2(0.5f, 1),
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Color4.AliceBlue,
                            Alpha            = 0.2f
                        },
                        boxes = new FlowContainer {
                            RelativeSizeAxes = Axes.X,
                            Padding          = new Vector2(0, 10),
                            Direction        = FlowDirection.VerticalOnly,
                        }
                    }
                });

                for (int i = 0; i < 10; i++)
                {
                    boxes.Add(new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Anchor           = Anchor.TopCentre,
                        Origin           = Anchor.TopCentre,
                        Size             = new Vector2(0.9f, 40),
                        Colour           = Color4.AliceBlue,
                        Alpha            = 0.2f
                    });
                }

                shrinkContainer.ScaleTo(new Vector2(1.5f, 1), 1000);
                shrinkContainer.Delay(1000);
                shrinkContainer.ScaleTo(new Vector2(1f, 1), 1000);
                shrinkContainer.Delay(1000);
                shrinkContainer.Loop();
                break;
            }

#if DEBUG
            //if (toggleDebugAutosize.State)
            //    testContainer.Children.FindAll(c => c.HasAutosizeChildren).ForEach(c => c.AutoSizeDebug = true);
#endif
        }