Beispiel #1
0
        public void DrawScrollableContainer(IRenderContext context, Rectangle layout, ScrollableContainer scrollableContainer, RenderTarget2D childContent)
        {
            this.DrawSunken(context, layout);

            var layoutWidth  = layout.Width - this.HorizontalScrollBarHeight;
            var layoutHeight = layout.Height - this.VerticalScrollBarWidth;

            this.m_RenderUtilities.RenderTexture(
                context,
                new Vector2(layout.X, layout.Y),
                new TextureAsset(childContent),
                new Vector2(layoutWidth, layoutHeight),
                sourceArea: new Rectangle(
                    (int)(scrollableContainer.ScrollX * (System.Math.Max(childContent.Width, layoutWidth) - layoutWidth)),
                    (int)(scrollableContainer.ScrollY * (System.Math.Max(childContent.Height, layoutHeight) - layoutHeight)),
                    layoutWidth,
                    layoutHeight));

            var raisedPadding = 3;

            this.DrawSunken(context, new Rectangle(
                                layout.X,
                                layout.Y + layout.Height - this.HorizontalScrollBarHeight,
                                layout.Width - this.VerticalScrollBarWidth,
                                this.HorizontalScrollBarHeight));
            this.DrawSunken(context, new Rectangle(
                                layout.X + layout.Width - this.VerticalScrollBarWidth,
                                layout.Y,
                                this.VerticalScrollBarWidth,
                                layout.Height - this.HorizontalScrollBarHeight));

            this.DrawRaised(context, new Rectangle(
                                (int)(layout.X + scrollableContainer.ScrollX * (layoutWidth - ((layoutWidth / (float)childContent.Width) * layoutWidth))) + raisedPadding,
                                layout.Y + layout.Height - this.HorizontalScrollBarHeight + raisedPadding,
                                (int)((layoutWidth / (float)childContent.Width) * layoutWidth) - raisedPadding * 2,
                                this.HorizontalScrollBarHeight - raisedPadding * 2));

            this.DrawRaised(context, new Rectangle(
                                layout.X + layout.Width - this.VerticalScrollBarWidth + raisedPadding,
                                (int)(layout.Y + scrollableContainer.ScrollY * (layoutHeight - ((layoutHeight / (float)childContent.Height) * layoutHeight))) + raisedPadding,
                                this.VerticalScrollBarWidth - raisedPadding * 2,
                                (int)((layoutHeight / (float)childContent.Height) * layoutHeight) - raisedPadding * 2));
        }
Beispiel #2
0
        public void DrawScrollableContainer(IRenderContext context, Rectangle layout, ScrollableContainer scrollableContainer, RenderTarget2D childContent)
        {
            this.DrawSunken(context, layout);

            var layoutWidth = layout.Width - this.HorizontalScrollBarHeight;
            var layoutHeight = layout.Height - this.VerticalScrollBarWidth;

            this.m_RenderUtilities.RenderTexture(
                context,
                new Vector2(layout.X, layout.Y),
                new TextureAsset(childContent),
                new Vector2(layoutWidth, layoutHeight),
                sourceArea: new Rectangle(
                    (int)(scrollableContainer.ScrollX * (System.Math.Max(childContent.Width, layoutWidth) - layoutWidth)),
                    (int)(scrollableContainer.ScrollY * (System.Math.Max(childContent.Height, layoutHeight) - layoutHeight)),
                    layoutWidth,
                    layoutHeight));

            var raisedPadding = 3;

            this.DrawSunken(context, new Rectangle(
                layout.X,
                layout.Y + layout.Height - this.HorizontalScrollBarHeight,
                layout.Width - this.VerticalScrollBarWidth,
                this.HorizontalScrollBarHeight));
            this.DrawSunken(context, new Rectangle(
                layout.X + layout.Width - this.VerticalScrollBarWidth,
                layout.Y,
                this.VerticalScrollBarWidth,
                layout.Height - this.HorizontalScrollBarHeight));

            this.DrawRaised(context, new Rectangle(
                (int)(layout.X + scrollableContainer.ScrollX * (layoutWidth - ((layoutWidth / (float)childContent.Width) * layoutWidth))) + raisedPadding,
                layout.Y + layout.Height - this.HorizontalScrollBarHeight + raisedPadding,
                (int)((layoutWidth / (float)childContent.Width) * layoutWidth) - raisedPadding * 2,
                this.HorizontalScrollBarHeight - raisedPadding * 2));

            this.DrawRaised(context, new Rectangle(
                layout.X + layout.Width - this.VerticalScrollBarWidth + raisedPadding,
                (int)(layout.Y + scrollableContainer.ScrollY * (layoutHeight - ((layoutHeight / (float)childContent.Height) * layoutHeight))) + raisedPadding,
                this.VerticalScrollBarWidth - raisedPadding * 2,
                (int)((layoutHeight / (float)childContent.Height) * layoutHeight) - raisedPadding * 2));
        }
Beispiel #3
0
        public IContainer Process(XmlNode node, Action <UserInterfaceBehaviourEvent, object> eventCallback, out Action <XmlNode, IContainer> processChild)
        {
            IContainer container;

            switch (node?.Attributes?["type"]?.Value)
            {
            case "horizontal":
                var horizontalContainer = new HorizontalContainer();
                processChild = (childNode, childContainer) =>
                {
                    horizontalContainer.AddChild(childContainer, childNode?.Attributes?["width"]?.Value ?? "*");
                };
                container = horizontalContainer;
                break;

            case "vertical":
                var verticalContainer = new VerticalContainer();
                processChild = (childNode, childContainer) =>
                {
                    verticalContainer.AddChild(childContainer, childNode?.Attributes?["height"]?.Value ?? "*");
                };
                container = verticalContainer;
                break;

            case "single":
                var singleContainer = new SingleContainer();
                processChild = (childNode, childContainer) =>
                {
                    singleContainer.SetChild(childContainer);
                };
                container = singleContainer;
                break;

            case "scrollable":
                var scrollableContainer = new ScrollableContainer();
                processChild = (childNode, childContainer) =>
                {
                    scrollableContainer.SetChild(childContainer);
                };
                container = scrollableContainer;
                break;

            case "relative":
                var relativeContainer = new RelativeContainer();
                processChild = (childNode, childContainer) =>
                {
                    relativeContainer.AddChild(childContainer, new Rectangle(
                                                   GetAttribute(childNode, "x"),
                                                   GetAttribute(childNode, "y"),
                                                   GetAttribute(childNode, "width"),
                                                   GetAttribute(childNode, "height")));
                };
                container = relativeContainer;
                break;

            case "adjusted":
                var adjustedContainer = new AdjustedContainer(new Point(
                                                                  GetAttribute(node, "anchorX"),
                                                                  GetAttribute(node, "anchorY")));
                processChild = (childNode, childContainer) =>
                {
                    adjustedContainer.AddChild(childContainer, new Rectangle(
                                                   GetAttribute(childNode, "x"),
                                                   GetAttribute(childNode, "y"),
                                                   GetAttribute(childNode, "width"),
                                                   GetAttribute(childNode, "height")));
                };
                container = adjustedContainer;
                break;

            case "empty":
                container    = new EmptyContainer();
                processChild = (childNode, childContainer) => { };
                break;

            default:
                processChild = (childNode, childContainer) => { };
                return(null);
            }

            return(container);
        }