RightToLeftExamples.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using NUnit.Framework;
  2. using QuestPDF.Examples.Engine;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. namespace QuestPDF.Examples
  7. {
  8. public class RightToLeftExamples
  9. {
  10. [Test]
  11. public void Unconstrained()
  12. {
  13. RenderingTest
  14. .Create()
  15. .ProduceImages()
  16. .PageSize(600, 600)
  17. .ShowResults()
  18. .Render(container =>
  19. {
  20. container
  21. .AlignCenter()
  22. .AlignMiddle()
  23. .ContentFromRightToLeft()
  24. .Unconstrained()
  25. .Background(Colors.Red.Medium)
  26. .Height(200)
  27. .Width(200);
  28. });
  29. }
  30. [Test]
  31. public void Row()
  32. {
  33. RenderingTest
  34. .Create()
  35. .ProduceImages()
  36. .PageSize(600, 600)
  37. .ShowResults()
  38. .Render(container =>
  39. {
  40. container
  41. .Padding(25)
  42. .ContentFromRightToLeft()
  43. .Border(1)
  44. .Row(row =>
  45. {
  46. row.ConstantItem(200).Background(Colors.Red.Lighten2).Height(200);
  47. row.ConstantItem(150).Background(Colors.Green.Lighten2).Height(200);
  48. row.ConstantItem(100).Background(Colors.Blue.Lighten2).Height(200);
  49. });
  50. });
  51. }
  52. [Test]
  53. public void MinimalBox()
  54. {
  55. RenderingTest
  56. .Create()
  57. .ProduceImages()
  58. .PageSize(600, 600)
  59. .ShowResults()
  60. .Render(container =>
  61. {
  62. container
  63. .Padding(25)
  64. .ContentFromRightToLeft()
  65. .Border(1)
  66. .MinimalBox()
  67. .Column(column =>
  68. {
  69. column.Item().Background(Colors.Red.Lighten2).Width(200).Height(200);
  70. column.Item().Background(Colors.Green.Lighten2).Width(150).Height(150);
  71. column.Item().Background(Colors.Blue.Lighten2).Width(100).Height(100);
  72. });
  73. });
  74. }
  75. [Test]
  76. public void Table()
  77. {
  78. RenderingTest
  79. .Create()
  80. .ProduceImages()
  81. .PageSize(600, 600)
  82. .ShowResults()
  83. .Render(container =>
  84. {
  85. container
  86. .Padding(25)
  87. .ContentFromRightToLeft()
  88. .Border(1)
  89. .Table(table =>
  90. {
  91. table.ColumnsDefinition(columns =>
  92. {
  93. columns.ConstantColumn(200);
  94. columns.ConstantColumn(150);
  95. columns.ConstantColumn(100);
  96. });
  97. table.Cell().Background(Colors.Red.Lighten2).Height(200);
  98. table.Cell().Background(Colors.Green.Lighten2).Height(200);
  99. table.Cell().Background(Colors.Blue.Lighten2).Height(200);
  100. });
  101. });
  102. }
  103. [Test]
  104. public void AspectRatio()
  105. {
  106. RenderingTest
  107. .Create()
  108. .ProduceImages()
  109. .PageSize(600, 600)
  110. .ShowResults()
  111. .Render(container =>
  112. {
  113. container
  114. .Padding(25)
  115. .ContentFromRightToLeft()
  116. .Border(1)
  117. .AspectRatio(0.55f, AspectRatioOption.FitArea)
  118. .Background(Colors.Red.Medium);
  119. });
  120. }
  121. [Test]
  122. public void Constrained()
  123. {
  124. RenderingTest
  125. .Create()
  126. .ProduceImages()
  127. .PageSize(600, 600)
  128. .ShowResults()
  129. .Render(container =>
  130. {
  131. container
  132. .Padding(25)
  133. .ContentFromRightToLeft()
  134. .Border(1)
  135. .MaxWidth(100)
  136. .Background(Colors.Red.Medium);
  137. });
  138. }
  139. }
  140. }