/// <summary>
        /// This function renders the contents of the console
        /// </summary>
        /// <param name="CurrTime">Current time information</param>
        protected override void DrawContents(GameTime CurrTime)
        {
            Rectangle LetterPos = new Rectangle(0, 0, cFont.CharacterHeight, cFont.CharacterWidth);

            //Draw the current command
            LetterPos.Y = ClientRegion.Height - cFont.CharacterHeight;
            cFont.WriteText(cDrawBatch, cCommand, LetterPos.Y, LetterPos.X, cFontColor);

            if (cCursorOn == true)
            {
                cFont.WriteAsciiCharacter(cDrawBatch, new byte[] { 220 }, cFont.CharacterHeight, LetterPos.Y, cFont.DetermineRenderWidth(cCommand), cFontColor);
            }

            //Draw all text lines in reverse order (bottom to top)
            if (cLines.Count > 0)
            {
                LetterPos.Y -= cFont.CharacterHeight;
                for (int Ctr = cLines.Count - 1; Ctr >= 0; Ctr--)
                {
                    cFont.WriteText(cDrawBatch, cLines[Ctr], LetterPos.Y, LetterPos.X, cFontColor);

                    LetterPos.Y -= cFont.CharacterHeight;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Function to render the contents of hte control to the screen or rendering targetsd
        /// </summary>
        /// <param name="CurrTime">Current time information</param>
        protected override void DrawContents(GameTime CurrTime)
        {
            string[] Lines;
            int      Ctr, LineWidth, LinesHeight, TextTop, TextLeft;

            if (cCaption.Length != 0)
            {
                Lines = cCaption.Split('\n');

                LinesHeight = Lines.Length * FontSize;

                for (Ctr = 0; Ctr < Lines.Length; Ctr++)
                {
                    LineWidth = cFont.DetermineRenderWidth(Lines[Ctr], FontSize);

                    switch (Alignment)
                    {
                    case Justify.TopLeft:
                        TextTop  = 0 + (Ctr * FontSize);
                        TextLeft = 0;
                        break;

                    case Justify.TopCenter:
                        TextTop  = 0 + (Ctr * FontSize);
                        TextLeft = (Width - LineWidth) / 2;
                        break;

                    case Justify.TopRight:
                        TextTop  = 0 + (Ctr * FontSize);
                        TextLeft = Width - LineWidth;
                        break;

                    case Justify.MiddleLeft:
                        TextTop  = ((Height - LinesHeight) / 2) + (Ctr * FontSize);
                        TextLeft = 0;
                        break;

                    case Justify.MiddleRight:
                        TextTop  = ((Height - LinesHeight) / 2) + (Ctr * FontSize);
                        TextLeft = Width - LineWidth;
                        break;

                    case Justify.BottomLeft:
                        TextTop  = (Height - LinesHeight) + (Ctr * FontSize);
                        TextLeft = 0;
                        break;

                    case Justify.BottomCenter:
                        TextTop  = (Height - LinesHeight) + (Ctr * FontSize);
                        TextLeft = (Width - LineWidth) / 2;
                        break;

                    case Justify.BottomRight:
                        TextTop  = (Height - LinesHeight) + (Ctr * FontSize);
                        TextLeft = Width - LineWidth;
                        break;

                    default:                              //Middle Center
                        TextTop  = ((Height - LinesHeight) / 2) + (Ctr * FontSize);
                        TextLeft = (Width - LineWidth) / 2;
                        break;
                    }

                    cFont.WriteText(cDrawBatch, Lines[Ctr], FontSize, TextTop, TextLeft, FontColor);
                }
            }
        }