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