Example #1
0
        /// <summary>
        /// Draws the text entry feild to the screen, draws in reverse from right to left, to enable easier text overflow.
        /// </summary>
        /// <param name="g">the graphics object to draw to</param>
        public override void Draw(CompactGraphics g)
        {
            int diffrence = (Bounds.x2 - Bounds.x1);
            int iDif;

            for (int i = Bounds.x2; i >= Bounds.x1; i--)
            {
                iDif = i - Bounds.x1;
                // if the length of the text is greater than the width of the text box offset the 0 point by the overlap.
                if (text.Length > diffrence)
                {
                    g.Draw(text[iDif + (text.Length - diffrence - 1)], forColor, i, Bounds.y1);
                }
                else
                {
                    //otherwise draw either the text of the unflled character.
                    if (iDif < text.Length)
                    {
                        g.Draw(text[iDif], forColor, i, Bounds.y1);
                    }
                    else
                    {
                        g.Draw('_', forColor, i, Bounds.y1);
                    }
                }
            }
        }
        public override void Draw(CompactGraphics g)
        {
            g.Draw(rendered, Bounds.x1, Bounds.y1);

            char[][]         image;
            ConsoleColor[][] background;
            ConsoleColor[][] forground;
            int h = Height / 2;
            int w = Width;

            image      = new char[h + 1][];
            background = new ConsoleColor[h + 1][];
            forground  = new ConsoleColor[h + 1][];

            for (int i = 0; i <= h; i++)
            {
                image[i]      = new char[w + 1];
                forground[i]  = new ConsoleColor[w + 1];
                background[i] = new ConsoleColor[w + 1];

                for (int j = 0; j <= w; j++)
                {
                    image[i][j]      = pFull;
                    forground[i][j]  = ConsoleColor.Black;
                    background[i][j] = ConsoleColor.Black;
                }
            }

            rendered = new TFrame(image, background, forground);
        }
        public void Draw(CompactGraphics g, int x, int y, int maxX)
        {
            int offset = 0;

            foreach (var item in content)
            {
                g.Draw(item.text, item.forground, item.background, x + offset, y);
                offset += item.text.Length;
            }
        }
Example #4
0
        public override void Draw(CompactGraphics g)
        {
            int offset = 0;

            if (lines.Count - 1 > Bounds.height)
            {
                offset = lines.Count - Bounds.height;
            }
            for (int i = offset; i < lines.Count; i++)
            {
                g.Draw(lines[i], forColor, Bounds.x1, Bounds.y1 + i - offset);
            }
        }
 public override void Draw(CompactGraphics g)
 {
     for (int i = Bounds.x1; i <= Bounds.x2; i++)
     {
         for (int j = Bounds.y1; j <= Bounds.y2; j++)
         {
             if (i == Bounds.x1 || i == Bounds.x2 || j == Bounds.y1 || j == Bounds.y2)
             {
                 g.Draw(borderchar, forColor, i, j);
             }
             g.DrawBackground(backcolor, i, j);
         }
     }
 }
 public override void Draw(CompactGraphics g)
 {
     for (int i = 0; i < Bounds.y2 - Bounds.y1; i++)
     {
         if (i < lines.Count)
         {
             if (Bounds.y1 + i < Bounds.y2)
             {
                 g.Draw(lines[i], forColor, Bounds.x1, Bounds.y1 + i);
             }
         }
         g.DrawBGRectangle(backColor, Bounds.x1, Bounds.x2, Bounds.y1 + i, Bounds.y1 + i + 1);
     }
 }
        public void DrawHighlighted(CompactGraphics g, int x, int y, int maxX)
        {
            int offset = 0;

            ConsoleColor invert(ConsoleColor color)
            {
                return(color == ConsoleColor.Black ? ConsoleColor.White : color == ConsoleColor.White ? ConsoleColor.Black : color == ConsoleColor.Yellow ? ConsoleColor.DarkYellow : color == ConsoleColor.Blue ? ConsoleColor.DarkBlue : color);
            }

            foreach (var item in content)
            {
                g.Draw(item.text, invert(item.forground), invert(item.background), x + offset, y);
                offset += item.text.Length;
            }
        }
        public override void Draw(CompactGraphics g, Input.inpuT mouse)
        {
            if (Bounds.Overlaps(mouse.MouseX, mouse.MouseY))
            {
                switch (mouse.buttonState)
                {
                case 0:
                    tempback = hover_color;
                    if (mouseDown == 1)
                    {
                        OnClick(mouse);
                    }
                    mouseDown = 0;
                    break;

                case 1 when mouseDown == 0 || mouseDown == 1:
                    tempback  = ClickColor;
                    mouseDown = 1;
                    break;

                default:
                    tempback  = backColor;
                    mouseDown = 0;
                    break;
                }
            }
            else
            {
                tempback = backColor;
            }
            for (int i = 0; i < lines.Count; i++)
            {
                if (Bounds.y1 + i < Bounds.y2)
                {
                    g.Draw(lines[i], tempfor, Bounds.x1, Bounds.y1 + i);
                    g.DrawBGRectangle(tempback, Bounds.x1, Bounds.x2 - 1, Bounds.y1 + i, Bounds.y1 + i);
                }
            }
        }