22 internal interface IGraphicsAction
27 internal interface IPrintableAction
31 double LineWidth {
get; }
34 LineDash LineDash {
get; }
36 Rectangle GetBounds();
39 internal class TransformAction : IGraphicsAction
41 public Point? Delta {
get; } =
null;
43 public double? Angle {
get; } =
null;
45 public Size? Scale {
get; } =
null;
47 public double[,] Matrix {
get; } =
null;
49 public TransformAction(Point delta)
54 public TransformAction(
double angle)
59 public TransformAction(Size scale)
64 public TransformAction(
double[,] matrix)
69 public double[,] GetMatrix()
71 if (this.Matrix !=
null)
75 else if (this.Delta !=
null)
77 return Graphics.TranslationMatrix(this.Delta.Value.X,
this.Delta.Value.Y);
79 else if (this.Angle !=
null)
81 return Graphics.RotationMatrix(this.Angle.Value);
83 else if (this.Scale !=
null)
85 return Graphics.ScaleMatrix(this.Scale.Value.Width,
this.Scale.Value.Height);
94 internal class StateAction : IGraphicsAction
96 public enum StateActionTypes
101 public StateActionTypes StateActionType {
get; }
103 public StateAction(StateActionTypes type)
105 this.StateActionType = type;
109 internal class TextAction : IGraphicsAction, IPrintableAction
111 public Brush Fill {
get; }
112 public Brush Stroke {
get; }
113 public double LineWidth {
get; }
116 public LineDash LineDash {
get; }
117 public string Tag {
get; }
118 public string Text {
get; }
119 public Point Origin {
get; }
121 public Font Font {
get; }
123 public TextAction(Point origin,
string text, Font font,
TextBaselines textBaseLine, Brush fill, Brush stroke,
double lineWidth,
LineCaps lineCap,
LineJoins lineJoin, LineDash lineDash,
string tag)
125 this.Origin = origin;
128 this.TextBaseline = textBaseLine;
130 this.Stroke = stroke;
131 this.LineCap = lineCap;
132 this.LineJoin = lineJoin;
133 this.LineWidth = lineWidth;
135 this.LineDash = lineDash;
138 public Rectangle GetBounds()
140 Font.DetailedFontMetrics metrics = this.Font.MeasureTextAdvanced(this.Text);
142 switch (this.TextBaseline)
145 return new Rectangle(this.Origin,
new Size(metrics.Width, metrics.Height));
147 return new Rectangle(this.Origin.X,
this.Origin.Y - metrics.Height, metrics.Width, metrics.Height);
149 return new Rectangle(this.Origin.X,
this.Origin.Y - metrics.Height * 0.5, metrics.Width, metrics.Height);
151 return new Rectangle(this.Origin.X,
this.Origin.Y - metrics.Top, metrics.Width, metrics.Height);
153 throw new System.ArgumentOutOfRangeException(nameof(TextBaseline), this.TextBaseline,
"Invalid text baseline!");
158 internal class RectangleAction : IGraphicsAction, IPrintableAction
160 public Brush Fill {
get; }
161 public Brush Stroke {
get; }
162 public double LineWidth {
get; }
165 public LineDash LineDash {
get; }
166 public string Tag {
get; }
167 public Point TopLeft {
get; }
168 public Size Size {
get; }
170 public RectangleAction(Point topLeft, Size size, Brush fill, Brush stroke,
double lineWidth,
LineCaps lineCap,
LineJoins lineJoin, LineDash lineDash,
string tag)
172 this.TopLeft = topLeft;
175 this.Stroke = stroke;
176 this.LineCap = lineCap;
177 this.LineJoin = lineJoin;
178 this.LineWidth = lineWidth;
179 this.LineDash = lineDash;
183 public Rectangle GetBounds()
185 return new Rectangle(this.TopLeft, this.Size);
189 internal class PathAction : IGraphicsAction, IPrintableAction
191 public GraphicsPath Path {
get; }
192 public Brush Fill {
get; }
193 public Brush Stroke {
get; }
194 public string Tag {
get; }
195 public double LineWidth {
get; }
198 public LineDash LineDash {
get; }
199 public bool IsClipping {
get; }
200 public Rectangle GetBounds()
202 return this.Path.GetBounds();
204 public PathAction(GraphicsPath path, Brush fill, Brush stroke,
double lineWidth,
LineCaps lineCap,
LineJoins lineJoin, LineDash lineDash,
string tag,
bool isClipping)
208 this.Stroke = stroke;
209 this.LineCap = lineCap;
210 this.LineJoin = lineJoin;
211 this.LineWidth = lineWidth;
212 this.LineDash = lineDash;
214 this.IsClipping = isClipping;
218 internal class RasterImageAction : IGraphicsAction, IPrintableAction
220 public Brush Fill {
get; }
221 public Brush Stroke {
get; }
222 public string Tag {
get; }
223 public double LineWidth {
get; }
226 public LineDash LineDash {
get; }
227 public int SourceX {
get; }
228 public int SourceY {
get; }
229 public int SourceWidth {
get; }
230 public int SourceHeight {
get; }
231 public double DestinationX {
get; }
232 public double DestinationY {
get; }
233 public double DestinationWidth {
get; }
234 public double DestinationHeight {
get; }
235 public RasterImage Image {
get; }
237 public RasterImageAction(
int sourceX,
int sourceY,
int sourceWidth,
int sourceHeight,
double destinationX,
double destinationY,
double destinationWidth,
double destinationHeight, RasterImage image,
string tag)
239 this.SourceX = sourceX;
240 this.SourceY = sourceY;
241 this.SourceWidth = sourceWidth;
242 this.SourceHeight = sourceHeight;
244 this.DestinationX = destinationX;
245 this.DestinationY = destinationY;
246 this.DestinationWidth = destinationWidth;
247 this.DestinationHeight = destinationHeight;
253 public Rectangle GetBounds()
255 return new Rectangle(this.DestinationX, this.DestinationY, this.DestinationWidth, this.DestinationHeight);
259 internal class FilteredGraphicsAction : IGraphicsAction, IPrintableAction
261 public Brush Fill {
get; }
262 public Brush Stroke {
get; }
263 public string Tag {
get; }
264 public double LineWidth {
get; }
267 public LineDash LineDash {
get; }
268 public int SourceX {
get; }
269 public int SourceY {
get; }
270 public int SourceWidth {
get; }
271 public int SourceHeight {
get; }
272 public double DestinationX {
get; }
273 public double DestinationY {
get; }
274 public double DestinationWidth {
get; }
275 public double DestinationHeight {
get; }
276 public RasterImage Image {
get; }
277 public Graphics Content {
get; }
280 public FilteredGraphicsAction(Graphics graphics,
IFilter filter)
282 this.Content = graphics;
283 this.Filter = filter;
286 public Rectangle GetBounds()
288 Rectangle bounds = this.Content.GetBounds();
290 return new Rectangle(bounds.Location.X -
this.Filter.TopLeftMargin.X, bounds.Location.Y -
this.Filter.TopLeftMargin.Y, bounds.Size.Width +
this.Filter.TopLeftMargin.X +
this.Filter.BottomRightMargin.X, bounds.Size.Height +
this.Filter.TopLeftMargin.Y +
this.Filter.BottomRightMargin.Y);