Пример #1
0
        /// <summary>
        /// Draw the texture at DrawPosition combined with its offset
        /// </summary>
        public override void DrawMyData()
        {
            if (this.columnLineTextureNames == null)
            {
                return;
            }

            // draw the background
            // Manager.ImageCompositor.Draw(CurrentTextureName, this.State, GUIColor.White());

            // draw lines if needed
            if (this.configLineWidth <= 0)
            {
                return;
            }

            var tempState = new DrawState();

            // draw the column lines
            for (var i = 0; i < this.columnLineTextureNames.Length; i++)
            {
                tempState.DrawPosition = new DVector2((float)i * (this.cellWidth + this.configLineWidth), 0) + State.DrawPosition;
                tempState.Width = this.configLineWidth;
                tempState.Height = Config.Height;
                tempState.SourceRectangle = new Rectangle(0, 0, tempState.Width, tempState.Height);

                var name = this.columnLineTextureNames[i];
                Manager.ImageCompositor.Draw(name, tempState, GUIColor.White());

                // System.Diagnostics.Debug.WriteLine("Drawing column line at : " + tempState.DrawPosition + " to " + (tempState.DrawPosition + new DVector2(tempState.Width, tempState.Height)));
            }

            // draw the row lines
            for (var i = 0; i < this.rowLineTextureNames.Length; i++)
            {
                tempState.DrawPosition = new DVector2(0, (float)i * (this.cellHeight + this.configLineWidth)) + State.DrawPosition;
                tempState.Width = Config.Width;
                tempState.Height = this.configLineWidth;
                tempState.SourceRectangle = new Rectangle(0, 0, tempState.Width, tempState.Height);

                var name = this.rowLineTextureNames[i];
                Manager.ImageCompositor.Draw(name, tempState, GUIColor.White());

                // System.Diagnostics.Debug.WriteLine("Drawing row line at : " + tempState.DrawPosition + " to " + (tempState.DrawPosition + new DVector2(tempState.Width, tempState.Height)));
            }
        }
Пример #2
0
 /// <summary>
 /// Draws the specified texture using specified draw-state , with a tint color.
 /// </summary>
 /// <param name="name">The name of the item to draw.</param>
 /// <param name="drawState">The state that contains all the info to draw the item.</param>
 /// <param name="tintColor">The color to use to tint the shown item.</param>
 public abstract void Draw(string name, DrawState drawState, GUIColor tintColor);
Пример #3
0
        /// <summary>
        /// Draws the specified texture using specified draw-state , with a tint color.
        /// </summary>
        /// <param name="name">The name of the item to draw.</param>
        /// <param name="drawState">The state that contains all the info to draw the item.</param>
        /// <param name="tintColor">The color to use to tint the shown item.</param>
        public override void Draw(string name, DrawState drawState, GUIColor tintColor)
        {
#if DEBUG
            if (drawState == null)
            {
                throw new ArgumentNullException("drawState", "DrawState is used for drawing. This can not be Null.");
            }
#endif
            // get the texture to draw
            var texture = this.resourcesTexture.Read(name);

            // calculate what part to draw where
            var scaleVector = new Vector2(drawState.Width / texture.Width, drawState.Height / texture.Height);
            var position = new Vector2(drawState.DrawPosition.X + drawState.Offset.X, drawState.DrawPosition.Y + drawState.Offset.Y);
            var origin = new Vector2();
            var color = new Color(tintColor.R, tintColor.G, tintColor.B, tintColor.A);
            
            Rectangle srcRect;
            if (drawState.SourceRectangle == null)
            {
                srcRect = new Rectangle(0, 0, texture.Width, texture.Height);
            }
            else
            {
                srcRect = new Rectangle((int)drawState.SourceRectangle.PositionX, (int)drawState.SourceRectangle.PositionY, (int)drawState.SourceRectangle.Width, (int)drawState.SourceRectangle.Height);
            }

            this.spriteBatch.Draw(
                                texture, 
                                position, 
                                srcRect, 
                                color, 
                                0, 
                                origin, 
                                scaleVector, 
                                SpriteEffects.None, 
                                0);
        }