Ejemplo n.º 1
0
        protected override void Drawing(ITerminal <TGlyph, TColor> terminal)
        {
            int itemWidth = Width - 1;
            int i         = 0;

            foreach (var item in _items)
            {
                if (i > Height)
                {
                    throw new Exception();
                }
                terminal.DrawString(Left + 1, Top + i, item.Glyphs.Fit(itemWidth, EllipsisGlyph),
                                    ColorTheme.Foreground, ColorTheme.Background);
                if (_unselectedItemIndex.HasValue && item == _items[_unselectedItemIndex.Value])
                {
                    terminal.Clear(Left, Top + i);
                    _unselectedItemIndex = null;
                }
                if (i == _selectedItemIndex)
                {
                    terminal.Draw(Left, Top + i, SelectionGlyph, ColorTheme.Foreground, ColorTheme.Background);
                }
                i++;
            }
        }
Ejemplo n.º 2
0
 public static void DrawWalls <TGlyph, TTerminalColor>(this ITerminal <TGlyph, TTerminalColor> terminal,
                                                       IEnumerable <Tuple <int, int> > walls, TGlyph wallGlyph, TTerminalColor foreground, TTerminalColor background)
 {
     foreach (var wall in walls)
     {
         terminal.Draw(wall.Item1, wall.Item2, wallGlyph, foreground, background);
     }
 }
Ejemplo n.º 3
0
        private static void Drawing(ITerminal <TGlyph, TColor> terminal, int left, int top, int width, int height,
                                    BorderTheme <TGlyph> borderTheme, ColorTheme <TColor> colorTheme)
        {
            terminal.Draw(left, top, borderTheme.TopLeft, colorTheme.Foreground, colorTheme.Background);
            terminal.DrawLine(left + 1, top, left + width - 2, top, borderTheme.Top, colorTheme.Foreground, colorTheme.Background);

            terminal.Draw(left + width - 1, top, borderTheme.TopRight, colorTheme.Foreground, colorTheme.Background);
            terminal.DrawLine(left + width - 1, top + 1, left + width - 1, top + height - 2, borderTheme.Right,
                              colorTheme.Foreground, colorTheme.Background);

            terminal.Draw(left + width - 1, top + height - 1, borderTheme.BottomRight, colorTheme.Foreground,
                          colorTheme.Background);
            terminal.DrawLine(left + width - 2, top + height - 1, left + 1, top + height - 1, borderTheme.Bottom,
                              colorTheme.Foreground, colorTheme.Background);

            terminal.Draw(left, top + height - 1, borderTheme.BottomLeft, colorTheme.Foreground, colorTheme.Background);
            terminal.DrawLine(left, top + height - 2, left, top + 1, borderTheme.Left, colorTheme.Foreground,
                              colorTheme.Background);
        }
Ejemplo n.º 4
0
 public static void FillRectangle <TGlyph, TTerminalColor>(this ITerminal <TGlyph, TTerminalColor> terminal,
                                                           int left, int top, int width, int height, TGlyph glyph, TTerminalColor foreground, TTerminalColor background)
 {
     for (var x = left; x < left + width; x++)
     {
         for (var y = top; y < top + height; y++)
         {
             terminal.Draw(x, y, glyph, foreground, background);
         }
     }
 }
Ejemplo n.º 5
0
        public static void DrawString <TGlyph, TTerminalColor>(this ITerminal <TGlyph, TTerminalColor> terminal,
                                                               int x, int y, IEnumerable <TGlyph> @string, TTerminalColor foreground, TTerminalColor background)
        {
            var i = 0;

            foreach (var glyph in @string)
            {
                terminal.Draw(x + i, y, glyph, foreground, background);
                i++;
            }
        }
Ejemplo n.º 6
0
 public static void DrawLine <TGlyph, TTerminalColor>(this ITerminal <TGlyph, TTerminalColor> terminal,
                                                      int x1, int y1, int x2, int y2, TGlyph glyph, TTerminalColor foreground, TTerminalColor background)
 {
     if (x1 == x2)
     {
         for (var y = Math.Min(y1, y2); y <= Math.Max(y1, y2); y++)
         {
             terminal.Draw(x1, y, glyph, foreground, background);
         }
     }
     else if (y1 == y2)
     {
         for (var x = Math.Min(x1, x2); x <= Math.Max(x1, x2); x++)
         {
             terminal.Draw(x, y1, glyph, foreground, background);
         }
     }
     else
     {
         throw new Exception("Only horizontal or vertical lines allowed now.");
     }
 }
 protected override void Drawing(int x, int y, TGlyph glyph, TColor foreground, TColor background)
 {
     _terminal.Draw(x + _offsetX, y + _offsetY, glyph, foreground, background);
 }