示例#1
0
        public void Draw(IRender render, Vector2 position)
        {
            render.AddViewRect(new ViewRect((int)Math.Round(position.X, 0), (int)Math.Round(position.Y, 0), Width, Height));

            if (currentAnimation == null)
            {
                return;
            }

            render.Begin();

            for (int n = 0; n < currentAnimation.Textures.Length; n++)
            {
                if (textureTimes[n] <= CurrentTime && textureTimeToEnd[n] >= CurrentTime)
                {
                    Vector2 pos = position;
                    if (SpriteEffect == SpriteEffects.FlipHorizontally)
                    {
                        pos.X += currentAnimation.Width;
                    }
                    if (SpriteEffect == SpriteEffects.FlipVertically)
                    {
                        pos.Y += currentAnimation.Height;
                    }

                    currentAnimation.Textures[n].Draw(render, position, SpriteEffect);
                }
            }

            render.End();
        }
示例#2
0
        void DrawOpen(GameTime gameTime, ViewRect viewRect)
        {
            if (IsClosed || !IsInitialized || !Activated || Hidden)
            {
                return;
            }

            viewRect.Add(MasterBoundaries);
            IRender render = GraphicsManager.GetRender();

            int x = RealX;
            int y = RealY;

            render.AddViewRect(new ViewRect(x, y + TextFieldHeight, TextFieldWidth, OpenHeight - TextFieldHeight));

            render.Begin();

            render.DrawRect(new Rectangle(x, y + TextFieldHeight, TextFieldWidth, OpenHeight - TextFieldHeight), OpenBackgroundColor);

            //DrawSprite items
            int drawY = y + TextFieldHeight - ItemPositionY + itemMargin;

            foreach (string line in Items)
            {
                Rectangle area = new Rectangle(x, drawY, TextFieldWidth, Font.CharHeight + Font.VerticalSpace);
                if (IsMouseInRect(area))
                {
                    render.DrawRect(area, MouseOverElementColor);
                }

                Font.DrawString(line, new Point(x + itemMargin, drawY), OpenFontColor, render);
                drawY += Font.CharHeight + Font.VerticalSpace;
            }

            render.End();
        }
示例#3
0
        public override void Project(Microsoft.Xna.Framework.GameTime gameTime, int x, int y, IRender render)
        {
            render.Begin();

            int n     = 0;
            int drawX = x + textMargin;

            foreach (string name in columnNames)
            {
                bool pressed = n == pressedColumnButton;

                int size = columnSizes[n];

                bool quit = false;
                if (drawX + columnSizes[n] >= RealX + Width)
                {
                    size = RealX + Width - drawX;
                    quit = true;
                }

                DrawButton(drawX, y, render, name, size, pressed);

                if (quit)
                {
                    break;
                }

                drawX += columnSizes[n];

                n += 1;
            }

            y += HeaderSize;

            render.DrawSprite(TopLeftCorner, new Vector2(x, y), Color.White);
            render.DrawSprite(TopRightCorner, new Vector2(x + Width - TopRightCorner.Width, y), Color.White);
            render.DrawSprite(BottomLeftCorner, new Vector2(x, y + Height - HeaderSize - BottomLeftCorner.Height), Color.White);
            render.DrawSprite(BottomRightCorner, new Vector2(x + Width - BottomRightCorner.Width, y + Height - HeaderSize - BottomRightCorner.Height), Color.White);

            render.DrawSprite(TopBorder, new Rectangle(x + TopLeftCorner.Width, y, Width - TopLeftCorner.Width - TopRightCorner.Width, TopBorder.Height), Color.White);
            render.DrawSprite(BottomBorder, new Rectangle(x + BottomLeftCorner.Width, y + Height - HeaderSize - BottomBorder.Height, Width - BottomLeftCorner.Width - BottomRightCorner.Width, BottomBorder.Height), Color.White);
            render.DrawSprite(LeftBorder, new Rectangle(x, y + TopLeftCorner.Height, LeftBorder.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height), Color.White);
            render.DrawSprite(RightBorder, new Rectangle(x + Width - RightBorder.Width, y + TopLeftCorner.Height, RightBorder.Width, Height - HeaderSize - TopRightCorner.Height - BottomRightCorner.Height), Color.White);

            render.DrawSprite(Inside, new Rectangle(x + TopLeftCorner.Width, y + TopLeftCorner.Height, Width - BottomLeftCorner.Width - BottomRightCorner.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height), Color.White);

            render.End();

            //DrawSprite list items:

            render.AddViewRect(new ViewRect(RealX + TopLeftCorner.Width,
                                            RealY + TopLeftCorner.Height + HeaderSize,
                                            Width - TopLeftCorner.Width - TopRightCorner.Width,
                                            Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height));

            render.Begin();

            int rowX      = RealX + TopLeftCorner.Width + textMargin;
            int rowY      = RealY + TopLeftCorner.Height + HeaderSize + textMargin;
            int rowNumber = 0;

            foreach (ListBoxRow row in Values)
            {
                if (rowNumber == rowUnderMouse)
                {
                    render.DrawRect(new Rectangle(rowX, rowY, Width - TopLeftCorner.Width - TopRightCorner.Width, Font.CharHeight + textMargin), ElementUnderMouseColor);
                }
                if (row == SelectedRow)
                {
                    render.DrawRect(new Rectangle(rowX, rowY, Width - TopLeftCorner.Width - TopRightCorner.Width, Font.CharHeight + textMargin), SelectedElementColor);
                }

                int index = 0;
                foreach (object val in row.Values)
                {
                    string valStr = val == null ? "NULL" : val.ToString();

                    Font.DrawString(valStr, new Point(rowX, rowY), ListElementColor, render);
                    rowX  += ColumnSizes[index];
                    index += 1;
                }

                rowX  = RealX + TopLeftCorner.Width + textMargin;
                rowY += Font.CharHeight + textMargin;

                rowNumber += 1;
            }

            render.End();
        }