public static BorderBuilder CreateThinWindowStyle(CharColors borderColors) { return(new BorderBuilder( topLeft: new FormattedString("┌\r\n│\r\n├", borderColors), topRight: new FormattedString("┐\r\n│\r\n┤", borderColors), bottomLeft: new FormattedString("└", borderColors), bottomRight: new FormattedString("┘", borderColors), leftStroke: new FormattedString("│", borderColors), topStroke: new FormattedString("─\r\n\r\n─", borderColors), rightStroke: new FormattedString("│", borderColors), bottomStroke: new FormattedString("─", borderColors))); }
public static BorderBuilder CreateThickStyle(CharColors borderColors) { return(new BorderBuilder( true, topLeft: new FormattedString("╔", borderColors), topRight: new FormattedString("╗", borderColors), bottomLeft: new FormattedString("╚", borderColors), bottomRight: new FormattedString("╝", borderColors), leftStroke: new FormattedString("║", borderColors), topStroke: new FormattedString("═", borderColors), rightStroke: new FormattedString("║", borderColors), bottomStroke: new FormattedString("═", borderColors))); }
public static BorderBuilder CreateExtraThickStyle(CharColors borderColors) { return(new BorderBuilder( true, topLeft: new FormattedString("╔═╦\r\n╠═╬", borderColors), topRight: new FormattedString("╦═╗\r\n╬═╣", borderColors), bottomLeft: new FormattedString("╠═╬\r\n╚═╩", borderColors), bottomRight: new FormattedString("╬═╣\r\n╩═╝", borderColors), leftStroke: new FormattedString("║ ║", borderColors), topStroke: new FormattedString("═\r\n═", borderColors), rightStroke: new FormattedString("║ ║", borderColors), bottomStroke: new FormattedString("═\r\n═", borderColors))); }
public static BorderBuilder CreateThinStyle(CharColors borderColors) { return(new BorderBuilder( true, topLeft: new FormattedString("┌", borderColors), topRight: new FormattedString("┐", borderColors), bottomLeft: new FormattedString("└", borderColors), bottomRight: new FormattedString("┘", borderColors), leftStroke: new FormattedString("│", borderColors), topStroke: new FormattedString("─", borderColors), rightStroke: new FormattedString("│", borderColors), bottomStroke: new FormattedString("─", borderColors))); }
public Solid( LayoutManager layoutManager, Region region, BorderBuilder borderBuilder, string name, CharColors fill) : base( layoutManager, region, borderBuilder, name) { this.fill = new Fill(this.InnerRegion, fill); }
public static BorderBuilder CreateExtraThickWindowStyle( CharColors borderColors, FormattedString?defaultNamePlate = null) { return(new BorderBuilder( defaultNamePlate, topLeft: new FormattedString("╔═╦\r\n║ ║\r\n╠═╬", borderColors), topRight: new FormattedString("╦═╗\r\n║ ║\r\n╬═╣", borderColors), bottomLeft: new FormattedString("╠═╬\r\n╚═╩", borderColors), bottomRight: new FormattedString("╬═╣\r\n╩═╝", borderColors), leftStroke: new FormattedString("║ ║", borderColors), topStroke: new FormattedString("═\r\n\r\n═", borderColors), rightStroke: new FormattedString("║ ║", borderColors), bottomStroke: new FormattedString("═\r\n═", borderColors))); }
public Fill(IReadOnlyRegion region, CharColors fill) { void Fill(IReadOnlyRegion fillToSize) { this.undelayedContent = new CharInfo[fillToSize.Height, fillToSize.Width]; this.undelayedContent.Fill(new CharInfo(' ', fill)); } this.Region = new Region(region); Fill(this.Region); this.Region.OnChanged += (obj, e) => { if (e.ChangeTypes.HasFlag(RegionChangeTypes.Resize)) { Fill(e.AfterChange); } }; }
public void Spooky() { Random random = new Random(); using (Source source = new Source()) using (Sink sink = new Sink("Game", Height, Width)) { ////CharInfo[,] info = new CharInfo[Height, Width]; ////for (int x = 0; x < Width; x++) ////{ //// for (int y = 0; y < Height; y++) //// { //// info[y, x] = new CharInfo(new CharUnion(), CharColors.GetRandom(random)); //// } ////} ////sink.WriteRegion( //// info, //// 0, //// 0); sink.Write("aaa"); sink.Write(default(CharInfo), Coord.Zero); sink.WriteRegion( new CharInfo[3, 3], new Coord(0, 0)); CharColors borderColors = new CharColors(ConsoleColor.Blue, ConsoleColor.Black); BorderBuilder builder = BorderBuilder.CreateExtraThickWindowStyle(borderColors); Region region = new Region(new Coord(0, 0), new Coord(50, 15)); Border border = builder.Build( region, new FormattedString( "═══════════\r\n<span fg=Red bg=Green dtime=100>Hello World</span>", borderColors)); border.Draw(sink); Text foo = new Text( new FormattedString( "Foo bar baz bazinga bazongo bingo bango bongo I don't want to leave the Congo oh no no no no no", new CharColors(ConsoleColor.Green, ConsoleColor.Black)), border.InnerRegion); foo.Draw(sink); Region otherRegion = new Region(new Coord(25, 5), new Coord(115, 28)); Border otherBorder = builder.Build(otherRegion); otherBorder.Draw(sink); Text bar = new Text( new FormattedString( LoremIpsum, new CharColors(ConsoleColor.Magenta, ConsoleColor.Black)), otherBorder.InnerRegion); bar.Draw(sink); ////sink.Write( //// "Hello, this is a test of a very long string which is being written with a delay inserted between printing of each character. I want to see if it will properly scroll, or if I'm going to need to do spooky math myself to make it work.", //// new CharColors(ConsoleColor.Green, ConsoleColor.Black), //// new Coord(30, 10), //// 35, //// DelayMode.PerWord); LayoutManager layout = new LayoutManager( sink, () => source.LeftMouseDown, () => source.RightMouseDown, false); Solid background = new Solid( layout, new Region(new Coord(2, 0), new Coord(Width, Height)), BorderBuilder.CreateThinStyle(borderColors), "background", CharColors.Standard); Button button = new Button( layout, new Region(new Coord(12, 12), new Coord(30, 20)), BorderBuilder.CreateThinWindowStyle(borderColors), "button", "Hello", Alignments.Default, CharColors.Standard); button.OnClicked += (obj, e) => { button.Text = new string(Enumerable .Range(0, random.Next(3, 9)) .Select(x => (char)random.Next(65, 91)) .ToArray()); }; layout.Add(background); layout.Add(button); Region constrainRegion = new Region(background.InnerRegion); constrainRegion.TopLeft += new Coord(1, 0); constrainRegion.BottomRight -= new Coord(1, 0); layout.SetConstraint(button, constrainRegion); source.OnKeyPressed += (obj, e) => { layout.KeyPressed(e); switch (e.Key) { case ConsoleKey.UpArrow: bar.AdjustLinesSkipped(-1); bar.Draw(sink); break; case ConsoleKey.DownArrow: bar.AdjustLinesSkipped(1); bar.Draw(sink); break; case ConsoleKey.PageDown: bar.AdjustLinesSkipped(bar.MaximumVisibleLines); bar.Draw(sink); break; case ConsoleKey.PageUp: bar.AdjustLinesSkipped(-bar.MaximumVisibleLines); bar.Draw(sink); break; case ConsoleKey.Spacebar: layout.Draw(); break; default: break; } }; source.OnLeftMouse += (obj, e) => { layout.LeftMouseEvent(e.Position, e.ButtonDown); }; source.OnRightMouse += (obj, e) => { layout.RightMouseEvent(e.Position, e.ButtonDown); }; source.OnMouseMove += (obj, e) => { layout.MouseMoveEvent(e.PreviousPosition, e.CurrentPosition); }; source.OnVerticalMouseWheel += (obj, e) => { layout.ScrollEvent(e.Position, e.Down); if (e.Down) { bar.AdjustLinesSkipped(3); } else { bar.AdjustLinesSkipped(-3); } bar.Draw(sink); }; layout.Active = true; source.DelayUntilExitAccepted(default).Wait();