Beispiel #1
0
 protected GuiComponent(WindowManager manager)
 {
     Manager = manager;
     Manager.AddComponent(this);
     Position   = new Coord(0, 0);
     Dimensions = new GuiDimensions(new Size(), new Size());
 }
Beispiel #2
0
 public TextBox(GuiComponent parent, int width, Coord position) : base(parent, position)
 {
     Dimensions   = new GuiDimensions(new Size(width), new Size(1));
     Value        = "";
     BackGround   = ConsoleColor.DarkCyan;
     Foreground   = ConsoleColor.Yellow;
     OnUserEscape = () => { };
 }
Beispiel #3
0
        protected GuiComponent(GuiComponent parent)
        {
            this.Parent = parent;
            Manager     = parent.Manager;

            Position   = parent.GetInnerCanvasTopLeft();
            Dimensions = new GuiDimensions(new Size(), new Size());

            parent.RegisterChildComponent(this);
        }
Beispiel #4
0
        public TextArea(GuiComponent parent, int width, int height, string content, Coord position) : base(parent, position)
        {
            lines = (content ?? "").Split(new[] { '\n' }, StringSplitOptions.None).ToList();

            Dimensions = new GuiDimensions(new Size(width), new Size(height));

            BackGround   = ConsoleColor.DarkCyan;
            Foreground   = ConsoleColor.Yellow;
            OnUserEscape = () => { RemoveMeAndChildren(); };
        }
Beispiel #5
0
        public override Canvass Paint()
        {
            var size = Dimensions;

            if (Dimensions.IsFullyAutosize())
            {
                var childrensSize = GetSize();
                var width         = Math.Max(childrensSize.Width.Pixels, title.Length + CloseButton.Length);
                size = new GuiDimensions(new Size(width), childrensSize.Height);
            }
            var titleline = title.PadRight(size.Width.Pixels - CloseButton.Length) + CloseButton;

            var c = new Canvass();

            c.RawPaintString(titleline, 0, 0, ConsoleColor.DarkGray, ConsoleColor.Gray);
            var line = "".PadRight(size.Width.Pixels);

            for (int y = 1; y < size.Height.Pixels; y++)
            {
                c.RawPaintString(line, 0, y, BackGround, Foreground);
            }

            return(c);
        }
Beispiel #6
0
 public static GuiDimensions Max(GuiDimensions a, GuiDimensions b)
 {
     return(a > b ? a : b);
 }