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