개정판 1f112f94
Fix: 페이지가 회전되었을때 ArrowTextControl 오류 수정
Change-Id: Ied10bcdf190699e00734c9af53d79ff30553031f
FinalService/KCOM_FinalService_DL/MarkupToPDF/Common/CommonFont.cs | ||
---|---|---|
51 | 51 |
/// <returns></returns> |
52 | 52 |
public static iTextSharp.text.Font CreateFont(FontFamily fontFamilly, FontStyle fontstyle, FontWeight fontweight, TextDecorationCollection isUnderline, iTextSharp.text.Rectangle rect, string text) |
53 | 53 |
{ |
54 |
///int iFonts = FontFactory.RegisterDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Fonts)); |
|
55 |
//string sFontPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial Unicode MS.TTF"); |
|
56 |
|
|
57 |
//bool bTextIsAscii = !text.Any(c => !Char.IsLetterOrDigit(c)); /// text가 ascii인지 확인 |
|
58 |
//if (bTextIsAscii) |
|
59 |
//{ |
|
60 |
// sFontPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "TIMES.TTF"); |
|
61 |
//} |
|
62 |
|
|
63 | 54 |
double dFontSize = double.MaxValue; |
64 | 55 |
|
65 | 56 |
BaseFont bf = CreateBaseFont(fontFamilly,BaseFont.IDENTITY_H, BaseFont.EMBEDDED, BaseFont.CACHED); |
FinalService/KCOM_FinalService_DL/MarkupToPDF/Controls_PDF/DrawSet_DrawString.cs | ||
---|---|---|
35 | 35 |
FontFamily fontFamilly, FontStyle fontstyle, FontWeight fontweight, TextDecorationCollection isUnderline, |
36 | 36 |
string text, System.Drawing.SizeF size, double opac, double Angle) |
37 | 37 |
{ |
38 |
|
|
39 | 38 |
if (string.IsNullOrWhiteSpace(text)) |
40 | 39 |
{ |
41 | 40 |
text = ""; |
... | ... | |
53 | 52 |
|
54 | 53 |
double textMargin = 0.5; |
55 | 54 |
|
56 |
rect.Inflate(lineSize * textMargin, lineSize * textMargin); /// 점을 중심으로 라인 두께가 그려짐으로 사각형 안쪽으로 텍스트가 쓰여지게 사각형을 키움 |
|
55 |
/// 점을 중심으로 라인 두께가 그려짐으로 사각형 안쪽으로 텍스트가 쓰여지게 사각형을 키움 |
|
56 |
rect.Inflate(lineSize * textMargin, lineSize * textMargin); |
|
57 | 57 |
|
58 | 58 |
var calRect = MathSet.GetPointsToRectX(points); |
59 | 59 |
if (lineSize * 2 > calRect.Height) lineSize *= 0.3; /// 텍스트가 뒤집어 지는것 방지 |
... | ... | |
74 | 74 |
|
75 | 75 |
contentByte.SetLineWidth((float)lineSize); |
76 | 76 |
|
77 |
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix(); |
|
78 |
|
|
79 |
if (Angle == 180) |
|
80 |
{ |
|
81 |
mat.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y)); |
|
82 |
mat.Translate((float)-rect.Width, (float)rect.Height); |
|
83 |
} |
|
84 |
else |
|
85 |
mat.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y)); |
|
86 |
|
|
77 |
#region 보더를 그린다. |
|
87 | 78 |
/// transform text border |
88 | 79 |
System.Drawing.PointF[] border = new System.Drawing.PointF[4] |
89 | 80 |
{ |
... | ... | |
92 | 83 |
new System.Drawing.PointF((float)points[2].X, (float)points[2].Y), |
93 | 84 |
new System.Drawing.PointF((float)points[3].X, (float)points[3].Y) |
94 | 85 |
}; |
95 |
mat.TransformPoints(border); /// transform if given angle is not 0 |
|
96 |
var transformed = border.Select(param => new Point(param.X, param.Y)).ToList(); |
|
97 |
/// up to here |
|
98 | 86 |
|
99 | 87 |
contentByte.NewPath(); |
100 |
contentByte.MoveTo(transformed[0].X, transformed[0].Y);
|
|
88 |
contentByte.MoveTo(border[0].X, border[0].Y);
|
|
101 | 89 |
|
102 | 90 |
if ((PaintStyle & PaintSet.Hatch) == PaintSet.Hatch) |
103 | 91 |
{ |
104 | 92 |
/// default arc length |
105 | 93 |
List<Point> rectPoints = new List<Point>(); |
106 | 94 |
|
107 |
for (int i = 1; i <= transformed.Count; ++i)
|
|
95 |
for (int i = 1; i <= border.Count(); ++i)
|
|
108 | 96 |
{ |
109 |
rectPoints.Add(new Point(transformed[i % transformed.Count].X, transformed[i % transformed.Count].Y));
|
|
97 |
rectPoints.Add(new Point(border[i % border.Count()].X, border[i % border.Count()].Y));
|
|
110 | 98 |
} |
111 | 99 |
|
112 | 100 |
if ((PaintStyle & PaintSet.Highlight) == PaintSet.Highlight) |
113 | 101 |
{ |
114 | 102 |
contentByte.NewPath(); |
115 |
contentByte.MoveTo(transformed[0].X, transformed[0].Y);
|
|
116 |
for (int i = 1; i <= transformed.Count; ++i) contentByte.LineTo(transformed[i % transformed.Count].X, transformed[i % transformed.Count].Y);
|
|
103 |
contentByte.MoveTo(border[0].X, border[0].Y);
|
|
104 |
for (int i = 1; i <= border.Count(); ++i) contentByte.LineTo(border[i % border.Count()].X, border[i % border.Count()].Y);
|
|
117 | 105 |
|
118 | 106 |
DrawSet_Shape.PaintFill(contentByte, PaintStyle, bs, opac); |
119 | 107 |
} |
... | ... | |
122 | 110 |
|
123 | 111 |
List<Point> newPointSet = new List<Point>(); |
124 | 112 |
|
125 |
newPointSet.Add(new Point(transformed[0].X, transformed[0].Y));
|
|
126 |
for (int i = 1; i <= transformed.Count; ++i) newPointSet.Add(new Point(transformed[i % points.Count].X, transformed[i % points.Count].Y));
|
|
113 |
newPointSet.Add(new Point(border[0].X, border[0].Y));
|
|
114 |
for (int i = 1; i <= border.Count(); ++i) newPointSet.Add(new Point(border[i % points.Count].X, border[i % points.Count].Y));
|
|
127 | 115 |
|
128 | 116 |
Controls_PDF.DrawSet_Cloud.DrawCloud(newPointSet, lineSize, ArcLength, contentByte, new DoubleCollection(), color, color, PaintSet.None, opac); |
129 | 117 |
} |
130 | 118 |
else if (((PaintStyle & PaintSet.Highlight) == PaintSet.Highlight) || ((PaintStyle & PaintSet.Fill) == PaintSet.Fill)) |
131 | 119 |
{ |
132 |
for (int i = 1; i <= transformed.Count; ++i) contentByte.LineTo(transformed[i % transformed.Count].X, transformed[i % transformed.Count].Y);
|
|
120 |
for (int i = 1; i <= border.Count(); ++i) contentByte.LineTo(border[i % border.Count()].X, border[i % border.Count()].Y);
|
|
133 | 121 |
|
134 | 122 |
DrawSet_Text.PaintFill(contentByte, PaintStyle, bs); |
135 | 123 |
} |
124 |
#endregion |
|
136 | 125 |
|
126 |
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix(); |
|
137 | 127 |
|
138 |
|
|
139 |
iTextSharp.text.Font itextFont = CommonFont.CreateFont(fontFamilly, fontstyle, fontweight, isUnderline, calRect, text); |
|
140 |
|
|
141 |
contentByte.SetColorStroke(bs); |
|
142 |
contentByte.SetColorFill(bs); |
|
143 |
|
|
144 |
string[] tokens = text.Split(new[] { Environment.NewLine, "\r" }, StringSplitOptions.None); |
|
145 |
/// single line text |
|
146 |
if (tokens.Length == 1) |
|
128 |
iTextSharp.text.Rectangle TextBox = null; |
|
129 |
#region TextBox에 크기에 맞게 폰트를 생성한다. |
|
130 |
iTextSharp.text.Font itextFont = null; |
|
131 |
if(Convert.ToInt32(Angle) == 90) |
|
147 | 132 |
{ |
148 |
float height = itextFont.BaseFont.GetAscentPoint(text, itextFont.CalculatedSize) - itextFont.BaseFont.GetDescentPoint(text, itextFont.CalculatedSize); |
|
149 |
float spacing = (float)((calRect.Height - height) * 0.5); |
|
150 |
System.Drawing.PointF[] origin = new System.Drawing.PointF[1] |
|
151 |
{ |
|
152 |
new System.Drawing.PointF((float)((calRect.Left + calRect.Right) * 0.5), (float)((calRect.Top + calRect.Bottom - height) * 0.5)) |
|
153 |
}; |
|
154 |
mat.TransformPoints(origin); |
|
133 |
float llx = calRect.Left; |
|
134 |
float lly = calRect.Bottom + (float)textMargin; |
|
135 |
float urx = calRect.Left + calRect.Height; |
|
136 |
float ury = lly + calRect.Width; |
|
137 |
TextBox = new iTextSharp.text.Rectangle(llx, lly, urx, ury); |
|
138 |
|
|
139 |
itextFont = CommonFont.CreateFont(fontFamilly, fontstyle, fontweight, isUnderline, TextBox, text); |
|
140 |
|
|
141 |
#region 회전 후에 이동시킴 |
|
142 |
mat.Translate(TextBox.Height, (float)0.0); |
|
143 |
mat.RotateAt((float)Angle * 1, new System.Drawing.PointF(TextBox.Left, TextBox.Bottom)); |
|
144 |
#endregion |
|
145 |
} |
|
146 |
else if (Convert.ToInt32(Angle) == 270) |
|
147 |
{ |
|
148 |
float llx = calRect.Left; |
|
149 |
float lly = calRect.Top - (float)textMargin; |
|
150 |
float urx = calRect.Left + calRect.Height; |
|
151 |
float ury = lly + calRect.Width; |
|
152 |
TextBox = new iTextSharp.text.Rectangle(llx, lly, urx, ury); |
|
155 | 153 |
|
156 |
UTF8Encoding utf8 = new UTF8Encoding(); |
|
157 |
Byte[] utf8String = utf8.GetBytes(text); |
|
154 |
itextFont = CommonFont.CreateFont(fontFamilly, fontstyle, fontweight, isUnderline, TextBox, text); |
|
158 | 155 |
|
159 |
ColumnText.ShowTextAligned(contentByte, Element.ALIGN_CENTER, new Phrase(new Chunk(utf8.GetString(utf8String), itextFont)), origin[0].X, origin[0].Y, (float)-Angle);
|
|
156 |
mat.RotateAt((float)Angle * 1, new System.Drawing.PointF(TextBox.Left, TextBox.Bottom));
|
|
160 | 157 |
} |
161 |
/// multi line text |
|
162 | 158 |
else |
163 | 159 |
{ |
164 |
ColumnText ct = new ColumnText(contentByte); |
|
165 |
PdfGState gs3 = new PdfGState(); |
|
166 |
gs3.StrokeOpacity = (float)opac; |
|
167 |
gs3.FillOpacity = (float)opac; |
|
168 |
|
|
169 |
ct.Canvas.Transform(mat); |
|
170 |
ct.Canvas.SetGState(gs3); |
|
171 |
float fLeadingSize = (calRect.Height / (float)tokens.Length); |
|
172 |
float spacing = ((float)calRect.Height - tokens.Length * itextFont.CalculatedSize) / (tokens.Length + 2); |
|
173 |
/// add paddings |
|
174 |
calRect.Right += (float)(lineSize * 0.5); |
|
175 |
if (calRect.Top > calRect.Bottom) |
|
176 |
calRect.Bottom -= (float)(lineSize * 0.5); |
|
177 |
else |
|
178 |
calRect.Top -= (float)(lineSize * 0.5); |
|
179 |
/// up to here |
|
180 |
ct.SetLeading(itextFont.CalculatedSize + (float)((tokens.Length > 1) ? spacing : 0), ct.MultipliedLeading); |
|
181 |
ct.SetSimpleColumn(calRect); |
|
182 |
ct.Alignment = Element.ALIGN_MIDDLE | Element.ALIGN_CENTER; |
|
183 |
ct.SetText(new Phrase(new Chunk(text, itextFont))); |
|
184 |
ct.Go(); |
|
160 |
TextBox = calRect; |
|
161 |
itextFont = CommonFont.CreateFont(fontFamilly, fontstyle, fontweight, isUnderline, TextBox, text); |
|
185 | 162 |
} |
163 |
#endregion |
|
164 |
|
|
165 |
#region 텍스트 쓰기 |
|
166 |
contentByte.SetColorStroke(bs); |
|
167 |
contentByte.SetColorFill(bs); |
|
168 |
|
|
169 |
string[] tokens = text.Split(new[] { Environment.NewLine, "\r" }, StringSplitOptions.None); |
|
170 |
ColumnText ct = new ColumnText(contentByte); |
|
171 |
PdfGState gs3 = new PdfGState(); |
|
172 |
gs3.StrokeOpacity = (float)opac; |
|
173 |
gs3.FillOpacity = (float)opac; |
|
174 |
|
|
175 |
ct.Canvas.Transform(mat); |
|
176 |
ct.Canvas.SetGState(gs3); |
|
177 |
float fLeadingSize = (TextBox.Height / (float)tokens.Length); |
|
178 |
float spacing = ((float)TextBox.Height - tokens.Length * itextFont.CalculatedSize) / (tokens.Length + 2); |
|
179 |
/// add paddings |
|
180 |
TextBox.Right += (float)(lineSize * 0.5); |
|
181 |
if (TextBox.Top > TextBox.Bottom) |
|
182 |
TextBox.Bottom -= (float)(lineSize * 0.5); |
|
183 |
else |
|
184 |
TextBox.Top -= (float)(lineSize * 0.5); |
|
185 |
/// up to here |
|
186 |
ct.SetLeading(itextFont.CalculatedSize + (float)((tokens.Length > 1) ? spacing : 0), ct.MultipliedLeading); |
|
187 |
ct.SetSimpleColumn(TextBox); |
|
188 |
ct.Alignment = Element.ALIGN_MIDDLE | Element.ALIGN_CENTER; |
|
189 |
ct.SetText(new Phrase(new Chunk(text, itextFont))); |
|
190 |
ct.Go(); |
|
191 |
#endregion |
|
186 | 192 |
|
187 | 193 |
contentByte.RestoreState(); |
188 | 194 |
} |
... | ... | |
208 | 214 |
/// <param name="size"></param> |
209 | 215 |
/// <param name="opac"></param> |
210 | 216 |
/// <param name="Angle"></param> |
211 |
public static void DrawString_ArrowText(Point sp, Point ep, Point ptHead, Point ptMid, Point ptEnd, bool bIsFixed,
|
|
217 |
public static void DrawString_ArrowText(System.Windows.Rect rect, Point ptHead, Point ptMid, Point ptEnd, bool bIsFixed,
|
|
212 | 218 |
double lineSize, iTextSharp.text.pdf.PdfContentByte contentByte, System.Drawing.Color color, PaintSet PaintStyle, double FontSize, |
213 | 219 |
bool isHighlight, FontFamily fontFamilly, FontStyle fontstyle, FontWeight fontweight, TextDecorationCollection isUnderline, |
214 | 220 |
string text, System.Drawing.SizeF size, double opac, double Angle) |
215 | 221 |
{ |
216 |
Rect rect = new Rect(sp, ep); |
|
217 |
|
|
218 |
List<Point> points = new List<Point> |
|
219 |
{ |
|
220 |
rect.TopLeft, rect.BottomLeft, |
|
221 |
rect.BottomRight, rect.TopRight |
|
222 |
}; |
|
223 |
|
|
224 |
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix(); |
|
225 |
|
|
226 |
mat.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y)); |
|
227 |
|
|
228 |
/// up to here |
|
229 |
|
|
230 |
DrawSet_Text.DrawString(sp, ep, lineSize, contentByte, color, PaintStyle, FontSize, fontFamilly, fontstyle, fontweight, isUnderline, text, size, opac, Angle); |
|
231 |
|
|
232 |
if (Angle == 270 || Angle == 90) |
|
233 |
{ |
|
234 |
/// transform text border |
|
235 |
System.Drawing.PointF[] border = new System.Drawing.PointF[4] |
|
236 |
{ |
|
237 |
new System.Drawing.PointF((float)points[0].X, (float)points[0].Y), |
|
238 |
new System.Drawing.PointF((float)points[1].X, (float)points[1].Y), |
|
239 |
new System.Drawing.PointF((float)points[2].X, (float)points[2].Y), |
|
240 |
new System.Drawing.PointF((float)points[3].X, (float)points[3].Y) |
|
241 |
}; |
|
242 |
|
|
243 |
|
|
244 |
mat.TransformPoints(border); /// transform if given angle is not 0 |
|
245 |
var transformed = border.Select(param => new Point(param.X, param.Y)).ToList(); |
|
246 |
|
|
247 |
if (Angle == 90 || Angle == 270) |
|
248 |
{ |
|
249 |
transformed.Add(new Point(transformed[0].X, transformed[0].Y - (transformed[0].Y - transformed[3].Y) / 2)); |
|
250 |
transformed.Add(new Point(transformed[1].X, transformed[1].Y - (transformed[1].Y - transformed[2].Y) / 2)); |
|
251 |
} |
|
252 |
|
|
253 |
ptEnd = MathSet.getNearPoint(transformed, ptMid); |
|
254 |
} |
|
255 |
else |
|
256 |
{ |
|
257 |
if (!bIsFixed) |
|
258 |
{ |
|
259 |
List<Point> newPoints = new List<Point>(); |
|
260 |
|
|
261 |
newPoints.Add(MidPoint(points[0], points[3])); |
|
262 |
newPoints.Add(MidPoint(points[0], points[1])); |
|
263 |
newPoints.Add(MidPoint(points[1], points[2])); |
|
264 |
newPoints.Add(MidPoint(points[2], points[3])); |
|
265 |
//newPoints.AddRange(points); |
|
266 |
|
|
267 |
ptEnd = MathSet.getNearPoint(newPoints, ptMid); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
222 |
DrawSet_Text.DrawString(rect.TopLeft, rect.BottomRight, lineSize, contentByte, color, PaintStyle, FontSize, fontFamilly, fontstyle, fontweight, isUnderline, text, size, opac, Angle); |
|
271 | 223 |
DrawLeaderLineNew(ptHead, ptMid, ptEnd, bIsFixed, lineSize, contentByte, color, opac); |
272 | 224 |
} |
273 | 225 |
|
274 |
private static Point MidPoint(Point a, Point b) |
|
275 |
{ |
|
276 |
Point middle = a; |
|
277 |
|
|
278 |
middle.X = (a.X + b.X) / 2; |
|
279 |
middle.Y = (a.Y + b.Y) / 2; |
|
280 |
|
|
281 |
return middle; |
|
282 |
} |
|
283 |
/// <summary> |
|
284 |
/// draw leader line for arrow_text |
|
285 |
/// </summary> |
|
286 |
/// <author>humkyung</author> |
|
287 |
/// <date>2019.06.12</date> |
|
288 |
/// <param name="start"></param> |
|
289 |
/// <param name="mid"></param> |
|
290 |
/// <param name="border"></param> |
|
291 |
/// <param name="LineSize"></param> |
|
292 |
/// <param name="contentByte"></param> |
|
293 |
/// <param name="color"></param> |
|
294 |
/// <param name="opac"></param> |
|
295 |
private static void DrawLeaderLine(Point start, Point mid, bool bIsFixed, List<Point> border, double LineSize, iTextSharp.text.pdf.PdfContentByte contentByte, System.Drawing.Color color, double opac) |
|
296 |
{ |
|
297 |
/// prepare connection points |
|
298 |
List<Point> ptConns = new List<Point>(); |
|
299 |
for (int i = 0; i < border.Count; ++i) |
|
300 |
{ |
|
301 |
ptConns.Add(new Point((border[i].X + border[(i + 1) % border.Count].X) * 0.5, (border[i].Y + border[(i + 1) % border.Count].Y) * 0.5)); |
|
302 |
} |
|
303 |
/// up to here |
|
304 |
|
|
305 |
Point? anchor = null; |
|
306 |
double dMinDist = Double.MaxValue; |
|
307 |
foreach (var point in ptConns) |
|
308 |
{ |
|
309 |
double dx = point.X - mid.X; |
|
310 |
double dy = point.Y - mid.Y; |
|
311 |
double dist = dx * dx + dy * dy; |
|
312 |
if (dist < dMinDist) |
|
313 |
{ |
|
314 |
dMinDist = dist; |
|
315 |
anchor = point; |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
Controls_PDF.DrawSet_Arrow.SingleAllow(start, bIsFixed ? mid : anchor.Value, LineSize, contentByte, color, opac); |
|
320 |
Controls_PDF.DrawSet_Line.DrawLine(start, bIsFixed ? mid : anchor.Value, LineSize, contentByte, new DoubleCollection(9999), color, opac); |
|
321 |
if (bIsFixed) |
|
322 |
{ |
|
323 |
Controls_PDF.DrawSet_Line.DrawLine(mid, anchor.Value, LineSize, contentByte, new DoubleCollection(9999), color, opac); |
|
324 |
} |
|
325 |
} |
|
326 |
|
|
327 | 226 |
/// <summary> |
328 | 227 |
/// Markus의 box끝에 맞는부분과 틀려 별도로 만듬 |
329 |
/// |
|
228 |
/// </summary>
|
|
330 | 229 |
/// kimteaseong |
331 | 230 |
/// </summary> |
332 | 231 |
/// <param name="start"></param> |
... | ... | |
339 | 238 |
/// <param name="opac"></param> |
340 | 239 |
private static void DrawLeaderLineNew(Point start, Point mid, Point end, bool bIsFixed, double LineSize, iTextSharp.text.pdf.PdfContentByte contentByte, System.Drawing.Color color, double opac) |
341 | 240 |
{ |
241 |
var DashSize = new DoubleCollection(9999); |
|
242 |
|
|
342 | 243 |
Controls_PDF.DrawSet_Arrow.SingleAllow(start, bIsFixed ? mid : end, LineSize, contentByte, color, opac); |
343 |
Controls_PDF.DrawSet_Line.DrawLine(start, bIsFixed ? mid : end, LineSize, contentByte, new DoubleCollection(9999), color, opac);
|
|
244 |
Controls_PDF.DrawSet_Line.DrawLine(start, bIsFixed ? mid : end, LineSize, contentByte, DashSize, color, opac);
|
|
344 | 245 |
if (bIsFixed) |
345 | 246 |
{ |
346 |
Controls_PDF.DrawSet_Line.DrawLine(mid, end, LineSize, contentByte, new DoubleCollection(9999), color, opac);
|
|
247 |
Controls_PDF.DrawSet_Line.DrawLine(mid, end, LineSize, contentByte, DashSize, color, opac);
|
|
347 | 248 |
} |
348 | 249 |
} |
349 | 250 |
|
FinalService/KCOM_FinalService_DL/MarkupToPDF/MarkupToPDF.cs | ||
---|---|---|
985 | 985 |
case "ArrowTextControl": |
986 | 986 |
using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
987 | 987 |
{ |
988 |
//using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
|
989 |
//{ |
|
990 |
// textcontrol.Angle = control.Angle; |
|
991 |
// textcontrol.BoxH = control.BoxHeight; |
|
992 |
// textcontrol.BoxW = control.BoxWidth; |
|
993 |
// textcontrol.EndPoint = control.EndPoint; |
|
994 |
// textcontrol.FontColor = "#FFFF0000"; |
|
995 |
// textcontrol.Name = "TextControl"; |
|
996 |
// textcontrol.Opac = control.Opac; |
|
997 |
// textcontrol.PointSet = new List<Point>(); |
|
998 |
// textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]); |
|
999 |
// textcontrol.StartPoint = control.StartPoint; |
|
1000 |
// textcontrol.Text = control.ArrowText; |
|
1001 |
// textcontrol.TransformPoint = control.TransformPoint; |
|
1002 |
// textcontrol.UserID = null; |
|
1003 |
// textcontrol.fontConfig = control.fontConfig; |
|
1004 |
// textcontrol.isHighLight = control.isHighLight; |
|
1005 |
// textcontrol.paintMethod = 1; |
|
1006 |
|
|
1007 |
// DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
1008 |
//} |
|
1009 |
|
|
1010 |
//using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
|
1011 |
//{ |
|
1012 |
// linecontrol.Angle = control.Angle; |
|
1013 |
// linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 }); |
|
1014 |
// linecontrol.EndPoint = control.EndPoint; |
|
1015 |
// linecontrol.MidPoint = control.MidPoint; |
|
1016 |
// linecontrol.Name = "ArrowControl_Multi"; |
|
1017 |
// linecontrol.Opac = control.Opac; |
|
1018 |
// linecontrol.PointSet = control.PointSet; |
|
1019 |
// linecontrol.SizeSet = control.SizeSet; |
|
1020 |
// linecontrol.StartPoint = control.StartPoint; |
|
1021 |
// linecontrol.StrokeColor = control.StrokeColor; |
|
1022 |
// linecontrol.TransformPoint = control.TransformPoint; |
|
1023 |
|
|
1024 |
// DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
1025 |
//} |
|
1026 | 988 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1027 | 989 |
Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
1028 | 990 |
Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
... | ... | |
1032 | 994 |
double fontsize = 30; |
1033 | 995 |
|
1034 | 996 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
1035 |
Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
|
1036 |
List<Point> tempPoint = new List<Point>(); |
|
997 |
List<Point> Connections = new List<Point>(control.GetConnectionPoints(tempEndPoint, scaleWidth, scaleHeight)); |
|
1037 | 998 |
|
1038 | 999 |
double Angle = control.Angle; |
1039 | 1000 |
|
1040 |
if (Math.Abs(Angle).ToString() == "90") |
|
1041 |
{ |
|
1042 |
Angle = 270; |
|
1043 |
} |
|
1044 |
else if (Math.Abs(Angle).ToString() == "270") |
|
1045 |
{ |
|
1046 |
Angle = 90; |
|
1047 |
} |
|
1048 |
|
|
1049 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
|
1050 |
tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
|
1051 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
|
1052 |
tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
|
1053 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
|
1054 |
|
|
1055 | 1001 |
var newStartPoint = tempStartPoint; |
1056 |
var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
|
1057 |
var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
|
1058 |
|
|
1059 |
//Point testPoint = tempEndPoint; |
|
1060 |
//if (Angle != 0) |
|
1061 |
//{ |
|
1062 |
// testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed); |
|
1063 |
// //testPoint = Test(rect, newMidPoint); |
|
1064 |
//} |
|
1002 |
var ConnectionPoint = MathSet.getNearPoint(Connections, tempMidPoint); |
|
1065 | 1003 |
|
1066 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth);
|
|
1004 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2[0]), scaleWidth);
|
|
1067 | 1005 |
System.Drawing.Color FontColor = _SetColor; |
1068 | 1006 |
bool isHighlight = control.isHighLight; |
1069 | 1007 |
double Opacity = control.Opac; |
... | ... | |
1125 | 1063 |
} |
1126 | 1064 |
|
1127 | 1065 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1128 |
if (control.fontConfig.Count() == 5)
|
|
1066 |
if (control.fontConfig.Count == 5) |
|
1129 | 1067 |
{ |
1130 | 1068 |
decoration = TextDecorations.Underline; |
1131 | 1069 |
} |
1132 | 1070 |
|
1133 | 1071 |
if (control.isTrans) |
1134 | 1072 |
{ |
1135 |
//인구 수정 Arrow Text Style적용 되도록 변경
|
|
1136 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
|
|
1137 |
newStartPoint, tempMidPoint, newEndPoint, control.isFixed,
|
|
1073 |
var border = control.GetBorderRectangle(tempEndPoint, scaleWidth, scaleHeight);
|
|
1074 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(border,
|
|
1075 |
newStartPoint, tempMidPoint, ConnectionPoint, control.isFixed,
|
|
1138 | 1076 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1139 | 1077 |
} |
1140 | 1078 |
else |
... | ... | |
1144 | 1082 |
var testP = new Point(0, 0); |
1145 | 1083 |
if (control.isFixed) |
1146 | 1084 |
{ |
1147 |
if (tempPoint[1] == newEndPoint)
|
|
1085 |
if (Connections[1] == ConnectionPoint)
|
|
1148 | 1086 |
{ |
1149 |
testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
|
|
1087 |
testP = new Point(ConnectionPoint.X, ConnectionPoint.Y - 10);
|
|
1150 | 1088 |
} |
1151 |
else if (tempPoint[3] == newEndPoint)
|
|
1089 |
else if (Connections[3] == ConnectionPoint)
|
|
1152 | 1090 |
{ |
1153 |
testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
|
|
1091 |
testP = new Point(ConnectionPoint.X, ConnectionPoint.Y + 10);
|
|
1154 | 1092 |
} |
1155 |
else if (tempPoint[0] == newEndPoint)
|
|
1093 |
else if (Connections[0] == ConnectionPoint)
|
|
1156 | 1094 |
{ |
1157 |
testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
|
|
1095 |
testP = new Point(ConnectionPoint.X - 10, ConnectionPoint.Y);
|
|
1158 | 1096 |
} |
1159 |
else if (tempPoint[2] == newEndPoint)
|
|
1097 |
else if (Connections[2] == ConnectionPoint)
|
|
1160 | 1098 |
{ |
1161 |
testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
|
|
1099 |
testP = new Point(ConnectionPoint.X + 10, ConnectionPoint.Y);
|
|
1162 | 1100 |
} |
1163 | 1101 |
} |
1164 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
|
1165 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
|
1166 |
tempStartPoint, testP, tempEndPoint, control.isFixed, |
|
1102 |
|
|
1103 |
var border = control.GetBorderRectangle(tempEndPoint, scaleWidth, scaleHeight); |
|
1104 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(border, |
|
1105 |
tempStartPoint, testP, ConnectionPoint, control.isFixed, |
|
1167 | 1106 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
1168 | 1107 |
FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1169 | 1108 |
} |
1170 | 1109 |
else |
1171 | 1110 |
{ |
1172 |
//인구 수정 Arrow Text Style적용 되도록 변경
|
|
1173 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
|
|
1174 |
newStartPoint, tempMidPoint, tempEndPoint, control.isFixed,
|
|
1111 |
var border = control.GetBorderRectangle(tempEndPoint, scaleWidth, scaleHeight);
|
|
1112 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(border,
|
|
1113 |
newStartPoint, tempMidPoint, ConnectionPoint, control.isFixed,
|
|
1175 | 1114 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1176 | 1115 |
} |
1177 | 1116 |
} |
... | ... | |
1180 | 1119 |
{ |
1181 | 1120 |
throw ex; |
1182 | 1121 |
} |
1183 |
|
|
1184 | 1122 |
} |
1185 | 1123 |
break; |
1186 | 1124 |
#endregion |
... | ... | |
1670 | 1608 |
} |
1671 | 1609 |
|
1672 | 1610 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1673 |
if (control.fontConfig.Count() == 4)
|
|
1611 |
if (control.fontConfig.Count == 4) |
|
1674 | 1612 |
{ |
1675 | 1613 |
decoration = TextDecorations.Underline; |
1676 | 1614 |
} |
FinalService/KCOM_FinalService_DL/MarkupToPDF/Serialize/S_Control/Detail/S_TextControl.cs | ||
---|---|---|
12 | 12 |
using System.Collections.Generic; |
13 | 13 |
using MarkupToPDF.Controls.Common; |
14 | 14 |
using MarkupToPDF.Controls.Text; |
15 |
using CommonLib.MARKUS_API; |
|
15 | 16 |
|
16 | 17 |
namespace MarkupToPDF.Serialize.S_Control |
17 | 18 |
{ |
... | ... | |
76 | 77 |
GC.Collect(); |
77 | 78 |
GC.SuppressFinalize(this); |
78 | 79 |
} |
79 |
} |
|
80 | 80 |
|
81 |
//[DataContract] |
|
82 |
//public class SolidBrushForm |
|
83 |
//{ |
|
84 |
// [DataMember] |
|
85 |
// public double B_Opac { get; set; } |
|
86 |
// [DataMember] |
|
87 |
// public Color B_Color { get; set; } |
|
88 |
//} |
|
81 |
/// <summary> |
|
82 |
/// Border 사각형을 리턴한다. |
|
83 |
/// </summary> |
|
84 |
/// <param name="Origin"></param> |
|
85 |
/// <param name="ScaleWidth"></param> |
|
86 |
/// <param name="ScaleHeight"></param> |
|
87 |
/// <returns></returns> |
|
88 |
public System.Windows.Rect GetBorderRectangle(Point Origin, float ScaleWidth, float ScaleHeight) |
|
89 |
{ |
|
90 |
if (Convert.ToInt32(this.Angle) == 90) |
|
91 |
{ |
|
92 |
double _BoxWidth = this.BoxHeight / ScaleHeight; |
|
93 |
double _BoxHeight = this.BoxWidth / ScaleWidth; |
|
94 |
Origin = new Point(Origin.X, Origin.Y + _BoxHeight); |
|
95 |
|
|
96 |
return new System.Windows.Rect(Origin, new Point(Origin.X + _BoxWidth, Origin.Y - _BoxHeight)); |
|
97 |
} |
|
98 |
else if (Convert.ToInt32(this.Angle) == 270) |
|
99 |
{ |
|
100 |
double _BoxWidth = this.BoxHeight / ScaleHeight; |
|
101 |
double _BoxHeight = this.BoxWidth / ScaleWidth; |
|
102 |
Origin = new Point(Origin.X - _BoxWidth, Origin.Y); |
|
103 |
|
|
104 |
return new System.Windows.Rect(Origin, new Point(Origin.X + _BoxWidth, Origin.Y - _BoxHeight)); |
|
105 |
} |
|
106 |
else |
|
107 |
{ |
|
108 |
double _BoxWidth = this.BoxWidth / ScaleWidth; |
|
109 |
double _BoxHeight = this.BoxHeight / ScaleHeight; |
|
110 |
|
|
111 |
return new System.Windows.Rect(Origin, new Point(Origin.X + _BoxWidth, Origin.Y - _BoxHeight)); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
/// <summary> |
|
116 |
/// 연결점을 리턴한다. |
|
117 |
/// </summary> |
|
118 |
/// <param name="Origin"></param> |
|
119 |
/// <param name="ScaleWidth"></param> |
|
120 |
/// <param name="ScaleHeight"></param> |
|
121 |
/// <returns></returns> |
|
122 |
public List<Point> GetConnectionPoints(Point Origin, float ScaleWidth, float ScaleHeight) |
|
123 |
{ |
|
124 |
List<Point> res = new List<Point>(); |
|
125 |
|
|
126 |
var rect = GetBorderRectangle(Origin, ScaleWidth, ScaleHeight); |
|
127 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
|
128 |
|
|
129 |
res.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
|
130 |
res.Add(new Point(tempRectMidPoint.X, rect.Top)); |
|
131 |
res.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
|
132 |
res.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
|
133 |
|
|
134 |
return res; |
|
135 |
} |
|
136 |
} |
|
89 | 137 |
} |
내보내기 Unified diff