Skip to content

Commit

Permalink
S6ProtoBox
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyagusev committed Dec 19, 2019
1 parent d8088fe commit 44292d4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/BookFx.Usage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static void Main()
ResultStore.Save(S3Calendar.Create(DateTime.Now.AddMonths(2).Year), $"{nameof(S3Calendar)}.xlsx");
ResultStore.Save(S4BigTable.Create(), $"{nameof(S4BigTable)}.xlsx");
ResultStore.Save(S5ProtoSheet.Create(), $"{nameof(S5ProtoSheet)}.xlsx");
ResultStore.Save(S6ProtoBox.Create(), $"{nameof(S6ProtoBox)}.xlsx");
}
}
}
6 changes: 5 additions & 1 deletion src/BookFx.Usage/S2Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

public static class S2Style
{
public const string PrototypeName = "ThePrototype";
public const string SlotName = "TheSlot";

public static byte[] Create() =>
Col()
.Style(Style()
Expand All @@ -26,10 +29,11 @@ public static class S2Style
)
.Add(Row()
.Add(Value("Red", Style().Font(Color.Red)))
.Add(Value("On green", Style().Back(Color.LightGreen)))
.Add(Value("On green", Style().Back(Color.LightGreen)).Name(SlotName)) // will be used in S6ProtoBox
.Add(Value("Arial 12", Style().Font("Arial", 12)))
.Add(Value("Wrapped long text", Style().Wrap()))
)
.Name(PrototypeName) // will be used in S6ProtoBox
.ToSheet()
.ToBook()
.ToBytes();
Expand Down
32 changes: 32 additions & 0 deletions src/BookFx.Usage/S6ProtoBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace BookFx.Usage
{
using System.Drawing;

public static class S6ProtoBox
{
public static byte[] Create()
{
byte[] preexistingStyleBookBytes = S2Style.Create();

return Make
.Row()

// use the prototype as-is, with with default slot content
.Add(Make.Proto(preexistingStyleBookBytes, S2Style.PrototypeName))

// use the prototype with a custom slot content
.Add(Make
.Proto(preexistingStyleBookBytes, S2Style.PrototypeName)
.Add(S2Style.SlotName, Make.Value("On pink").Style(Make.Style().Back(Color.Pink))))

// use the prototype with another custom slot content
.Add(Make
.Proto(preexistingStyleBookBytes, S2Style.PrototypeName)
.Add(S2Style.SlotName, Make.Value("On gray").Style(Make.Style().Color(Color.White, Color.Gray))))

.ToSheet()
.ToBook()
.ToBytes();
}
}
}

0 comments on commit 44292d4

Please sign in to comment.