개정판 5a565c3c
Fix: *.bak 파일 삭제
Change-Id: I4f151cfcda7685355050b856225163c8fa840dca
MarkupToPDF/Controls/Shape/CircleControl.cs.bak | ||
---|---|---|
1 |
using MarkupToPDF.Common; |
|
2 |
using MarkupToPDF.Controls.Common; |
|
3 |
using System; |
|
4 |
using System.Collections.Generic; |
|
5 |
using System.ComponentModel; |
|
6 |
using System.Windows; |
|
7 |
using System.Windows.Media; |
|
8 |
using System.Windows.Shapes; |
|
9 | ||
10 |
namespace MarkupToPDF.Controls.Shape |
|
11 |
{ |
|
12 |
[TemplatePart(Name = "PART_CirclePath", Type = typeof(Path))] |
|
13 |
public class CircleControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, ICircleControl |
|
14 |
{ |
|
15 |
private const string PART_CirclePath = "PART_CirclePath"; |
|
16 |
public Path Base_CirclePath = null; |
|
17 | ||
18 |
static CircleControl() |
|
19 |
{ |
|
20 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(CircleControl), new FrameworkPropertyMetadata(typeof(CircleControl))); |
|
21 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
|
22 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
23 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
24 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
25 |
} |
|
26 | ||
27 |
#region Dependency Properties |
|
28 | ||
29 |
public static readonly DependencyProperty IsSelectedProperty = |
|
30 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(CircleControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
31 | ||
32 |
public static readonly DependencyProperty ControlTypeProperty = |
|
33 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CircleControl), new FrameworkPropertyMetadata(ControlType.Circle)); |
|
34 | ||
35 | ||
36 | ||
37 | ||
38 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
39 |
"OverViewPathData", typeof(Geometry), typeof(CircleControl), new PropertyMetadata(null)); |
|
40 | ||
41 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
42 |
"LineSize", typeof(double), typeof(CircleControl), new PropertyMetadata((Double)3)); |
|
43 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
44 |
"UserID", typeof(string), typeof(CircleControl), new PropertyMetadata(null)); |
|
45 |
|
|
46 |
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
|
47 |
"FillColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
48 | ||
49 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
50 |
"StrokeColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
51 | ||
52 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
53 |
"PathData", typeof(Geometry), typeof(CircleControl), null); |
|
54 |
//강인구 추가 |
|
55 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
|
56 |
"Paint", typeof(PaintSet), typeof(CircleControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
|
57 | ||
58 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
59 |
"EndPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
60 | ||
61 |
//강인구 추가 |
|
62 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
63 |
"DashSize", typeof(DoubleCollection), typeof(CircleControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged)); |
|
64 | ||
65 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
|
66 |
"TopRightPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
67 | ||
68 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
|
69 |
"LeftBottomPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
70 | ||
71 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
72 |
"StartPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
73 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
74 |
"PointSet", typeof(List<Point>), typeof(CircleControl), new PropertyMetadata(new List<Point>())); |
|
75 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(CircleControl), |
|
76 |
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
|
77 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CircleControl), |
|
78 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
79 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CircleControl), |
|
80 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
|
81 |
public static readonly DependencyProperty mousemodeProperty = |
|
82 |
DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(CircleControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
|
83 |
#endregion |
|
84 |
#region PropertyChanged Method |
|
85 | ||
86 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
87 |
{ |
|
88 |
//var instance = (CircleControl)sender; |
|
89 | ||
90 |
//if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
|
91 |
//{ |
|
92 | ||
93 |
// instance.SetValue(e.Property, e.NewValue); |
|
94 | ||
95 |
// if (instance.IsSelected) |
|
96 |
// { |
|
97 |
// instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Blue); |
|
98 |
// } |
|
99 |
// else |
|
100 |
// { |
|
101 |
// instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Red); |
|
102 |
// } |
|
103 |
//} |
|
104 |
} |
|
105 | ||
106 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
107 |
{ |
|
108 |
var instance = (CircleControl)sender; |
|
109 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
|
110 |
{ |
|
111 |
instance.SetValue(e.Property, e.NewValue); |
|
112 |
instance.SetCircle(); |
|
113 |
} |
|
114 |
} |
|
115 | ||
116 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
117 |
{ |
|
118 |
var instance = (CircleControl)sender; |
|
119 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
|
120 |
{ |
|
121 |
instance.SetValue(e.Property, e.NewValue); |
|
122 |
instance.SetCircle(); |
|
123 |
} |
|
124 |
} |
|
125 | ||
126 | ||
127 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
128 |
{ |
|
129 |
var instance = (CircleControl)sender; |
|
130 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
|
131 |
{ |
|
132 |
instance.SetValue(e.Property, e.NewValue); |
|
133 |
instance.SetCircle(); |
|
134 |
} |
|
135 |
} |
|
136 |
#endregion |
|
137 |
#region Properties |
|
138 |
public string UserID |
|
139 |
{ |
|
140 |
get { return (string)GetValue(UserIDProperty); } |
|
141 |
set |
|
142 |
{ |
|
143 |
if (this.UserID != value) |
|
144 |
{ |
|
145 |
SetValue(UserIDProperty, value); |
|
146 |
OnPropertyChanged("UserID"); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
public MouseMode mousemode |
|
151 |
{ |
|
152 |
get |
|
153 |
{ |
|
154 |
return (MouseMode)GetValue(mousemodeProperty); |
|
155 |
} |
|
156 |
set |
|
157 |
{ |
|
158 |
SetValue(mousemodeProperty, value); |
|
159 |
OnPropertyChanged("mousemode"); |
|
160 |
} |
|
161 |
} |
|
162 | ||
163 |
public Double LineSize |
|
164 |
{ |
|
165 |
get { return (Double)GetValue(LineSizeProperty); } |
|
166 |
set |
|
167 |
{ |
|
168 |
if (this.LineSize != value) |
|
169 |
{ |
|
170 |
SetValue(LineSizeProperty, value); |
|
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 SolidColorBrush FillColor |
|
186 |
{ |
|
187 |
get { return (SolidColorBrush)GetValue(FillColorProperty); } |
|
188 |
set |
|
189 |
{ |
|
190 |
if (this.FillColor != value) |
|
191 |
{ |
|
192 |
SetValue(FillColorProperty, value); |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
public Point TopRightPoint |
|
197 |
{ |
|
198 |
get { return (Point)GetValue(TopRightPointProperty); } |
|
199 |
set |
|
200 |
{ |
|
201 |
SetValue(TopRightPointProperty, value); |
|
202 |
OnPropertyChanged("TopRightPoint"); |
|
203 |
} |
|
204 |
} |
|
205 |
public Point LeftBottomPoint |
|
206 |
{ |
|
207 |
get { return (Point)GetValue(LeftBottomPointProperty); } |
|
208 |
set |
|
209 |
{ |
|
210 |
SetValue(LeftBottomPointProperty, value); |
|
211 |
OnPropertyChanged("LeftBottomPoint"); |
|
212 |
} |
|
213 |
} |
|
214 |
public SolidColorBrush StrokeColor |
|
215 |
{ |
|
216 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
|
217 |
set |
|
218 |
{ |
|
219 |
if (this.StrokeColor != value) |
|
220 |
{ |
|
221 |
SetValue(StrokeColorProperty, value); |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
public Geometry PathData |
|
226 |
{ |
|
227 |
get { return (Geometry)GetValue(PathDataProperty); } |
|
228 |
set { SetValue(PathDataProperty, value); } |
|
229 |
} |
|
230 | ||
231 |
public Geometry OverViewPathData |
|
232 |
{ |
|
233 |
get |
|
234 |
{ |
|
235 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
236 |
} |
|
237 |
set |
|
238 |
{ |
|
239 |
SetValue(OverViewPathDataProperty, value); |
|
240 |
OnPropertyChanged("OverViewPathData"); |
|
241 |
} |
|
242 |
} |
|
243 |
public PaintSet Paint |
|
244 |
{ |
|
245 |
get { return (PaintSet)GetValue(PaintProperty); } |
|
246 |
set |
|
247 |
{ |
|
248 |
if (this.Paint != value) |
|
249 |
{ |
|
250 |
SetValue(PaintProperty, value); |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
public Point EndPoint |
|
255 |
{ |
|
256 |
get { return (Point)GetValue(EndPointProperty); } |
|
257 |
set { SetValue(EndPointProperty, value); } |
|
258 |
} |
|
259 |
public Point StartPoint |
|
260 |
{ |
|
261 |
get { return (Point)GetValue(StartPointProperty); } |
|
262 |
set { SetValue(StartPointProperty, value); } |
|
263 |
} |
|
264 |
//public double CenterX |
|
265 |
//{ |
|
266 |
// get { return (double)GetValue(CenterXProperty); } |
|
267 |
// set { SetValue(CenterXProperty, value); } |
|
268 |
//} |
|
269 |
//public double CenterY |
|
270 |
//{ |
|
271 |
// get { return (double)GetValue(CenterYProperty); } |
|
272 |
// set { SetValue(CenterYProperty, value); } |
|
273 |
//} |
|
274 |
public double AngleValue |
|
275 |
{ |
|
276 |
get { return (double)GetValue(AngleProperty); } |
|
277 |
set { SetValue(AngleProperty, value); } |
|
278 |
} |
|
279 |
public double Angle |
|
280 |
{ |
|
281 |
get { return (double)GetValue(AngleProperty); } |
|
282 |
set |
|
283 |
{ |
|
284 |
if (this.Angle != value) |
|
285 |
{ |
|
286 |
SetValue(AngleProperty, value); |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
public List<Point> PointSet |
|
291 |
{ |
|
292 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
293 |
set { SetValue(PointSetProperty, value); } |
|
294 |
} |
|
295 | ||
296 |
public bool IsSelected |
|
297 |
{ |
|
298 |
get |
|
299 |
{ |
|
300 |
return (bool)GetValue(IsSelectedProperty); |
|
301 |
} |
|
302 |
set |
|
303 |
{ |
|
304 |
SetValue(IsSelectedProperty, value); |
|
305 |
} |
|
306 |
} |
|
307 | ||
308 |
public ControlType ControlType |
|
309 |
{ |
|
310 |
get |
|
311 |
{ |
|
312 |
return (ControlType)GetValue(ControlTypeProperty); |
|
313 |
} |
|
314 |
set |
|
315 |
{ |
|
316 |
SetValue(ControlTypeProperty, value); |
|
317 |
} |
|
318 |
} |
|
319 | ||
320 |
public double CenterX |
|
321 |
{ |
|
322 |
get { return (double)GetValue(CenterXProperty); } |
|
323 |
set { SetValue(CenterXProperty, value); } |
|
324 |
} |
|
325 |
public double CenterY |
|
326 |
{ |
|
327 |
get { return (double)GetValue(CenterYProperty); } |
|
328 |
set { SetValue(CenterYProperty, value); } |
|
329 |
} |
|
330 |
#endregion |
|
331 |
#region Object & Variable |
|
332 |
EllipseGeometry instance = new EllipseGeometry(); |
|
333 |
GeometryGroup CircleGroup = new GeometryGroup(); |
|
334 | ||
335 |
#endregion |
|
336 |
public override void OnApplyTemplate() |
|
337 |
{ |
|
338 |
base.OnApplyTemplate(); |
|
339 |
Base_CirclePath = GetTemplateChild(PART_CirclePath) as Path; |
|
340 | ||
341 |
if (Base_CirclePath == null) |
|
342 |
{ |
|
343 |
return; |
|
344 |
} |
|
345 |
this.SetCircle(); |
|
346 |
} |
|
347 |
public void Dispose() |
|
348 |
{ |
|
349 |
GC.Collect(); |
|
350 |
GC.SuppressFinalize(this); |
|
351 |
} |
|
352 | ||
353 |
public event PropertyChangedEventHandler PropertyChanged; |
|
354 |
protected void OnPropertyChanged(string propName) |
|
355 |
{ |
|
356 |
if (PropertyChanged != null) |
|
357 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
|
358 |
} |
|
359 |
public void SetCircle() |
|
360 |
{ |
|
361 |
Base_CirclePath.StrokeDashArray.Clear(); |
|
362 |
foreach (var item in this.DashSize) |
|
363 |
{ |
|
364 |
Base_CirclePath.StrokeDashArray.Add(item); |
|
365 |
} |
|
366 |
Base_CirclePath.StrokeDashCap = PenLineCap.Square; |
|
367 | ||
368 |
Point middle = MathSet.getMiddlePoint(this.EndPoint, this.StartPoint); |
|
369 | ||
370 |
instance.RadiusX = (MathSet.DistanceTo(this.LeftBottomPoint, this.EndPoint) / 2); |
|
371 |
instance.RadiusY = (MathSet.DistanceTo(this.EndPoint, this.TopRightPoint) / 2); |
|
372 |
instance.Center = middle; |
|
373 |
switch (this.Paint) |
|
374 |
{ |
|
375 |
case PaintSet.None: |
|
376 |
this.FillColor = null; |
|
377 |
Base_CirclePath.Fill = this.FillColor; |
|
378 |
break; |
|
379 |
case PaintSet.Fill: |
|
380 |
this.FillColor = this.StrokeColor; |
|
381 |
Base_CirclePath.Fill = this.FillColor; |
|
382 |
break; |
|
383 |
case PaintSet.Hatch: |
|
384 |
Base_CirclePath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
|
385 |
break; |
|
386 |
default: |
|
387 |
break; |
|
388 |
} |
|
389 | ||
390 | ||
391 |
CircleGroup.Children.Clear(); |
|
392 |
CircleGroup.FillRule = FillRule.Nonzero; |
|
393 |
CircleGroup.Children.Add(instance); |
|
394 | ||
395 |
try |
|
396 |
{ |
|
397 |
//강인구 수정(원 테두리가 잘리는것 방지) |
|
398 |
//this.Width = Math.Abs(this.CircleGroup.Bounds.Right + 2); |
|
399 |
//this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + 2); |
|
400 |
this.Width = Math.Abs(this.CircleGroup.Bounds.Right + 20); |
|
401 |
this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + 20); |
|
402 |
} |
|
403 |
catch (Exception) |
|
404 |
{ |
|
405 |
|
|
406 |
} |
|
407 |
CenterX = Math.Abs(this.CircleGroup.Bounds.X / 2); |
|
408 |
CenterY = Math.Abs(this.CircleGroup.Bounds.Y / 2); |
|
409 |
this.PathData = CircleGroup; |
|
410 |
ApplyOverViewData(); |
|
411 |
} |
|
412 |
public void updateControl() |
|
413 |
{ |
|
414 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
415 |
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
416 |
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
|
417 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
|
418 |
} |
|
419 | ||
420 |
public void SetCenterXY() |
|
421 |
{ |
|
422 |
CenterX = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).X; |
|
423 |
CenterY = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).Y; |
|
424 |
} |
|
425 | ||
426 |
public void ApplyOverViewData() |
|
427 |
{ |
|
428 |
this.OverViewPathData = this.PathData; |
|
429 |
} |
|
430 | ||
431 |
public void ChangePaint(PaintSet state) |
|
432 |
{ |
|
433 |
this.Paint = state; |
|
434 |
this.SetCircle(); |
|
435 |
} |
|
436 |
} |
|
437 |
} |
MarkupToPDF/Controls/Shape/RectCloudControl.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.Shape |
|
17 |
{ |
|
18 |
public class RectCloudControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, IDashControl |
|
19 |
{ |
|
20 |
#region 초기 선언 |
|
21 |
private const string PART_ArcPath = "PART_ArcPath"; |
|
22 |
private const string PART_BodyPath = "PART_BodyPath"; |
|
23 |
public event PropertyChangedEventHandler PropertyChanged; |
|
24 | ||
25 |
public Path Base_ArcPath = null; |
|
26 |
public Path Base_BodyPath = null; |
|
27 | ||
28 |
#endregion |
|
29 | ||
30 |
static RectCloudControl() |
|
31 |
{ |
|
32 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(RectCloudControl), new FrameworkPropertyMetadata(typeof(RectCloudControl))); |
|
33 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
|
34 |
ResourceDictionary dictionary = new ResourceDictionary(); |
|
35 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
|
36 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
|
37 |
} |
|
38 | ||
39 |
#region Dependency Properties |
|
40 | ||
41 |
public static readonly DependencyProperty mousemodeProperty = |
|
42 |
DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(RectangleControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
|
43 |
public static readonly DependencyProperty IsSelectedProperty = |
|
44 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(RectCloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
45 | ||
46 |
public static readonly DependencyProperty ControlTypeProperty = |
|
47 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(RectCloudControl), new FrameworkPropertyMetadata(ControlType.RectCloud)); |
|
48 | ||
49 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
50 |
"OverViewPathData", typeof(Geometry), typeof(RectCloudControl), new PropertyMetadata(null)); |
|
51 | ||
52 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
53 |
"LineSize", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)3)); |
|
54 | ||
55 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
56 |
"UserID", typeof(string), typeof(RectCloudControl), new PropertyMetadata(null)); |
|
57 | ||
58 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
59 |
"DashSize", typeof(DoubleCollection), typeof(RectCloudControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
|
60 | ||
61 |
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
|
62 |
"FillColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
63 | ||
64 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
|
65 |
"Paint", typeof(PaintSet), typeof(RectCloudControl), new PropertyMetadata(PaintSet.None)); |
|
66 | ||
67 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
68 |
"StrokeColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
69 | ||
70 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
71 |
"PathData", typeof(Geometry), typeof(RectCloudControl), null); |
|
72 | ||
73 |
public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register( |
|
74 |
"PathSubData", typeof(Geometry), typeof(RectCloudControl), null); |
|
75 | ||
76 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
77 |
"EndPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
78 | ||
79 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
80 |
"StartPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
81 | ||
82 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
|
83 |
"TopRightPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
84 | ||
85 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
|
86 |
"LeftBottomPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
87 | ||
88 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
89 |
"PointSet", typeof(List<Point>), typeof(RectCloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
|
90 | ||
91 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(RectCloudControl), |
|
92 |
new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged))); |
|
93 | ||
94 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(RectCloudControl), |
|
95 |
new PropertyMetadata((double)0, PointValueChanged)); |
|
96 | ||
97 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(RectCloudControl), |
|
98 |
new PropertyMetadata((double)0, PointValueChanged)); |
|
99 | ||
100 |
#endregion |
|
101 | ||
102 |
#region PropertyChanged Method |
|
103 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
104 |
{ |
|
105 |
var instance = (RectCloudControl)sender; |
|
106 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
|
107 |
{ |
|
108 |
instance.SetValue(e.Property, e.NewValue); |
|
109 |
instance.SetRectCloud(); |
|
110 |
} |
|
111 |
} |
|
112 |
#endregion |
|
113 | ||
114 |
#region Properties |
|
115 | ||
116 |
public MouseMode mousemode |
|
117 |
{ |
|
118 |
get |
|
119 |
{ |
|
120 |
return (MouseMode)GetValue(mousemodeProperty); |
|
121 |
} |
|
122 |
set |
|
123 |
{ |
|
124 |
SetValue(mousemodeProperty, value); |
|
125 |
OnPropertyChanged("mousemode"); |
|
126 |
} |
|
127 |
} |
|
128 |
public Double LineSize |
|
129 |
{ |
|
130 |
get { return (Double)GetValue(LineSizeProperty); } |
|
131 |
set |
|
132 |
{ |
|
133 |
if (this.LineSize != value) |
|
134 |
{ |
|
135 |
SetValue(LineSizeProperty, value); |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
public DoubleCollection DashSize |
|
140 |
{ |
|
141 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
|
142 |
set |
|
143 |
{ |
|
144 |
if (this.DashSize != value) |
|
145 |
{ |
|
146 |
SetValue(DashSizeProperty, value); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
public string UserID |
|
151 |
{ |
|
152 |
get { return (string)GetValue(UserIDProperty); } |
|
153 |
set |
|
154 |
{ |
|
155 |
if (this.UserID != value) |
|
156 |
{ |
|
157 |
SetValue(UserIDProperty, value); |
|
158 |
OnPropertyChanged("UserID"); |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
public PaintSet Paint |
|
163 |
{ |
|
164 |
get { return (PaintSet)GetValue(PaintProperty); } |
|
165 |
set |
|
166 |
{ |
|
167 |
if (this.Paint != value) |
|
168 |
{ |
|
169 |
SetValue(PaintProperty, value); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
public SolidColorBrush FillColor |
|
174 |
{ |
|
175 |
get { return (SolidColorBrush)GetValue(FillColorProperty); } |
|
176 |
set |
|
177 |
{ |
|
178 |
if (this.FillColor != value) |
|
179 |
{ |
|
180 |
SetValue(FillColorProperty, value); |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
public SolidColorBrush StrokeColor |
|
185 |
{ |
|
186 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
|
187 |
set |
|
188 |
{ |
|
189 |
if (this.StrokeColor != value) |
|
190 |
{ |
|
191 |
SetValue(StrokeColorProperty, value); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 | ||
196 |
public Geometry OverViewPathData |
|
197 |
{ |
|
198 |
get |
|
199 |
{ |
|
200 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
201 |
} |
|
202 |
set |
|
203 |
{ |
|
204 |
SetValue(OverViewPathDataProperty, value); |
|
205 |
OnPropertyChanged("OverViewPathData"); |
|
206 |
} |
|
207 |
} |
|
208 | ||
209 |
public Geometry PathData |
|
210 |
{ |
|
211 |
get { return (Geometry)GetValue(PathDataProperty); } |
|
212 |
set { SetValue(PathDataProperty, value); } |
|
213 |
} |
|
214 |
public Geometry PathSubData |
|
215 |
{ |
|
216 |
get { return (Geometry)GetValue(PathSubDataProperty); } |
|
217 |
set { SetValue(PathSubDataProperty, value); } |
|
218 |
} |
|
219 |
public Point EndPoint |
|
220 |
{ |
|
221 |
get { return (Point)GetValue(EndPointProperty); } |
|
222 |
set { SetValue(EndPointProperty, value); } |
|
223 |
} |
|
224 |
public Point StartPoint |
|
225 |
{ |
|
226 |
get { return (Point)GetValue(StartPointProperty); } |
|
227 |
set { SetValue(StartPointProperty, value); } |
|
228 |
} |
|
229 |
public List<Point> PointSet |
|
230 |
{ |
|
231 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
232 |
set { SetValue(PointSetProperty, value); } |
|
233 |
} |
|
234 |
public bool IsSelected |
|
235 |
{ |
|
236 |
get |
|
237 |
{ |
|
238 |
return (bool)GetValue(IsSelectedProperty); |
|
239 |
} |
|
240 |
set |
|
241 |
{ |
|
242 |
SetValue(IsSelectedProperty, value); |
|
243 |
} |
|
244 |
} |
|
245 |
public ControlType ControlType |
|
246 |
{ |
|
247 |
get |
|
248 |
{ |
|
249 |
return (ControlType)GetValue(ControlTypeProperty); |
|
250 |
} |
|
251 |
set |
|
252 |
{ |
|
253 |
SetValue(ControlTypeProperty, value); |
|
254 |
} |
|
255 |
} |
|
256 | ||
257 | ||
258 |
private double _toler = 1; |
|
259 |
public double Toler |
|
260 |
{ |
|
261 |
get { return _toler; } |
|
262 |
set { _toler = value; } |
|
263 |
} |
|
264 |
private double _arcLength = 30; |
|
265 |
public double ArcLength |
|
266 |
{ |
|
267 |
get { return _arcLength; } |
|
268 |
set { _arcLength = value; } |
|
269 |
} |
|
270 | ||
271 |
private bool _fill = false; |
|
272 |
public bool Fill |
|
273 |
{ |
|
274 |
get { return _fill; } |
|
275 |
set { _fill = value; } |
|
276 |
} |
|
277 |
public double Angle |
|
278 |
{ |
|
279 |
get { return (double)GetValue(AngleProperty); } |
|
280 |
set |
|
281 |
{ |
|
282 |
if (this.Angle != value) |
|
283 |
{ |
|
284 |
SetValue(AngleProperty, value); |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
public double CenterX |
|
289 |
{ |
|
290 |
get { return (double)GetValue(CenterXProperty); } |
|
291 |
set { SetValue(CenterXProperty, value); } |
|
292 |
} |
|
293 |
public double CenterY |
|
294 |
{ |
|
295 |
get { return (double)GetValue(CenterYProperty); } |
|
296 |
set { SetValue(CenterYProperty, value); } |
|
297 |
} |
|
298 |
public Point LeftBottomPoint |
|
299 |
{ |
|
300 |
get { return (Point)GetValue(LeftBottomPointProperty); } |
|
301 |
set |
|
302 |
{ |
|
303 |
SetValue(LeftBottomPointProperty, value); |
|
304 |
OnPropertyChanged("LeftBottomPoint"); |
|
305 |
} |
|
306 |
} |
|
307 |
public Point TopRightPoint |
|
308 |
{ |
|
309 |
get { return (Point)GetValue(TopRightPointProperty); } |
|
310 |
set |
|
311 |
{ |
|
312 |
SetValue(TopRightPointProperty, value); |
|
313 |
OnPropertyChanged("TopRightPoint"); |
|
314 |
} |
|
315 |
} |
|
316 |
#endregion |
|
317 | ||
318 |
#region Data |
|
319 |
private PathGeometry _pathGeometry = new PathGeometry(); |
|
320 |
#endregion |
|
321 | ||
322 |
public override void OnApplyTemplate() |
|
323 |
{ |
|
324 |
base.OnApplyTemplate(); |
|
325 |
Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
|
326 |
Base_BodyPath = GetTemplateChild(PART_BodyPath) as Path; |
|
327 | ||
328 |
this.SetRectCloud(); |
|
329 | ||
330 |
} |
|
331 |
protected void OnPropertyChanged(string propName) |
|
332 |
{ |
|
333 |
if (PropertyChanged != null) |
|
334 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
|
335 |
} |
|
336 |
public void Dispose() |
|
337 |
{ |
|
338 |
GC.Collect(); |
|
339 |
GC.SuppressFinalize(this); |
|
340 |
} |
|
341 | ||
342 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
343 |
{ |
|
344 |
//var instance = (RectCloudControl)sender; |
|
345 | ||
346 |
//if (e.OldValue != e.NewValue && instance.Base_BodyPath != null) |
|
347 |
//{ |
|
348 | ||
349 |
// instance.SetValue(e.Property, e.NewValue); |
|
350 | ||
351 |
// if (instance.IsSelected) |
|
352 |
// { |
|
353 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
|
354 |
// } |
|
355 |
// else |
|
356 |
// { |
|
357 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
|
358 |
// } |
|
359 |
//} |
|
360 |
} |
|
361 | ||
362 |
public void SetRectCloud() |
|
363 |
{ |
|
364 |
this.ApplyTemplate(); |
|
365 |
PathFigure pathFigure = new PathFigure(); |
|
366 | ||
367 |
Base_ArcPath.StrokeDashArray.Clear(); |
|
368 |
Base_BodyPath.StrokeDashArray.Clear(); |
|
369 | ||
370 |
foreach (var item in this.DashSize) |
|
371 |
{ |
|
372 |
Base_ArcPath.StrokeDashArray.Add(item); |
|
373 |
Base_BodyPath.StrokeDashArray.Add(item); |
|
374 |
} |
|
375 | ||
376 |
switch (this.Paint) |
|
377 |
{ |
|
378 |
case PaintSet.None: |
|
379 |
pathFigure.IsFilled = false; |
|
380 |
break; |
|
381 |
case PaintSet.Fill: |
|
382 |
{ |
|
383 |
Base_BodyPath.Stroke = this.StrokeColor; |
|
384 |
Base_BodyPath.StrokeThickness = 0.5; |
|
385 |
Base_ArcPath.Stroke = this.StrokeColor; |
|
386 | ||
387 |
Base_ArcPath.Fill = this.FillColor; |
|
388 |
Base_BodyPath.Fill = this.FillColor; |
|
389 |
} |
|
390 |
//this.FillColor = this.StrokeColor; |
|
391 |
//Base_BodyPath.Fill = this.FillColor; |
|
392 |
//Base_ArcPath.Fill = this.FillColor; |
|
393 |
//Base_BodyPath.Stroke = this.StrokeColor; |
|
394 |
//Base_BodyPath.StrokeThickness = 2; |
|
395 |
//Base_ArcPath.Stroke = this.StrokeColor; |
|
396 |
//Base_ArcPath.StrokeThickness = 2; |
|
397 |
//pathFigure.IsFilled = true; |
|
398 |
break; |
|
399 |
case PaintSet.Hatch: |
|
400 |
Base_BodyPath.Stroke = new SolidColorBrush(Colors.Transparent); |
|
401 |
Base_BodyPath.StrokeThickness = 2; |
|
402 |
Base_BodyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
|
403 |
Base_ArcPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
|
404 |
pathFigure.IsFilled = true; |
|
405 |
break; |
|
406 |
default: |
|
407 |
break; |
|
408 |
} |
|
409 | ||
410 |
#region 사각형 만들기 |
|
411 |
if (this.Paint != PaintSet.None) |
|
412 |
{ |
|
413 | ||
414 | ||
415 |
pathFigure.StartPoint = this.StartPoint; |
|
416 | ||
417 |
LineSegment lineSegment0 = new LineSegment(); |
|
418 |
lineSegment0.Point = this.StartPoint; |
|
419 |
pathFigure.Segments.Add(lineSegment0); |
|
420 | ||
421 |
LineSegment lineSegment1 = new LineSegment(); |
|
422 |
lineSegment1.Point = this.LeftBottomPoint; |
|
423 |
pathFigure.Segments.Add(lineSegment1); |
|
424 | ||
425 |
LineSegment lineSegment2 = new LineSegment(); |
|
426 |
lineSegment2.Point = this.EndPoint; |
|
427 |
pathFigure.Segments.Add(lineSegment2); |
|
428 | ||
429 |
LineSegment lineSegment3 = new LineSegment(); |
|
430 |
lineSegment3.Point = this.TopRightPoint; |
|
431 |
pathFigure.Segments.Add(lineSegment3); |
|
432 | ||
433 |
PathGeometry pathGeometry = new PathGeometry(); |
|
434 |
pathGeometry.Figures = new PathFigureCollection(); |
|
435 |
pathFigure.IsClosed = true; |
|
436 |
pathGeometry.Figures.Add(pathFigure); |
|
437 |
//this.FillColor = new SolidColorBrush(Colors.Red); |
|
438 |
this.PathSubData = pathGeometry; |
|
439 |
} |
|
440 | ||
441 | ||
442 |
#endregion |
|
443 |
#region Cloud 만들기 |
|
444 |
/// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
|
445 |
/// |
|
446 | ||
447 |
double size = MathSet.DistanceTo(this.StartPoint, this.EndPoint); |
|
448 |
ArcLength = (size * 0.05); |
|
449 |
if (ArcLength <= 10) |
|
450 |
{ |
|
451 |
ArcLength = 10; |
|
452 |
} |
|
453 | ||
454 |
//ArcLength = 10; |
|
455 | ||
456 |
System.Diagnostics.Debug.WriteLine(ArcLength); |
|
457 |
double area = MathSet.AreaOf(new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint }); |
|
458 |
bool reverse = (area > 0); |
|
459 |
/// up to here |
|
460 |
this._pathGeometry = new PathGeometry(); |
|
461 |
int count = this.PointSet.Count; |
|
462 |
PathFigure pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.StartPoint, this.LeftBottomPoint, this.ArcLength, reverse); |
|
463 |
_pathGeometry.Figures.Add(pathSubFigure); |
|
464 | ||
465 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.LeftBottomPoint, this.EndPoint, this.ArcLength, reverse); |
|
466 |
_pathGeometry.Figures.Add(pathSubFigure); |
|
467 | ||
468 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.EndPoint, this.TopRightPoint, this.ArcLength, reverse); |
|
469 |
_pathGeometry.Figures.Add(pathSubFigure); |
|
470 | ||
471 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.TopRightPoint, this.StartPoint, this.ArcLength, reverse); |
|
472 |
_pathGeometry.Figures.Add(pathSubFigure); |
|
473 | ||
474 |
if (this.Paint != PaintSet.None) |
|
475 |
{ |
|
476 |
foreach (var item in _pathGeometry.Figures) |
|
477 |
{ |
|
478 |
item.IsFilled = true; |
|
479 |
} |
|
480 |
} |
|
481 | ||
482 | ||
483 |
//for (int i = 0; i < (count - 1); i++) |
|
484 |
//{ |
|
485 |
// PathFigure pathSubFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse); |
|
486 |
// _pathGeometry.Figures.Add(pathSubFigure); |
|
487 |
//} |
|
488 | ||
489 |
//Base_ArcPath.StrokeThickness = 3; |
|
490 |
//Base_BodyPath.StrokeThickness = 3; |
|
491 | ||
492 |
this.PathData = _pathGeometry; |
|
493 |
ApplyOverViewData(); |
|
494 |
#endregion |
|
495 |
} |
|
496 | ||
497 |
public void ChangePaint(PaintSet state) |
|
498 |
{ |
|
499 |
this.Paint = state; |
|
500 |
this.SetRectCloud(); |
|
501 |
} |
|
502 | ||
503 |
public void CloseSettingPoint() |
|
504 |
{ |
|
505 |
this.PointSet[0] = this.StartPoint; |
|
506 |
this.PointSet[1] = this.LeftBottomPoint; |
|
507 |
this.PointSet[2] = this.EndPoint; |
|
508 |
this.PointSet[3] = this.TopRightPoint; |
|
509 |
} |
|
510 | ||
511 |
public void ApplyOverViewData() |
|
512 |
{ |
|
513 |
this.OverViewPathData = this.PathData; |
|
514 |
} |
|
515 | ||
516 |
public void updateControl() |
|
517 |
{ |
|
518 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
|
519 |
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
|
520 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
|
521 |
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
|
522 |
} |
|
523 | ||
524 |
public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
|
525 |
{ |
|
526 |
PathFigure pathFigure = new PathFigure(); |
|
527 |
pathFigure.StartPoint = p1; |
|
528 | ||
529 |
double arcLength = arcLength_; |
|
530 |
/// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
|
531 |
double dx = p2.X - p1.X; |
|
532 |
double dy = p2.Y - p1.Y; |
|
533 |
double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
|
534 |
double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
|
535 |
Point lastPt = new Point(p1.X, p1.Y); |
|
536 |
double count = l / arcLength; |
|
537 |
/// normalize |
|
538 |
dx /= l; |
|
539 |
dy /= l; |
|
540 |
Double j = 1; |
|
541 |
for (j = 1; j < (count - 1); j++) |
|
542 |
{ |
|
543 |
ArcSegment arcSeg = new ArcSegment(); |
|
544 |
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc |
|
545 |
arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
|
546 |
lastPt = arcSeg.Point; /// save last point |
|
547 |
arcSeg.RotationAngle = theta + 90; |
|
548 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
|
549 |
pathFigure.Segments.Add(arcSeg); |
|
550 |
} |
|
551 | ||
552 |
/// draw arc between last point and end point |
|
553 |
if ((count > j) || (count > 0)) |
|
554 |
{ |
|
555 |
arcLength = MathSet.DistanceTo(lastPt, p2); |
|
556 |
ArcSegment arcSeg = new ArcSegment(); |
|
557 |
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc |
|
558 |
arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
|
559 |
arcSeg.RotationAngle = theta; |
|
560 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
|
561 |
pathFigure.Segments.Add(arcSeg); |
|
562 |
} |
|
563 |
pathFigure.IsClosed = false; |
|
564 |
pathFigure.IsFilled = false; |
|
565 |
/// up to here |
|
566 |
//pathFigure.IsFilled = true; |
|
567 |
return pathFigure; |
|
568 |
} |
|
569 |
} |
|
570 |
} |
MarkupToPDF/Controls/Shape/RectangleControl.cs.bak | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.ComponentModel; |
|
4 |
using System.Linq; |
|
5 |
using System.Text; |
|
6 |
using System.Threading.Tasks; |
|
7 |
using System.Windows; |
|
8 |
using System.Windows.Shapes; |
|
9 |
using System.Windows.Controls; |
|
10 |
using System.Windows.Media; |
|
11 |
using MarkupToPDF.Controls.Common; |
|
12 |
using MarkupToPDF.Common; |
|
13 | ||
14 |
namespace MarkupToPDF.Controls.Shape |
|
15 |
{ |
|
16 |
//강인구 추가 IShapeControl |
|
17 |
public class RectangleControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, IPath |
|
18 |
{ |
|
19 |
public Path Base_RectPath { get; set; } |
|
20 |
private const string PART_RectPath = "PART_RectPath"; |
|
21 | ||
22 |
#region Property |
|
23 | ||
24 | ||
25 |
public MouseMode mousemode |
|
26 |
{ |
|
27 |
get |
|
28 |
{ |
|
29 |
return (MouseMode)GetValue(mousemodeProperty); |
|
30 |
} |
|
31 |
set |
|
32 |
{ |
|
33 |
SetValue(mousemodeProperty, value); |
|
34 |
OnPropertyChanged("mousemode"); |
|
35 |
} |
|
36 |
} |
|
37 | ||
38 |
public SolidColorBrush StrokeColor |
|
39 |
{ |
|
40 |
get |
|
41 |
{ |
|
42 |
return (SolidColorBrush)GetValue(StrokeColorProperty); |
|
43 |
} |
|
44 |
set |
|
45 |
{ |
|
46 |
SetValue(StrokeColorProperty, value); |
|
47 |
OnPropertyChanged("StrokeColor"); |
|
48 |
} |
|
49 |
} |
|
50 | ||
51 |
public Double LineSize |
|
52 |
{ |
|
53 |
get |
|
54 |
{ |
|
55 |
return (Double)GetValue(LineSizeProperty); |
|
56 |
} |
|
57 |
set |
|
58 |
{ |
|
59 |
SetValue(LineSizeProperty, value); |
|
60 |
OnPropertyChanged("LineSize"); |
|
61 |
} |
|
62 |
} |
|
63 | ||
64 |
public Geometry PathData |
|
65 |
{ |
|
66 |
get |
|
67 |
{ |
|
68 |
return (Geometry)GetValue(PathDataProperty); |
|
69 |
} |
|
70 |
set |
|
71 |
{ |
|
72 |
SetValue(PathDataProperty, value); |
|
73 |
OnPropertyChanged("PathData"); |
|
74 |
} |
|
75 | ||
76 |
} |
|
77 | ||
78 |
public Geometry OverViewPathData |
|
79 |
{ |
|
80 |
get |
|
81 |
{ |
|
82 |
return (Geometry)GetValue(OverViewPathDataProperty); |
|
83 |
} |
|
84 |
set |
|
85 |
{ |
|
86 |
SetValue(OverViewPathDataProperty, value); |
|
87 |
OnPropertyChanged("OverViewPathData"); |
|
88 |
} |
|
89 |
} |
|
90 | ||
91 |
public SolidColorBrush FillColor |
|
92 |
{ |
|
93 |
get { return (SolidColorBrush)GetValue(FillColorProperty); } |
|
94 |
set |
|
95 |
{ |
|
96 |
SetValue(FillColorProperty, value); |
|
97 |
OnPropertyChanged("FillColor"); |
|
98 |
} |
|
99 |
} |
|
100 |
//강인구 추가 |
|
101 |
public DoubleCollection DashSize |
|
102 |
{ |
|
103 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
|
104 |
set |
|
105 |
{ |
|
106 |
if (this.DashSize != value) |
|
107 |
{ |
|
108 |
SetValue(DashSizeProperty, value); |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 | ||
113 |
public Point StartPoint |
|
114 |
{ |
|
115 |
get |
|
116 |
{ |
|
117 |
return (Point)GetValue(StartPointProperty); |
|
118 |
} |
|
119 |
set |
|
120 |
{ |
|
121 |
SetValue(StartPointProperty, value); |
|
122 |
OnPropertyChanged("StartPoint"); |
|
123 |
} |
|
124 |
} |
|
125 | ||
126 |
public Point SetPoint |
|
127 |
{ |
|
128 |
get |
|
129 |
{ |
|
130 |
return (Point)GetValue(SetPointProperty); |
|
131 |
} |
|
132 |
set |
|
133 |
{ |
|
134 |
SetValue(SetPointProperty, value); |
|
135 |
OnPropertyChanged("SetPoint"); |
|
136 |
} |
|
137 |
} |
|
138 | ||
139 |
public Point OriginPoint |
|
140 |
{ |
|
141 |
get |
|
142 |
{ |
|
143 |
return (Point)GetValue(OriginPointProperty); |
|
144 |
} |
|
145 |
set |
|
146 |
{ |
|
147 |
SetValue(OriginPointProperty, value); |
|
148 |
OnPropertyChanged("OriginPoint"); |
|
149 |
} |
|
150 |
} |
|
151 | ||
152 |
public Point TopRightPoint |
|
153 |
{ |
|
154 |
get |
|
155 |
{ |
|
156 |
return (Point)GetValue(TopRightPointProperty); |
|
157 |
} |
|
158 |
set |
|
159 |
{ |
|
160 |
SetValue(TopRightPointProperty, value); |
|
161 |
OnPropertyChanged("TopRightPoint"); |
|
162 |
} |
|
163 |
} |
|
164 | ||
165 |
public Point LeftBottomPoint |
|
166 |
{ |
|
167 |
get |
|
168 |
{ |
|
169 |
return (Point)GetValue(LeftBottomPointProperty); |
|
170 |
} |
|
171 |
set |
|
172 |
{ |
|
173 |
SetValue(LeftBottomPointProperty, value); |
|
174 |
OnPropertyChanged("LeftBottomPoint"); |
|
175 |
} |
|
176 |
} |
|
177 | ||
178 |
public Point EndPoint |
|
179 |
{ |
|
180 |
get |
|
181 |
{ |
|
182 |
return (Point)GetValue(EndPointProperty); |
|
183 |
} |
|
184 |
set |
|
185 |
{ |
|
186 |
SetValue(EndPointProperty, value); |
|
187 |
OnPropertyChanged("EndPoint"); |
|
188 |
} |
|
189 |
} |
|
190 | ||
191 |
public bool IsSelected |
|
192 |
{ |
|
193 |
get |
|
194 |
{ |
|
195 |
return (bool)GetValue(IsSelectedProperty); |
|
196 |
} |
|
197 |
set |
|
198 |
{ |
|
199 |
SetValue(IsSelectedProperty, value); |
|
200 |
OnPropertyChanged("IsSelected"); |
|
201 |
} |
|
202 |
} |
|
203 | ||
204 |
public ControlType ControlType |
|
205 |
{ |
|
206 |
set |
|
207 |
{ |
|
208 |
SetValue(ControlTypeProperty, value); |
|
209 |
OnPropertyChanged("ControlType"); |
|
210 |
} |
|
211 |
get |
|
212 |
{ |
|
213 |
return (ControlType)GetValue(ControlTypeProperty); |
|
214 |
} |
|
215 |
} |
|
216 | ||
217 |
public List<Point> PointSet |
|
218 |
{ |
|
219 |
get { return (List<Point>)GetValue(PointSetProperty); } |
|
220 |
set { SetValue(PointSetProperty, value); } |
|
221 |
} |
|
222 | ||
223 | ||
224 |
public double CanvasX |
|
225 |
{ |
|
226 |
get { return (double)GetValue(CanvasXProperty); } |
|
227 |
set |
|
228 |
{ |
|
229 |
if (this.CanvasX != value) |
|
230 |
{ |
|
231 |
SetValue(CanvasXProperty, value); |
|
232 |
OnPropertyChanged("CanvasX"); |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 | ||
237 |
public double CanvasY |
|
238 |
{ |
|
239 |
get { return (double)GetValue(CanvasYProperty); } |
|
240 |
set |
|
241 |
{ |
|
242 |
if (this.CanvasY != value) |
|
243 |
{ |
|
244 |
SetValue(CanvasYProperty, value); |
|
245 |
OnPropertyChanged("CanvasY"); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 | ||
250 |
public PaintSet Paint |
|
251 |
{ |
|
252 |
get { return (PaintSet)GetValue(PaintProperty); } |
|
253 |
set |
|
254 |
{ |
|
255 |
if (this.Paint != value) |
|
256 |
{ |
|
257 |
SetValue(PaintProperty, value); |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 | ||
262 |
public double Angle |
|
263 |
{ |
|
264 |
get { return (double)GetValue(AngleProperty); } |
|
265 |
set |
|
266 |
{ |
|
267 |
if (this.Angle != value) |
|
268 |
{ |
|
269 |
SetValue(AngleProperty, value); |
|
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 |
public string UserID |
|
274 |
{ |
|
275 |
get { return (string)GetValue(UserIDProperty); } |
|
276 |
set |
|
277 |
{ |
|
278 |
if (this.UserID != value) |
|
279 |
{ |
|
280 |
SetValue(UserIDProperty, value); |
|
281 |
OnPropertyChanged("UserID"); |
|
282 |
} |
|
283 |
} |
|
284 |
} |
|
285 | ||
286 |
#endregion |
|
287 | ||
288 |
#region Dependency Property |
|
289 | ||
290 | ||
291 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
|
292 |
"UserID", typeof(string), typeof(RectangleControl), new PropertyMetadata(null)); |
|
293 | ||
294 |
public static readonly DependencyProperty mousemodeProperty = |
|
295 |
DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(RectCloudControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
|
296 | ||
297 |
public static readonly DependencyProperty IsSelectedProperty = |
|
298 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(RectangleControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
|
299 | ||
300 |
public static readonly DependencyProperty ControlTypeProperty = |
|
301 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(RectangleControl), new FrameworkPropertyMetadata(ControlType.Rectangle)); |
|
302 | ||
303 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
|
304 |
"StrokeColor", typeof(SolidColorBrush), typeof(RectangleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
|
305 | ||
306 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
|
307 |
"LineSize", typeof(double), typeof(RectangleControl), new PropertyMetadata((Double)3)); |
|
308 | ||
309 |
//강인구 추가 |
|
310 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
|
311 |
"DashSize", typeof(DoubleCollection), typeof(RectangleControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged)); |
|
312 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
|
313 |
"PathData", typeof(Geometry), typeof(RectangleControl), null); |
|
314 | ||
315 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
|
316 |
"OverViewPathData", typeof(Geometry), typeof(RectangleControl), null); |
|
317 | ||
318 |
//강인구 추가 |
|
319 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
|
320 |
"Paint", typeof(PaintSet), typeof(RectangleControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
|
321 | ||
322 | ||
323 |
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
|
324 |
"FillColor", typeof(SolidColorBrush), typeof(RectangleControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
|
325 | ||
326 |
public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
|
327 |
"CanvasX", typeof(double), typeof(RectangleControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
|
328 | ||
329 |
public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
|
330 |
"CanvasY", typeof(double), typeof(RectangleControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
|
331 | ||
332 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
|
333 |
"TopRightPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
334 | ||
335 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
|
336 |
"LeftBottomPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
337 | ||
338 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
|
339 |
"StartPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
340 | ||
341 |
public static readonly DependencyProperty SetPointProperty = DependencyProperty.Register( |
|
342 |
"SetPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
343 | ||
344 |
public static readonly DependencyProperty OriginPointProperty = DependencyProperty.Register( |
|
345 |
"OriginPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
346 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
|
347 |
"Angle", typeof(double), typeof(RectangleControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
|
348 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
|
349 |
"PointSet", typeof(List<Point>), typeof(RectangleControl), new PropertyMetadata(new List<Point>())); |
|
350 | ||
351 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
|
352 |
"EndPoint", typeof(Point), typeof(RectangleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
|
353 | ||
354 |
#endregion Dependency Property |
|
355 | ||
356 |
#region Dependency PropertyChanged |
|
357 |
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
358 |
{ |
|
359 |
var instance = (RectangleControl)sender; |
|
360 | ||
361 |
if (e.OldValue != e.NewValue && instance != null) |
|
362 |
{ |
|
363 |
instance.SetValue(e.Property, e.NewValue); |
|
364 |
Canvas.SetLeft(instance, instance.SetPoint.X); |
|
365 |
Canvas.SetTop(instance, instance.SetPoint.Y); |
|
366 |
//Canvas.SetLeft(instance, instance.CanvasX); |
|
367 |
//Canvas.SetTop(instance, instance.CanvasY); |
|
368 |
} |
|
369 |
} |
|
370 | ||
371 | ||
372 |
public static void OnUpdateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
373 |
{ |
|
374 |
var instance = (RectangleControl)sender; |
|
375 | ||
376 |
if (e.OldValue != e.NewValue && instance != null) |
|
377 |
{ |
|
378 |
instance.SetValue(e.Property, e.NewValue); |
|
379 |
instance.SetRectPath(); |
|
380 |
} |
|
381 |
} |
|
382 | ||
383 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
384 |
{ |
|
385 |
var instance = (RectangleControl)sender; |
|
386 |
if (e.OldValue != e.NewValue && instance.Base_RectPath != null) |
|
387 |
{ |
|
388 |
instance.SetValue(e.Property, e.NewValue); |
|
389 |
instance.SetRectPath(); |
|
390 |
} |
|
391 |
} |
|
392 | ||
393 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
394 |
{ |
|
395 |
//var instance = (RectangleControl)sender; |
|
396 | ||
397 |
//if (e.OldValue != e.NewValue && instance.Base_RectPath != null) |
|
398 |
//{ |
|
399 |
// instance.SetValue(e.Property, e.NewValue); |
|
400 | ||
401 |
// if (instance.IsSelected) |
|
402 |
// { |
|
403 |
// instance.Base_RectPath.Stroke = new SolidColorBrush(Colors.Blue); |
|
404 |
// } |
|
405 |
// else |
|
406 |
// { |
|
407 |
// instance.Base_RectPath.Stroke = new SolidColorBrush(Colors.Red); |
|
408 |
// } |
|
409 |
//} |
|
410 |
} |
|
411 | ||
412 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
413 |
{ |
|
414 |
var instance = (RectangleControl)sender; |
|
415 | ||
416 |
if (e.OldValue != e.NewValue && instance.Base_RectPath != null) |
|
417 |
{ |
|
418 |
instance.SetValue(e.Property, e.NewValue); |
|
419 |
instance.SetRectPath(); |
|
420 |
} |
|
421 |
} |
|
422 |
#endregion Dependency PropertyChanged |
|
423 | ||
424 |
public void SetRectPath() |
|
425 |
{ |
|
426 |
this.ApplyTemplate(); |
|
427 | ||
428 |
if (Base_RectPath != null) |
|
429 |
{ |
|
430 |
//강인구 추가 |
|
431 |
Base_RectPath.StrokeDashArray.Clear(); |
|
432 |
if (DashSize != null) |
|
433 |
{ |
|
434 |
foreach (var item in this.DashSize) |
|
435 |
{ |
|
436 |
Base_RectPath.StrokeDashArray.Add(item); |
|
437 |
} |
|
438 |
Base_RectPath.StrokeDashCap = PenLineCap.Square; |
|
439 |
} |
|
440 | ||
441 |
PathFigure pathFigure = new PathFigure |
|
442 |
{ |
|
443 |
IsClosed = true |
|
444 |
}; |
|
445 | ||
446 |
if (ControlType == ControlType.Rectangle) |
|
447 |
{ |
|
448 |
switch (this.Paint) |
|
449 |
{ |
|
450 |
case PaintSet.None: |
|
451 |
this.FillColor = null; |
|
452 |
pathFigure.IsFilled = false; |
|
453 |
break; |
|
454 |
case PaintSet.Fill: |
|
455 |
this.FillColor = this.StrokeColor; |
|
456 |
Base_RectPath.Fill = this.FillColor; |
|
457 |
pathFigure.IsFilled = true; |
|
458 |
break; |
|
459 |
case PaintSet.Hatch: |
|
460 |
Base_RectPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
|
461 |
pathFigure.IsFilled = true; |
|
462 |
break; |
|
463 |
default: |
|
464 |
{ |
|
465 | ||
466 |
} |
|
467 |
break; |
|
468 |
} |
내보내기 Unified diff