개정판 f7ca524b
Fix: 텍스트 컨트롤의 Cloud Mark 크기 조절 오류 수정
Change-Id: Idbcb94c257f6c3ece2a39089c7802ab10d03e21a
MarkupToPDF/Controls/Text/TextControl.cs.bak | ||
---|---|---|
1 | 1 |
using MarkupToPDF.Common; |
2 | 2 |
using MarkupToPDF.Controls.Common; |
3 |
using MarkupToPDF.Serialize.Core; |
|
4 |
using MarkupToPDF.Serialize.S_Control; |
|
3 | 5 |
using System; |
4 | 6 |
using System.Collections.Generic; |
5 | 7 |
using System.ComponentModel; |
... | ... | |
10 | 12 |
using System.Windows.Controls; |
11 | 13 |
using System.Windows.Media; |
12 | 14 |
using System.Windows.Shapes; |
15 |
using Markus.Fonts; |
|
16 |
using MarkupToPDF.Controls.Polygon; |
|
13 | 17 |
|
14 | 18 |
namespace MarkupToPDF.Controls.Text |
15 |
{ |
|
16 |
public class TextControl : CommentUserInfo, INotifyPropertyChanged, IMarkupControlData, IPath, IShapeControl
|
|
19 |
{
|
|
20 |
public class TextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData
|
|
17 | 21 |
{ |
18 | 22 |
public event PropertyChangedEventHandler PropertyChanged; |
19 | 23 |
|
... | ... | |
22 | 26 |
private const string PART_TextBox = "PART_TextBox"; |
23 | 27 |
private const string PART_TextPath = "PART_TextPath"; |
24 | 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 |
|
|
25 | 32 |
//private const string PART_TextPrefix = "PART_TextPrefix"; |
26 |
|
|
33 |
|
|
27 | 34 |
public Path Base_TextPath = null; |
28 | 35 |
public Grid Base_Grid = null; |
29 | 36 |
public Border Base_Border = null; |
37 |
public Canvas Base_Canvas = null; |
|
30 | 38 |
//public TextBlock Base_TextPrefixBlock = null; |
31 | 39 |
public TextBlock Base_TextBlock = null; |
32 | 40 |
public TextBox Base_TextBox = null; |
41 |
public Border BaseTextbox_Caret = null; |
|
33 | 42 |
|
34 | 43 |
public RotateTransform _rotation = null; |
35 | 44 |
public TranslateTransform _translation = null; |
36 | 45 |
public ScaleTransform _scale = null; |
37 | 46 |
|
38 |
public bool IsSelected |
|
47 |
private const double _CloudArcDepth = 0.8; /// 2018.05.14 added by humkyung |
|
48 |
|
|
49 |
public override bool IsSelected |
|
39 | 50 |
{ |
40 | 51 |
get |
41 | 52 |
{ |
... | ... | |
52 | 63 |
|
53 | 64 |
public TextControl() |
54 | 65 |
{ |
55 |
this.DefaultStyleKey = typeof(TextControl); |
|
66 |
//this.DefaultStyleKey = typeof(TextControl);
|
|
56 | 67 |
} |
57 | 68 |
|
58 | 69 |
static TextControl() |
59 | 70 |
{ |
60 | 71 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(TextControl), new FrameworkPropertyMetadata(typeof(TextControl))); |
61 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
62 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
63 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
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 |
|
|
64 | 77 |
} |
65 | 78 |
|
79 |
|
|
66 | 80 |
public override void OnApplyTemplate() |
67 | 81 |
{ |
68 | 82 |
base.OnApplyTemplate(); |
... | ... | |
72 | 86 |
Base_TextBlock = GetTemplateChild(PART_TextBlock) as TextBlock; |
73 | 87 |
Base_Grid = GetTemplateChild(PART_Grid) as Grid; |
74 | 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(); |
|
75 | 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 |
} |
|
76 | 109 |
|
77 |
//Base_TextPrefixBlock = GetTemplateChild(PART_TextPrefix) as TextBlock; |
|
78 |
|
|
79 |
//Canvas.SetLeft(this, this.StartPoint.X); |
|
80 |
//Canvas.SetTop(this, this.StartPoint.Y); |
|
110 |
public void SetFontFamily(FontFamily fontFamily) |
|
111 |
{ |
|
112 |
|
|
113 |
if (this.Base_TextBlock != null) { |
|
114 |
this.Base_TextBlock.FontFamily = fontFamily; |
|
115 |
} |
|
81 | 116 |
|
82 |
//CanvasX = StartPoint.X; |
|
83 |
//CanvasY = StartPoint.Y; |
|
117 |
if (this.Base_TextBox != null) { |
|
118 |
this.Base_TextBox.FontFamily = fontFamily; |
|
119 |
} |
|
120 |
this.FontFamily = fontFamily; |
|
121 |
this.TextFamily = fontFamily; |
|
122 |
} |
|
84 | 123 |
|
85 |
//this.LostFocus += new RoutedEventHandler(TextControl_LostFocus); |
|
86 |
//this.GotFocus += new RoutedEventHandler(TextControl_GotFocus); |
|
87 |
this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
|
88 |
this.Base_TextBlock.SizeChanged += Base_TextBlock_SizeChanged; |
|
89 | 124 |
|
90 |
this.Base_TextBox.LostFocus += Base_TextBox_LostFocus; |
|
91 |
//this.MouseDown += TextControl_MouseDown; |
|
125 |
/// <summary> |
|
126 |
/// Moves the custom caret on the canvas. |
|
127 |
/// </summary> |
|
128 |
public void MoveCustomCaret() |
|
129 |
{ |
|
92 | 130 |
|
131 |
var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location; |
|
93 | 132 |
|
133 |
if (!double.IsInfinity(caretLocation.X)) { |
|
134 |
Canvas.SetLeft(this.BaseTextbox_Caret, caretLocation.X); |
|
135 |
} |
|
94 | 136 |
|
95 |
SetText(); |
|
96 |
Base_TextBox.Focus(); |
|
137 |
if (!double.IsInfinity(caretLocation.Y)) { |
|
138 |
Canvas.SetTop(this.BaseTextbox_Caret, (LineSize.Top + caretLocation.Y)); |
|
139 |
} |
|
97 | 140 |
} |
98 | 141 |
|
99 |
private void Base_TextBox_LostFocus(object sender, RoutedEventArgs e) |
|
100 |
{ |
|
101 |
IsEditing = false; |
|
102 |
UnEditingMode(); |
|
103 |
ApplyOverViewData(); |
|
104 |
} |
|
142 |
|
|
105 | 143 |
|
106 |
public void ApplyOverViewData() |
|
144 |
public override void ApplyOverViewData()
|
|
107 | 145 |
{ |
108 | 146 |
this.OverViewPathData = this.PathData; |
109 |
this.OverViewText = this.Text; |
|
147 |
if (Text == "") |
|
148 |
this.Text = this.OverViewText; |
|
149 |
else |
|
150 |
this.OverViewText = this.Text; |
|
151 |
|
|
110 | 152 |
this.OverViewPaint = this.Paint; |
111 | 153 |
|
112 |
} |
|
154 |
}
|
|
113 | 155 |
|
114 |
void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
156 |
void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
115 | 157 |
{ |
116 |
this.Text = Base_TextBox.Text; |
|
117 |
|
|
118 | 158 |
BoxWidth = e.NewSize.Width; |
119 | 159 |
BoxHeight = e.NewSize.Height; |
120 | 160 |
|
121 |
this.ApplyTemplate(); |
|
122 |
|
|
123 | 161 |
DrawingCloud(); |
124 | 162 |
} |
125 |
|
|
126 |
//void TextControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) |
|
127 |
//{ |
|
128 |
// this.Focus(); |
|
129 |
//} |
|
130 |
|
|
131 |
void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e) |
|
163 |
private void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e) |
|
132 | 164 |
{ |
133 |
this.Text = Base_TextBox.Text; |
|
134 |
|
|
135 | 165 |
BoxWidth = e.NewSize.Width; |
136 | 166 |
BoxHeight = e.NewSize.Height; |
137 |
this.ApplyTemplate(); |
|
138 | 167 |
|
139 | 168 |
DrawingCloud(); |
140 | 169 |
} |
141 |
|
|
142 |
void TextControl_GotFocus(object sender, RoutedEventArgs e) |
|
170 |
private void Base_TextBox_TextChanged(object sender, TextChangedEventArgs e) |
|
143 | 171 |
{ |
144 |
if (EnableEditing)
|
|
172 |
if (IsEditingMode)
|
|
145 | 173 |
{ |
146 |
IsEditing = true; |
|
147 |
EditingMode(); |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
IsEditing = false; |
|
152 |
UnEditingMode(); |
|
153 |
} |
|
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; |
|
154 | 190 |
} |
155 | 191 |
|
156 |
void TextControl_LostFocus(object sender, RoutedEventArgs e)
|
|
192 |
void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
|
|
157 | 193 |
{ |
158 |
IsEditing = false; |
|
159 |
UnEditingMode(); |
|
194 |
this.Text = Base_TextBox.Text; |
|
195 |
this.BaseTextbox_Caret.Visibility = Visibility.Collapsed; |
|
196 |
this.IsEditingMode = false; |
|
160 | 197 |
ApplyOverViewData(); |
161 | 198 |
} |
162 | 199 |
|
... | ... | |
188 | 225 |
// new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
189 | 226 |
// IsEditing = false; |
190 | 227 |
//} |
191 |
|
|
192 | 228 |
public void EditingMode() |
193 |
{ |
|
194 |
System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString()); |
|
229 |
{ |
|
195 | 230 |
TextBoxVisibility = Visibility.Visible; |
196 |
//Base_TextBox.Visibility = System.Windows.Visibility.Visible; |
|
197 |
|
|
198 | 231 |
TextBlockVisibility = Visibility.Collapsed; |
199 |
//Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed; |
|
200 |
|
|
201 |
|
|
202 |
//this.Base_TextBox.BorderThickness = new Thickness(1); |
|
232 |
this.BaseTextbox_Caret.Visibility = Visibility.Visible; |
|
203 | 233 |
|
204 | 234 |
if (UnderLine != null) |
205 | 235 |
Base_TextBlock.TextDecorations = UnderLine; |
206 | 236 |
|
207 |
if (this.Text != null) |
|
208 |
Base_TextBox.Text = this.Text; |
|
209 |
|
|
210 |
// Base_TextBox.Margin = |
|
211 |
//new Thickness(Base_TextBlock.Margin.Left + -2, Base_TextBlock.Margin.Top + 0, |
|
212 |
//Base_TextBlock.Margin.Right + 0, Base_TextBlock.Margin.Bottom + -2); |
|
213 | 237 |
} |
214 | 238 |
|
215 | 239 |
public void UnEditingMode() |
216 |
{ |
|
217 |
if (EnableEditing) |
|
218 |
this.Text = Base_TextBox.Text; |
|
219 |
|
|
220 |
TextBoxVisibility = Visibility.Collapsed; |
|
221 |
//Base_TextBox.Visibility = System.Windows.Visibility.Collapsed; |
|
222 |
|
|
223 |
TextBlockVisibility = Visibility.Visible; |
|
224 |
//Base_TextBlock.Visibility = System.Windows.Visibility.Visible; |
|
240 |
{ |
|
241 |
TextBoxVisibility = Visibility.Collapsed; |
|
242 |
TextBlockVisibility = Visibility.Visible; |
|
243 |
this.BaseTextbox_Caret.Visibility = Visibility.Collapsed; |
|
225 | 244 |
|
226 | 245 |
if (UnderLine != null) |
227 | 246 |
Base_TextBlock.TextDecorations = UnderLine; |
228 | 247 |
|
229 |
//Base_TextBox.Focusable = false; |
|
230 |
|
|
231 |
//Base_TextBlock.Margin = |
|
232 |
// new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, |
|
233 |
// Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
|
234 |
|
|
235 |
// Base_TextBlock.Margin = |
|
236 |
//new Thickness(Base_TextBox.Margin.Left + 2, Base_TextBox.Margin.Top + 2, |
|
237 |
// Base_TextBox.Margin.Right + 2, Base_TextBox.Margin.Bottom + 2); |
|
238 |
|
|
239 |
// Base_TextBlock.Margin = |
|
240 |
//new Thickness(Base_TextBox.Margin.Left + 5, Base_TextBox.Margin.Top + 0, |
|
241 |
//Base_TextBox.Margin.Right + 0, Base_TextBox.Margin.Bottom + 2); |
|
248 |
|
|
242 | 249 |
} |
243 |
|
|
244 | 250 |
public void SetText() |
245 | 251 |
{ |
246 |
this.ApplyTemplate(); |
|
247 | 252 |
if (IsHighLight) |
248 | 253 |
{ |
249 | 254 |
this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
... | ... | |
253 | 258 |
} |
254 | 259 |
else |
255 | 260 |
{ |
261 |
//this.BackInnerColor = new SolidColorBrush(Color.FromArgb(0x003, 0xFF, 0xFF, 0xFF)); |
|
262 |
//this.BackColor = new SolidColorBrush(Color.FromArgb(0x003, 0xFF, 0xFF, 0xFF)); |
|
263 |
|
|
256 | 264 |
this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
257 | 265 |
Colors.White.R, Colors.White.G, Colors.White.B)); |
258 | 266 |
|
259 | 267 |
this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), |
260 | 268 |
Colors.White.R, Colors.White.G, Colors.White.B)); |
261 |
|
|
262 |
|
|
263 |
//this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
|
264 |
// Colors.White.R, Colors.White.G, Colors.White.B)); |
|
265 |
//this.BackColor = null; |
|
266 | 269 |
} |
267 | 270 |
if (Base_TextPath != null) |
268 | 271 |
{ |
269 | 272 |
Base_TextPath.StrokeThickness = LineSize.Left; |
270 | 273 |
} |
271 |
|
|
272 |
OverViewPathData = PathData; |
|
273 |
OverViewText = Text; |
|
274 |
|
|
274 | 275 |
} |
275 | 276 |
|
276 | 277 |
public void DrawingCloud() |
277 | 278 |
{ |
278 |
this.ApplyTemplate(); |
|
279 |
|
|
280 |
//pathGeometry = new PathGeometry(); |
|
281 |
|
|
279 |
|
|
282 | 280 |
List<Point> pCloud = new List<Point> |
283 | 281 |
{ |
284 |
//new Point(0, 0), |
|
285 |
//new Point(0, 0 + BoxHeight + 2), |
|
286 |
//new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2), |
|
287 |
//new Point(0 + BoxWidth + 4 ,0), |
|
288 |
//new Point(0, 0) |
|
289 |
|
|
290 | 282 |
new Point(0, 0), |
291 | 283 |
new Point(0, 0 + BoxHeight + 0), |
292 | 284 |
new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0), |
293 |
new Point(0 + BoxWidth + 2 ,0), |
|
294 |
new Point(0, 0) |
|
285 |
new Point(0 + BoxWidth + 2 ,0) |
|
295 | 286 |
}; |
296 |
|
|
287 |
//this.Base_TextBox.Select(Base_TextBox.Text.Length, 0); |
|
297 | 288 |
if (Base_TextPath != null) |
298 | 289 |
{ |
299 | 290 |
switch (ControlType_No) |
... | ... | |
307 | 298 |
case 1: |
308 | 299 |
{ |
309 | 300 |
PathData = (Generate_Rect(pCloud)); |
310 |
|
|
311 | 301 |
List<Point> pCloud2 = new List<Point> |
312 | 302 |
{ |
313 |
//new Point(0, 0), |
|
314 |
//new Point(0, 0 + BoxHeight + 2), |
|
315 |
//new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2), |
|
316 |
//new Point(0 + BoxWidth + 4 ,0), |
|
317 |
//new Point(0, 0) |
|
318 |
|
|
319 | 303 |
new Point(0, 0), |
320 | 304 |
new Point(0, 0 + BoxHeight + 0), |
321 | 305 |
new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0), |
322 |
new Point(0 + BoxWidth + 10 ,0), |
|
323 |
new Point(0, 0) |
|
306 |
new Point(0 + BoxWidth + 10 ,0) |
|
324 | 307 |
}; |
325 |
|
|
326 | 308 |
PathDataInner = (GenerateInner(pCloud)); |
327 | 309 |
} |
328 | 310 |
break; |
329 | 311 |
case 2: |
330 | 312 |
{ |
331 |
PathData = (Generate(pCloud)); |
|
313 |
PathData = (Generate(pCloud, this.ArcLength));
|
|
332 | 314 |
PathDataInner = (GenerateInner(pCloud)); |
333 | 315 |
} |
334 | 316 |
break; |
335 | 317 |
} |
336 | 318 |
} |
337 |
|
|
338 |
SetText(); |
|
339 | 319 |
} |
340 | 320 |
#endregion Internal Method |
341 | 321 |
|
342 | 322 |
public void Dispose() |
343 | 323 |
{ |
344 |
GC.Collect(); |
|
345 |
GC.SuppressFinalize(this); |
|
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; |
|
346 | 331 |
} |
347 |
public void updateControl() |
|
332 |
|
|
333 |
public override void UpdateControl() |
|
348 | 334 |
{ |
349 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
350 |
this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
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 |
} |
|
351 | 340 |
} |
352 | 341 |
|
353 | 342 |
#region Drawing Cloud Method |
354 | 343 |
public static PathGeometry Generate_Rect(List<Point> pData) |
355 | 344 |
{ |
356 |
//this.StartPoint; |
|
357 |
|
|
358 | 345 |
PathFigure pathFigure = new PathFigure(); |
359 | 346 |
pathFigure.StartPoint = pData[0]; |
360 | 347 |
|
361 |
LineSegment lineSegment0 = new LineSegment(); |
|
362 |
lineSegment0.Point = pData[0]; |
|
363 |
pathFigure.Segments.Add(lineSegment0); |
|
364 |
|
|
365 |
LineSegment lineSegment1 = new LineSegment(); |
|
366 |
lineSegment1.Point = pData[1]; |
|
367 |
pathFigure.Segments.Add(lineSegment1); |
|
368 |
|
|
369 |
LineSegment lineSegment2 = new LineSegment(); |
|
370 |
lineSegment2.Point = pData[2]; |
|
371 |
pathFigure.Segments.Add(lineSegment2); |
|
372 |
|
|
373 |
LineSegment lineSegment3 = new LineSegment(); |
|
374 |
lineSegment3.Point = pData[3]; |
|
375 |
pathFigure.Segments.Add(lineSegment3); |
|
348 |
PolyLineSegment polyline = new PolyLineSegment(pData, true); |
|
349 |
pathFigure.Segments.Add(polyline); |
|
376 | 350 |
|
377 | 351 |
PathGeometry rectPathGeometry = new PathGeometry(); |
378 | 352 |
rectPathGeometry.Figures = new PathFigureCollection(); |
... | ... | |
384 | 358 |
return rectPathGeometry; |
385 | 359 |
} |
386 | 360 |
|
387 |
public static PathGeometry Generate(List<Point> pData) |
|
361 |
public static PathGeometry Generate(List<Point> pData, double _ArcLength = 20)
|
|
388 | 362 |
{ |
389 | 363 |
var _pathGeometry = new PathGeometry(); |
390 | 364 |
double area = MathSet.AreaOf(pData); |
391 | 365 |
bool reverse = (area > 0); |
392 | 366 |
int count = pData.Count; |
393 |
for (int i = 0; i < (count - 1); i++)
|
|
367 |
for (int i = 0; i < count; i++)
|
|
394 | 368 |
{ |
395 |
PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
|
|
369 |
PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i % count], pData[(i + 1) % count], _ArcLength, reverse);
|
|
396 | 370 |
pathFigure.IsClosed = false; |
397 | 371 |
pathFigure.IsFilled = true; |
398 | 372 |
_pathGeometry.Figures.Add(pathFigure); |
399 | 373 |
} |
400 | 374 |
|
401 |
// PathFigure pathFigur2= new PathFigure(); |
|
402 |
//pathFigur2.StartPoint = pData[0]; |
|
403 |
|
|
404 |
// LineSegment lineSegment0 = new LineSegment(); |
|
405 |
// lineSegment0.Point = pData[0]; |
|
406 |
//pathFigur2.Segments.Add(lineSegment0); |
|
407 |
|
|
408 |
// LineSegment lineSegment1 = new LineSegment(); |
|
409 |
// lineSegment1.Point = pData[1]; |
|
410 |
//pathFigur2.Segments.Add(lineSegment1); |
|
411 |
|
|
412 |
// LineSegment lineSegment2 = new LineSegment(); |
|
413 |
// lineSegment2.Point = pData[2]; |
|
414 |
//pathFigur2.Segments.Add(lineSegment2); |
|
415 |
|
|
416 |
// LineSegment lineSegment3 = new LineSegment(); |
|
417 |
// lineSegment3.Point = pData[3]; |
|
418 |
//pathFigur2.Segments.Add(lineSegment3); |
|
419 |
|
|
420 |
|
|
421 |
//pathFigur2.IsClosed = true; |
|
422 |
//pathFigur2.IsFilled = true; |
|
423 |
//_pathGeometry.Figures.Add(pathFigur2); |
|
424 |
|
|
425 | 375 |
return _pathGeometry; |
426 | 376 |
} |
427 | 377 |
|
... | ... | |
436 | 386 |
PathFigure pathFigur2 = new PathFigure(); |
437 | 387 |
pathFigur2.StartPoint = pData[0]; |
438 | 388 |
|
439 |
LineSegment lineSegment0 = new LineSegment(); |
|
440 |
lineSegment0.Point = pData[0]; |
|
441 |
pathFigur2.Segments.Add(lineSegment0); |
|
442 |
|
|
443 |
LineSegment lineSegment1 = new LineSegment(); |
|
444 |
lineSegment1.Point = pData[1]; |
|
445 |
pathFigur2.Segments.Add(lineSegment1); |
|
446 |
|
|
447 |
LineSegment lineSegment2 = new LineSegment(); |
|
448 |
lineSegment2.Point = pData[2]; |
|
449 |
pathFigur2.Segments.Add(lineSegment2); |
|
450 |
|
|
451 |
LineSegment lineSegment3 = new LineSegment(); |
|
452 |
lineSegment3.Point = pData[3]; |
|
453 |
pathFigur2.Segments.Add(lineSegment3); |
|
454 |
|
|
389 |
PolyLineSegment polyline = new PolyLineSegment(pData, true); |
|
390 |
pathFigur2.Segments.Add(polyline); |
|
455 | 391 |
|
456 | 392 |
pathFigur2.IsClosed = true; |
457 | 393 |
pathFigur2.IsFilled = true; |
... | ... | |
459 | 395 |
|
460 | 396 |
return _pathGeometry; |
461 | 397 |
} |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse) |
|
466 |
{ |
|
467 |
PathFigure pathFigure = new PathFigure(); |
|
468 |
pathFigure.StartPoint = p1; |
|
469 |
|
|
470 |
double arcLength = _arcLength; |
|
471 |
double dx = p2.X - p1.X; |
|
472 |
double dy = p2.Y - p1.Y; |
|
473 |
double l = MathSet.DistanceTo(p1, p2); |
|
474 |
double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
|
475 |
Point lastPt = new Point(p1.X, p1.Y); |
|
476 |
double count = l / _arcLength; |
|
477 |
|
|
478 |
dx /= l; |
|
479 |
dy /= l; |
|
480 |
|
|
481 |
Double j = 1; |
|
482 |
for (j = 1; j < (count - 1); j++) |
|
483 |
{ |
|
484 |
ArcSegment arcSeg = new ArcSegment(); |
|
485 |
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); |
|
486 |
|
|
487 |
arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); |
|
488 |
lastPt = arcSeg.Point; |
|
489 |
arcSeg.RotationAngle = theta + 90; |
|
490 |
if (true == reverse) |
|
491 |
arcSeg.SweepDirection = SweepDirection.Clockwise; |
|
492 |
pathFigure.Segments.Add(arcSeg); |
|
493 |
} |
|
494 |
|
|
495 |
if ((count > j) || count > 0) |
|
496 |
{ |
|
497 |
arcLength = MathSet.DistanceTo(lastPt, p2); |
|
498 |
ArcSegment arcSeg = new ArcSegment(); |
|
499 |
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); |
|
500 |
arcSeg.Point = new Point(p2.X, p2.Y); |
|
501 |
arcSeg.RotationAngle = theta; |
|
502 |
|
|
503 |
if (true == reverse) |
|
504 |
arcSeg.SweepDirection = SweepDirection.Clockwise; |
|
505 |
|
|
506 |
pathFigure.Segments.Add(arcSeg); |
|
507 |
|
|
508 |
} |
|
509 |
return pathFigure; |
|
510 |
} |
|
511 | 398 |
#endregion |
512 | 399 |
|
513 | 400 |
#region Dependency Properties |
... | ... | |
527 | 414 |
"Text", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
528 | 415 |
|
529 | 416 |
public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register( |
530 |
"OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
|
417 |
"OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
|
|
531 | 418 |
|
532 | 419 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
533 | 420 |
"UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
534 | 421 |
|
535 |
public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register( |
|
536 |
"FontColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
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)); |
|
537 | 430 |
|
538 | 431 |
//강인구 추가 |
539 | 432 |
public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register( |
... | ... | |
549 | 442 |
"UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null)); |
550 | 443 |
|
551 | 444 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
552 |
"LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4)));
|
|
445 |
"LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4), PointValueChanged)); //여기만 4인지 모르겠지만 4 그대로 두겠음
|
|
553 | 446 |
|
554 | 447 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
555 | 448 |
"PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>())); |
... | ... | |
558 | 451 |
"PathData", typeof(Geometry), typeof(TextControl), null); |
559 | 452 |
|
560 | 453 |
public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register( |
561 |
"PathDataInner", typeof(Geometry), typeof(TextControl), null); |
|
454 |
"PathDataInner", typeof(Geometry), typeof(TextControl), null);
|
|
562 | 455 |
|
563 | 456 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
564 | 457 |
"OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null); |
... | ... | |
567 | 460 |
"TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal)); |
568 | 461 |
|
569 | 462 |
public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register( |
570 |
"TextFamily", typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial"))); |
|
463 |
"TextFamily", typeof(FontFamily), typeof(TextControl), |
|
464 |
new PropertyMetadata(new PropertyChangedCallback(TextFamilyPropertyChanged))); |
|
571 | 465 |
|
572 | 466 |
public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register( |
573 | 467 |
"TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal)); |
... | ... | |
585 | 479 |
"CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
586 | 480 |
|
587 | 481 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
588 |
"StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
|
482 |
"StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
589 | 483 |
|
590 | 484 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
591 |
"EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
|
|
485 |
"EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
|
592 | 486 |
|
593 | 487 |
public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register( |
594 |
"TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged));
|
|
488 |
"TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged)); |
|
595 | 489 |
|
596 | 490 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
597 |
"Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
|
|
491 |
"Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
|
598 | 492 |
|
599 | 493 |
public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register( |
600 |
"OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
|
|
494 |
"OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
|
601 | 495 |
|
602 | 496 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
603 | 497 |
"Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
604 | 498 |
|
605 |
public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register( |
|
606 |
"IsEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((false), new PropertyChangedCallback(OnIsEditingChanged))); |
|
607 |
|
|
608 | 499 |
public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register( |
609 |
"EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true))); |
|
500 |
"EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
|
|
610 | 501 |
|
611 | 502 |
public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register( |
612 |
"TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged)); |
|
503 |
"TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
|
|
613 | 504 |
|
614 | 505 |
public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register( |
615 |
"TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged)); |
|
506 |
"TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
|
|
616 | 507 |
|
617 | 508 |
#endregion Dependency Properties |
618 | 509 |
|
619 | 510 |
#region dp Properties |
620 | 511 |
|
621 |
public bool IsEditing |
|
512 |
|
|
513 |
public override SolidColorBrush StrokeColor |
|
622 | 514 |
{ |
623 |
get { return (bool)GetValue(IsEditingProperty); }
|
|
515 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
|
|
624 | 516 |
set |
625 | 517 |
{ |
626 |
if (this.IsEditing != value)
|
|
518 |
if (this.StrokeColor != value)
|
|
627 | 519 |
{ |
628 |
SetValue(IsEditingProperty, value); |
|
629 |
|
|
630 |
OnPropertyChanged("IsEditing"); |
|
520 |
SetValue(StrokeColorProperty, value); |
|
521 |
} |
|
522 |
} |
|
523 |
} |
|
631 | 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"); |
|
632 | 534 |
} |
633 | 535 |
} |
634 | 536 |
} |
... | ... | |
662 | 564 |
} |
663 | 565 |
} |
664 | 566 |
|
665 |
|
|
666 |
|
|
667 |
|
|
668 |
public ControlType ControlType |
|
567 |
public override ControlType ControlType |
|
669 | 568 |
{ |
670 | 569 |
get |
671 | 570 |
{ |
... | ... | |
704 | 603 |
public double CenterX |
705 | 604 |
{ |
706 | 605 |
get { return (double)GetValue(CenterXProperty); } |
707 |
set { SetValue(CenterXProperty, value); |
|
708 |
OnPropertyChanged("CenterX"); |
|
709 |
|
|
606 |
set |
|
607 |
{ |
|
608 |
SetValue(CenterXProperty, value); |
|
609 |
OnPropertyChanged("CenterX"); |
|
610 |
|
|
710 | 611 |
} |
711 | 612 |
} |
712 | 613 |
|
713 | 614 |
public double CenterY |
714 | 615 |
{ |
715 | 616 |
get { return (double)GetValue(CenterYProperty); } |
716 |
set { SetValue(CenterYProperty, value); |
|
717 |
OnPropertyChanged("CenterY"); |
|
617 |
set |
|
618 |
{ |
|
619 |
SetValue(CenterYProperty, value); |
|
620 |
OnPropertyChanged("CenterY"); |
|
718 | 621 |
} |
719 | 622 |
} |
720 | 623 |
|
... | ... | |
798 | 701 |
} |
799 | 702 |
} |
800 | 703 |
} |
801 |
|
|
704 |
/* |
|
802 | 705 |
public SolidColorBrush FontColor |
803 | 706 |
{ |
804 | 707 |
get { return (SolidColorBrush)GetValue(FontColorProperty); } |
... | ... | |
810 | 713 |
OnPropertyChanged("FontColor"); |
811 | 714 |
} |
812 | 715 |
} |
813 |
} |
|
716 |
}*/
|
|
814 | 717 |
|
815 | 718 |
public SolidColorBrush BackColor |
816 | 719 |
{ |
... | ... | |
838 | 741 |
} |
839 | 742 |
} |
840 | 743 |
|
841 |
|
|
744 |
|
|
842 | 745 |
|
843 | 746 |
public TextDecorationCollection UnderLine |
844 | 747 |
{ |
... | ... | |
990 | 893 |
public Geometry PathData |
991 | 894 |
{ |
992 | 895 |
get { return (Geometry)GetValue(PathDataProperty); } |
993 |
set { SetValue(PathDataProperty, value); |
|
994 |
OnPropertyChanged("PathData"); |
|
896 |
set |
|
897 |
{ |
|
898 |
SetValue(PathDataProperty, value); |
|
899 |
OnPropertyChanged("PathData"); |
|
995 | 900 |
} |
996 | 901 |
} |
997 | 902 |
|
... | ... | |
1005 | 910 |
} |
1006 | 911 |
} |
1007 | 912 |
|
1008 |
public double Angle
|
|
913 |
public override double CommentAngle
|
|
1009 | 914 |
{ |
1010 | 915 |
get { return (double)GetValue(AngleProperty); } |
1011 | 916 |
set |
1012 | 917 |
{ |
1013 |
if (this.Angle != value) |
|
918 |
if (this.CommentAngle != value)
|
|
1014 | 919 |
{ |
1015 | 920 |
SetValue(AngleProperty, value); |
1016 | 921 |
|
... | ... | |
1036 | 941 |
public List<Point> PointSet |
1037 | 942 |
{ |
1038 | 943 |
get { return (List<Point>)GetValue(PointSetProperty); } |
1039 |
set { SetValue(PointSetProperty, value); |
|
1040 |
OnPropertyChanged("PointSet"); |
|
944 |
set |
|
945 |
{ |
|
946 |
SetValue(PointSetProperty, value); |
|
947 |
OnPropertyChanged("PointSet"); |
|
1041 | 948 |
} |
1042 | 949 |
} |
1043 | 950 |
|
... | ... | |
1045 | 952 |
|
1046 | 953 |
#region Properties |
1047 | 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 |
} |
|
1048 | 968 |
|
1049 |
|
|
1050 |
public PathGeometry PathGeometry |
|
969 |
public PathGeometry PathGeometry |
|
1051 | 970 |
{ |
1052 | 971 |
get { return (PathGeometry)GetValue(PathGeometryProperty); } |
1053 | 972 |
set |
... | ... | |
1088 | 1007 |
#endregion |
1089 | 1008 |
|
1090 | 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 |
|
|
1091 | 1018 |
public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1092 | 1019 |
{ |
1093 | 1020 |
var instance = (TextControl)sender; |
... | ... | |
1121 | 1048 |
|
1122 | 1049 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1123 | 1050 |
{ |
1124 |
var instance = (TextControl)sender; |
|
1051 |
//var instance = (TextControl)sender;
|
|
1125 | 1052 |
|
1126 |
if (e.OldValue != e.NewValue && instance.Base_Border != null) |
|
1127 |
{ |
|
1128 |
instance.SetValue(e.Property, e.NewValue); |
|
1053 |
//if (e.OldValue != e.NewValue && instance.Base_Border != null)
|
|
1054 |
//{
|
|
1055 |
// instance.SetValue(e.Property, e.NewValue);
|
|
1129 | 1056 |
|
1130 |
if (instance.IsSelected) |
|
1131 |
{ |
|
1132 |
instance.FontColor = new SolidColorBrush(Colors.Blue);
|
|
1133 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue); |
|
1134 |
} |
|
1135 |
else |
|
1136 |
{ |
|
1137 |
instance.FontColor = new SolidColorBrush(Colors.Red);
|
|
1138 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red); |
|
1139 |
//instance.FontColor = new SolidColorBrush(Colors.Transparent); |
|
1140 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent); |
|
1141 |
} |
|
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 |
// }
|
|
1142 | 1069 |
|
1143 |
} |
|
1070 |
//}
|
|
1144 | 1071 |
} |
1145 | 1072 |
|
1146 | 1073 |
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
... | ... | |
1152 | 1079 |
instance.SetValue(e.Property, e.NewValue); |
1153 | 1080 |
|
1154 | 1081 |
Canvas.SetLeft(instance, instance.CanvasX); |
1155 |
|
|
1156 | 1082 |
Canvas.SetTop(instance, instance.CanvasY); |
1157 | 1083 |
} |
1158 | 1084 |
} |
... | ... | |
1167 | 1093 |
|
1168 | 1094 |
if (instance.EnableEditing) |
1169 | 1095 |
{ |
1170 |
if (instance.IsEditing) |
|
1171 |
{ |
|
1172 |
instance.EditingMode(); |
|
1173 |
} |
|
1174 |
else |
|
1175 |
{ |
|
1176 |
instance.UnEditingMode(); |
|
1177 |
} |
|
1096 |
instance.EditingMode(); |
|
1178 | 1097 |
} |
1179 | 1098 |
else |
1180 | 1099 |
{ |
... | ... | |
1182 | 1101 |
} |
1183 | 1102 |
} |
1184 | 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 |
} |
|
1185 | 1113 |
|
1186 | 1114 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1187 | 1115 |
{ |
... | ... | |
1190 | 1118 |
if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
1191 | 1119 |
{ |
1192 | 1120 |
instance.SetValue(e.Property, e.NewValue); |
1193 |
instance.SetText();
|
|
1121 |
//instance.DrawingCloud();
|
|
1194 | 1122 |
} |
1195 | 1123 |
} |
1196 | 1124 |
|
... | ... | |
1200 | 1128 |
if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
1201 | 1129 |
{ |
1202 | 1130 |
instance.SetValue(e.Property, e.NewValue); |
1203 |
instance.SetText();
|
|
1131 |
//instance.DrawingCloud();
|
|
1204 | 1132 |
} |
1205 | 1133 |
} |
1206 | 1134 |
|
1207 | 1135 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1208 | 1136 |
{ |
1209 | 1137 |
var instance = (TextControl)sender; |
1210 |
if (e.OldValue != e.NewValue && instance!= null) |
|
1211 |
{
|
|
1212 |
instance.SetValue(e.Property, e.NewValue);
|
|
1138 |
|
|
1139 |
if (e.OldValue != e.NewValue && instance.Base_TextBox != null)
|
|
1140 |
{
|
|
1213 | 1141 |
instance.SetText(); |
1142 |
instance.DrawingCloud(); |
|
1214 | 1143 |
} |
1144 |
|
|
1215 | 1145 |
} |
1216 |
|
|
1146 |
|
|
1217 | 1147 |
#endregion CallBack Method |
1218 | 1148 |
|
1219 | 1149 |
protected void OnPropertyChanged(string propName) |
1220 | 1150 |
{ |
1221 | 1151 |
if (PropertyChanged != null) |
1222 | 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 |
} |
|
1223 | 1298 |
} |
1224 | 1299 |
} |
1225 | 1300 |
} |
내보내기 Unified diff