コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: PageFlipControl.cs プロジェクト: hubo6/helloGame
        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);
            }
        }
コード例 #3
0
ファイル: Control.cs プロジェクト: hubo6/helloGame
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public virtual void Draw(DrawContext context)
 {
     Vector2 origin = context.DrawOffset;
     for(int i=0; i<ChildCount; i++)
     {
         Control child = children[i];
         if (child.Visible)
         {
             context.DrawOffset = origin + child.Position;
             child.Draw(context);
         }
     }
 }
コード例 #4
0
ファイル: TextControl.cs プロジェクト: hubo6/helloGame
        public override void Draw(DrawContext context)
        {
            base.Draw(context);

            context.SpriteBatch.DrawString(font, Text, context.DrawOffset, Color);
        }
コード例 #5
0
ファイル: ImageControl.cs プロジェクト: hubo6/helloGame
        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);
        }