예제 #1
0
        public void Centered()
        {
            var layout = new PaddedLayout(10, 10, 10, 10, _shim);

            layout.Position   = new Point(10, 20);
            layout.Scale      = 2f;
            layout.Horizontal = HorizontalAlignment.Center;
            layout.Vertical   = VerticalAlignment.Center;
            layout.Left.ShouldBe(10);
            layout.Right.ShouldBe(10);
            layout.Top.ShouldBe(10);
            layout.Bottom.ShouldBe(10);
            layout.Rect.Left.ShouldBe(-20);
            layout.Rect.Right.ShouldBe(40);
            layout.Rect.Top.ShouldBe(-20);
            layout.Rect.Bottom.ShouldBe(60);
            layout.Rect.Width.ShouldBe(60);
            layout.Rect.Height.ShouldBe(80);

            _shim.Rect.Left.ShouldBe(0);
            _shim.Rect.Right.ShouldBe(20);
            _shim.Rect.Top.ShouldBe(0);
            _shim.Rect.Bottom.ShouldBe(40);
            _shim.Rect.Width.ShouldBe(20);
            _shim.Rect.Height.ShouldBe(40);
        }
예제 #2
0
        public override async Task LoadContent()
        {
            await base.LoadContent();

            var layout = new RelativeLayout
            {
                Horizontal = HorizontalAlignment.Center,
                Vertical   = VerticalAlignment.Center,
                Position   = Resolution.TitleSafeArea.Center,
            };

            //create the message widget
            var width = 0f;
            var msg   = new PaddedLayout(0, 0, 24, 0, new Label("Creating Gif...", Content)
            {
                Highlightable = false
            })
            {
                Horizontal = HorizontalAlignment.Right,
                Vertical   = VerticalAlignment.Center,
            };

            width += msg.Rect.Width;

            Texture2D hourglassTex = null;

            try
            {
                hourglassTex = Content.Load <Texture2D>(StyleSheet.LoadingScreenHourglassImageResource);
            }
            catch (Exception)
            {
                //No hourglass texture :P
            }

            if (null != hourglassTex)
            {
                //create the hourglass widget
                var hourglass = new Image(hourglassTex)
                {
                    Horizontal    = HorizontalAlignment.Left,
                    Vertical      = VerticalAlignment.Center,
                    Scale         = 1.5f,
                    Highlightable = false,
                };
                layout.AddItem(hourglass);
                width += hourglass.Rect.Width;

                //add a little shim in between the widgets
                width += 32f;
            }

            layout.AddItem(msg);
            layout.Size = new Vector2(width, 64f);
            AddItem(layout);

            AddCancelButton();
        }
예제 #3
0
        public void Default()
        {
            var layout = new PaddedLayout(0, 0, 0, 0, _shim);

            layout.Left.ShouldBe(0);
            layout.Right.ShouldBe(0);
            layout.Top.ShouldBe(0);
            layout.Bottom.ShouldBe(0);
            layout.Rect.Left.ShouldBe(0);
            layout.Rect.Right.ShouldBe(10);
            layout.Rect.Top.ShouldBe(0);
            layout.Rect.Bottom.ShouldBe(20);
            layout.Rect.Width.ShouldBe(10);
            layout.Rect.Height.ShouldBe(20);

            _shim.Rect.Left.ShouldBe(0);
            _shim.Rect.Right.ShouldBe(10);
            _shim.Rect.Top.ShouldBe(0);
            _shim.Rect.Bottom.ShouldBe(20);
            _shim.Rect.Width.ShouldBe(10);
            _shim.Rect.Height.ShouldBe(20);
        }
예제 #4
0
        public void Left()
        {
            var layout = new PaddedLayout(10, 0, 0, 0, _shim);

            layout.Position = new Point(10, 20);
            layout.Left.ShouldBe(10);
            layout.Right.ShouldBe(0);
            layout.Top.ShouldBe(0);
            layout.Bottom.ShouldBe(0);
            layout.Rect.Left.ShouldBe(10);
            layout.Rect.Right.ShouldBe(30);
            layout.Rect.Top.ShouldBe(20);
            layout.Rect.Bottom.ShouldBe(40);
            layout.Rect.Width.ShouldBe(20);
            layout.Rect.Height.ShouldBe(20);

            _shim.Rect.Left.ShouldBe(20);
            _shim.Rect.Right.ShouldBe(30);
            _shim.Rect.Top.ShouldBe(20);
            _shim.Rect.Bottom.ShouldBe(40);
            _shim.Rect.Width.ShouldBe(10);
            _shim.Rect.Height.ShouldBe(20);
        }
예제 #5
0
        public void Scale()
        {
            var layout = new PaddedLayout(10, 10, 10, 10, _shim);

            layout.Position = new Point(10, 20);
            layout.Scale    = 2f;
            layout.Left.ShouldBe(10);
            layout.Right.ShouldBe(10);
            layout.Top.ShouldBe(10);
            layout.Bottom.ShouldBe(10);
            layout.Rect.Left.ShouldBe(10);
            layout.Rect.Right.ShouldBe(70);
            layout.Rect.Top.ShouldBe(20);
            layout.Rect.Bottom.ShouldBe(100);
            layout.Rect.Width.ShouldBe(60);
            layout.Rect.Height.ShouldBe(80);

            _shim.Rect.Left.ShouldBe(30);
            _shim.Rect.Right.ShouldBe(50);
            _shim.Rect.Top.ShouldBe(40);
            _shim.Rect.Bottom.ShouldBe(80);
            _shim.Rect.Width.ShouldBe(20);
            _shim.Rect.Height.ShouldBe(40);
        }