|
1 | | -using System; |
2 | | -using System.Drawing; |
3 | | -using System.Drawing.Imaging; |
4 | | -using System.Collections.Generic; |
5 | | -using System.Drawing.Drawing2D; |
| 1 | +using System; |
| 2 | +using System.Drawing; |
| 3 | +using System.Drawing.Imaging; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.Drawing.Drawing2D; |
6 | 6 | using System.IO; |
7 | | -using System.Threading.Tasks; |
8 | | - |
9 | | -namespace NGraphics |
| 7 | +using System.Threading.Tasks; |
| 8 | + |
| 9 | +namespace NGraphics |
10 | 10 | { |
11 | 11 | public class SystemDrawingPlatform : IPlatform |
12 | 12 | { |
@@ -160,22 +160,22 @@ public void RestoreState() |
160 | 160 |
|
161 | 161 | public Size MeasureText(string text, Font font) |
162 | 162 | { |
163 | | - using (var netFont = new System.Drawing.Font(font.Name, (float)font.Size, FontStyle.Regular, GraphicsUnit.Point)) |
164 | | - { |
165 | | - var result = graphics.MeasureString(text, netFont); |
166 | | - return new Size(result.Width, result.Height); |
167 | | - } |
168 | | - } |
| 163 | + using (var netFont = new System.Drawing.Font(font.Name, (float)font.Size, FontStyle.Regular, GraphicsUnit.Point)) |
| 164 | + { |
| 165 | + var result = graphics.MeasureString(text, netFont); |
| 166 | + return new Size(result.Width, result.Height); |
| 167 | + } |
| 168 | + } |
169 | 169 |
|
170 | 170 | public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null) |
171 | 171 | { |
172 | | - if (brush == null) throw new ArgumentNullException(nameof(brush)); |
173 | | - |
| 172 | + if (brush == null) |
| 173 | + return; |
174 | 174 | var sdfont = new System.Drawing.Font(font.Family, (float)font.Size, FontStyle.Regular, GraphicsUnit.Point); |
175 | 175 | var sz = graphics.MeasureString(text, sdfont); |
176 | 176 | var point = frame.Position; |
177 | | - var fr = new Rect(point, new Size(sz.Width, sz.Height)); |
178 | | - graphics.DrawString(text, sdfont, Conversions.GetBrush(brush, fr), Conversions.GetPointF(point));// - new Point(0, sdfont.Height))); |
| 177 | + var fr = new Rect(point, new Size(sz.Width, sz.Height)); |
| 178 | + graphics.DrawString(text, sdfont, Conversions.GetBrush(brush, fr), Conversions.GetPointF(point - new Point(0, sdfont.Height))); |
179 | 179 | } |
180 | 180 | public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null) |
181 | 181 | { |
@@ -419,6 +419,5 @@ public static System.Drawing.Rectangle GetRectangle(this Rect frame) |
419 | 419 | { |
420 | 420 | return new System.Drawing.Rectangle((int)frame.X, (int)frame.Y, (int)frame.Width, (int)frame.Height); |
421 | 421 | } |
422 | | - } |
423 | | -} |
424 | | - |
| 422 | + } |
| 423 | +} |
0 commit comments