프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / MarkupToPDF / Controls / Etc / SignControl.cs @ de691472

이력 | 보기 | 이력해설 | 다운로드 (23.1 KB)

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