1 |
787a4489
|
KangIngu
|
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 |
036650a0
|
humkyung
|
using MarkupToPDF.Serialize.Core;
|
16 |
|
|
using MarkupToPDF.Serialize.S_Control;
|
17 |
787a4489
|
KangIngu
|
|
18 |
|
|
namespace MarkupToPDF.Controls.Etc
|
19 |
|
|
{
|
20 |
|
|
[TemplatePart(Name = "PART_ViewBox", Type = typeof(Viewbox))]
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
public class SymControlN : CommentUserInfo, INotifyPropertyChanged , IViewBox, IMarkupCommonData
|
24 |
|
|
{
|
25 |
|
|
private const string PART_ViewBox = "PART_ViewBox";
|
26 |
|
|
public Viewbox Base_ViewBox = null;
|
27 |
a6272c57
|
humkyung
|
public string STAMP { get; set; }
|
28 |
43e1d368
|
taeseongkim
|
public Dictionary<string,string> STAMP_Contents { get; set; }
|
29 |
787a4489
|
KangIngu
|
|
30 |
|
|
static SymControlN()
|
31 |
|
|
{
|
32 |
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(SymControlN), new FrameworkPropertyMetadata(typeof(SymControlN)));
|
33 |
|
|
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
|
34 |
a6f7f9b6
|
djkim
|
//ResourceDictionary dictionary = new ResourceDictionary();
|
35 |
|
|
//dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
|
36 |
|
|
//Application.Current.Resources.MergedDictionaries.Add(dictionary);
|
37 |
|
|
// System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count);
|
38 |
787a4489
|
KangIngu
|
}
|
39 |
|
|
|
40 |
7b34fb3a
|
swate0609
|
public override void Copy(CommentUserInfo lhs)
|
41 |
|
|
{
|
42 |
|
|
if (lhs is SymControlN symControlN)
|
43 |
|
|
{
|
44 |
|
|
this.PointSet = symControlN.PointSet.ConvertAll(x => new Point(x.X, x.Y));
|
45 |
|
|
this.StartPoint = new Point(symControlN.StartPoint.X, symControlN.StartPoint.Y);
|
46 |
|
|
this.EndPoint = new Point(symControlN.EndPoint.X, symControlN.EndPoint.Y);
|
47 |
|
|
this.CommentAngle = symControlN.CommentAngle;
|
48 |
|
|
this.LeftBottomPoint = new Point(symControlN.LeftBottomPoint.X, symControlN.LeftBottomPoint.Y);
|
49 |
|
|
this.TopRightPoint = new Point(symControlN.TopRightPoint.X, symControlN.TopRightPoint.Y);
|
50 |
|
|
this.Opacity = symControlN.Opacity;
|
51 |
|
|
this.PathXathData = symControlN.PathXathData;
|
52 |
|
|
this.Memo = symControlN.Memo;
|
53 |
|
|
}
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
public override CommentUserInfo Clone()
|
57 |
|
|
{
|
58 |
|
|
var clone = new SymControlN();
|
59 |
|
|
clone.Copy(this);
|
60 |
|
|
return clone;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
787a4489
|
KangIngu
|
public event PropertyChangedEventHandler PropertyChanged;
|
64 |
|
|
protected void RaisePropertyChanged(string propName)
|
65 |
|
|
{
|
66 |
|
|
if (PropertyChanged != null)
|
67 |
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propName));
|
68 |
|
|
}
|
69 |
|
|
#region 내장 프로퍼티
|
70 |
|
|
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
|
71 |
|
|
"UserID", typeof(string), typeof(SymControlN), new PropertyMetadata(null));
|
72 |
|
|
public static readonly DependencyProperty PathXathDataProperty = DependencyProperty.Register(
|
73 |
|
|
"PathXathData", typeof(string), typeof(SymControlN), new PropertyMetadata(null));
|
74 |
|
|
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
|
75 |
|
|
"LineSize", typeof(double), typeof(SymControlN), new PropertyMetadata((Double)1));
|
76 |
|
|
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
|
77 |
|
|
"EndPoint", typeof(Point), typeof(SymControlN), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
78 |
|
|
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
|
79 |
|
|
"StartPoint", typeof(Point), typeof(SymControlN), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
80 |
|
|
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register(
|
81 |
|
|
"TopRightPoint", typeof(Point), typeof(SymControlN), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
82 |
|
|
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
|
83 |
|
|
"StrokeColor", typeof(SolidColorBrush), typeof(SymControlN), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
|
84 |
|
|
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register(
|
85 |
|
|
"LeftBottomPoint", typeof(Point), typeof(SymControlN), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
86 |
|
|
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
|
87 |
|
|
"PointSet", typeof(List<Point>), typeof(SymControlN), new PropertyMetadata(new List<Point>()));
|
88 |
|
|
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
|
89 |
|
|
"PathData", typeof(Geometry), typeof(SymControlN), null);
|
90 |
|
|
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(SymControlN),
|
91 |
|
|
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
|
92 |
|
|
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(SymControlN),
|
93 |
|
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
94 |
|
|
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(SymControlN),
|
95 |
|
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
96 |
|
|
|
97 |
|
|
public static readonly DependencyProperty IsSelectedProperty =
|
98 |
|
|
DependencyProperty.Register("IsSelected", typeof(bool), typeof(SymControlN), new FrameworkPropertyMetadata(false, IsSelectedChanged));
|
99 |
|
|
|
100 |
|
|
public static readonly DependencyProperty ControlTypeProperty =
|
101 |
d7123191
|
KangIngu
|
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(SymControlN), new FrameworkPropertyMetadata(ControlType.Stamp));
|
102 |
787a4489
|
KangIngu
|
#endregion
|
103 |
|
|
|
104 |
|
|
#region PropertyChanged Method
|
105 |
|
|
|
106 |
|
|
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
107 |
|
|
{
|
108 |
|
|
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
112 |
|
|
{
|
113 |
|
|
var instance = (SymControlN)sender;
|
114 |
|
|
if (e.OldValue != e.NewValue && instance.Base_ViewBox != null)
|
115 |
|
|
{
|
116 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
117 |
|
|
instance.SetViewBox();
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
121 |
|
|
{
|
122 |
|
|
var instance = (SymControlN)sender;
|
123 |
|
|
if (e.OldValue != e.NewValue && instance.Base_ViewBox != null)
|
124 |
|
|
{
|
125 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
126 |
|
|
instance.SetViewBox();
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
130 |
|
|
{
|
131 |
|
|
var instance = (SymControlN)sender;
|
132 |
|
|
if (e.OldValue != e.NewValue && instance.Base_ViewBox != null)
|
133 |
|
|
{
|
134 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
135 |
|
|
instance.SetViewBox();
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
#endregion
|
139 |
|
|
|
140 |
|
|
#region Properties
|
141 |
|
|
public string UserID
|
142 |
|
|
{
|
143 |
|
|
get { return (string)GetValue(UserIDProperty); }
|
144 |
|
|
set
|
145 |
|
|
{
|
146 |
|
|
if (this.UserID != value)
|
147 |
|
|
{
|
148 |
|
|
SetValue(UserIDProperty, value);
|
149 |
|
|
RaisePropertyChanged("UserID");
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
}
|
153 |
|
|
public SolidColorBrush StrokeColor
|
154 |
|
|
{
|
155 |
|
|
get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
|
156 |
|
|
set
|
157 |
|
|
{
|
158 |
|
|
if (this.StrokeColor != value)
|
159 |
|
|
{
|
160 |
|
|
SetValue(StrokeColorProperty, value);
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
public string PathXathData
|
166 |
|
|
{
|
167 |
|
|
get
|
168 |
|
|
{
|
169 |
|
|
return (string)GetValue(PathXathDataProperty);
|
170 |
|
|
}
|
171 |
|
|
set
|
172 |
|
|
{
|
173 |
|
|
SetValue(PathXathDataProperty, value);
|
174 |
|
|
RaisePropertyChanged("PathXathData");
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
}
|
178 |
|
|
public List<Point> PointSet
|
179 |
|
|
{
|
180 |
|
|
get { return (List<Point>)GetValue(PointSetProperty); }
|
181 |
|
|
set { SetValue(PointSetProperty, value); }
|
182 |
|
|
}
|
183 |
|
|
public Point TopRightPoint
|
184 |
|
|
{
|
185 |
|
|
get { return (Point)GetValue(TopRightPointProperty); }
|
186 |
|
|
set
|
187 |
|
|
{
|
188 |
|
|
SetValue(TopRightPointProperty, value);
|
189 |
|
|
RaisePropertyChanged("TopRightPoint");
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
|
|
public Point LeftBottomPoint
|
193 |
|
|
{
|
194 |
|
|
get { return (Point)GetValue(LeftBottomPointProperty); }
|
195 |
|
|
set
|
196 |
|
|
{
|
197 |
|
|
SetValue(LeftBottomPointProperty, value);
|
198 |
|
|
RaisePropertyChanged("LeftBottomPoint");
|
199 |
|
|
}
|
200 |
|
|
}
|
201 |
|
|
public Point EndPoint
|
202 |
|
|
{
|
203 |
|
|
get { return (Point)GetValue(EndPointProperty); }
|
204 |
|
|
set
|
205 |
|
|
{
|
206 |
|
|
SetValue(EndPointProperty, value);
|
207 |
|
|
RaisePropertyChanged("EndPoint");
|
208 |
|
|
}
|
209 |
|
|
}
|
210 |
|
|
public Point StartPoint
|
211 |
|
|
{
|
212 |
|
|
get { return (Point)GetValue(StartPointProperty); }
|
213 |
|
|
set
|
214 |
|
|
{
|
215 |
|
|
SetValue(StartPointProperty, value);
|
216 |
|
|
RaisePropertyChanged("StartPoint");
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
#endregion
|
220 |
|
|
|
221 |
|
|
public override void OnApplyTemplate()
|
222 |
|
|
{
|
223 |
|
|
base.OnApplyTemplate();
|
224 |
|
|
Base_ViewBox = GetTemplateChild(PART_ViewBox) as Viewbox;
|
225 |
|
|
SetViewBox();
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
public void SetViewBox()
|
229 |
|
|
{
|
230 |
|
|
this.ApplyTemplate();
|
231 |
|
|
Point mid = MathSet.FindCentroid(new List<Point>()
|
232 |
|
|
{
|
233 |
|
|
this.StartPoint,
|
234 |
|
|
this.LeftBottomPoint,
|
235 |
|
|
this.EndPoint,
|
236 |
|
|
this.TopRightPoint,
|
237 |
|
|
});
|
238 |
|
|
double AngleData = 0;
|
239 |
|
|
|
240 |
|
|
PathFigure pathFigure = new PathFigure();
|
241 |
|
|
pathFigure.StartPoint = MathSet.RotateAbout(mid, this.StartPoint, AngleData);
|
242 |
|
|
|
243 |
|
|
LineSegment lineSegment0 = new LineSegment();
|
244 |
|
|
lineSegment0.Point = MathSet.RotateAbout(mid, this.StartPoint, AngleData);
|
245 |
|
|
pathFigure.Segments.Add(lineSegment0);
|
246 |
|
|
|
247 |
|
|
LineSegment lineSegment1 = new LineSegment();
|
248 |
|
|
lineSegment1.Point = MathSet.RotateAbout(mid, this.LeftBottomPoint, AngleData);
|
249 |
|
|
pathFigure.Segments.Add(lineSegment1);
|
250 |
|
|
|
251 |
|
|
LineSegment lineSegment2 = new LineSegment();
|
252 |
|
|
lineSegment2.Point = MathSet.RotateAbout(mid, this.EndPoint, AngleData);
|
253 |
|
|
pathFigure.Segments.Add(lineSegment2);
|
254 |
|
|
|
255 |
|
|
LineSegment lineSegment3 = new LineSegment();
|
256 |
|
|
lineSegment3.Point = MathSet.RotateAbout(mid, this.TopRightPoint, AngleData);
|
257 |
|
|
pathFigure.Segments.Add(lineSegment3);
|
258 |
|
|
|
259 |
|
|
PathGeometry pathGeometry = new PathGeometry();
|
260 |
|
|
pathGeometry.Figures = new PathFigureCollection();
|
261 |
|
|
pathFigure.IsClosed = true;
|
262 |
|
|
pathGeometry.Figures.Add(pathFigure);
|
263 |
|
|
this.Base_ViewBox.Width = pathGeometry.Bounds.Width;
|
264 |
cd988cd8
|
djkim
|
this.Base_ViewBox.Height = pathGeometry.Bounds.Height;
|
265 |
787a4489
|
KangIngu
|
this.Tag = pathGeometry;
|
266 |
|
|
|
267 |
|
|
if(Base_ViewBox.Child == null)
|
268 |
|
|
{
|
269 |
|
|
SetChild();
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
Canvas.SetLeft(this, MathSet.RotateAbout(mid, mid, AngleData).X - this.Base_ViewBox.Width / 2);
|
273 |
|
|
Canvas.SetTop(this, MathSet.RotateAbout(mid, mid, AngleData).Y - this.Base_ViewBox.Height / 2);
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
public void SetChild()
|
277 |
cd988cd8
|
djkim
|
{
|
278 |
|
|
if(this.PathXathData != null)
|
279 |
|
|
{
|
280 |
|
|
var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStamp(this.PathXathData);
|
281 |
|
|
System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
282 |
|
|
System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
|
283 |
|
|
writer.Write(xamlData);
|
284 |
|
|
writer.Flush();
|
285 |
|
|
stream.Position = 0;
|
286 |
787a4489
|
KangIngu
|
|
287 |
cd988cd8
|
djkim
|
object obj = System.Windows.Markup.XamlReader.Load(stream);
|
288 |
|
|
UIElement ob = obj as UIElement;
|
289 |
|
|
|
290 |
|
|
Base_ViewBox.Child = ob;
|
291 |
|
|
}
|
292 |
787a4489
|
KangIngu
|
}
|
293 |
|
|
|
294 |
959b3ef2
|
humkyung
|
public override bool IsSelected
|
295 |
787a4489
|
KangIngu
|
{
|
296 |
|
|
get
|
297 |
|
|
{
|
298 |
|
|
return (bool)GetValue(IsSelectedProperty);
|
299 |
|
|
}
|
300 |
|
|
set
|
301 |
|
|
{
|
302 |
|
|
SetValue(IsSelectedProperty, value);
|
303 |
|
|
}
|
304 |
|
|
}
|
305 |
|
|
|
306 |
5529d2a2
|
humkyung
|
public override ControlType ControlType
|
307 |
787a4489
|
KangIngu
|
{
|
308 |
|
|
set
|
309 |
|
|
{
|
310 |
|
|
SetValue(ControlTypeProperty, value);
|
311 |
|
|
}
|
312 |
|
|
get
|
313 |
|
|
{
|
314 |
|
|
return (ControlType)GetValue(ControlTypeProperty);
|
315 |
|
|
}
|
316 |
|
|
}
|
317 |
|
|
|
318 |
fa48eb85
|
taeseongkim
|
public override double CommentAngle
|
319 |
787a4489
|
KangIngu
|
{
|
320 |
|
|
get { return (double)GetValue(AngleProperty); }
|
321 |
|
|
set
|
322 |
|
|
{
|
323 |
fa48eb85
|
taeseongkim
|
if (this.CommentAngle != value)
|
324 |
787a4489
|
KangIngu
|
{
|
325 |
|
|
SetValue(AngleProperty, value);
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
public Double LineSize
|
332 |
|
|
{
|
333 |
|
|
get { return (Double)GetValue(LineSizeProperty); }
|
334 |
|
|
set
|
335 |
|
|
{
|
336 |
|
|
if (this.LineSize != value)
|
337 |
|
|
{
|
338 |
|
|
SetValue(LineSizeProperty, value);
|
339 |
|
|
}
|
340 |
|
|
}
|
341 |
|
|
}
|
342 |
|
|
public Geometry PathData
|
343 |
|
|
{
|
344 |
|
|
get { return (Geometry)GetValue(PathDataProperty); }
|
345 |
|
|
set
|
346 |
|
|
{
|
347 |
|
|
SetValue(PathDataProperty, value);
|
348 |
|
|
RaisePropertyChanged("PathData");
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
|
352 |
0d00f9c8
|
humkyung
|
public override void UpdateControl()
|
353 |
787a4489
|
KangIngu
|
{
|
354 |
|
|
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
|
355 |
|
|
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
|
356 |
|
|
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
|
357 |
|
|
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y);
|
358 |
|
|
this.SetViewBox();
|
359 |
|
|
}
|
360 |
036650a0
|
humkyung
|
|
361 |
|
|
/// <summary>
|
362 |
a6272c57
|
humkyung
|
/// call when mouse is moving while drawing control
|
363 |
|
|
/// </summary>
|
364 |
|
|
/// <author>humkyung</author>
|
365 |
|
|
/// <param name="pt"></param>
|
366 |
|
|
/// <param name="bAxisLocked"></param>
|
367 |
233ef333
|
taeseongkim
|
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
|
368 |
a6272c57
|
humkyung
|
{
|
369 |
|
|
if (this.StartPoint == this.EndPoint)
|
370 |
|
|
{
|
371 |
43e1d368
|
taeseongkim
|
var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStamp(this.STAMP);
|
372 |
|
|
|
373 |
|
|
if (STAMP_Contents?.Count > 0)
|
374 |
|
|
{
|
375 |
|
|
foreach (var item in STAMP_Contents)
|
376 |
|
|
{
|
377 |
|
|
xamlData = xamlData.Replace(item.Key, System.Security.SecurityElement.Escape(item.Value));
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
a6272c57
|
humkyung
|
|
381 |
|
|
System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
382 |
|
|
System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
|
383 |
|
|
writer.Write(xamlData);
|
384 |
|
|
writer.Flush();
|
385 |
|
|
stream.Position = 0;
|
386 |
|
|
|
387 |
|
|
this.StrokeColor = new SolidColorBrush(Colors.Red);
|
388 |
|
|
object obj = System.Windows.Markup.XamlReader.Load(stream);
|
389 |
|
|
UIElement ob = obj as UIElement;
|
390 |
|
|
|
391 |
|
|
this.SetViewBox();
|
392 |
|
|
this.PathXathData = this.STAMP;
|
393 |
|
|
this.Base_ViewBox.Child = ob;
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
this.EndPoint = pt;
|
397 |
|
|
this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y);
|
398 |
|
|
this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y);
|
399 |
|
|
|
400 |
|
|
this.PointSet = new List<Point>
|
401 |
|
|
{
|
402 |
|
|
this.StartPoint,
|
403 |
|
|
this.LeftBottomPoint,
|
404 |
|
|
this.EndPoint,
|
405 |
|
|
this.TopRightPoint,
|
406 |
|
|
};
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
/// <summary>
|
410 |
d2114d3b
|
humkyung
|
/// move control point has same location of given pt along given delta
|
411 |
|
|
/// </summary>
|
412 |
|
|
/// <author>humkyung</author>
|
413 |
|
|
/// <date>2019.06.20</date>
|
414 |
|
|
/// <param name="pt"></param>
|
415 |
|
|
/// <param name="dx"></param>
|
416 |
|
|
/// <param name="dy"></param>
|
417 |
233ef333
|
taeseongkim
|
public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
|
418 |
d2114d3b
|
humkyung
|
{
|
419 |
|
|
IPath path = (this as IPath);
|
420 |
|
|
|
421 |
|
|
Point selected = MathSet.getNearPoint(path.PointSet, pt);
|
422 |
|
|
selected.X += dx;
|
423 |
|
|
selected.Y += dy;
|
424 |
|
|
|
425 |
9005f973
|
humkyung
|
int idx = (this as IPath).PointSet.FindIndex(x => x.Equals(pt));
|
426 |
|
|
|
427 |
|
|
var OppositeP = (idx + path.PointSet.Count / 2) % path.PointSet.Count;
|
428 |
|
|
var PreviousP = (idx + (path.PointSet.Count - 1)) % path.PointSet.Count;
|
429 |
|
|
var NextP = (idx + 1) % path.PointSet.Count;
|
430 |
ab7fe8c0
|
humkyung
|
if (bAxisLocked)
|
431 |
|
|
{
|
432 |
9005f973
|
humkyung
|
var PrevV = path.PointSet[PreviousP] - path.PointSet[OppositeP];
|
433 |
|
|
double PrevLength = PrevV.Length;
|
434 |
|
|
PrevV.Normalize();
|
435 |
d2114d3b
|
humkyung
|
|
436 |
ab7fe8c0
|
humkyung
|
var NextV = path.PointSet[NextP] - path.PointSet[OppositeP];
|
437 |
9005f973
|
humkyung
|
double NextVLength = NextV.Length;
|
438 |
ab7fe8c0
|
humkyung
|
NextV.Normalize();
|
439 |
d2114d3b
|
humkyung
|
|
440 |
9005f973
|
humkyung
|
double _dx = selected.X - path.PointSet[OppositeP].X;
|
441 |
|
|
double _dy = selected.Y - path.PointSet[OppositeP].Y;
|
442 |
|
|
var dir = new Vector(_dx, _dy);
|
443 |
|
|
if (PrevLength > NextVLength)
|
444 |
|
|
{
|
445 |
|
|
double ratio = NextVLength / PrevLength;
|
446 |
|
|
|
447 |
|
|
double dot = MathSet.DotProduct(PrevV.X, PrevV.Y, dir.X, dir.Y);
|
448 |
|
|
|
449 |
|
|
path.PointSet[PreviousP] = path.PointSet[OppositeP] + PrevV * dot;
|
450 |
|
|
path.PointSet[NextP] = path.PointSet[OppositeP] + NextV * dot * ratio;
|
451 |
|
|
path.PointSet[idx] = path.PointSet[OppositeP] + PrevV * dot + NextV * dot * ratio;
|
452 |
|
|
}
|
453 |
|
|
else
|
454 |
|
|
{
|
455 |
|
|
double ratio = PrevLength / NextVLength;
|
456 |
|
|
|
457 |
|
|
double dot = MathSet.DotProduct(NextV.X, NextV.Y, dir.X, dir.Y);
|
458 |
|
|
|
459 |
|
|
path.PointSet[PreviousP] = path.PointSet[OppositeP] + PrevV * dot * ratio;
|
460 |
|
|
path.PointSet[NextP] = path.PointSet[OppositeP] + NextV * dot;
|
461 |
|
|
path.PointSet[idx] = path.PointSet[OppositeP] + PrevV * dot * ratio + NextV * dot;
|
462 |
|
|
}
|
463 |
ab7fe8c0
|
humkyung
|
}
|
464 |
|
|
else
|
465 |
|
|
{
|
466 |
|
|
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[OppositeP], path.PointSet[PreviousP]);
|
467 |
9005f973
|
humkyung
|
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[idx].X - path.PointSet[OppositeP].X,
|
468 |
|
|
path.PointSet[idx].Y - path.PointSet[OppositeP].Y);
|
469 |
ab7fe8c0
|
humkyung
|
path.PointSet[PreviousP] = new Point(path.PointSet[OppositeP].X + PreviousV.X * l, path.PointSet[OppositeP].Y + PreviousV.Y * l);
|
470 |
|
|
|
471 |
|
|
var NextV = MathSet.GetNormVectorBetween(path.PointSet[OppositeP], path.PointSet[NextP]);
|
472 |
9005f973
|
humkyung
|
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[idx].X - path.PointSet[OppositeP].X, path.PointSet
|
473 |
|
|
[idx].Y - path.PointSet[OppositeP].Y);
|
474 |
ab7fe8c0
|
humkyung
|
path.PointSet[NextP] = new Point(path.PointSet[OppositeP].X + NextV.X * l, path.PointSet[OppositeP].Y + NextV.Y * l);
|
475 |
9005f973
|
humkyung
|
|
476 |
|
|
path.PointSet[idx] = selected;
|
477 |
ab7fe8c0
|
humkyung
|
}
|
478 |
d2114d3b
|
humkyung
|
|
479 |
0d00f9c8
|
humkyung
|
this.UpdateControl();
|
480 |
d2114d3b
|
humkyung
|
}
|
481 |
|
|
|
482 |
|
|
/// <summary>
|
483 |
91efe37a
|
humkyung
|
/// return SymControlN's area
|
484 |
|
|
/// </summary>
|
485 |
|
|
/// <author>humkyung</author>
|
486 |
|
|
/// <date>2019.06.13</date>
|
487 |
|
|
public override Rect ItemRect
|
488 |
|
|
{
|
489 |
|
|
get
|
490 |
|
|
{
|
491 |
|
|
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
|
492 |
|
|
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
|
493 |
|
|
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
|
494 |
|
|
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
|
495 |
|
|
|
496 |
|
|
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
|
497 |
|
|
}
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
/// <summary>
|
501 |
036650a0
|
humkyung
|
/// Serialize this
|
502 |
|
|
/// </summary>
|
503 |
|
|
/// <param name="sUserId"></param>
|
504 |
|
|
/// <returns></returns>
|
505 |
|
|
public override string Serialize()
|
506 |
|
|
{
|
507 |
|
|
using (S_SymControlN STemp = new S_SymControlN())
|
508 |
|
|
{
|
509 |
|
|
STemp.TransformPoint = "0|0";
|
510 |
|
|
STemp.PointSet = this.PointSet;
|
511 |
|
|
//STemp.XamlData = this.PathXathData;
|
512 |
|
|
STemp.UserID = this.UserID;
|
513 |
|
|
STemp.DBData = this.PathXathData;
|
514 |
|
|
//STemp.StrokeColor = this.StrokeColor.Color.ToString();
|
515 |
|
|
STemp.StartPoint = this.StartPoint;
|
516 |
fa48eb85
|
taeseongkim
|
STemp.Angle = this.CommentAngle;
|
517 |
036650a0
|
humkyung
|
STemp.EndPoint = this.EndPoint;
|
518 |
|
|
STemp.LB = this.LeftBottomPoint;
|
519 |
|
|
STemp.TR = this.TopRightPoint;
|
520 |
|
|
STemp.Opac = this.Opacity;
|
521 |
|
|
STemp.Name = this.GetType().Name.ToString();
|
522 |
|
|
|
523 |
|
|
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
|
524 |
|
|
}
|
525 |
|
|
}
|
526 |
661b7416
|
humkyung
|
|
527 |
|
|
/// <summary>
|
528 |
|
|
/// create a symcontroln from given string
|
529 |
|
|
/// </summary>
|
530 |
|
|
/// <param name="str"></param>
|
531 |
|
|
/// <returns></returns>
|
532 |
|
|
public static SymControlN FromString(string str, SolidColorBrush brush, string sProjectNo)
|
533 |
|
|
{
|
534 |
|
|
using (S_SymControlN s = JsonSerializerHelper.JsonDeserialize<S_SymControlN>(str))
|
535 |
|
|
{
|
536 |
|
|
return new SymControlN()
|
537 |
|
|
{
|
538 |
|
|
PointSet = s.PointSet,
|
539 |
|
|
StartPoint = s.StartPoint,
|
540 |
|
|
EndPoint = s.EndPoint,
|
541 |
fa48eb85
|
taeseongkim
|
CommentAngle = s.Angle,
|
542 |
661b7416
|
humkyung
|
LeftBottomPoint = s.LB,
|
543 |
|
|
TopRightPoint = s.TR,
|
544 |
|
|
Opacity = s.Opac,
|
545 |
|
|
PathXathData = s.DBData,
|
546 |
|
|
Memo = s.Memo
|
547 |
|
|
};
|
548 |
|
|
}
|
549 |
|
|
}
|
550 |
787a4489
|
KangIngu
|
}
|
551 |
|
|
}
|
552 |
|
|
|