markus / MarkupToPDF / Controls / Text / TextControl.cs @ 81173d69
이력 | 보기 | 이력해설 | 다운로드 (45.7 KB)
1 | 787a4489 | KangIngu | using MarkupToPDF.Common; |
---|---|---|---|
2 | using MarkupToPDF.Controls.Common; |
||
3 | 036650a0 | humkyung | using MarkupToPDF.Serialize.Core; |
4 | using MarkupToPDF.Serialize.S_Control; |
||
5 | 787a4489 | KangIngu | using System; |
6 | using System.Collections.Generic; |
||
7 | using System.ComponentModel; |
||
8 | using System.Linq; |
||
9 | using System.Text; |
||
10 | using System.Threading.Tasks; |
||
11 | using System.Windows; |
||
12 | using System.Windows.Controls; |
||
13 | using System.Windows.Media; |
||
14 | using System.Windows.Shapes; |
||
15 | |||
16 | namespace MarkupToPDF.Controls.Text |
||
17 | { |
||
18 | [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))] |
||
19 | [TemplatePart(Name = "PART_TextBlock", Type = typeof(TextBlock))] |
||
20 | [TemplatePart(Name = "PART_TextPath", Type = typeof(Path))] |
||
21 | [TemplatePart(Name = "PART_Border", Type = typeof(Border))] |
||
22 | [TemplatePart(Name = "PART_Grid", Type = typeof(Grid))] |
||
23 | public class TextControl : CommentUserInfo, INotifyPropertyChanged, IMarkupControlData, IPath |
||
24 | { |
||
25 | public event PropertyChangedEventHandler PropertyChanged; |
||
26 | |||
27 | private const string PART_Grid = "PART_Grid"; |
||
28 | private const string PART_Border = "PART_Border"; |
||
29 | private const string PART_TextBox = "PART_TextBox"; |
||
30 | private const string PART_TextPath = "PART_TextPath"; |
||
31 | private const string PART_TextBlock = "PART_TextBlock"; |
||
32 | 0d00f9c8 | humkyung | private const string PART_Canvas = "PART_TextControlCanvas"; |
33 | 3074202c | 송근호 | private const string PART_BaseTextbox_Caret = "Caret"; |
34 | |||
35 | 787a4489 | KangIngu | //private const string PART_TextPrefix = "PART_TextPrefix"; |
36 | 3074202c | 송근호 | |
37 | 787a4489 | KangIngu | public Path Base_TextPath = null; |
38 | public Grid Base_Grid = null; |
||
39 | public Border Base_Border = null; |
||
40 | 0d00f9c8 | humkyung | public Canvas Base_Canvas = null; |
41 | 787a4489 | KangIngu | //public TextBlock Base_TextPrefixBlock = null; |
42 | public TextBlock Base_TextBlock = null; |
||
43 | public TextBox Base_TextBox = null; |
||
44 | 3074202c | 송근호 | public Border BaseTextbox_Caret = null; |
45 | 787a4489 | KangIngu | |
46 | public RotateTransform _rotation = null; |
||
47 | public TranslateTransform _translation = null; |
||
48 | public ScaleTransform _scale = null; |
||
49 | |||
50 | 53393bae | KangIngu | private const double _CloudArcDepth = 0.8; /// 2018.05.14 added by humkyung |
51 | 5a9353a9 | humkyung | |
52 | 959b3ef2 | humkyung | public override bool IsSelected |
53 | 787a4489 | KangIngu | { |
54 | get |
||
55 | { |
||
56 | return (bool)GetValue(IsSelectedProperty); |
||
57 | } |
||
58 | set |
||
59 | { |
||
60 | SetValue(IsSelectedProperty, value); |
||
61 | OnPropertyChanged("IsSelected"); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | #region Internal Method |
||
66 | |||
67 | public TextControl() |
||
68 | { |
||
69 | 90db87f6 | 송근호 | this.DefaultStyleKey = typeof(TextControl); |
70 | 787a4489 | KangIngu | } |
71 | |||
72 | static TextControl() |
||
73 | { |
||
74 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TextControl), new FrameworkPropertyMetadata(typeof(TextControl))); |
||
75 | ResourceDictionary dictionary = new ResourceDictionary(); |
||
76 | dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
77 | Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
78 | 90db87f6 | 송근호 | |
79 | 787a4489 | KangIngu | } |
80 | 90db87f6 | 송근호 | |
81 | |||
82 | 787a4489 | KangIngu | public override void OnApplyTemplate() |
83 | { |
||
84 | 90db87f6 | 송근호 | base.OnApplyTemplate(); |
85 | 787a4489 | KangIngu | |
86 | Base_TextPath = GetTemplateChild(PART_TextPath) as Path; |
||
87 | Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox; |
||
88 | Base_TextBlock = GetTemplateChild(PART_TextBlock) as TextBlock; |
||
89 | Base_Grid = GetTemplateChild(PART_Grid) as Grid; |
||
90 | Base_Border = GetTemplateChild(PART_Border) as Border; |
||
91 | 0d00f9c8 | humkyung | Base_Canvas = GetTemplateChild(PART_Canvas) as Canvas; |
92 | 3074202c | 송근호 | BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border; |
93 | this.Base_TextBox.Text = this.Text; |
||
94 | this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length; |
||
95 | this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent); |
||
96 | this.Base_TextBox.ApplyTemplate(); |
||
97 | MoveCustomCaret(); |
||
98 | |||
99 | 787a4489 | KangIngu | this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
100 | 6b5d33c6 | djkim | this.Base_TextBlock.SizeChanged += new SizeChangedEventHandler(Base_TextBlock_SizeChanged); |
101 | this.Base_TextBox.GotFocus += new RoutedEventHandler(TextControl_GotFocus); |
||
102 | 819630e9 | 송근호 | this.Base_TextBox.LostFocus += new RoutedEventHandler(TextControl_LostFocus); |
103 | 3074202c | 송근호 | this.Base_TextBox.TextChanged += new TextChangedEventHandler(Base_TextBox_TextChanged); |
104 | this.Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret(); |
||
105 | b1ec47cb | 송근호 | |
106 | 6b5d33c6 | djkim | DrawingCloud(); |
107 | 787a4489 | KangIngu | SetText(); |
108 | 3074202c | 송근호 | |
109 | |||
110 | |||
111 | |||
112 | } |
||
113 | /// <summary> |
||
114 | /// Moves the custom caret on the canvas. |
||
115 | /// </summary> |
||
116 | public void MoveCustomCaret() |
||
117 | { |
||
118 | |||
119 | var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location; |
||
120 | |||
121 | if (!double.IsInfinity(caretLocation.X)) { |
||
122 | Canvas.SetLeft(this.BaseTextbox_Caret, caretLocation.X); |
||
123 | } |
||
124 | |||
125 | if (!double.IsInfinity(caretLocation.Y)) { |
||
126 | Canvas.SetTop(this.BaseTextbox_Caret, caretLocation.Y); |
||
127 | } |
||
128 | 787a4489 | KangIngu | } |
129 | |||
130 | 414aaec1 | 송근호 | private void Base_TextBox_TextChanged(object sender, TextChangedEventArgs e) |
131 | { |
||
132 | if (Base_TextBox.Text.Contains("|OR||DZ|")) { |
||
133 | Base_TextBox.Text = this.Text; |
||
134 | } |
||
135 | b1ec47cb | 송근호 | |
136 | |||
137 | 414aaec1 | 송근호 | this.Text = Base_TextBox.Text; |
138 | 3074202c | 송근호 | |
139 | b1ec47cb | 송근호 | |
140 | 414aaec1 | 송근호 | DrawingCloud(); |
141 | } |
||
142 | |||
143 | f513c215 | humkyung | public override void ApplyOverViewData() |
144 | 787a4489 | KangIngu | { |
145 | this.OverViewPathData = this.PathData; |
||
146 | this.OverViewText = this.Text; |
||
147 | this.OverViewPaint = this.Paint; |
||
148 | |||
149 | } |
||
150 | |||
151 | void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e) |
||
152 | { |
||
153 | BoxWidth = e.NewSize.Width; |
||
154 | BoxHeight = e.NewSize.Height; |
||
155 | 3074202c | 송근호 | |
156 | 787a4489 | KangIngu | DrawingCloud(); |
157 | } |
||
158 | |||
159 | void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e) |
||
160 | { |
||
161 | 90db87f6 | 송근호 | if (Base_TextBox.Text.Contains("|OR||DZ|")) { |
162 | Base_TextBox.Text = this.Text; |
||
163 | } |
||
164 | |||
165 | this.Text = Base_TextBox.Text; |
||
166 | 787a4489 | KangIngu | BoxWidth = e.NewSize.Width; |
167 | BoxHeight = e.NewSize.Height; |
||
168 | 90e7968d | ljiyeon | DrawingCloud(); |
169 | 787a4489 | KangIngu | } |
170 | |||
171 | void TextControl_GotFocus(object sender, RoutedEventArgs e) |
||
172 | { |
||
173 | if (EnableEditing) |
||
174 | { |
||
175 | EditingMode(); |
||
176 | 3074202c | 송근호 | |
177 | 787a4489 | KangIngu | } |
178 | else |
||
179 | { |
||
180 | 3074202c | 송근호 | |
181 | 787a4489 | KangIngu | UnEditingMode(); |
182 | } |
||
183 | } |
||
184 | |||
185 | void TextControl_LostFocus(object sender, RoutedEventArgs e) |
||
186 | { |
||
187 | UnEditingMode(); |
||
188 | ApplyOverViewData(); |
||
189 | } |
||
190 | |||
191 | //void TextControl_GotFocus(object sender, RoutedEventArgs e) |
||
192 | //{ |
||
193 | // Base_TextBox.Visibility = Visibility.Visible; |
||
194 | // Base_TextBlock.Visibility = Visibility.Collapsed; |
||
195 | // this.Base_TextBox.BorderThickness = new Thickness(1); |
||
196 | // if (UnderLine != null) |
||
197 | // { |
||
198 | // Base_TextBlock.TextDecorations = UnderLine; |
||
199 | // } |
||
200 | // if (this.Text != null) |
||
201 | // { |
||
202 | // Base_TextBox.Text = this.Text; |
||
203 | // } |
||
204 | // IsEditing = true; |
||
205 | //} |
||
206 | //void TextControl_LostFocus(object sender, RoutedEventArgs e) |
||
207 | //{ |
||
208 | // Base_TextBox.Visibility = Visibility.Collapsed; |
||
209 | // Base_TextBlock.Visibility = Visibility.Visible; |
||
210 | // this.Text = Base_TextBox.Text; |
||
211 | // if (UnderLine != null) |
||
212 | // { |
||
213 | // Base_TextBlock.TextDecorations = UnderLine; |
||
214 | // } |
||
215 | // Base_TextBlock.Margin = |
||
216 | // new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
||
217 | // IsEditing = false; |
||
218 | //} |
||
219 | |||
220 | public void EditingMode() |
||
221 | { |
||
222 | 6b5d33c6 | djkim | //this.Base_TextBox.Focus(); |
223 | 2aac9b2b | djkim | //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString()); |
224 | 3074202c | 송근호 | |
225 | |||
226 | 787a4489 | KangIngu | TextBoxVisibility = Visibility.Visible; |
227 | //Base_TextBox.Visibility = System.Windows.Visibility.Visible; |
||
228 | |||
229 | TextBlockVisibility = Visibility.Collapsed; |
||
230 | //Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed; |
||
231 | 3074202c | 송근호 | this.BaseTextbox_Caret.Visibility = Visibility.Visible; |
232 | |||
233 | 787a4489 | KangIngu | //this.Base_TextBox.BorderThickness = new Thickness(1); |
234 | |||
235 | if (UnderLine != null) |
||
236 | Base_TextBlock.TextDecorations = UnderLine; |
||
237 | |||
238 | 3074202c | 송근호 | if (this.Text != null) { |
239 | this.Base_TextBox.Text = this.Text; |
||
240 | MoveCustomCaret(); |
||
241 | //this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length; |
||
242 | //this.Base_TextBox.Select(Base_TextBox.Text.Length, 0); |
||
243 | } |
||
244 | |||
245 | 787a4489 | KangIngu | // Base_TextBox.Margin = |
246 | //new Thickness(Base_TextBlock.Margin.Left + -2, Base_TextBlock.Margin.Top + 0, |
||
247 | //Base_TextBlock.Margin.Right + 0, Base_TextBlock.Margin.Bottom + -2); |
||
248 | } |
||
249 | |||
250 | public void UnEditingMode() |
||
251 | { |
||
252 | if (EnableEditing) |
||
253 | this.Text = Base_TextBox.Text; |
||
254 | |||
255 | 3074202c | 송근호 | this.Base_TextBox.Select(Base_TextBox.Text.Length, 0); |
256 | |||
257 | 787a4489 | KangIngu | TextBoxVisibility = Visibility.Collapsed; |
258 | //Base_TextBox.Visibility = System.Windows.Visibility.Collapsed; |
||
259 | |||
260 | TextBlockVisibility = Visibility.Visible; |
||
261 | //Base_TextBlock.Visibility = System.Windows.Visibility.Visible; |
||
262 | |||
263 | 3074202c | 송근호 | this.BaseTextbox_Caret.Visibility = Visibility.Collapsed; |
264 | |||
265 | 787a4489 | KangIngu | if (UnderLine != null) |
266 | Base_TextBlock.TextDecorations = UnderLine; |
||
267 | |||
268 | //Base_TextBox.Focusable = false; |
||
269 | |||
270 | //Base_TextBlock.Margin = |
||
271 | // new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, |
||
272 | // Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
||
273 | |||
274 | // Base_TextBlock.Margin = |
||
275 | //new Thickness(Base_TextBox.Margin.Left + 2, Base_TextBox.Margin.Top + 2, |
||
276 | // Base_TextBox.Margin.Right + 2, Base_TextBox.Margin.Bottom + 2); |
||
277 | |||
278 | // Base_TextBlock.Margin = |
||
279 | //new Thickness(Base_TextBox.Margin.Left + 5, Base_TextBox.Margin.Top + 0, |
||
280 | //Base_TextBox.Margin.Right + 0, Base_TextBox.Margin.Bottom + 2); |
||
281 | } |
||
282 | |||
283 | public void SetText() |
||
284 | { |
||
285 | this.ApplyTemplate(); |
||
286 | 3074202c | 송근호 | |
287 | 787a4489 | KangIngu | if (IsHighLight) |
288 | { |
||
289 | this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
||
290 | Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
||
291 | this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), |
||
292 | Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
||
293 | } |
||
294 | else |
||
295 | { |
||
296 | this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
||
297 | Colors.White.R, Colors.White.G, Colors.White.B)); |
||
298 | |||
299 | this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), |
||
300 | Colors.White.R, Colors.White.G, Colors.White.B)); |
||
301 | } |
||
302 | if (Base_TextPath != null) |
||
303 | { |
||
304 | Base_TextPath.StrokeThickness = LineSize.Left; |
||
305 | } |
||
306 | } |
||
307 | |||
308 | public void DrawingCloud() |
||
309 | { |
||
310 | this.ApplyTemplate(); |
||
311 | 90db87f6 | 송근호 | |
312 | 787a4489 | KangIngu | List<Point> pCloud = new List<Point> |
313 | { |
||
314 | new Point(0, 0), |
||
315 | new Point(0, 0 + BoxHeight + 0), |
||
316 | new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0), |
||
317 | new Point(0 + BoxWidth + 2 ,0), |
||
318 | }; |
||
319 | 3074202c | 송근호 | //this.Base_TextBox.Select(Base_TextBox.Text.Length, 0); |
320 | 787a4489 | KangIngu | if (Base_TextPath != null) |
321 | { |
||
322 | switch (ControlType_No) |
||
323 | { |
||
324 | case 0: |
||
325 | { |
||
326 | PathData = new PathGeometry(); |
||
327 | PathDataInner = (GenerateInner(pCloud)); |
||
328 | } |
||
329 | break; |
||
330 | case 1: |
||
331 | { |
||
332 | PathData = (Generate_Rect(pCloud)); |
||
333 | List<Point> pCloud2 = new List<Point> |
||
334 | { |
||
335 | new Point(0, 0), |
||
336 | new Point(0, 0 + BoxHeight + 0), |
||
337 | new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0), |
||
338 | new Point(0 + BoxWidth + 10 ,0), |
||
339 | }; |
||
340 | PathDataInner = (GenerateInner(pCloud)); |
||
341 | } |
||
342 | break; |
||
343 | case 2: |
||
344 | { |
||
345 | PathData = (Generate(pCloud)); |
||
346 | PathDataInner = (GenerateInner(pCloud)); |
||
347 | } |
||
348 | break; |
||
349 | } |
||
350 | } |
||
351 | |||
352 | 6b5d33c6 | djkim | //SetText(); |
353 | 787a4489 | KangIngu | } |
354 | #endregion Internal Method |
||
355 | |||
356 | public void Dispose() |
||
357 | { |
||
358 | GC.Collect(); |
||
359 | GC.SuppressFinalize(this); |
||
360 | } |
||
361 | 0d00f9c8 | humkyung | |
362 | public override void UpdateControl() |
||
363 | 787a4489 | KangIngu | { |
364 | 0d00f9c8 | humkyung | if (this.PointSet.Count > 1) |
365 | { |
||
366 | this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
||
367 | this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
||
368 | } |
||
369 | 787a4489 | KangIngu | } |
370 | |||
371 | #region Drawing Cloud Method |
||
372 | public static PathGeometry Generate_Rect(List<Point> pData) |
||
373 | { |
||
374 | PathFigure pathFigure = new PathFigure(); |
||
375 | pathFigure.StartPoint = pData[0]; |
||
376 | |||
377 | 10df01b4 | humkyung | PolyLineSegment polyline = new PolyLineSegment(pData, true); |
378 | pathFigure.Segments.Add(polyline); |
||
379 | 787a4489 | KangIngu | |
380 | PathGeometry rectPathGeometry = new PathGeometry(); |
||
381 | rectPathGeometry.Figures = new PathFigureCollection(); |
||
382 | pathFigure.IsClosed = true; |
||
383 | pathFigure.IsFilled = false; |
||
384 | rectPathGeometry.Figures.Add(pathFigure); |
||
385 | |||
386 | |||
387 | return rectPathGeometry; |
||
388 | } |
||
389 | |||
390 | public static PathGeometry Generate(List<Point> pData) |
||
391 | { |
||
392 | var _pathGeometry = new PathGeometry(); |
||
393 | double area = MathSet.AreaOf(pData); |
||
394 | bool reverse = (area > 0); |
||
395 | int count = pData.Count; |
||
396 | 10df01b4 | humkyung | for (int i = 0; i < count; i++) |
397 | 787a4489 | KangIngu | { |
398 | 90db87f6 | 송근호 | PathFigure pathFigure = GenerateLineWithCloud(pData[i % count], pData[(i + 1) % count], 20, reverse); |
399 | 787a4489 | KangIngu | pathFigure.IsClosed = false; |
400 | pathFigure.IsFilled = true; |
||
401 | _pathGeometry.Figures.Add(pathFigure); |
||
402 | } |
||
403 | |||
404 | return _pathGeometry; |
||
405 | } |
||
406 | |||
407 | |||
408 | public static PathGeometry GenerateInner(List<Point> pData) |
||
409 | { |
||
410 | var _pathGeometry = new PathGeometry(); |
||
411 | double area = MathSet.AreaOf(pData); |
||
412 | bool reverse = (area > 0); |
||
413 | int count = pData.Count; |
||
414 | |||
415 | PathFigure pathFigur2 = new PathFigure(); |
||
416 | pathFigur2.StartPoint = pData[0]; |
||
417 | |||
418 | 10df01b4 | humkyung | PolyLineSegment polyline = new PolyLineSegment(pData, true); |
419 | pathFigur2.Segments.Add(polyline); |
||
420 | 787a4489 | KangIngu | |
421 | pathFigur2.IsClosed = true; |
||
422 | pathFigur2.IsFilled = true; |
||
423 | _pathGeometry.Figures.Add(pathFigur2); |
||
424 | |||
425 | return _pathGeometry; |
||
426 | } |
||
427 | |||
428 | public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse) |
||
429 | { |
||
430 | PathFigure pathFigure = new PathFigure(); |
||
431 | pathFigure.StartPoint = p1; |
||
432 | |||
433 | double arcLength = _arcLength; |
||
434 | double dx = p2.X - p1.X; |
||
435 | double dy = p2.Y - p1.Y; |
||
436 | double l = MathSet.DistanceTo(p1, p2); |
||
437 | double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
||
438 | Point lastPt = new Point(p1.X, p1.Y); |
||
439 | double count = l / _arcLength; |
||
440 | |||
441 | dx /= l; |
||
442 | dy /= l; |
||
443 | |||
444 | Double j = 1; |
||
445 | for (j = 1; j < (count - 1); j++) |
||
446 | { |
||
447 | ArcSegment arcSeg = new ArcSegment(); |
||
448 | 5a9353a9 | humkyung | arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth); |
449 | 787a4489 | KangIngu | arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); |
450 | lastPt = arcSeg.Point; |
||
451 | arcSeg.RotationAngle = theta + 90; |
||
452 | if (true == reverse) |
||
453 | arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
454 | pathFigure.Segments.Add(arcSeg); |
||
455 | } |
||
456 | |||
457 | if ((count > j) || count > 0) |
||
458 | { |
||
459 | arcLength = MathSet.DistanceTo(lastPt, p2); |
||
460 | ArcSegment arcSeg = new ArcSegment(); |
||
461 | 5a9353a9 | humkyung | arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth); |
462 | 787a4489 | KangIngu | arcSeg.Point = new Point(p2.X, p2.Y); |
463 | arcSeg.RotationAngle = theta; |
||
464 | |||
465 | if (true == reverse) |
||
466 | arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
467 | |||
468 | pathFigure.Segments.Add(arcSeg); |
||
469 | |||
470 | } |
||
471 | return pathFigure; |
||
472 | } |
||
473 | #endregion |
||
474 | |||
475 | #region Dependency Properties |
||
476 | public static readonly DependencyProperty ControlTypeProperty = |
||
477 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(TextControl), new FrameworkPropertyMetadata(ControlType.TextControl)); |
||
478 | |||
479 | public static readonly DependencyProperty ControlType_NoProperty = |
||
480 | DependencyProperty.Register("ControlType_No", typeof(int), typeof(TextControl), new FrameworkPropertyMetadata(0)); |
||
481 | |||
482 | public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register( |
||
483 | "IsSelected", typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
484 | |||
485 | public static readonly DependencyProperty PathGeometryProperty = DependencyProperty.Register( |
||
486 | "PathGeometry", typeof(PathGeometry), typeof(TextControl), new PropertyMetadata(null, SetPathGeometryChanged)); |
||
487 | |||
488 | public static readonly DependencyProperty TextProperty = DependencyProperty.Register( |
||
489 | "Text", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
490 | |||
491 | public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register( |
||
492 | "OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
493 | |||
494 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
495 | "UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
496 | |||
497 | 05009a0e | ljiyeon | /*public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register( |
498 | "FontColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));*/ |
||
499 | |||
500 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
501 | "StrokeColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
502 | 787a4489 | KangIngu | |
503 | //강인구 추가 |
||
504 | public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register( |
||
505 | "IsHighLight", typeof(bool), typeof(TextControl), new PropertyMetadata(false, PointValueChanged)); |
||
506 | |||
507 | public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register( |
||
508 | "BackColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
||
509 | |||
510 | public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register( |
||
511 | "BackInnerColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
||
512 | |||
513 | public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register( |
||
514 | "UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null)); |
||
515 | |||
516 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
517 | f8769f8a | ljiyeon | "LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4), PointValueChanged)); //여기만 4인지 모르겠지만 4 그대로 두겠음 |
518 | 787a4489 | KangIngu | |
519 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
520 | "PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>())); |
||
521 | |||
522 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
523 | "PathData", typeof(Geometry), typeof(TextControl), null); |
||
524 | |||
525 | 05009a0e | ljiyeon | |
526 | |||
527 | 787a4489 | KangIngu | public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register( |
528 | "PathDataInner", typeof(Geometry), typeof(TextControl), null); |
||
529 | |||
530 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
531 | "OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null); |
||
532 | |||
533 | public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( |
||
534 | "TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal)); |
||
535 | |||
536 | public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register( |
||
537 | "TextFamily", typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial"))); |
||
538 | |||
539 | public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register( |
||
540 | "TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal)); |
||
541 | |||
542 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register( |
||
543 | "CenterX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
544 | |||
545 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register( |
||
546 | "CenterY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
547 | |||
548 | public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
||
549 | "CanvasX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
550 | |||
551 | public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
||
552 | "CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
553 | |||
554 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
555 | "StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
556 | |||
557 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
558 | "EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
||
559 | |||
560 | public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register( |
||
561 | "TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged)); |
||
562 | |||
563 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
564 | "Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
||
565 | |||
566 | public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register( |
||
567 | "OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
||
568 | |||
569 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
||
570 | "Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
||
571 | |||
572 | public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register( |
||
573 | 71d7e0bf | 송근호 | "EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged))); |
574 | 787a4489 | KangIngu | |
575 | public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register( |
||
576 | "TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged)); |
||
577 | |||
578 | public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register( |
||
579 | "TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged)); |
||
580 | |||
581 | #endregion Dependency Properties |
||
582 | |||
583 | #region dp Properties |
||
584 | |||
585 | 05009a0e | ljiyeon | |
586 | public override SolidColorBrush StrokeColor |
||
587 | { |
||
588 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
589 | set |
||
590 | { |
||
591 | if (this.StrokeColor != value) |
||
592 | { |
||
593 | SetValue(StrokeColorProperty, value); |
||
594 | } |
||
595 | } |
||
596 | } |
||
597 | |||
598 | 90db87f6 | 송근호 | |
599 | 787a4489 | KangIngu | |
600 | public bool EnableEditing |
||
601 | { |
||
602 | get { return (bool)GetValue(EnableEditingProperty); } |
||
603 | set |
||
604 | { |
||
605 | if (this.EnableEditing != value) |
||
606 | { |
||
607 | SetValue(EnableEditingProperty, value); |
||
608 | OnPropertyChanged("EnableEditing"); |
||
609 | } |
||
610 | } |
||
611 | } |
||
612 | |||
613 | public Thickness LineSize |
||
614 | { |
||
615 | get |
||
616 | { |
||
617 | return (Thickness)GetValue(LineSizeProperty); |
||
618 | } |
||
619 | set |
||
620 | { |
||
621 | if (this.LineSize != value) |
||
622 | { |
||
623 | SetValue(LineSizeProperty, value); |
||
624 | OnPropertyChanged("LineSize"); |
||
625 | } |
||
626 | } |
||
627 | } |
||
628 | |||
629 | 5529d2a2 | humkyung | public override ControlType ControlType |
630 | 787a4489 | KangIngu | { |
631 | get |
||
632 | { |
||
633 | return (ControlType)GetValue(ControlTypeProperty); |
||
634 | } |
||
635 | set |
||
636 | { |
||
637 | SetValue(ControlTypeProperty, value); |
||
638 | } |
||
639 | } |
||
640 | public int ControlType_No |
||
641 | { |
||
642 | get |
||
643 | { |
||
644 | return (int)GetValue(ControlType_NoProperty); |
||
645 | } |
||
646 | set |
||
647 | { |
||
648 | SetValue(ControlType_NoProperty, value); |
||
649 | } |
||
650 | } |
||
651 | |||
652 | public string UserID |
||
653 | { |
||
654 | get { return (string)GetValue(UserIDProperty); } |
||
655 | set |
||
656 | { |
||
657 | if (this.UserID != value) |
||
658 | { |
||
659 | SetValue(UserIDProperty, value); |
||
660 | OnPropertyChanged("UserID"); |
||
661 | } |
||
662 | } |
||
663 | } |
||
664 | |||
665 | public double CenterX |
||
666 | { |
||
667 | get { return (double)GetValue(CenterXProperty); } |
||
668 | 90db87f6 | 송근호 | set |
669 | { |
||
670 | SetValue(CenterXProperty, value); |
||
671 | OnPropertyChanged("CenterX"); |
||
672 | |||
673 | 787a4489 | KangIngu | } |
674 | } |
||
675 | |||
676 | public double CenterY |
||
677 | { |
||
678 | get { return (double)GetValue(CenterYProperty); } |
||
679 | 90db87f6 | 송근호 | set |
680 | { |
||
681 | SetValue(CenterYProperty, value); |
||
682 | OnPropertyChanged("CenterY"); |
||
683 | 787a4489 | KangIngu | } |
684 | } |
||
685 | |||
686 | public string Text |
||
687 | { |
||
688 | get { return (string)GetValue(TextProperty); } |
||
689 | set |
||
690 | { |
||
691 | if (this.Text != value) |
||
692 | { |
||
693 | SetValue(TextProperty, value); |
||
694 | OnPropertyChanged("Text"); |
||
695 | } |
||
696 | } |
||
697 | } |
||
698 | |||
699 | public string OverViewText |
||
700 | { |
||
701 | get { return (string)GetValue(OverViewTextProperty); } |
||
702 | set |
||
703 | { |
||
704 | if (this.OverViewText != value) |
||
705 | { |
||
706 | SetValue(OverViewTextProperty, value); |
||
707 | OnPropertyChanged("OverViewText"); |
||
708 | } |
||
709 | } |
||
710 | } |
||
711 | |||
712 | public Geometry OverViewPathData |
||
713 | { |
||
714 | get { return (Geometry)GetValue(OverViewPathDataProperty); } |
||
715 | set |
||
716 | { |
||
717 | if (this.OverViewPathData != value) |
||
718 | { |
||
719 | SetValue(OverViewPathDataProperty, value); |
||
720 | OnPropertyChanged("OverViewPathData"); |
||
721 | } |
||
722 | } |
||
723 | } |
||
724 | |||
725 | public Visibility TextBoxVisibility |
||
726 | { |
||
727 | get { return (Visibility)GetValue(TextBoxVisibilityProperty); } |
||
728 | set |
||
729 | { |
||
730 | if (this.TextBoxVisibility != value) |
||
731 | { |
||
732 | SetValue(TextBoxVisibilityProperty, value); |
||
733 | OnPropertyChanged("TextBoxVisibility"); |
||
734 | } |
||
735 | } |
||
736 | } |
||
737 | |||
738 | |||
739 | public Visibility TextBlockVisibility |
||
740 | { |
||
741 | get { return (Visibility)GetValue(TextBlockVisibilityProperty); } |
||
742 | set |
||
743 | { |
||
744 | if (this.TextBlockVisibility != value) |
||
745 | { |
||
746 | SetValue(TextBlockVisibilityProperty, value); |
||
747 | OnPropertyChanged("TextBlockVisibility"); |
||
748 | } |
||
749 | } |
||
750 | } |
||
751 | |||
752 | |||
753 | |||
754 | public Double TextSize |
||
755 | { |
||
756 | get { return (Double)GetValue(TextSizeProperty); } |
||
757 | set |
||
758 | { |
||
759 | if (this.TextSize != value) |
||
760 | { |
||
761 | SetValue(TextSizeProperty, value); |
||
762 | OnPropertyChanged("TextSize"); |
||
763 | } |
||
764 | } |
||
765 | } |
||
766 | 05009a0e | ljiyeon | /* |
767 | 787a4489 | KangIngu | public SolidColorBrush FontColor |
768 | { |
||
769 | get { return (SolidColorBrush)GetValue(FontColorProperty); } |
||
770 | set |
||
771 | { |
||
772 | if (this.FontColor != value) |
||
773 | { |
||
774 | SetValue(FontColorProperty, value); |
||
775 | OnPropertyChanged("FontColor"); |
||
776 | } |
||
777 | } |
||
778 | 05009a0e | ljiyeon | }*/ |
779 | 787a4489 | KangIngu | |
780 | public SolidColorBrush BackColor |
||
781 | { |
||
782 | get { return (SolidColorBrush)GetValue(BackColorProperty); } |
||
783 | set |
||
784 | { |
||
785 | if (this.BackColor != value) |
||
786 | { |
||
787 | SetValue(BackColorProperty, value); |
||
788 | OnPropertyChanged("BackColor"); |
||
789 | } |
||
790 | } |
||
791 | } |
||
792 | |||
793 | public SolidColorBrush BackInnerColor |
||
794 | { |
||
795 | get { return (SolidColorBrush)GetValue(BackInnerColorProperty); } |
||
796 | set |
||
797 | { |
||
798 | if (this.BackInnerColor != value) |
||
799 | { |
||
800 | SetValue(BackInnerColorProperty, value); |
||
801 | OnPropertyChanged("BackInnerColor"); |
||
802 | } |
||
803 | } |
||
804 | } |
||
805 | |||
806 | 90db87f6 | 송근호 | |
807 | 787a4489 | KangIngu | |
808 | public TextDecorationCollection UnderLine |
||
809 | { |
||
810 | get |
||
811 | { |
||
812 | return (TextDecorationCollection)GetValue(UnderLineProperty); |
||
813 | } |
||
814 | set |
||
815 | { |
||
816 | if (this.UnderLine != value) |
||
817 | { |
||
818 | SetValue(UnderLineProperty, value); |
||
819 | OnPropertyChanged("UnderLine"); |
||
820 | } |
||
821 | } |
||
822 | } |
||
823 | |||
824 | public double CanvasX |
||
825 | { |
||
826 | get { return (double)GetValue(CanvasXProperty); } |
||
827 | set |
||
828 | { |
||
829 | if (this.CanvasX != value) |
||
830 | { |
||
831 | SetValue(CanvasXProperty, value); |
||
832 | OnPropertyChanged("CanvasX"); |
||
833 | } |
||
834 | } |
||
835 | } |
||
836 | |||
837 | public double CanvasY |
||
838 | { |
||
839 | get { return (double)GetValue(CanvasYProperty); } |
||
840 | set |
||
841 | { |
||
842 | if (this.CanvasY != value) |
||
843 | { |
||
844 | SetValue(CanvasYProperty, value); |
||
845 | OnPropertyChanged("CanvasY"); |
||
846 | } |
||
847 | } |
||
848 | } |
||
849 | |||
850 | public Point EndPoint |
||
851 | { |
||
852 | get { return (Point)GetValue(EndPointProperty); } |
||
853 | set |
||
854 | { |
||
855 | if (this.EndPoint != value) |
||
856 | { |
||
857 | SetValue(EndPointProperty, value); |
||
858 | OnPropertyChanged("EndPoint"); |
||
859 | } |
||
860 | } |
||
861 | } |
||
862 | |||
863 | public Point StartPoint |
||
864 | { |
||
865 | get { return (Point)GetValue(StartPointProperty); } |
||
866 | set |
||
867 | { |
||
868 | if (this.StartPoint != value) |
||
869 | { |
||
870 | SetValue(StartPointProperty, value); |
||
871 | OnPropertyChanged("StartPoint"); |
||
872 | } |
||
873 | } |
||
874 | } |
||
875 | |||
876 | public FontStyle TextStyle |
||
877 | { |
||
878 | get { return (FontStyle)GetValue(TextStyleProperty); } |
||
879 | set |
||
880 | { |
||
881 | if (this.TextStyle != value) |
||
882 | { |
||
883 | SetValue(TextStyleProperty, value); |
||
884 | OnPropertyChanged("TextStyle"); |
||
885 | } |
||
886 | } |
||
887 | } |
||
888 | |||
889 | public FontFamily TextFamily |
||
890 | { |
||
891 | get { return (FontFamily)GetValue(TextFamilyProperty); } |
||
892 | set |
||
893 | { |
||
894 | if (this.TextFamily != value) |
||
895 | { |
||
896 | SetValue(TextFamilyProperty, value); |
||
897 | OnPropertyChanged("TextFamily"); |
||
898 | } |
||
899 | } |
||
900 | } |
||
901 | |||
902 | public FontWeight TextWeight |
||
903 | { |
||
904 | get { return (FontWeight)GetValue(TextWeightProperty); } |
||
905 | set |
||
906 | { |
||
907 | if (this.TextWeight != value) |
||
908 | { |
||
909 | SetValue(TextWeightProperty, value); |
||
910 | OnPropertyChanged("TextWeight"); |
||
911 | } |
||
912 | } |
||
913 | } |
||
914 | |||
915 | public PaintSet Paint |
||
916 | { |
||
917 | get { return (PaintSet)GetValue(PaintProperty); } |
||
918 | set |
||
919 | { |
||
920 | if (this.Paint != value) |
||
921 | { |
||
922 | SetValue(PaintProperty, value); |
||
923 | OnPropertyChanged("Paint"); |
||
924 | } |
||
925 | } |
||
926 | } |
||
927 | |||
928 | public PaintSet OverViewPaint |
||
929 | { |
||
930 | get { return (PaintSet)GetValue(OverViewPaintProperty); } |
||
931 | set |
||
932 | { |
||
933 | if (this.OverViewPaint != value) |
||
934 | { |
||
935 | SetValue(OverViewPaintProperty, value); |
||
936 | OnPropertyChanged("OverViewPaint"); |
||
937 | } |
||
938 | } |
||
939 | } |
||
940 | |||
941 | double IPath.LineSize |
||
942 | { |
||
943 | get |
||
944 | { |
||
945 | return this.LineSize.Left; |
||
946 | } |
||
947 | set |
||
948 | { |
||
949 | this.LineSize = new Thickness(value); |
||
950 | OnPropertyChanged("LineSize"); |
||
951 | } |
||
952 | } |
||
953 | |||
954 | |||
955 | public Geometry PathData |
||
956 | { |
||
957 | get { return (Geometry)GetValue(PathDataProperty); } |
||
958 | 90db87f6 | 송근호 | set |
959 | { |
||
960 | SetValue(PathDataProperty, value); |
||
961 | OnPropertyChanged("PathData"); |
||
962 | 787a4489 | KangIngu | } |
963 | } |
||
964 | |||
965 | public Geometry PathDataInner |
||
966 | { |
||
967 | get { return (Geometry)GetValue(PathDataInnerProperty); } |
||
968 | set |
||
969 | { |
||
970 | SetValue(PathDataInnerProperty, value); |
||
971 | OnPropertyChanged("PathDataInner"); |
||
972 | } |
||
973 | } |
||
974 | |||
975 | 54e35b39 | 송근호 | public override double Angle |
976 | 787a4489 | KangIngu | { |
977 | get { return (double)GetValue(AngleProperty); } |
||
978 | set |
||
979 | { |
||
980 | if (this.Angle != value) |
||
981 | { |
||
982 | SetValue(AngleProperty, value); |
||
983 | |||
984 | OnPropertyChanged("Angle"); |
||
985 | UpdateLayout(); |
||
986 | } |
||
987 | } |
||
988 | } |
||
989 | |||
990 | public bool IsHighLight |
||
991 | { |
||
992 | get { return (bool)GetValue(IsHighlightProperty); } |
||
993 | set |
||
994 | { |
||
995 | if (this.IsHighLight != value) |
||
996 | { |
||
997 | SetValue(IsHighlightProperty, value); |
||
998 | OnPropertyChanged("IsHighLight"); |
||
999 | } |
||
1000 | } |
||
1001 | } |
||
1002 | |||
1003 | public List<Point> PointSet |
||
1004 | { |
||
1005 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
1006 | 90db87f6 | 송근호 | set |
1007 | { |
||
1008 | SetValue(PointSetProperty, value); |
||
1009 | OnPropertyChanged("PointSet"); |
||
1010 | 787a4489 | KangIngu | } |
1011 | } |
||
1012 | |||
1013 | #endregion Properties |
||
1014 | |||
1015 | #region Properties |
||
1016 | |||
1017 | |||
1018 | |||
1019 | 90db87f6 | 송근호 | public PathGeometry PathGeometry |
1020 | 787a4489 | KangIngu | { |
1021 | get { return (PathGeometry)GetValue(PathGeometryProperty); } |
||
1022 | set |
||
1023 | { |
||
1024 | SetValue(PathGeometryProperty, value); |
||
1025 | OnPropertyChanged("PathGeometry"); |
||
1026 | } |
||
1027 | } |
||
1028 | |||
1029 | private double _BoxWidth; |
||
1030 | public double BoxWidth |
||
1031 | { |
||
1032 | get |
||
1033 | { |
||
1034 | return _BoxWidth; |
||
1035 | } |
||
1036 | set |
||
1037 | { |
||
1038 | _BoxWidth = value; |
||
1039 | OnPropertyChanged("BoxWidth"); |
||
1040 | } |
||
1041 | } |
||
1042 | |||
1043 | private double _BoxHeight; |
||
1044 | public double BoxHeight |
||
1045 | { |
||
1046 | get |
||
1047 | { |
||
1048 | return _BoxHeight; |
||
1049 | } |
||
1050 | set |
||
1051 | { |
||
1052 | _BoxHeight = value; |
||
1053 | OnPropertyChanged("BoxHeight"); |
||
1054 | } |
||
1055 | } |
||
1056 | |||
1057 | #endregion |
||
1058 | |||
1059 | #region CallBack Method |
||
1060 | public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1061 | { |
||
1062 | var instance = (TextControl)sender; |
||
1063 | |||
1064 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
1065 | { |
||
1066 | instance.SetValue(e.Property, e.NewValue); |
||
1067 | } |
||
1068 | } |
||
1069 | |||
1070 | |||
1071 | public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1072 | { |
||
1073 | var instance = (TextControl)sender; |
||
1074 | |||
1075 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
1076 | { |
||
1077 | instance.SetValue(e.Property, e.NewValue); |
||
1078 | } |
||
1079 | } |
||
1080 | |||
1081 | public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1082 | { |
||
1083 | var instance = (TextControl)sender; |
||
1084 | |||
1085 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
1086 | { |
||
1087 | instance.SetValue(e.Property, e.NewValue); |
||
1088 | } |
||
1089 | } |
||
1090 | |||
1091 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1092 | { |
||
1093 | var instance = (TextControl)sender; |
||
1094 | |||
1095 | if (e.OldValue != e.NewValue && instance.Base_Border != null) |
||
1096 | { |
||
1097 | instance.SetValue(e.Property, e.NewValue); |
||
1098 | |||
1099 | if (instance.IsSelected) |
||
1100 | { |
||
1101 | 05009a0e | ljiyeon | instance.StrokeColor = new SolidColorBrush(Colors.Blue); |
1102 | 787a4489 | KangIngu | //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue); |
1103 | } |
||
1104 | else |
||
1105 | { |
||
1106 | 05009a0e | ljiyeon | instance.StrokeColor = new SolidColorBrush(Colors.Red); |
1107 | 787a4489 | KangIngu | //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red); |
1108 | //instance.FontColor = new SolidColorBrush(Colors.Transparent); |
||
1109 | //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent); |
||
1110 | } |
||
1111 | |||
1112 | } |
||
1113 | } |
||
1114 | |||
1115 | public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1116 | { |
||
1117 | var instance = (TextControl)sender; |
||
1118 | |||
1119 | if (e.OldValue != e.NewValue && instance != null) |
||
1120 | { |
||
1121 | instance.SetValue(e.Property, e.NewValue); |
||
1122 | |||
1123 | Canvas.SetLeft(instance, instance.CanvasX); |
||
1124 | Canvas.SetTop(instance, instance.CanvasY); |
||
1125 | } |
||
1126 | } |
||
1127 | |||
1128 | public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1129 | { |
||
1130 | var instance = (TextControl)sender; |
||
1131 | |||
1132 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
1133 | { |
||
1134 | instance.SetValue(e.Property, e.NewValue); |
||
1135 | |||
1136 | 819630e9 | 송근호 | //if (instance.EnableEditing) |
1137 | //{ |
||
1138 | // instance.EditingMode(); |
||
1139 | //} |
||
1140 | //else |
||
1141 | //{ |
||
1142 | // instance.UnEditingMode(); |
||
1143 | //} |
||
1144 | 787a4489 | KangIngu | } |
1145 | } |
||
1146 | |||
1147 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1148 | { |
||
1149 | var instance = (TextControl)sender; |
||
1150 | |||
1151 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
1152 | { |
||
1153 | instance.SetValue(e.Property, e.NewValue); |
||
1154 | 6b5d33c6 | djkim | //instance.DrawingCloud(); |
1155 | 787a4489 | KangIngu | } |
1156 | } |
||
1157 | |||
1158 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1159 | { |
||
1160 | var instance = (TextControl)sender; |
||
1161 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
1162 | { |
||
1163 | instance.SetValue(e.Property, e.NewValue); |
||
1164 | 05009a0e | ljiyeon | //instance.DrawingCloud(); |
1165 | 787a4489 | KangIngu | } |
1166 | } |
||
1167 | |||
1168 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
1169 | { |
||
1170 | var instance = (TextControl)sender; |
||
1171 | 90db87f6 | 송근호 | if (e.OldValue != e.NewValue && instance != null) |
1172 | 787a4489 | KangIngu | { |
1173 | instance.SetValue(e.Property, e.NewValue); |
||
1174 | 05009a0e | ljiyeon | //instance.DrawingCloud(); |
1175 | 787a4489 | KangIngu | } |
1176 | } |
||
1177 | 90db87f6 | 송근호 | |
1178 | 787a4489 | KangIngu | #endregion CallBack Method |
1179 | |||
1180 | protected void OnPropertyChanged(string propName) |
||
1181 | { |
||
1182 | if (PropertyChanged != null) |
||
1183 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
1184 | } |
||
1185 | 036650a0 | humkyung | |
1186 | /// <summary> |
||
1187 | 91efe37a | humkyung | /// return textcontrols' area |
1188 | 036650a0 | humkyung | /// </summary> |
1189 | 91efe37a | humkyung | public override Rect ItemRect |
1190 | { |
||
1191 | get |
||
1192 | { |
||
1193 | e6a9ddaf | humkyung | Point start = new Point(this.CanvasX, this.CanvasY); |
1194 | 91efe37a | humkyung | |
1195 | Point length = new Point(); |
||
1196 | double angle = this.Angle * Math.PI / 180; |
||
1197 | |||
1198 | length.X = this.BoxWidth * Math.Cos(angle) - this.BoxHeight * Math.Sin(angle); |
||
1199 | length.Y = this.BoxWidth * Math.Sin(angle) + this.BoxHeight * Math.Cos(angle); |
||
1200 | |||
1201 | Point end = new Point(start.X + length.X, start.Y + length.Y); |
||
1202 | return new Rect(start, end); |
||
1203 | } |
||
1204 | } |
||
1205 | |||
1206 | e6a9ddaf | humkyung | /// <summary> |
1207 | 0d00f9c8 | humkyung | /// translate control along given dx,dy |
1208 | e6a9ddaf | humkyung | /// </summary> |
1209 | /// <param name="dx"></param> |
||
1210 | /// <param name="dy"></param> |
||
1211 | 0d00f9c8 | humkyung | public override void OnTranslate(double dx, double dy) |
1212 | e6a9ddaf | humkyung | { |
1213 | 0d00f9c8 | humkyung | //this.CanvasX = Canvas.GetLeft(this) + dx; |
1214 | //this.CanvasY = Canvas.GetTop(this) + dy; |
||
1215 | 359bfdbe | 송근호 | this.StartPoint = new Point(this.StartPoint.X + dx, this.StartPoint.Y + dy); |
1216 | this.EndPoint = new Point(this.EndPoint.X + dx, this.EndPoint.Y + dy); |
||
1217 | 0d00f9c8 | humkyung | |
1218 | 54e35b39 | 송근호 | this.SetValue(TextControl.CanvasXProperty, Canvas.GetLeft(this) + dx); |
1219 | this.SetValue(TextControl.CanvasYProperty, Canvas.GetTop(this) + dy); |
||
1220 | |||
1221 | 0d00f9c8 | humkyung | |
1222 | 90db87f6 | 송근호 | |
1223 | |||
1224 | 54e35b39 | 송근호 | //Canvas.SetLeft(this, Canvas.GetLeft(this) + dx); |
1225 | //Canvas.SetTop(this, Canvas.GetTop(this) + dy); |
||
1226 | e6a9ddaf | humkyung | } |
1227 | |||
1228 | /// <summary> |
||
1229 | /// Serialize this |
||
1230 | /// </summary> |
||
1231 | /// <param name="sUserId"></param> |
||
1232 | /// <returns></returns> |
||
1233 | public override string Serialize() |
||
1234 | 036650a0 | humkyung | { |
1235 | using (S_TextControl STemp = new S_TextControl()) |
||
1236 | { |
||
1237 | STemp.TransformPoint = "0|0"; |
||
1238 | STemp.SizeSet = String.Format("{0}|{1}", this.LineSize.Left.ToString(), this.TextSize.ToString()); |
||
1239 | STemp.Text = this.Text; |
||
1240 | STemp.UserID = this.UserID; |
||
1241 | 05009a0e | ljiyeon | STemp.FontColor = this.StrokeColor.Color.ToString(); |
1242 | 036650a0 | humkyung | //STemp.FontColor = "#FFFFFF00"; |
1243 | |||
1244 | if (this.StartPoint == new Point()) |
||
1245 | STemp.StartPoint = new Point(this.CanvasX, this.CanvasY); |
||
1246 | else |
||
1247 | STemp.StartPoint = this.StartPoint; |
||
1248 | |||
1249 | STemp.EndPoint = this.EndPoint; |
||
1250 | STemp.Opac = this.Opacity; |
||
1251 | STemp.PointSet = this.PointSet; |
||
1252 | STemp.Angle = this.Angle; |
||
1253 | STemp.paintMethod = this.ControlType_No; |
||
1254 | STemp.BoxW = this.BoxWidth; |
||
1255 | STemp.BoxH = this.BoxHeight; |
||
1256 | STemp.isHighLight = this.IsHighLight; |
||
1257 | STemp.Name = this.GetType().Name.ToString(); |
||
1258 | STemp.fontConfig = new List<string>() |
||
1259 | { |
||
1260 | this.TextFamily.ToString(), |
||
1261 | this.TextStyle.ToString(), |
||
1262 | this.TextWeight.ToString(), |
||
1263 | }; |
||
1264 | |||
1265 | |||
1266 | |||
1267 | if (this.UnderLine != null) |
||
1268 | { |
||
1269 | STemp.fontConfig.Add("true"); |
||
1270 | } |
||
1271 | |||
1272 | ///강인구 추가(2017.11.02) |
||
1273 | ///Memo 추가 |
||
1274 | STemp.Memo = this.Memo; |
||
1275 | |||
1276 | return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
||
1277 | } |
||
1278 | } |
||
1279 | 661b7416 | humkyung | |
1280 | /// <summary> |
||
1281 | /// create a textcontrol from given string |
||
1282 | /// </summary> |
||
1283 | /// <param name="str"></param> |
||
1284 | /// <returns></returns> |
||
1285 | public static TextControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
1286 | { |
||
1287 | using (S_TextControl s = JsonSerializerHelper.JsonDeserialize<S_TextControl>(str)) |
||
1288 | { |
||
1289 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1290 | TextControl instance = new TextControl() |
||
1291 | { |
||
1292 | Text = s.Text, |
||
1293 | StartPoint = s.StartPoint, |
||
1294 | EndPoint = s.EndPoint, |
||
1295 | CanvasX = s.StartPoint.X, |
||
1296 | CanvasY = s.StartPoint.Y, |
||
1297 | BoxWidth = s.BoxW, |
||
1298 | BoxHeight = s.BoxH, |
||
1299 | ControlType_No = s.paintMethod, |
||
1300 | LineSize = new Thickness(Convert.ToDouble(data2.First())), |
||
1301 | TextSize = Convert.ToDouble(data2[1]), |
||
1302 | 05009a0e | ljiyeon | StrokeColor = brush, |
1303 | 661b7416 | humkyung | FontSize = 10, |
1304 | UserID = s.UserID, |
||
1305 | IsHighLight = s.isHighLight, |
||
1306 | Angle = s.Angle, |
||
1307 | PointSet = s.PointSet, |
||
1308 | Opacity = s.Opac, |
||
1309 | TextFamily = new FontFamily(s.fontConfig[0]), |
||
1310 | //인구 추가(2018.04.17) |
||
1311 | TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]), |
||
1312 | TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]), |
||
1313 | }; |
||
1314 | |||
1315 | if (s.fontConfig.Count() == 4) |
||
1316 | { |
||
1317 | instance.UnderLine = TextDecorations.Underline; |
||
1318 | } |
||
1319 | |||
1320 | return instance; |
||
1321 | } |
||
1322 | } |
||
1323 | 787a4489 | KangIngu | } |
1324 | } |