Пример #1
0
        //+~~~~~~~~~~+\
        //|          |_\
        //|             |
        //|             |
        //+~~~~~~~~~~~~~+
        private static void PaintNote(Canvass canvass, Note note, bool paintSelectableIds)
        {
            int px = note.Pos.X, py = note.Pos.Y;
            var rows = note.Text.Split('\n');

            for (var y = 0; y < note.H; y++)
            {
                if (y == 0)
                {
                    var line = "~".Repeat(note.W - 3);
                    Canvass.PaintString(canvass, $"+{line}+\\", px, py + y, note.Id, ConsoleColor.Black, ConsoleColor.Gray);
                }
                else if (y == 1)
                {
                    var line = "".PadLeft(note.W - 3);
                    Canvass.PaintString(canvass, $"|{line}|_\\", px, py + y, note.Id, ConsoleColor.Black, ConsoleColor.Gray);
                }
                else if (y < note.H - 1)
                {
                    var line = rows[y - 2].PadRight(note.W - 1);
                    Canvass.PaintString(canvass, $"|{line}|", px, py + y, note.Id, ConsoleColor.Black, ConsoleColor.Gray);
                }
                else
                {
                    var line = "~".Repeat(note.W - 1);
                    Canvass.PaintString(canvass, $"+{line}+", px, py + y, note.Id, ConsoleColor.Black, ConsoleColor.Gray);
                }
            }

            if (paintSelectableIds)
            {
                canvass.RawPaintString(note.Id.ToString(), note.Pos, ConsoleColor.DarkGreen, ConsoleColor.Green);
            }
        }
Пример #2
0
        private static void PaintLabel(Canvass canvass, Label label, bool paintSelectableIds)
        {
            var lines = label.Text.Split('\n');

            switch (label.Direction)
            {
            case LabelDirection.LeftToRight:
                lines.Each((line, extraY) => Canvass.PaintString(canvass, line, label.X, label.Y + extraY, label.Id, ConsoleColor.Black,
                                                                 ConsoleColor.Gray));
                break;

            case LabelDirection.TopDown:
                var extraX = 0;
                foreach (var line in lines)
                {
                    for (var i = 0; i < line.Length; i++)
                    {
                        canvass.Paint(new Coord(label.X + extraX, label.Y + i), line[i], label.Id);
                    }
                    extraX++;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (paintSelectableIds)
            {
                canvass.RawPaintString(label.Id.ToString(), label.Pos, ConsoleColor.DarkGreen, ConsoleColor.Green);
            }
        }
Пример #3
0
        public static void PaintBox(Canvass c, Box b)
        {
            b.GetFrameCoords().Each(pos => c.Paint(pos, '*', b.Id));
            const int padX = 2, padY = 1;             // TODO make padding configurable pr. box

            if (!string.IsNullOrWhiteSpace(b.Text))
            {
                b.Text.Split('\n').Each((text, i) => Canvass.PaintString(c, text, b.X + padX, b.Y + padY + i, b.Id, ConsoleColor.Black, ConsoleColor.Gray));
            }
        }
Пример #4
0
        public static void PaintBox(Canvass c, Box b, bool paintSelectableIds)
        {
            b.GetFrameParts().Each(part => c.Paint(part.Item1, GetCharForStyle(b.Style, part.Item2), b.Id));
            const int padX = 2, padY = 1;             // TODO make padding configurable pr. box

            if (!string.IsNullOrWhiteSpace(b.Text))
            {
                b.Text.Split('\n').Each((text, i) =>
                                        Canvass.PaintString(c, text, b.X + padX, b.Y + padY + i, b.Id, ConsoleColor.Black, ConsoleColor.Gray));
            }

            if (paintSelectableIds)
            {
                c.RawPaintString(b.Id.ToString(), b.Pos, ConsoleColor.DarkGreen, ConsoleColor.Green);
            }
        }
Пример #5
0
        private static void PaintUmlUser(Canvass canvass, UmlUser user, bool paintSelectableIds)
        {
            var gfx = @"
,-.
`-'
/|\
 |
/ \
" + (user.Text ?? "");

            var lines = gfx.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Each((line, row) => Canvass.PaintString(canvass, line, user.Pos.X, user.Pos.Y + row, user.Id));

            if (paintSelectableIds)
            {
                canvass.RawPaintString(user.Id.ToString(), user.Pos, ConsoleColor.DarkGreen, ConsoleColor.Green);
            }
        }