protected GuiComponent(WindowManager manager) { Manager = manager; Manager.AddComponent(this); Position = new Coord(0, 0); Dimensions = new GuiDimensions(new Size(), new Size()); }
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 = () => { }; }
protected GuiComponent(GuiComponent parent) { this.Parent = parent; Manager = parent.Manager; Position = parent.GetInnerCanvasTopLeft(); Dimensions = new GuiDimensions(new Size(), new Size()); parent.RegisterChildComponent(this); }
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(); }; }
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); }
public static GuiDimensions Max(GuiDimensions a, GuiDimensions b) { return(a > b ? a : b); }