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);
        }
Example #2
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 ExampleMenu(ComapactGraphicsV2.CompactGraphics graphics) : base(graphics)
        {
            Random rng = new Random();

            listItems = new List <StyledTextT>();
            for (int i = 0; i < 200; i++)
            {
                listItems.Add(new StyledTextT()
                {
                    content = new List <ColoredStringT>()
                    {
                        new ColoredStringT($"S{rng.Next()}")
                    }
                });
            }
            test = new Frame('#', new Rect(1, 9, 1, 9), ConsoleColor.White, ConsoleColor.Black, Widget.DrawPoint.Center);
            onPage.Add(test);
            r         = new Rect(20, 40, 40, 60);
            content   = new Life(80, 60, 100, 50);
            pallet    = new ExtendedColors();
            pixelGrid = new PixelGrid(r);
            testGrid  = new PixelGrid(new Rect(10, 50, 30, 70));
            //onPage.Add(testGrid);
            onPage.Add(pixelGrid);


            onPage.Add(new ListBox(listItems, new Rect(20, 120, 10, 20), true));
            //onPage.Add(new ListBox(new List<Textbox>(), new Rect(10,40,5,40)));
            //onPage.Add(new Frame('%', r));
            //onPage.Add(new Button(r, "This is some text"));
        }
Example #4
0
 public CompactGui(CompactGraphics g)
 {
     NavHyrachy   = new Dictionary <string, NavItemT>();
     TravelLog    = new List <string>();
     currentIndex = -1;
     this.g       = g;
     current      = new Menu(g);
     IndexMenu    = typeof(Menu);
 }
        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;
            }
        }
 public override void Draw(CompactGraphics g, Input.inpuT input)
 {
     if (isIteractable)
     {
         inputAction(input);
     }
     else
     {
         action();
     }
 }
        public override void Draw(CompactGraphics g)
        {
            int yOffset = 0;

            foreach (StyledTextT line in lines)
            {
                if (yOffset < Bounds.height)
                {
                    line.Draw(g, Bounds.x1, Bounds.y1 + yOffset, Bounds.x2);
                }
            }
        }
Example #8
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);
     }
 }
Example #11
0
 /// <summary>
 /// Update the text entry with a key input then draw to the screen buffer.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="keyInfo"></param>
 public override void Draw(CompactGraphics g, ConsoleKeyInfo keyInfo)
 {
     if (keyInfo.Key != ConsoleKey.Backspace)
     {
         text += keyInfo.KeyChar;
     }
     else if (keyInfo.Key == ConsoleKey.Backspace)
     {
         if (text.Length > 0)
         {
             text = text.Remove(text.Length - 1);
         }
     }
     Draw(g);
 }
        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);
                }
            }
        }
Example #14
0
 public CompactGui(CompactGraphics g, Menu Index) : this(g)
 {
     current   = Index;
     IndexMenu = Index.GetType();
 }
Example #15
0
 public Menu(CompactGraphics g, object state) : this(g)
 {
 }
Example #16
0
 public Menu(CompactGraphics g)
 {
     this.g = g;
     status = -1;
     onPage = new List <Widget>();
 }
 public override void Draw(CompactGraphics g)
 {
     action();
 }
 public override void Draw(CompactGraphics g, Input I)
 {
     Draw(g);
 }
 public override void Draw(CompactGraphics g, ConsoleKeyInfo keyInfo)
 {
     Draw(g);
 }