19 using System.Collections.Generic;
24 internal class MarkdownContext
26 public Font Font {
get;
set; }
40 double maxX = Math.Max(BottomRight.X, value.X + Translation.X);
41 double maxY = Math.Max(BottomRight.Y, value.Y + Translation.Y);
43 this.BottomRight =
new Point(maxX, maxY);
47 public Colour Colour {
get;
set; }
48 public bool Underline {
get;
set; }
49 public bool StrikeThrough {
get;
set; }
51 private Point translation;
52 public Point Translation
63 double maxX = Math.Max(BottomRight.X, cursor.X + value.X);
64 double maxY = Math.Max(BottomRight.Y, cursor.Y + value.Y);
66 this.BottomRight =
new Point(maxX, maxY);
70 public Point MarginBottomRight {
get;
set; }
72 public Line CurrentLine {
get;
set; }
73 public int ListDepth {
get;
set; }
74 public List<(
double MaxX,
double MinY,
double MaxY)> ForbiddenAreasRight {
get;
set; }
75 public List<(
double MinX,
double MinY,
double MaxY)> ForbiddenAreasLeft {
get;
set; }
76 public Page CurrentPage {
get;
set; }
77 public Point BottomRight {
get;
set; }
78 public string Tag {
get;
set; } =
null;
79 public Dictionary<string, string> LinkDestinations {
get;
set; } =
new Dictionary<string, string>();
80 public Dictionary<string, string> InternalAnchors {
get;
set; } =
new Dictionary<string, string>();
82 public MarkdownContext()
84 this.ForbiddenAreasRight =
new List<(double MaxX, double MinY, double MaxY)>();
85 this.ForbiddenAreasLeft =
new List<(double MinX, double MinY, double MaxY)>();
88 public MarkdownContext Clone()
90 return new MarkdownContext()
95 Underline = this.Underline,
96 StrikeThrough = this.StrikeThrough,
97 Translation = this.Translation,
98 CurrentLine = this.CurrentLine,
99 ListDepth = this.ListDepth,
100 ForbiddenAreasRight = this.ForbiddenAreasRight,
101 ForbiddenAreasLeft = this.ForbiddenAreasLeft,
102 CurrentPage = this.CurrentPage,
104 LinkDestinations = this.LinkDestinations,
105 InternalAnchors = this.InternalAnchors,
106 MarginBottomRight = this.MarginBottomRight
110 public double GetMaxX(
double y,
double pageMaxX)
112 y = y + Translation.Y;
114 double maxX = pageMaxX;
116 foreach ((
double MaxX,
double MinY,
double MaxY) in ForbiddenAreasRight)
118 if (MinY <= y && MaxY >= y)
120 maxX = Math.Min(maxX, MaxX - this.Translation.X);
127 public double GetMaxX(
double y0,
double y1,
double pageMaxX)
129 y0 = y0 + Translation.Y;
130 y1 = y1 + Translation.Y;
132 double maxX = pageMaxX;
134 foreach ((
double MaxX,
double MinY,
double MaxY) in ForbiddenAreasRight)
136 if (!((MinY < y0 && MaxY < y0) || (MinY > y1 && MaxY > y1)))
138 maxX = Math.Min(maxX, MaxX - this.Translation.X);
145 public double GetMinX(
double y)
147 y = y + Translation.Y;
151 foreach ((
double MinX,
double MinY,
double MaxY) in ForbiddenAreasLeft)
153 if (MinY <= y && MaxY >= y)
155 minX = Math.Max(minX, MinX - Translation.X);
162 public double GetMinX(
double y0,
double y1)
165 y0 = y0 + Translation.Y;
166 y1 = y1 + Translation.Y;
170 foreach ((
double MinX,
double MinY,
double MaxY) in ForbiddenAreasLeft)
172 if (!((MinY < y0 && MaxY < y0) || (MinY > y1 && MaxY > y1)))
174 minX = Math.Max(minX, MinX - Translation.X);
200 public double Top {
get; }
214 public Margins(
double left,
double top,
double right,
double bottom)