Пример #1
0
        public void Draw(IRenderingContext renderContext)
        {
            if (texture == null)
                texture = renderContext.CreateColorResource(color);

            renderContext.Draw(texture, layer, new MegaMan.Common.Geometry.Point((int)x, (int)y),
                new MegaMan.Common.Geometry.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
Пример #2
0
            public void Draw(IRenderingContext renderContext, int layer, string text, Point position)
            {
                if (charTex == null)
                    charTex = renderContext.LoadResource(info.ImagePath);

                if (!info.CaseSensitive)
                {
                    text = text.ToUpper();
                }

                int xpos = position.X;

                foreach (char c in text)
                {
                    if (c == ' ')
                    {
                        xpos += info.CharWidth;
                        continue;
                    }

                    var location = info[c];

                    if (location != null)
                    {
                        renderContext.Draw(charTex, layer, new Point(xpos, position.Y),
                            new Rectangle(location.Value.X, location.Value.Y, info.CharWidth, info.CharWidth));

                        xpos += info.CharWidth;
                    }
                }
            }
Пример #3
0
        private void Draw(IRenderingContext context, float positionX, float positionY)
        {
            if (meterTexture == null)
            {
                meterTexture = context.LoadResource(this.info.Background);
                bounds = new RectangleF(positionX, positionY, meterTexture.Width, meterTexture.Height);
            }

            if (tickTexture == null)
                tickTexture = context.LoadResource(this.info.TickImage);

            if (tickTexture != null)
            {
                int i = 0;
                int ticks = (int)Math.Ceiling(value / tickSize);
                // prevent float errors
                if (ticks > 28) ticks = 28;

                if (meterTexture != null)
                    context.Draw(meterTexture, 4, new Common.Geometry.Point((int)positionX, (int)positionY));

                if (horizontal)
                {
                    for (int y = (int)positionX; i < ticks; i++, y += tickTexture.Width)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point(y, (int)positionY));
                    }
                }
                else
                {
                    for (int y = 54 + (int)positionY; i < ticks; i++, y -= tickTexture.Height)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point((int)(positionX + tickOffset.X), (int)(y + tickOffset.Y)));
                    }
                }
            }
        }