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