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