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