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