개정판 b84c78a8
Fix: ArrowTextControl의 꺽인선 위치 오류 수정
Change-Id: I8f1cdc8e7de8a1980eb5ba232d3709593566f1a2
FinalService/KCOM_FinalService_DL/MarkupToPDF/Controls/Line/ArcControl.cs.bak | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Net; |
|
3 |
using System.Windows; |
|
4 |
using System.Windows.Controls; |
|
5 |
using System.Windows.Documents; |
|
6 |
using System.Windows.Ink; |
|
7 |
using System.Windows.Input; |
|
8 |
using System.Windows.Media; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Shapes; |
|
11 |
using System.ComponentModel; |
|
12 |
using System.Collections.Generic; |
|
13 |
using MarkupToPDF.Controls.Common; |
|
14 |
using MarkupToPDF.Common; |
|
15 |
|
|
16 |
namespace MarkupToPDF.Controls.Line |
|
17 |
{ |
|
18 |
|
|
19 |
public class ArcControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IMarkupCommonData, IPath |
|
20 |
{ |
|
21 |
#region 초기선언 |
|
22 |
public event PropertyChangedEventHandler PropertyChanged; |
|
23 |
private const string PART_ArcPath = "PART_ArcPath"; |
|
24 |
public Path Base_ArcPath = null; |
|
25 |
#endregion |
|
26 |
static ArcControl() |
|
27 |
{ |
|
28 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(ArcControl), new FrameworkPropertyMetadata(typeof(ArcControl))); |
|
29 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
|
30 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
31 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
32 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
33 |
//System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
|
34 |
} |
|
35 |
|
|
36 |
public ArcControl() |
|
37 |
{ |
|
38 |
this.DefaultStyleKey = typeof(ArcControl); |
|
39 |
} |
|
40 |
|
|
41 |
public void Dispose() |
|
42 |
{ |
|
43 |
GC.Collect(); |
|
44 |
GC.SuppressFinalize(this); |
|
45 |
Control control = new Control(); |
|
46 |
} |
|
47 |
protected void OnPropertyChanged(string propName) |
|
48 |
{ |
|
49 |
if (PropertyChanged != null) |
|
50 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
|
51 |
} |
|
52 |
|
|
53 |
#region Dependency Properties |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
public static readonly DependencyProperty IsSelectedProperty = |
|
58 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ArcControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
59 |
|
|
60 |
public static readonly DependencyProperty ControlTypeProperty = |
|
61 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(ArcControl), new FrameworkPropertyMetadata(ControlType.ArcLine)); |
|
62 |
|
|
63 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
64 |
"OverViewPathData", typeof(Geometry), typeof(ArcControl), new PropertyMetadata(null)); |
|
65 |
|
|
66 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
67 |
"UserID", typeof(string), typeof(ArcControl), new PropertyMetadata(null)); |
|
68 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
69 |
"LineSize", typeof(double), typeof(ArcControl), new PropertyMetadata((Double)3)); |
|
70 |
|
|
71 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
72 |
"DashSize", typeof(DoubleCollection), typeof(ArcControl), new PropertyMetadata(new DoubleCollection { 1, 1 })); |
|
73 |
|
|
74 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
75 |
"StrokeColor", typeof(SolidColorBrush), typeof(ArcControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
76 |
|
|
77 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
78 |
"PathData", typeof(Geometry), typeof(ArcControl), null); |
|
79 |
|
|
80 |
//public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
|
81 |
// "Clock", typeof(SweepDirection), typeof(ArcControl), new PropertyMetadata(SweepDirection.Clockwise)); |
|
82 |
public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
|
83 |
"Clock", typeof(bool), typeof(ArcControl), new PropertyMetadata(false)); |
|
84 |
|
|
85 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
86 |
"StartPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
87 |
public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register( |
|
88 |
"MidPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
89 |
|
|
90 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
91 |
"EndPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
92 |
|
|
93 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
94 |
"PointSet", typeof(List<Point>), typeof(ArcControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
|
95 |
|
|
96 |
public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register( |
|
97 |
"isTransOn", typeof(bool), typeof(ArcControl), new PropertyMetadata(false)); |
|
98 |
|
|
99 |
public static readonly DependencyProperty AngleProperty = |
|
100 |
DependencyProperty.Register("AngleValue", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback |
|
101 |
(AngleValueChanged))); |
|
102 |
|
|
103 |
public static readonly DependencyProperty CenterXProperty = |
|
104 |
DependencyProperty.Register("CenterX", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
105 |
|
|
106 |
public static readonly DependencyProperty CenterYProperty = |
|
107 |
DependencyProperty.Register("CenterY", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
108 |
#endregion |
|
109 |
#region PropertyChanged Method |
|
110 |
|
|
111 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
112 |
{ |
|
113 |
//var instance = (ArcControl)sender; |
|
114 |
|
|
115 |
//if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
|
116 |
//{ |
|
117 |
|
|
118 |
// instance.SetValue(e.Property, e.NewValue); |
|
119 |
|
|
120 |
// if (instance.IsSelected) |
|
121 |
// { |
|
122 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
|
123 |
// } |
|
124 |
// else |
|
125 |
// { |
|
126 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
|
127 |
// } |
|
128 |
//} |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
133 |
{ |
|
134 |
var instance = (ArcControl)sender; |
|
135 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
|
136 |
{ |
|
137 |
instance.SetValue(e.Property, e.NewValue); |
|
138 |
instance.SetArcPath(); |
|
139 |
} |
|
140 |
} |
|
141 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
142 |
{ |
|
143 |
var instance = (ArcControl)sender; |
|
144 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
|
145 |
{ |
|
146 |
instance.SetValue(e.Property, e.NewValue); |
|
147 |
instance.SetArcPath(); |
|
148 |
} |
|
149 |
} |
|
150 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
151 |
{ |
|
152 |
var instance = (ArcControl)sender; |
|
153 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
|
154 |
{ |
|
155 |
instance.SetValue(e.Property, e.NewValue); |
|
156 |
instance.SetArcPath(); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
#endregion |
|
163 |
#region Properties |
|
164 |
public string UserID |
|
165 |
{ |
|
166 |
get { return (string)GetValue(UserIDProperty); } |
|
167 |
set |
|
168 |
{ |
|
169 |
if (this.UserID != value) |
|
170 |
{ |
|
171 |
SetValue(UserIDProperty, value); |
|
172 |
OnPropertyChanged("UserID"); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
public Double LineSize |
|
177 |
{ |
|
178 |
get { return (Double)GetValue(LineSizeProperty); } |
|
179 |
set |
|
180 |
{ |
|
181 |
if (this.LineSize != value) |
|
182 |
{ |
|
183 |
SetValue(LineSizeProperty, value); |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
|
|
189 |
public bool Clock |
|
190 |
{ |
|
191 |
get { return (bool)GetValue(ClockProperty); } |
|
192 |
set |
|
193 |
{ |
|
194 |
if (this.Clock != value) |
|
195 |
{ |
|
196 |
SetValue(ClockProperty, value); |
|
197 |
OnPropertyChanged("Clock"); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
//public SweepDirection Clock |
|
203 |
//{ |
|
204 |
// get { return (SweepDirection)GetValue(ClockProperty); } |
|
205 |
// set |
|
206 |
// { |
|
207 |
// if (this.Clock != value) |
|
208 |
// { |
|
209 |
// SetValue(ClockProperty, value); |
|
210 |
// OnPropertyChanged("Clock"); |
|
211 |
// } |
|
212 |
// } |
|
213 |
//} |
|
214 |
public DoubleCollection DashSize |
|
215 |
{ |
|
216 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
|
217 |
set |
|
218 |
{ |
|
219 |
if (this.DashSize != value) |
|
220 |
{ |
|
221 |
SetValue(DashSizeProperty, value); |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
public List<Point> PointSet |
|
226 |
{ |
|
227 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
228 |
set { SetValue(PointSetProperty, value); } |
|
229 |
} |
|
230 |
public double CenterX |
|
231 |
{ |
|
232 |
get { return (double)GetValue(CenterXProperty); } |
|
233 |
set { SetValue(CenterXProperty, value); } |
|
234 |
} |
|
235 |
public double CenterY |
|
236 |
{ |
|
237 |
get { return (double)GetValue(CenterYProperty); } |
|
238 |
set { SetValue(CenterYProperty, value); } |
|
239 |
} |
|
240 |
public SolidColorBrush StrokeColor |
|
241 |
{ |
|
242 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
|
243 |
set |
|
244 |
{ |
|
245 |
if (this.StrokeColor != value) |
|
246 |
{ |
|
247 |
SetValue(StrokeColorProperty, value); |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
251 |
|
|
252 |
public Geometry OverViewPathData |
|
253 |
{ |
|
254 |
get |
|
255 |
{ |
|
256 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
257 |
} |
|
258 |
set |
|
259 |
{ |
|
260 |
SetValue(OverViewPathDataProperty, value); |
|
261 |
OnPropertyChanged("OverViewPathData"); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
public Geometry PathData |
|
266 |
{ |
|
267 |
get { return (Geometry)GetValue(PathDataProperty); } |
|
268 |
set |
|
269 |
{ |
|
270 |
SetValue(PathDataProperty, value); |
|
271 |
OnPropertyChanged("PathData"); |
|
272 |
} |
|
273 |
} |
|
274 |
public bool IsSelected |
|
275 |
{ |
|
276 |
get |
|
277 |
{ |
|
278 |
return (bool)GetValue(IsSelectedProperty); |
|
279 |
} |
|
280 |
set |
|
281 |
{ |
|
282 |
SetValue(IsSelectedProperty, value); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
public ControlType ControlType |
|
287 |
{ |
|
288 |
get |
|
289 |
{ |
|
290 |
return (ControlType)GetValue(ControlTypeProperty); |
|
291 |
} |
|
292 |
set |
|
293 |
{ |
|
294 |
SetValue(ControlTypeProperty, value); |
|
295 |
OnPropertyChanged("ControlType"); |
|
296 |
} |
|
297 |
} |
|
298 |
public double AngleValue |
|
299 |
{ |
|
300 |
get { return (double)GetValue(AngleProperty); } |
|
301 |
set { SetValue(AngleProperty, value); } |
|
302 |
} |
|
303 |
public double Angle |
|
304 |
{ |
|
305 |
get { return (double)GetValue(AngleProperty); } |
|
306 |
set |
|
307 |
{ |
|
308 |
if (this.Angle != value) |
|
309 |
{ |
|
310 |
SetValue(AngleProperty, value); |
|
311 |
} |
|
312 |
} |
|
313 |
} |
|
314 |
public Point EndPoint |
|
315 |
{ |
|
316 |
get { return (Point)GetValue(EndPointProperty); } |
|
317 |
set |
|
318 |
{ |
|
319 |
SetValue(EndPointProperty, value); |
|
320 |
OnPropertyChanged("EndPoint"); |
|
321 |
} |
|
322 |
} |
|
323 |
public Point StartPoint |
|
324 |
{ |
|
325 |
get { return (Point)GetValue(StartPointProperty); } |
|
326 |
set |
|
327 |
{ |
|
328 |
SetValue(StartPointProperty, value); |
|
329 |
OnPropertyChanged("StartPoint"); |
|
330 |
} |
|
331 |
} |
|
332 |
public Point MidPoint |
|
333 |
{ |
|
334 |
get { return (Point)GetValue(MidPointProperty); } |
|
335 |
set |
|
336 |
{ |
|
337 |
SetValue(MidPointProperty, value); |
|
338 |
OnPropertyChanged("MidPoint"); |
|
339 |
} |
|
340 |
} |
|
341 |
public bool isTransOn |
|
342 |
{ |
|
343 |
get { return (bool)GetValue(isTransOnProperty); } |
|
344 |
set |
|
345 |
{ |
|
346 |
SetValue(isTransOnProperty, value); |
|
347 |
OnPropertyChanged("isTransOn"); |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
#endregion |
|
352 |
#region Object & Variable |
|
353 |
PathGeometry pathGeometry = new PathGeometry(); |
|
354 |
GeometryGroup instanceGroup = new GeometryGroup(); |
|
355 |
#endregion |
|
356 |
public override void OnApplyTemplate() |
|
357 |
{ |
|
358 |
base.OnApplyTemplate(); |
|
359 |
Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
|
360 |
} |
|
361 |
public void updateControl() |
|
362 |
{ |
|
363 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
364 |
this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
365 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
|
366 |
} |
|
367 |
|
|
368 |
public void setClock() |
|
369 |
{ |
|
370 |
if (Clock) |
|
371 |
{ |
|
372 |
this.Clock = false; |
|
373 |
} |
|
374 |
else |
|
375 |
{ |
|
376 |
this.Clock = true; |
|
377 |
} |
|
378 |
} |
|
379 |
|
|
380 |
//public void setClock() |
|
381 |
//{ |
|
382 |
// if(this.Clock == SweepDirection.Clockwise) |
|
383 |
// { |
|
384 |
// this.Clock = SweepDirection.Counterclockwise; |
|
385 |
// } |
|
386 |
// else |
|
387 |
// { |
|
388 |
// this.Clock =SweepDirection.Clockwise; |
|
389 |
// } |
|
390 |
//} |
|
391 |
public void SetArcPath() |
|
392 |
{ |
|
393 |
this.ApplyTemplate(); |
|
394 |
|
|
395 |
//보류 |
|
396 |
//foreach (var item in this.DashSize) |
|
397 |
//{ |
|
398 |
// Base_ArcPath.StrokeDashArray.Add(item); |
|
399 |
//} |
|
400 |
instanceGroup.Children.Clear(); |
|
401 |
|
|
402 |
|
|
403 |
PathFigure pathFigure = new PathFigure(); |
|
404 |
|
|
405 |
pathFigure.StartPoint = this.StartPoint; |
|
406 |
QuadraticBezierSegment qb = new QuadraticBezierSegment(); |
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
if (MidPoint != null) |
|
417 |
{ |
|
418 |
if (MidPoint == new Point(0,0)) |
|
419 |
{ |
|
420 |
double xSharp = 0; |
|
421 |
double ySharp = 0; |
|
422 |
|
|
423 |
//Point t_start = new Point(0, 0); |
|
424 |
//Point t_end = new Point(30, 10); |
|
425 |
|
|
426 |
var midP = MathSet.getMiddlePoint(StartPoint, EndPoint); |
|
427 |
Point normalV = MathSet.GetNormVectorBetween(StartPoint, EndPoint); |
|
428 |
var dis = MathSet.DistanceTo(StartPoint, EndPoint); |
|
429 |
|
|
430 |
if (!this.Clock) |
|
431 |
{ |
|
432 |
xSharp = -normalV.Y; |
|
433 |
ySharp = normalV.X; |
|
434 |
} |
|
435 |
else |
|
436 |
{ |
|
437 |
xSharp = normalV.Y; |
|
438 |
ySharp = -normalV.X; |
|
439 |
} |
|
440 |
|
|
441 |
var pointN = new Point(xSharp * dis, ySharp * dis); |
|
442 |
MidPoint = new Point(pointN.X + midP.X, pointN.Y + midP.Y); |
|
443 |
} |
|
444 |
////System.Diagnostics.Debug.WriteLine(this.MidPoint.ToString()); |
|
445 |
//qb.Point1 = new Point(200, 200); |
|
446 |
//qb.Point1 = this.MidPoint; |
|
447 |
qb.Point1 = this.MidPoint; |
|
448 |
} |
|
449 |
|
|
450 |
qb.Point2 = this.EndPoint; |
|
451 |
pathFigure.Segments.Add(qb); |
|
452 |
pathGeometry.Figures = new PathFigureCollection(); |
|
453 |
pathGeometry.Figures.Add(pathFigure); |
|
454 |
pathFigure.IsFilled = false; |
|
455 |
pathFigure.IsClosed = false; |
|
456 |
instanceGroup.Children.Add(pathGeometry); |
|
457 |
|
|
458 |
//Arc Arrow |
|
459 |
//if(ControlType == ControlType.ArcArrow) |
|
460 |
if (isTransOn) |
|
461 |
{ |
|
462 |
//isTransOn = true; |
|
463 |
instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize)); |
|
464 |
instanceGroup.Children.Add(ConverseAllow(this.EndPoint, this.MidPoint, this.LineSize)); |
|
465 |
this.Base_ArcPath.Fill = this.StrokeColor; |
|
466 |
} |
|
467 |
//Base_ArcPath.StrokeThickness = 3; |
|
468 |
|
|
469 |
instanceGroup.FillRule = FillRule.Nonzero; |
|
470 |
this.PathData = instanceGroup; |
|
471 |
this.OverViewPathData = PathData; |
|
472 |
|
|
473 |
} |
|
474 |
|
|
475 |
|
|
476 |
public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize) |
|
477 |
{ |
|
478 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
479 |
PathGeometry pathGeometry = new PathGeometry(); |
|
480 |
PathFigure pathFigure = new PathFigure(); |
|
481 |
pathFigure.StartPoint = p1; |
|
482 |
|
|
483 |
Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 4); |
|
484 |
Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 4); |
|
485 |
|
|
486 |
LineSegment seg1 = new LineSegment(); |
|
487 |
seg1.Point = lpoint; |
|
488 |
pathFigure.Segments.Add(seg1); |
|
489 |
|
|
490 |
LineSegment seg2 = new LineSegment(); |
|
491 |
seg2.Point = rpoint; |
|
492 |
pathFigure.Segments.Add(seg2); |
|
493 |
|
|
494 |
LineSegment seg3 = new LineSegment(); |
|
495 |
seg3.Point = p1; |
|
496 |
pathFigure.Segments.Add(seg3); |
|
497 |
|
|
498 |
pathFigure.IsClosed = true; |
|
499 |
pathFigure.IsFilled = true; |
|
500 |
|
|
501 |
pathGeometry.Figures.Add(pathFigure); |
|
502 |
pathGeometry.FillRule = FillRule.Nonzero; |
|
503 |
RotateTransform transform = new RotateTransform(); |
|
504 |
transform.Angle = theta - 90; |
|
505 |
transform.CenterX = p1.X; |
|
506 |
transform.CenterY = p1.Y; |
|
507 |
pathGeometry.Transform = transform; |
|
508 |
return pathGeometry; |
|
509 |
} |
|
510 |
|
|
511 |
public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize) |
|
512 |
{ |
|
513 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
514 |
PathGeometry pathGeometry2 = new PathGeometry(); |
|
515 |
PathFigure pathFigure2 = new PathFigure(); |
|
516 |
pathFigure2.StartPoint = p2; |
|
517 |
|
|
518 |
Point lpoint2 = new Point(p2.X + lineSize * 2, p2.Y + lineSize * 4); |
|
519 |
Point rpoint2 = new Point(p2.X - lineSize * 2, p2.Y + lineSize * 4); |
|
520 |
LineSegment seg1_1 = new LineSegment(); |
|
521 |
seg1_1.Point = lpoint2; |
|
522 |
pathFigure2.Segments.Add(seg1_1); |
|
523 |
|
|
524 |
LineSegment seg2_1 = new LineSegment(); |
|
525 |
seg2_1.Point = rpoint2; |
|
526 |
pathFigure2.Segments.Add(seg2_1); |
|
527 |
|
|
528 |
LineSegment seg3_1 = new LineSegment(); |
|
529 |
seg3_1.Point = p2; |
|
530 |
pathFigure2.Segments.Add(seg3_1); |
|
531 |
|
|
532 |
LineSegment seg4_1 = new LineSegment(); |
|
533 |
|
|
534 |
seg4_1.Point = new Point(lpoint2.X, lpoint2.Y); |
|
535 |
pathFigure2.Segments.Add(seg4_1); |
|
536 |
|
|
537 |
//pathFigure2.IsFilled = true; |
|
538 |
//pathFigure2.IsClosed = true; |
|
539 |
|
|
540 |
RotateTransform transform2 = new RotateTransform(); |
|
541 |
transform2.Angle = theta + 90; |
|
542 |
transform2.CenterX = p2.X; |
|
543 |
transform2.CenterY = p2.Y; |
|
544 |
pathGeometry2.Figures.Add(pathFigure2); |
|
545 |
pathGeometry2.Transform = transform2; |
|
546 |
return pathGeometry2; |
|
547 |
} |
|
548 |
|
|
549 |
public void ApplyOverViewData() |
|
550 |
{ |
|
551 |
this.OverViewPathData = this.PathData; |
|
552 |
} |
|
553 |
} |
|
554 |
} |
FinalService/KCOM_FinalService_DL/MarkupToPDF/Controls/Line/ArrowControl_Multi.cs.bak | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Net; |
|
3 |
using System.Windows; |
|
4 |
using System.Windows.Controls; |
|
5 |
using System.Windows.Documents; |
|
6 |
using System.Windows.Ink; |
|
7 |
using System.Windows.Input; |
|
8 |
using System.Windows.Media; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Shapes; |
|
11 |
using System.ComponentModel; |
|
12 |
using System.Collections.Generic; |
|
13 |
using MarkupToPDF.Controls.Common; |
|
14 |
using MarkupToPDF.Common; |
|
15 |
|
|
16 |
namespace MarkupToPDF.Controls.Line |
|
17 |
{ |
|
18 |
|
|
19 |
public class ArrowControl_Multi : CommentUserInfo, IDisposable, INotifyPropertyChanged, IMarkupCommonData, IPath |
|
20 |
{ |
|
21 |
|
|
22 |
public event PropertyChangedEventHandler PropertyChanged; |
|
23 |
private const string PART_ArrowMultiPath = "PART_ArrowMultiPath"; |
|
24 |
public Path Base_ArrowMultiPath = null; |
|
25 |
|
|
26 |
static ArrowControl_Multi() |
|
27 |
{ |
|
28 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowControl_Multi), new FrameworkPropertyMetadata(typeof(ArrowControl_Multi))); |
|
29 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
|
30 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
31 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
32 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
33 |
System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
|
34 |
} |
|
35 |
|
|
36 |
public ArrowControl_Multi() |
|
37 |
{ |
|
38 |
this.DefaultStyleKey = typeof(ArrowControl_Multi); |
|
39 |
} |
|
40 |
|
|
41 |
#region Dependency Properties |
|
42 |
|
|
43 |
public static readonly DependencyProperty IsSelectedProperty = |
|
44 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ArrowControl_Multi), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
45 |
|
|
46 |
public static readonly DependencyProperty ControlTypeProperty = |
|
47 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(ArrowControl_Multi), new FrameworkPropertyMetadata(ControlType.ArrowMultiLine)); |
|
48 |
|
|
49 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
50 |
"OverViewPathData", typeof(Geometry), typeof(ArrowControl_Multi), new PropertyMetadata(null)); |
|
51 |
|
|
52 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
53 |
"UserID", typeof(string), typeof(ArrowControl_Multi), new PropertyMetadata(null)); |
|
54 |
|
|
55 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
56 |
"LineSize", typeof(double), typeof(ArrowControl_Multi), new PropertyMetadata((Double)3)); |
|
57 |
|
|
58 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
59 |
"DashSize", typeof(DoubleCollection), typeof(ArrowControl_Multi), new PropertyMetadata(new DoubleCollection { 1, 1 })); |
|
60 |
|
|
61 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
62 |
"StrokeColor", typeof(SolidColorBrush), typeof(ArrowControl_Multi), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
63 |
|
|
64 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
65 |
"PathData", typeof(Geometry), typeof(ArrowControl_Multi), null); |
|
66 |
|
|
67 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
68 |
"StartPoint", typeof(Point), typeof(ArrowControl_Multi), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
69 |
|
|
70 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
71 |
"EndPoint", typeof(Point), typeof(ArrowControl_Multi), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
|
72 |
public static readonly DependencyProperty MiddlePointProperty = DependencyProperty.Register( |
|
73 |
"MiddlePoint", typeof(Point), typeof(ArrowControl_Multi), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
74 |
|
|
75 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
76 |
"PointSet", typeof(List<Point>), typeof(ArrowControl_Multi), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
|
77 |
#endregion |
|
78 |
#region PropertyChanged Method |
|
79 |
|
|
80 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
81 |
{ |
|
82 |
//var instance = (ArrowControl_Multi)sender; |
|
83 |
|
|
84 |
//if (e.OldValue != e.NewValue && instance.Base_ArrowMultiPath != null) |
|
85 |
//{ |
|
86 |
|
|
87 |
// instance.SetValue(e.Property, e.NewValue); |
|
88 |
|
|
89 |
// if (instance.IsSelected) |
|
90 |
// { |
|
91 |
// instance.Base_ArrowMultiPath.Stroke = new SolidColorBrush(Colors.Blue); |
|
92 |
// } |
|
93 |
// else |
|
94 |
// { |
|
95 |
// instance.Base_ArrowMultiPath.Stroke = new SolidColorBrush(Colors.Red); |
|
96 |
// } |
|
97 |
//} |
|
98 |
} |
|
99 |
|
|
100 |
|
|
101 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
102 |
{ |
|
103 |
var instance = (ArrowControl_Multi)sender; |
|
104 |
if (e.OldValue != e.NewValue && instance.Base_ArrowMultiPath != null) |
|
105 |
{ |
|
106 |
instance.SetValue(e.Property, e.NewValue); |
|
107 |
instance.SetArrowMultiPath(); |
|
108 |
} |
|
109 |
} |
|
110 |
#endregion |
|
111 |
#region Properties |
|
112 |
public string UserID |
|
113 |
{ |
|
114 |
get { return (string)GetValue(UserIDProperty); } |
|
115 |
set |
|
116 |
{ |
|
117 |
if (this.UserID != value) |
|
118 |
{ |
|
119 |
SetValue(UserIDProperty, value); |
|
120 |
OnPropertyChanged("UserID"); |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
public Double LineSize |
|
125 |
{ |
|
126 |
get { return (Double)GetValue(LineSizeProperty); } |
|
127 |
set |
|
128 |
{ |
|
129 |
if (this.LineSize != value) |
|
130 |
{ |
|
131 |
SetValue(LineSizeProperty, value); |
|
132 |
} |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
public Geometry OverViewPathData |
|
137 |
{ |
|
138 |
get |
|
139 |
{ |
|
140 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
141 |
} |
|
142 |
set |
|
143 |
{ |
|
144 |
SetValue(OverViewPathDataProperty, value); |
|
145 |
OnPropertyChanged("OverViewPathData"); |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
public bool IsSelected |
|
150 |
{ |
|
151 |
get |
|
152 |
{ |
|
153 |
return (bool)GetValue(IsSelectedProperty); |
|
154 |
} |
|
155 |
set |
|
156 |
{ |
|
157 |
SetValue(IsSelectedProperty, value); |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
public ControlType ControlType |
|
162 |
{ |
|
163 |
get |
|
164 |
{ |
|
165 |
return (ControlType)GetValue(ControlTypeProperty); |
|
166 |
} |
|
167 |
set |
|
168 |
{ |
|
169 |
SetValue(ControlTypeProperty, value); |
|
170 |
} |
|
171 |
} |
|
172 |
|
|
173 |
|
|
174 |
public DoubleCollection DashSize |
|
175 |
{ |
|
176 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
|
177 |
set |
|
178 |
{ |
|
179 |
if (this.DashSize != value) |
|
180 |
{ |
|
181 |
SetValue(DashSizeProperty, value); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
public List<Point> PointSet |
|
186 |
{ |
|
187 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
188 |
set { SetValue(PointSetProperty, value); } |
|
189 |
} |
|
190 |
public SolidColorBrush StrokeColor |
|
191 |
{ |
|
192 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
|
193 |
set |
|
194 |
{ |
|
195 |
if (this.StrokeColor != value) |
|
196 |
{ |
|
197 |
SetValue(StrokeColorProperty, value); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
public Geometry PathData |
|
202 |
{ |
|
203 |
get { return (Geometry)GetValue(PathDataProperty); } |
|
204 |
set { SetValue(PathDataProperty, value); } |
|
205 |
} |
|
206 |
public Point EndPoint |
|
207 |
{ |
|
208 |
get { return (Point)GetValue(EndPointProperty); } |
|
209 |
set { SetValue(EndPointProperty, value); } |
|
210 |
} |
|
211 |
public Point StartPoint |
|
212 |
{ |
|
213 |
get { return (Point)GetValue(StartPointProperty); } |
|
214 |
set { SetValue(StartPointProperty, value); } |
|
215 |
} |
|
216 |
public Point MiddlePoint |
|
217 |
{ |
|
218 |
get { return (Point)GetValue(MiddlePointProperty); } |
|
219 |
set |
|
220 |
{ |
|
221 |
SetValue(MiddlePointProperty, value); |
|
222 |
OnPropertyChanged("MiddlePoint"); |
|
223 |
} |
|
224 |
} |
|
225 |
#endregion |
|
226 |
#region Object & Variable |
|
227 |
GeometryGroup instanceGroup = new GeometryGroup(); |
|
228 |
#endregion |
|
229 |
public override void OnApplyTemplate() |
|
230 |
{ |
|
231 |
base.OnApplyTemplate(); |
|
232 |
Base_ArrowMultiPath = GetTemplateChild(PART_ArrowMultiPath) as Path; |
|
233 |
} |
|
234 |
|
|
235 |
public void ApplyOverViewData() |
|
236 |
{ |
|
237 |
this.OverViewPathData = this.PathData; |
|
238 |
} |
|
239 |
|
|
240 |
public void SetArrowMultiPath() |
|
241 |
{ |
|
242 |
|
|
243 |
|
|
244 |
Base_ArrowMultiPath.StrokeDashArray.Clear(); |
|
245 |
foreach (var item in this.DashSize) |
|
246 |
{ |
|
247 |
Base_ArrowMultiPath.StrokeDashArray.Add(item); |
|
248 |
} |
|
249 |
Base_ArrowMultiPath.StrokeDashCap = PenLineCap.Square; |
|
250 |
instanceGroup.Children.Clear(); |
|
251 |
PathFigure pathFigure = new PathFigure(); |
|
252 |
|
|
253 |
pathFigure.StartPoint = this.StartPoint; |
|
254 |
LineSegment lineSegment0 = new LineSegment(); |
|
255 |
lineSegment0.Point = this.StartPoint; |
|
256 |
pathFigure.Segments.Add(lineSegment0); |
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
//if (this.EndPoint == this.MiddlePoint) |
|
261 |
if (this.MiddlePoint == new Point(0,0)) |
|
262 |
{ |
|
263 |
//instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.MiddlePoint, this.LineSize)); |
|
264 |
instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
265 |
} |
|
266 |
else |
|
267 |
{ |
|
268 |
instanceGroup.Children.Add(SingleAllow(this.MiddlePoint, this.EndPoint, this.LineSize)); |
|
269 |
LineSegment lineSegment1 = new LineSegment(); |
|
270 |
lineSegment1.Point = this.MiddlePoint; |
|
271 |
pathFigure.Segments.Add(lineSegment1); |
|
272 |
} |
|
273 |
|
|
274 |
LineSegment lineSegment2 = new LineSegment(); |
|
275 |
lineSegment2.Point = this.EndPoint; |
|
276 |
pathFigure.Segments.Add(lineSegment2); |
|
277 |
|
|
278 |
PathGeometry pathGeometry = new PathGeometry(); |
|
279 |
pathGeometry.Figures.Add(pathFigure); |
|
280 |
pathFigure.IsFilled = false; |
|
281 |
instanceGroup.Children.Add(pathGeometry); |
|
282 |
//this.Base_ArrowMultiPath.Stroke = this.StrokeColor; |
|
283 |
|
|
284 |
//if (this.IsSelected) |
|
285 |
//{ |
|
286 |
// Base_ArrowMultiPath.Stroke = new SolidColorBrush(Colors.Blue); |
|
287 |
//} |
|
288 |
//else |
|
289 |
//{ |
|
290 |
// Base_ArrowMultiPath.Stroke = new SolidColorBrush(Colors.Red); |
|
291 |
//} |
|
292 |
|
|
293 |
this.PathData = instanceGroup; |
|
294 |
OverViewPathData = PathData; |
|
295 |
} |
|
296 |
//public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize) |
|
297 |
//{ |
|
298 |
// double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
299 |
// PathGeometry pathGeometry = new PathGeometry(); |
|
300 |
// PathFigure pathFigure = new PathFigure(); |
|
301 |
// pathFigure.StartPoint = p1; |
|
302 |
|
|
303 |
// Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6); |
|
304 |
// Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6); |
|
305 |
|
|
306 |
// //Point lpoint = new Point(p1.X + lineSize, p1.Y + lineSize * 4); |
|
307 |
// //Point rpoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4); |
|
308 |
|
|
309 |
// //Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6); |
|
310 |
// //Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6); |
|
311 |
|
|
312 |
// LineSegment seg1 = new LineSegment(); |
|
313 |
// seg1.Point = lpoint; |
|
314 |
// pathFigure.Segments.Add(seg1); |
|
315 |
|
|
316 |
// LineSegment seg2 = new LineSegment(); |
|
317 |
// seg2.Point = rpoint; |
|
318 |
// pathFigure.Segments.Add(seg2); |
|
319 |
|
|
320 |
// LineSegment seg3 = new LineSegment(); |
|
321 |
// seg3.Point = p1; |
|
322 |
// pathFigure.Segments.Add(seg3); |
|
323 |
|
|
324 |
// pathFigure.IsClosed = true; |
|
325 |
// pathFigure.IsFilled = true; |
|
326 |
|
|
327 |
// pathGeometry.Figures.Add(pathFigure); |
|
328 |
// pathGeometry.FillRule = FillRule.Nonzero; |
|
329 |
// RotateTransform transform = new RotateTransform(); |
|
330 |
// transform.Angle = theta - 90; |
|
331 |
// transform.CenterX = p1.X; |
|
332 |
// transform.CenterY = p1.Y; |
|
333 |
// pathGeometry.Transform = transform; |
|
334 |
// return pathGeometry; |
|
335 |
//} |
|
336 |
|
|
337 |
public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize) |
|
338 |
{ |
|
339 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
340 |
PathGeometry pathGeometry = new PathGeometry(); |
|
341 |
PathFigure pathFigure = new PathFigure(); |
|
342 |
pathFigure.StartPoint = p1; |
|
343 |
lineSize = 2; |
|
344 |
Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6); |
|
345 |
Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6); |
|
346 |
|
|
347 |
LineSegment seg1 = new LineSegment(); |
|
348 |
seg1.Point = lpoint; |
|
349 |
pathFigure.Segments.Add(seg1); |
|
350 |
|
|
351 |
LineSegment seg2 = new LineSegment(); |
|
352 |
seg2.Point = rpoint; |
|
353 |
pathFigure.Segments.Add(seg2); |
|
354 |
|
|
355 |
LineSegment seg3 = new LineSegment(); |
|
356 |
seg3.Point = p1; |
|
357 |
pathFigure.Segments.Add(seg3); |
|
358 |
|
|
359 |
pathFigure.IsClosed = true; |
|
360 |
pathFigure.IsFilled = true; |
|
361 |
|
|
362 |
pathGeometry.Figures.Add(pathFigure); |
|
363 |
pathGeometry.FillRule = FillRule.Nonzero; |
|
364 |
RotateTransform transform = new RotateTransform(); |
|
365 |
transform.Angle = theta - 90; |
|
366 |
transform.CenterX = p1.X; |
|
367 |
transform.CenterY = p1.Y; |
|
368 |
pathGeometry.Transform = transform; |
|
369 |
return pathGeometry; |
|
370 |
} |
|
371 |
protected void OnPropertyChanged(string propName) |
|
372 |
{ |
|
373 |
if (PropertyChanged != null) |
|
374 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
|
375 |
} |
|
376 |
public void updateControl() |
|
377 |
{ |
|
378 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
379 |
this.MiddlePoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
380 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
|
381 |
} |
|
382 |
public void Dispose() |
|
383 |
{ |
|
384 |
GC.Collect(); |
|
385 |
GC.SuppressFinalize(this); |
|
386 |
} |
|
387 |
} |
|
388 |
} |
|
389 |
|
FinalService/KCOM_FinalService_DL/MarkupToPDF/Controls/Line/LineControl.cs.bak | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Net; |
|
3 |
using System.Windows; |
|
4 |
using System.Windows.Controls; |
|
5 |
using System.Windows.Documents; |
|
6 |
using System.Windows.Ink; |
|
7 |
using System.Windows.Input; |
|
8 |
using System.Windows.Media; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Shapes; |
|
11 |
using System.ComponentModel; |
|
12 |
using System.Collections.Generic; |
|
13 |
using MarkupToPDF.Controls.Common; |
|
14 |
using MarkupToPDF.Common; |
|
15 |
|
|
16 |
namespace MarkupToPDF.Controls.Line |
|
17 |
{ |
|
18 |
[TemplatePart(Name = "PART_LinePath", Type = typeof(Path))] |
|
19 |
public class LineControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IMarkupCommonData, IPath |
|
20 |
{ |
|
21 |
public event PropertyChangedEventHandler PropertyChanged; |
|
22 |
|
|
23 |
private const string PART_LinePath = "PART_LinePath"; |
|
24 |
public Path Base_LinePath = null; |
|
25 |
|
|
26 |
static LineControl() |
|
27 |
{ |
|
28 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(LineControl), new FrameworkPropertyMetadata(typeof(LineControl))); |
|
29 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
|
30 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
31 |
|
|
32 |
dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
33 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
34 |
//System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
|
35 |
} |
|
36 |
|
|
37 |
public double DimSize |
|
38 |
{ |
|
39 |
get { return (double)GetValue(DimSizeProperty); } |
|
40 |
set |
|
41 |
{ |
|
42 |
if (this.DimSize != value) |
|
43 |
{ |
|
44 |
SetValue(DimSizeProperty, value); |
|
45 |
OnPropertyChanged("DimSize"); |
|
46 |
} |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
public LineControl() |
|
51 |
{ |
|
52 |
this.DefaultStyleKey = typeof(LineControl); |
|
53 |
} |
|
54 |
|
|
55 |
public void Dispose() |
|
56 |
{ |
|
57 |
GC.Collect(); |
|
58 |
GC.SuppressFinalize(this); |
|
59 |
} |
|
60 |
protected void OnPropertyChanged(string propName) |
|
61 |
{ |
|
62 |
if (PropertyChanged != null) |
|
63 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
|
64 |
} |
|
65 |
#region Dependency Properties |
|
66 |
|
|
67 |
public static readonly DependencyProperty IsSelectedProperty = |
|
68 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(LineControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
69 |
|
|
70 |
public static readonly DependencyProperty ControlTypeProperty = |
|
71 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(LineControl), new FrameworkPropertyMetadata(ControlType.SingleLine)); |
|
72 |
|
|
73 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
74 |
"OverViewPathData", typeof(Geometry), typeof(LineControl), new PropertyMetadata(null)); |
|
75 |
|
|
76 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
77 |
"UserID", typeof(string), typeof(LineControl), new PropertyMetadata(null)); |
|
78 |
|
|
79 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
80 |
"LineSize", typeof(double), typeof(LineControl), new PropertyMetadata((Double)3)); |
|
81 |
|
|
82 |
public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register( |
|
83 |
"Interval", typeof(double), typeof(LineControl), new PropertyMetadata((double)10)); |
|
84 |
|
|
85 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
86 |
"DashSize", typeof(DoubleCollection), typeof(LineControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged)); |
|
87 |
|
|
88 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
89 |
"StrokeColor", typeof(SolidColorBrush), typeof(LineControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
90 |
|
|
91 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
92 |
"PathData", typeof(Geometry), typeof(LineControl), null); |
|
93 |
|
|
94 |
public static readonly DependencyProperty LineStyleProperty = DependencyProperty.Register( |
|
95 |
"LineStyleSet", typeof(LineStyleSet), typeof(LineControl), new PropertyMetadata(LineStyleSet.SingleLine)); |
|
96 |
|
|
97 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
98 |
"StartPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
99 |
|
|
100 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
101 |
"EndPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
|
102 |
|
|
103 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
104 |
"PointSet", typeof(List<Point>), typeof(LineControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
|
105 |
|
|
106 |
|
|
107 |
public static readonly DependencyProperty MiddlePointProperty = DependencyProperty.Register( |
|
108 |
"MiddlePoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0))); |
|
109 |
public static readonly DependencyProperty DimSizeProperty = DependencyProperty.Register( |
|
110 |
"DimSize", typeof(double), typeof(LineControl), new PropertyMetadata((double)5)); |
|
111 |
|
|
112 |
public static readonly DependencyProperty AngleProperty = |
|
113 |
DependencyProperty.Register("AngleValue", typeof(double), typeof(LineControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
|
114 |
|
|
115 |
public static readonly DependencyProperty CenterXProperty = |
|
116 |
DependencyProperty.Register("CenterX", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
117 |
|
|
118 |
public static readonly DependencyProperty CenterYProperty = |
|
119 |
DependencyProperty.Register("CenterY", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
120 |
#endregion |
|
121 |
#region PropertyChanged Method |
|
122 |
|
|
123 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
124 |
{ |
|
125 |
//var instance = (LineControl)sender; |
|
126 |
|
|
127 |
//if (e.OldValue != e.NewValue && instance.Base_LinePath != null) |
|
128 |
//{ |
|
129 |
|
|
130 |
// instance.SetValue(e.Property, e.NewValue); |
|
131 |
|
|
132 |
// if (instance.IsSelected) |
|
133 |
// { |
|
134 |
// instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Blue); |
|
135 |
// } |
|
136 |
// else |
|
137 |
// { |
|
138 |
// instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Red); |
|
139 |
// } |
|
140 |
//} |
|
141 |
} |
|
142 |
|
|
143 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
144 |
{ |
|
145 |
var instance = (LineControl)sender; |
|
146 |
if (e.OldValue != e.NewValue && instance.Base_LinePath != null) |
|
147 |
{ |
|
148 |
instance.SetValue(e.Property, e.NewValue); |
|
149 |
instance.SetLinePath(); |
|
150 |
} |
|
151 |
} |
|
152 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
153 |
{ |
|
154 |
var instance = (LineControl)sender; |
|
155 |
if (e.OldValue != e.NewValue && instance.Base_LinePath != null) |
|
156 |
{ |
|
157 |
instance.SetValue(e.Property, e.NewValue); |
|
158 |
instance.SetLinePath(); |
|
159 |
} |
|
160 |
} |
|
161 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
162 |
{ |
|
163 |
var instance = (LineControl)sender; |
|
164 |
if (e.OldValue != e.NewValue && instance.Base_LinePath != null) |
|
165 |
{ |
|
166 |
instance.SetValue(e.Property, e.NewValue); |
|
167 |
instance.SetLinePath(); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
#endregion |
|
172 |
#region Properties |
|
173 |
public string UserID |
|
174 |
{ |
|
175 |
get { return (string)GetValue(UserIDProperty); } |
|
176 |
set |
|
177 |
{ |
|
178 |
if (this.UserID != value) |
|
179 |
{ |
|
180 |
SetValue(UserIDProperty, value); |
|
181 |
OnPropertyChanged("UserID"); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
public double Interval |
|
187 |
{ |
|
188 |
get { return (double)GetValue(IntervalProperty); } |
|
189 |
set |
|
190 |
{ |
|
191 |
if (this.Interval != value) |
|
192 |
{ |
|
193 |
SetValue(IntervalProperty, value); |
|
194 |
OnPropertyChanged("Interval"); |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
public Double LineSize |
|
199 |
{ |
|
200 |
get { return (Double)GetValue(LineSizeProperty); } |
|
201 |
set |
|
202 |
{ |
|
203 |
if (this.LineSize != value) |
|
204 |
{ |
|
205 |
SetValue(LineSizeProperty, value); |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
public DoubleCollection DashSize |
|
210 |
{ |
|
211 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
|
212 |
set |
|
213 |
{ |
|
214 |
if (this.DashSize != value) |
|
215 |
{ |
|
216 |
SetValue(DashSizeProperty, value); |
|
217 |
} |
|
218 |
} |
|
219 |
} |
|
220 |
public List<Point> PointSet |
|
221 |
{ |
|
222 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
223 |
set { SetValue(PointSetProperty, value); } |
|
224 |
} |
|
225 |
public double CenterX |
|
226 |
{ |
|
227 |
get { return (double)GetValue(CenterXProperty); } |
|
228 |
set { SetValue(CenterXProperty, value); } |
|
229 |
} |
|
230 |
public double CenterY |
|
231 |
{ |
|
232 |
get { return (double)GetValue(CenterYProperty); } |
|
233 |
set { SetValue(CenterYProperty, value); } |
|
234 |
} |
|
235 |
public SolidColorBrush StrokeColor |
|
236 |
{ |
|
237 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
|
238 |
set |
|
239 |
{ |
|
240 |
if (this.StrokeColor != value) |
|
241 |
{ |
|
242 |
SetValue(StrokeColorProperty, value); |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
|
|
248 |
public Geometry PathData |
|
249 |
{ |
|
250 |
get { return (Geometry)GetValue(PathDataProperty); } |
|
251 |
set |
|
252 |
{ |
|
253 |
SetValue(PathDataProperty, value); |
|
254 |
OnPropertyChanged("PathData"); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
public Geometry OverViewPathData |
|
261 |
{ |
|
262 |
get |
|
263 |
{ |
|
264 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
265 |
} |
|
266 |
set |
|
267 |
{ |
|
268 |
SetValue(OverViewPathDataProperty, value); |
|
269 |
OnPropertyChanged("OverViewPathData"); |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
public bool IsSelected |
|
274 |
{ |
|
275 |
get |
|
276 |
{ |
|
277 |
return (bool)GetValue(IsSelectedProperty); |
|
278 |
} |
|
279 |
set |
|
280 |
{ |
|
281 |
SetValue(IsSelectedProperty, value); |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
public LineStyleSet LineStyleSet |
|
286 |
{ |
|
287 |
get |
|
288 |
{ |
|
289 |
return (LineStyleSet)GetValue(LineStyleProperty); |
|
290 |
} |
|
291 |
set |
|
292 |
{ |
|
293 |
SetValue(LineStyleProperty, value); |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
297 |
public ControlType ControlType |
|
298 |
{ |
|
299 |
get |
|
300 |
{ |
|
301 |
return (ControlType)GetValue(ControlTypeProperty); |
|
302 |
} |
|
303 |
set |
|
304 |
{ |
|
305 |
SetValue(ControlTypeProperty, value); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
public double AngleValue |
|
310 |
{ |
|
311 |
get { return (double)GetValue(AngleProperty); } |
|
312 |
set { SetValue(AngleProperty, value); } |
|
313 |
} |
|
314 |
public double Angle |
|
315 |
{ |
|
316 |
get { return (double)GetValue(AngleProperty); } |
|
317 |
set |
|
318 |
{ |
|
319 |
if (this.Angle != value) |
|
320 |
{ |
|
321 |
SetValue(AngleProperty, value); |
|
322 |
} |
|
323 |
} |
|
324 |
} |
|
325 |
public Point EndPoint |
|
326 |
{ |
|
327 |
get { return (Point)GetValue(EndPointProperty); } |
|
328 |
set |
|
329 |
{ |
|
330 |
SetValue(EndPointProperty, value); |
|
331 |
OnPropertyChanged("EndPoint"); |
|
332 |
} |
|
333 |
} |
|
334 |
public Point StartPoint |
|
335 |
{ |
|
336 |
get { return (Point)GetValue(StartPointProperty); } |
|
337 |
set |
|
338 |
{ |
|
339 |
SetValue(StartPointProperty, value); |
|
340 |
OnPropertyChanged("StartPoint"); |
|
341 |
} |
|
342 |
} |
|
343 |
GeometryGroup instanceGroup = new GeometryGroup(); |
|
344 |
LineGeometry connectorGeometry = new LineGeometry(); |
|
345 |
|
|
346 |
#endregion |
|
347 |
public override void OnApplyTemplate() |
|
348 |
{ |
|
349 |
base.OnApplyTemplate(); |
|
350 |
Base_LinePath = GetTemplateChild("PART_LinePath") as Path; |
|
351 |
|
|
352 |
} |
|
353 |
public void updateControl() |
|
354 |
{ |
|
355 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
356 |
this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
357 |
} |
|
358 |
public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize) |
|
359 |
{ |
|
360 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
361 |
PathGeometry pathGeometry = new PathGeometry(); |
|
362 |
PathFigure pathFigure = new PathFigure(); |
|
363 |
pathFigure.StartPoint = new Point(p1.X, p1.Y); |
|
364 |
lineSize = 2; |
|
365 |
Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6); |
|
366 |
Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6); |
|
367 |
LineSegment seg1 = new LineSegment(); |
|
368 |
seg1.Point = lpoint; |
|
369 |
pathFigure.Segments.Add(seg1); |
|
370 |
LineSegment seg2 = new LineSegment(); |
|
371 |
seg2.Point = rpoint; |
|
372 |
pathFigure.Segments.Add(seg2); |
|
373 |
|
|
374 |
LineSegment seg3 = new LineSegment(); |
|
375 |
seg3.Point = p1; |
|
376 |
pathFigure.Segments.Add(seg3); |
|
377 |
|
|
378 |
pathFigure.IsClosed = true; |
|
379 |
pathFigure.IsFilled = true; |
|
380 |
pathGeometry.Figures.Add(pathFigure); |
|
381 |
pathGeometry.FillRule = FillRule.Nonzero; |
|
382 |
RotateTransform transform = new RotateTransform(); |
|
383 |
transform.Angle = theta - 90; |
|
384 |
transform.CenterX = p1.X; |
|
385 |
transform.CenterY = p1.Y; |
|
386 |
pathGeometry.Transform = transform; |
|
387 |
return pathGeometry; |
|
388 |
} |
|
389 |
|
|
390 |
|
|
391 |
public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize) |
|
392 |
{ |
|
393 |
lineSize = 2; |
|
394 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
395 |
PathGeometry pathGeometry2 = new PathGeometry(); |
|
396 |
PathFigure pathFigure2 = new PathFigure(); |
|
397 |
pathFigure2.StartPoint = p2; |
|
398 |
|
|
399 |
Point lpoint2 = new Point(p2.X + lineSize * 3, p2.Y + lineSize * 6); |
|
400 |
Point rpoint2 = new Point(p2.X - lineSize * 3, p2.Y + lineSize * 6); |
|
401 |
LineSegment seg1_1 = new LineSegment(); |
|
402 |
seg1_1.Point = lpoint2; |
|
403 |
pathFigure2.Segments.Add(seg1_1); |
|
404 |
|
|
405 |
LineSegment seg2_1 = new LineSegment(); |
|
406 |
seg2_1.Point = rpoint2; |
|
407 |
pathFigure2.Segments.Add(seg2_1); |
|
408 |
|
|
409 |
LineSegment seg3_1 = new LineSegment(); |
|
410 |
seg3_1.Point = p2; |
|
411 |
pathFigure2.Segments.Add(seg3_1); |
|
412 |
|
|
413 |
LineSegment seg4_1 = new LineSegment(); |
|
414 |
|
|
415 |
seg4_1.Point = new Point(lpoint2.X, lpoint2.Y); |
|
416 |
pathFigure2.Segments.Add(seg4_1); |
|
417 |
RotateTransform transform2 = new RotateTransform(); |
|
418 |
transform2.Angle = theta + 90; |
|
419 |
transform2.CenterX = p2.X; |
|
420 |
transform2.CenterY = p2.Y; |
|
421 |
pathGeometry2.Figures.Add(pathFigure2); |
|
422 |
pathGeometry2.Transform = transform2; |
|
423 |
return pathGeometry2; |
|
424 |
} |
|
425 |
public static List<LineGeometry> DimAllow(Point p1, Point p2, Double lineSize, double DimSize) |
|
426 |
{ |
|
427 |
lineSize = 2; |
|
428 |
List<LineGeometry> GeometrySet = new List<LineGeometry>(); |
|
429 |
double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI; |
|
430 |
|
|
431 |
|
|
432 |
LineGeometry ld = new LineGeometry(); |
|
433 |
//ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4 - DimSize); |
|
434 |
//ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize); |
|
435 |
ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4); |
|
436 |
ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize); |
|
437 |
|
|
438 |
RotateTransform transform3 = new RotateTransform(); |
|
439 |
transform3.Angle = theta; |
|
440 |
transform3.CenterX = p2.X; |
|
441 |
transform3.CenterY = p2.Y; |
|
442 |
ld.Transform = transform3; |
|
443 |
GeometrySet.Add(ld); |
|
444 |
|
|
445 |
LineGeometry ld1 = new LineGeometry(); |
|
446 |
//ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4 - DimSize); |
|
447 |
//ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize); |
|
448 |
ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4); |
|
449 |
ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize); |
|
450 |
|
|
451 |
RotateTransform transform4 = new RotateTransform(); |
|
452 |
transform4.Angle = theta; |
|
453 |
transform4.CenterX = p1.X; |
|
454 |
transform4.CenterY = p1.Y; |
|
455 |
ld1.Transform = transform4; |
|
456 |
GeometrySet.Add(ld1); |
|
457 |
return GeometrySet; |
|
458 |
} |
|
459 |
|
|
460 |
|
|
461 |
public void ApplyOverViewData() |
|
462 |
{ |
|
463 |
this.OverViewPathData = this.PathData; |
|
464 |
} |
|
465 |
|
|
466 |
public void SetLinePath() |
|
467 |
{ |
|
468 |
this.ApplyTemplate(); |
|
469 |
if (this.DashSize != null) |
|
470 |
{ |
|
471 |
Base_LinePath.StrokeDashArray.Clear(); |
|
472 |
foreach (var item in this.DashSize) |
|
473 |
{ |
|
474 |
Base_LinePath.StrokeDashArray.Add(item); |
|
475 |
} |
|
476 |
Base_LinePath.StrokeDashCap = PenLineCap.Square; |
|
477 |
} |
|
478 |
|
|
479 |
PathFigure pathFigure = new PathFigure(); |
|
480 |
pathFigure.StartPoint = this.StartPoint; |
|
481 |
LineSegment lineSegment0 = new LineSegment(); |
|
482 |
lineSegment0.Point = this.EndPoint; |
|
483 |
pathFigure.Segments.Add(lineSegment0); |
|
484 |
PathGeometry pathGeometry = new PathGeometry(); |
|
485 |
pathGeometry.Figures = new PathFigureCollection(); |
|
486 |
pathGeometry.Figures.Add(pathFigure); |
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
instanceGroup.Children.Clear(); |
|
491 |
switch (LineStyleSet) |
|
492 |
{ |
|
493 |
case LineStyleSet.ArrowLine: |
|
494 |
instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
495 |
break; |
|
496 |
case LineStyleSet.TwinLine: |
|
497 |
instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
498 |
instanceGroup.Children.Add(ConverseAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
499 |
break; |
|
500 |
case LineStyleSet.DimLine: |
|
501 |
List<LineGeometry> metrySet = DimAllow(this.StartPoint, this.EndPoint, this.LineSize, this.DimSize); |
|
502 |
instanceGroup.Children.Add(metrySet[0]); |
|
503 |
instanceGroup.Children.Add(metrySet[1]); |
|
504 |
instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
505 |
instanceGroup.Children.Add(ConverseAllow(this.StartPoint, this.EndPoint, this.LineSize)); |
|
506 |
break; |
|
507 |
case LineStyleSet.CancelLine: |
|
508 |
PathFigure pathFigure_Multi = new PathFigure(); |
|
509 |
LineSegment lineSegment1 = new LineSegment(); |
|
510 |
|
|
511 |
var x = Math.Abs((Math.Abs(this.StartPoint.X) - Math.Abs(this.EndPoint.X))); |
|
512 |
var y = Math.Abs((Math.Abs(this.StartPoint.Y) - Math.Abs(this.EndPoint.Y))); |
|
513 |
|
|
514 |
if (x > y) |
|
515 |
{ |
|
516 |
pathFigure_Multi.StartPoint = new Point(this.StartPoint.X, this.StartPoint.Y + (this.Interval)); |
|
517 |
lineSegment1.Point = new Point(this.EndPoint.X, this.EndPoint.Y + (this.Interval)); |
|
518 |
} |
|
519 |
else |
|
520 |
{ |
|
521 |
pathFigure_Multi.StartPoint = new Point(this.StartPoint.X + (this.Interval), this.StartPoint.Y); |
|
522 |
lineSegment1.Point = new Point(this.EndPoint.X + (this.Interval), this.EndPoint.Y); |
|
523 |
} |
|
524 |
pathFigure_Multi.Segments.Add(lineSegment1); |
|
525 |
pathGeometry.Figures.Add(pathFigure_Multi); |
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
this.PathData = pathGeometry; |
|
530 |
this.OverViewPathData = PathData; |
|
531 |
|
|
532 |
break; |
내보내기 Unified diff