public Button( LayoutManager layoutManager, Region region, BorderBuilder borderBuilder, string name, FormattedString content, Alignments alignments, CharColors?backgroundFill = null) : base( layoutManager, region, borderBuilder, name) { this.text = content; this.alignments = alignments; this.inverted = false; if (backgroundFill.HasValue) { this.background = new Fill(this.InnerRegion, backgroundFill.Value); } this.InnerRegion.OnChanged += (obj, e) => this.label.Region.TryTranslate(e.AfterChange.TopLeft - e.BeforeChange.TopLeft, out _); this.Recalculate(); }
private Border[] FindAllBorders(Joint[] AllJoints, bool inner) { ArrayList res = new ArrayList(); for (int i = 0; i < AllJoints.Length; ++i) { if (!AllJoints[i].forwardUsed) { BorderBuilder bb = FindBorder(AllJoints[i], true); if (bb != null && bb.IsOriented == inner && bb.IsClosed) { res.Add(bb.BuildBorder(true)); } } if (!AllJoints[i].reverseUsed) { BorderBuilder bb = FindBorder(AllJoints[i], false); if (bb != null && bb.IsOriented == inner && bb.IsClosed) { res.Add(bb.BuildBorder(true)); } } } return((Border[])res.ToArray(typeof(Border))); }
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 Solid( LayoutManager layoutManager, Region region, BorderBuilder borderBuilder, string name, FormattedString fill, CharColors?backgroundFill = null) : base( layoutManager, region, borderBuilder, name) { this.fill = new Fill(this.InnerRegion, fill, backgroundFill); }
private void FillCheckTable(TableBuilder tableBuilder) { tableBuilder.SetWidth(PageWidth / 2 - 8).SetBorder(Stroke.None) .AddColumnPercent("", 100); var rowBuilder = tableBuilder.AddRow(); rowBuilder.SetBorder(BorderBuilder.New() .SetRightWidth(0) .SetTopWidth(0) .SetLeftWidth(0) .SetBottomWidth(0.5f) .SetBottomStroke(Stroke.Solid) ); var cellBuilder = rowBuilder.AddCell().SetPadding(0, 4, 0, 4); var paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .AddTextToParagraph("o", FNTZ12) .AddTextToParagraph(" Please check box if address is incorrect or insurance information has changed, and indicate change(s) on reverse side.", FNT7); rowBuilder = tableBuilder.AddRow(); rowBuilder.SetBorder(borderBuilder => { borderBuilder.SetWidth(0); }); cellBuilder = rowBuilder.AddCell().SetPadding(0, 4, 0, 0); paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .SetFont(FNT8B) .AddTextToParagraph("MAKE CHECKS PAYABLE TO"); paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .SetFont(FNT9B_B) .AddTextToParagraph(ps.CenterName + "\n" + ps.CenterAddress); paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .SetMarginTop(20).SetFont(FNT8B) .AddTextToParagraph("CHANGE SERVICE REQUESTED"); paragraphBuilder = cellBuilder.AddParagraph(); paragraphBuilder .SetFont(FNT9) .AddTextToParagraph("For Billing inquries: " + ps.CenterPhone + "\nPatent Name: " + ps.CenterPatent); }
private void BuildBody(SectionBuilder sectionBuilder) { var tableBuilder = sectionBuilder.AddTable(); tableBuilder .SetWidth(XUnit.FromPercent(100)) .SetBorder(Stroke.None) .AddColumnPercentToTable("", 17) .AddColumnPercentToTable("", 47) .AddColumnPercentToTable("", 12) .AddColumnPercentToTable("", 12) .AddColumnPercent("", 12); var rowBuilder = tableBuilder.AddRow(); rowBuilder .SetBackColor(BLUE_COLOR) .SetFont(FNT9B_W) .SetHorizontalAlignment(HorizontalAlignment.Center); var cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .AddParagraphToCell("Date of Service"); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .AddParagraphToCell("Description"); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell("Charges"); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell("Payment/ Adjustments"); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell("Patient Balance"); int i = rowsData.Count; foreach (RowData rowData in rowsData) { FontBuilder curFont = (--i) == 0 ? FNT10B : FNT10; rowBuilder = tableBuilder.AddRow(); rowBuilder .SetFont(curFont) .SetBorder(BorderBuilder.New() .SetRightWidth(0) .SetTopWidth(0) .SetLeftWidth(0) .SetBottomWidth(0.5f) .SetBottomStroke(Stroke.Solid) ); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .AddParagraphToCell(rowData.Date); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .AddParagraphToCell(rowData.Description); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell(rowData.Charges); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell(rowData.Payment); cellBuilder = rowBuilder.AddCell(); cellBuilder .SetPadding(4) .SetHorizontalAlignment(HorizontalAlignment.Right) .AddParagraphToCell(rowData.Balance); } }
private BorderBuilder FindBorder(Joint startWith, bool forward) { BorderBuilder bb = new BorderBuilder(); bb.Precision = clusterSize; if (startWith.curve.Length == 0.0) { return(null); // sollte nicht vorkommen, kommt aber vor } bb.AddSegment(startWith.curve.CloneReverse(!forward)); Cluster cl; Cluster startCluster; if (forward) { cl = startWith.EndCluster; startCluster = startWith.StartCluster; // hier sollte eine Exception geworfen werden wenn schon benutzt!! if (startWith.forwardUsed) { return(null); // schon benutzt, sollte nicht vorkommen } startWith.forwardUsed = true; } else { cl = startWith.StartCluster; startCluster = startWith.EndCluster; if (startWith.reverseUsed) { return(null); // schon benutzt, sollte nicht vorkommen } startWith.reverseUsed = true; } while (cl != startCluster) { int ind = -1; for (int i = 0; i < cl.Joints.Count; ++i) { if (cl.Joints[i] == startWith) { ind = i - 1; if (ind < 0) { ind = cl.Joints.Count - 1; } break; } } startWith = cl.Joints[ind] as Joint; forward = (startWith.StartCluster == cl); if (startWith.curve.Length == 0.0) { return(null); // sollte nicht vorkommen, kommt aber vor } bb.AddSegment(startWith.curve.CloneReverse(!forward)); if (forward) { cl = startWith.EndCluster; if (startWith.forwardUsed) { return(null); // schon benutzt, innere Schleife } startWith.forwardUsed = true; } else { cl = startWith.StartCluster; if (startWith.reverseUsed) { return(null); // schon benutzt, innere Schleife } startWith.reverseUsed = true; // auch hier Exception, wenn es schon benutzt war!! } } return(bb); }
public BorderBuilderTests() { _target = new BorderBuilder(); }
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();