public override void Draw(DrawContext context)
 {
     // To render the scrolled panel, we just adjust our offset before rendering our child controls as
     // a normal PanelControl
     context.DrawOffset.Y = -scrollTracker.ViewRect.Y;
     base.Draw(context);
 }
Esempio n. 2
0
        public override void Draw(DrawContext context)
        {
            int childCount = ChildCount;
            if (childCount < 2)
            {
                // Default rendering behavior if we don't have enough
                // children to flip through.
                base.Draw(context);
                return;
            }
            Vector2 origin = context.DrawOffset;
            int iCurrent = tracker.CurrentPage;

            float horizontalOffset = tracker.CurrentPageOffset;
            context.DrawOffset = origin + new Vector2 { X = horizontalOffset };
            this[iCurrent].Draw(context);

            if (horizontalOffset > 0)
            {
                // The screen has been dragged to the right, so the edge of another
                // page is visible to the left.
                int iLeft = (iCurrent + childCount - 1) % childCount;
                context.DrawOffset.X = origin.X + horizontalOffset - tracker.EffectivePageWidth(iLeft);
                this[iLeft].Draw(context);
            }

            if (horizontalOffset + this[iCurrent].Size.X < context.Device.Viewport.Width)
            {
                // The edge of another page is visible to the right.
                // Note that if we have two pages, it's possible that a page will be
                // drawn twice, with parts of it visible on each edge of the screen.
                int iRight = (iCurrent + 1) % childCount;
                context.DrawOffset.X = origin.X + horizontalOffset + tracker.EffectivePageWidth(iCurrent);
                this[iRight].Draw(context);
            }
        }
Esempio n. 3
0
        public override void Draw(DrawContext context)
        {
            base.Draw(context);

            context.SpriteBatch.DrawString(font, Text, context.DrawOffset, Color);
        }
Esempio n. 4
0
        public override void Draw(DrawContext context)
        {
            base.Draw(context);
            Texture2D drawTexture = texture ?? context.BlankTexture;

            Vector2 actualSourceSize = SourceSize ?? Size;
            Rectangle sourceRectangle = new Rectangle
            {
                X = (int)origin.X,
                Y = (int)origin.Y,
                Width = (int)actualSourceSize.X,
                Height = (int)actualSourceSize.Y,
            };
            Rectangle destRectangle = new Rectangle
            {
                X = (int)context.DrawOffset.X,
                Y = (int)context.DrawOffset.Y,
                Width = (int)Size.X,
                Height = (int)Size.Y
            };
            context.SpriteBatch.Draw(drawTexture, destRectangle, sourceRectangle, Color);
        }