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