프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ 4913851c

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

1
using KCOM.Common;
2
using KCOMDataModel;
3
using KCOMDataModel.DataModel;
4
using MarkupToPDF.Common;
5
using MarkupToPDF.Controls.Parsing;
6
using MarkupToPDF.Serialize.Core;
7
using MarkupToPDF.Serialize.S_Control;
8
using System;
9
using System.Collections.Generic;
10
using System.IO;
11
using System.Linq;
12
using System.Runtime.InteropServices;
13
using System.Text;
14
using System.Windows;
15
using System.Windows.Controls;
16
using System.Windows.Data;
17
using System.Windows.Documents;
18
using System.Windows.Input;
19
using System.Windows.Media;
20
using System.Windows.Media.Imaging;
21
using System.Windows.Navigation;
22
using System.Windows.Shapes;
23
using System.Xml;
24
using Telerik.Windows.Controls;
25
using WinInterop = System.Windows.Interop;
26

    
27
namespace KCOM
28
{
29
    /// <summary>
30
    /// MainWindow.xaml에 대한 상호 작용 논리
31
    /// </summary>
32
    public partial class MainWindow : Window
33
    {
34
        public MainWindow()
35
        {
36
            //InitializeComponent();
37
            this.Loaded += MainWindow_Loaded;
38
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
39
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
40
            this.SourceInitialized += new EventHandler(win_SourceInitialized);
41
            
42
        }
43

    
44
        public static BitmapImage CursorChange()
45
        {
46
            BitmapImage bmp = new BitmapImage();
47
            bmp.BeginInit();
48
            bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
49
            return bmp;
50
        }
51

    
52
        public void DialogMessage_Alert(string content, string header)
53
        {
54
            var box = new TextBlock();
55
            box.MinWidth = 400;
56
            box.FontSize = 12;
57
            box.Text = content;
58
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
59

    
60
            Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
61
            {
62
                Owner = Application.Current.MainWindow,
63
                Content = box,
64
                Header = header,
65
                Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
66
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
67
            };
68
            Telerik.Windows.Controls.RadWindow.Alert(parameters);
69
        }
70

    
71
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
72
        {
73
            InitializeComponent();
74

    
75
            //cursor change  
76
            this.Cursor = new Cursor(CursorChange().StreamSource);
77

    
78
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
79
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
80
            //this.Width += 40;
81
            double windowWidth = this.Width;
82
            double windowHeight = this.Height;
83
            this.Left = (screenWidth / 2) - (windowWidth / 2);
84
            this.Top = (screenHeight / 2) - (windowHeight / 2);
85

    
86

    
87
            ViewerDataModel.Instance.SystemMain = this;
88

    
89
            if (!App.ParameterMode)
90
            {
91
                //App.ViewInfo = new IKCOM.ViewInfo
92
                //{
93
                //    DocumentItemID = "11111112",
94
                //    //DocumentItemID = "10001",
95
                //    bPartner = false,
96
                //    CreateFinalPDFPermission = true,
97
                //    NewCommentPermission = true,
98
                //    ProjectNO = "000000",
99
                //    UserID = "H2011357",
100
                //    //UserID = "H2009115",
101
                //    //Mode = 0 , 1 , 2
102
                //};
103
                //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
104

    
105
                //#if DEBUG
106
                //                App.ViewInfo = new IKCOM.ViewInfo
107
                //                {
108
                //                    DocumentItemID = "11111112",
109
                //                    //DocumentItemID = "10001",
110
                //                    bPartner = false,
111
                //                    CreateFinalPDFPermission = true,
112
                //                    NewCommentPermission = true,
113
                //                    ProjectNO = "000000",
114
                //                    UserID = "H2011357",
115
                //                    //UserID = "H2009115",
116
                //                    //Mode = 0 , 1 , 2
117
                //                };
118
                //                App.ParameterMode = true;
119
                //                this.dzMainMenu.ServiceOn();
120
                //                this.dzMainMenu.SetView(App.ViewInfo);
121
                //#else
122

    
123
                DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
124
                this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
125
                this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
126
                this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
127
                this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
128
                this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
129
                //#endif
130
            }
131
            else
132
            {
133
                this.dzMainMenu.ServiceOn();
134

    
135
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
136
                {
137
                    this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
138
                    var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
139
                    list.ForEach(item => item.Visibility = Visibility.Collapsed);
140
                    this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
141
                    this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
142
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
143
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
144
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
145
                }
146
                this.dzMainMenu.SetView(App.ViewInfo);
147
                this.dzMainMenu.HubSet();
148
            }
149

    
150
            //App.ViewInfo = new IKCOM.ViewInfo
151
            //{
152
            //    DocumentItemID = "11111112",
153
            //    //DocumentItemID = "10001",
154
            //    bPartner = false,
155
            //    CreateFinalPDFPermission = true,
156
            //    NewCommentPermission = true,
157
            //    ProjectNO = "000000",
158
            //    UserID = "H2011357",
159
            //    //UserID = "H2009115",
160
            //    //Mode = 0 , 1 , 2
161
            //};
162

    
163
            //this.dzMainMenu.ServiceOn();
164
            //this.dzMainMenu.SetView(App.ViewInfo);
165
        }
166

    
167

    
168
        bool restoreIfMove = false;
169

    
170
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
171
        {
172
            if (e.ClickCount == 2)
173
            {
174
                if ((ResizeMode == ResizeMode.CanResize) ||
175
                    (ResizeMode == ResizeMode.CanResizeWithGrip))
176
                {
177
                    SwitchState();
178
                }
179
            }
180
            else
181
            {
182
                if (WindowState == WindowState.Maximized)
183
                {
184
                    restoreIfMove = true;
185
                }
186

    
187
                this.DragMove();
188
            }
189
        }
190

    
191
        private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
192
        {
193
            restoreIfMove = false;
194
        }
195

    
196
        private void WindowDragEventMove(object sender, MouseEventArgs e)
197
        {
198
            if (restoreIfMove)
199
            {
200
                if (Mouse.LeftButton == MouseButtonState.Pressed)
201
                {
202
                    //this.WindowState = WindowState.Normal;
203

    
204
                    restoreIfMove = false;
205

    
206
                    double percentHorizontal = e.GetPosition(this).X / ActualWidth;
207
                    double targetHorizontal = RestoreBounds.Width * percentHorizontal;
208

    
209
                    double percentVertical = e.GetPosition(this).Y / ActualHeight;
210
                    double targetVertical = RestoreBounds.Height * percentVertical;
211

    
212
                    POINT lMousePosition;
213
                    GetCursorPos(out lMousePosition);
214

    
215
                    Left = lMousePosition.X - targetHorizontal;
216
                    double top = lMousePosition.Y - targetVertical;
217
                    if(top < 10)
218
                    {
219
                        top = 10;
220
                    }
221
                    Top = lMousePosition.Y;
222

    
223

    
224
                    WindowState = WindowState.Normal;
225

    
226
                    this.DragMove();
227
                }
228
            }
229
        }
230

    
231
        [DllImport("user32.dll")]
232
        [return: MarshalAs(UnmanagedType.Bool)]
233
        static extern bool GetCursorPos(out POINT lpPoint);
234

    
235
        [StructLayout(LayoutKind.Sequential)]
236
        public struct POINT
237
        {
238
            public int X;
239
            public int Y;
240

    
241
            public POINT(int x, int y)
242
            {
243
                this.X = x;
244
                this.Y = y;
245
            }
246
        }
247

    
248
        private void SwitchState()
249
        {
250
            switch (WindowState)
251
            {
252
                case WindowState.Normal:
253
                    {
254
                        WindowState = WindowState.Maximized;
255
                        break;
256
                    }
257
                case WindowState.Maximized:
258
                    {
259
                        WindowState = WindowState.Normal;
260
                        break;
261
                    }
262
            }
263
        }
264

    
265
        private void RadButton_Click(object sender, RoutedEventArgs e)
266
        {
267
            Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
268

    
269
            switch (button.CommandParameter.ToString())
270
            {
271
                case ("Min"):
272
                    {
273
                        WindowState = WindowState.Minimized;
274
                    }
275
                    break;
276
                case ("Max"):
277
                    {
278
                        WindowState = WindowState.Maximized;
279
                    }
280
                    break;
281
                case ("Exit"):
282
                    {
283

    
284
                    }
285
                    break;
286
            }
287
        }
288

    
289
        private void WinState(object sender, MouseButtonEventArgs e)
290
        {
291
            switch ((e.Source as Image).Name)
292
            {
293
                case ("Win_min"):
294
                    {
295
                        WindowState = WindowState.Minimized;
296
                    }
297
                    break;
298
                case ("Win_max"):
299
                    {
300
                        if (WindowState == WindowState.Maximized)
301
                        {
302
                            WindowState = WindowState.Normal;
303
                        }
304
                        else
305
                        {
306
                            WindowState = WindowState.Maximized;
307
                        }
308
                    }
309
                    break;
310
                case ("Win_Close"):
311
                    {
312
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
313
                        {
314
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
315
                            DateTime updatetime = DateTime.Now.AddDays(-1);
316
                            if (ViewerDataModel.Instance._markupInfoList.Count > 0)
317
                            {
318
                                updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
319
                            }
320

    
321
                            if (undoTime > updatetime)
322
                            {
323
                                var box = new TextBlock();
324
                                box.MinWidth = 400;
325
                                box.FontSize = 11;
326
                                box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
327
                                box.TextWrapping = System.Windows.TextWrapping.Wrap;
328

    
329
                                DialogParameters parameters = new DialogParameters()
330
                                {
331
                                    Owner = Application.Current.MainWindow,
332
                                    Content = box,
333
                                    Header = "Confirm",
334
                                    Theme = new VisualStudio2013Theme(),
335
                                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
336
                                    Closed = Onclose,
337
                                };
338
                                RadWindow.Confirm(parameters);
339
                            }
340
                        }
341
                        this.Close();
342
                    }
343
                    break;
344
            }
345
        }
346

    
347
        private void Onclose(object sender, WindowClosedEventArgs e)
348
        {
349
            if (e.DialogResult == true)
350
            {
351
                dzTopMenu.SaveEvent(null, null);
352
            }
353
        }
354

    
355
        void win_SourceInitialized(object sender, EventArgs e)
356
        {
357
            System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle;
358
            WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc));
359
        }
360

    
361
        private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
362
        {
363
            switch (msg)
364
            {
365
                case 0x0024:
366
                    WmGetMinMaxInfo(hwnd, lParam);
367
                    handled = true;
368
                    break;
369
            }
370
            return (System.IntPtr)0;
371
        }
372

    
373
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
374
        {
375
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
376
            int MONITOR_DEFAULTTONEAREST = 0x00000002;
377
            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
378

    
379
            if (monitor != System.IntPtr.Zero)
380
            {
381
                MONITORINFO monitorInfo = new MONITORINFO();
382
                GetMonitorInfo(monitor, monitorInfo);
383
                RECT rcWorkArea = monitorInfo.rcWork;
384
                RECT rcMonitorArea = monitorInfo.rcMonitor;
385
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
386
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
387
                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
388
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
389
            }
390
            Marshal.StructureToPtr(mmi, lParam, true);
391
        }
392

    
393
        [StructLayout(LayoutKind.Sequential)]
394
        public struct POINT2
395
        {
396
            public int x;
397
            public int y;
398
            public POINT2(int x, int y)
399
            {
400
                this.x = x;
401
                this.y = y;
402
            }
403
        }
404

    
405
        [StructLayout(LayoutKind.Sequential)]
406
        public struct MINMAXINFO
407
        {
408
            public POINT2 ptReserved;
409
            public POINT2 ptMaxSize;
410
            public POINT2 ptMaxPosition;
411
            public POINT2 ptMinTrackSize;
412
            public POINT2 ptMaxTrackSize;
413
        };
414

    
415
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
416
        public class MONITORINFO
417
        {
418
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
419
            public RECT rcMonitor = new RECT();
420
            public RECT rcWork = new RECT();
421
            public int dwFlags = 0;
422
        }
423

    
424
        [StructLayout(LayoutKind.Sequential, Pack = 0)]
425
        public struct RECT
426
        {
427
            public int left;
428
            public int top;
429
            public int right;
430
            public int bottom;
431

    
432
            public static readonly RECT Empty = new RECT();
433

    
434
            public int Width
435
            {
436
                get { return Math.Abs(right - left); }  // Abs needed for BIDI OS
437
            }
438

    
439
            public int Height
440
            {
441
                get { return bottom - top; }
442
            }
443

    
444
            public RECT(int left, int top, int right, int bottom)
445
            {
446
                this.left = left;
447
                this.top = top;
448
                this.right = right;
449
                this.bottom = bottom;
450
            }
451

    
452
            public RECT(RECT rcSrc)
453
            {
454
                this.left = rcSrc.left;
455
                this.top = rcSrc.top;
456
                this.right = rcSrc.right;
457
                this.bottom = rcSrc.bottom;
458
            }
459

    
460
            public bool IsEmpty
461
            {
462
                get
463
                {
464
                    // BUGBUG : On Bidi OS (hebrew arabic) left > right
465
                    return left >= right || top >= bottom;
466
                }
467
            }
468

    
469
            public override bool Equals(object obj)
470
            {
471
                if (!(obj is Rect)) { return false; }
472
                return (this == (RECT)obj);
473
            }
474

    
475
            public override int GetHashCode()
476
            {
477
                return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode();
478
            }
479

    
480
            public static bool operator ==(RECT rect1, RECT rect2)
481
            {
482
                return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom);
483
            }
484

    
485
            public static bool operator !=(RECT rect1, RECT rect2)
486
            {
487
                return !(rect1 == rect2);
488
            }
489
        }
490

    
491
        [DllImport("user32")]
492
        internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
493
        [DllImport("User32")]
494
        internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
495

    
496
        private void WindowKeyDown(object sender, KeyEventArgs e)
497
        {
498
            if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) //Ctrl + V 
499
            {
500
                if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
501
                {
502
                    if (Clipboard.GetText().Contains("|OR||DZ|"))
503
                    {
504
                        TextBox_Paste_Start();
505
                    }
506

    
507
                }
508
            }
509
        }
510

    
511
        public void TextBox_Paste_Start()
512
        {
513
            if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
514
            {
515
                if (Clipboard.GetText().Contains("|OR||DZ|"))
516
                {
517
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
518

    
519
                    string[] delimiterChars = { "|OR|" };
520
                    string[] delimiterChars2 = { "|OR|", "|SymbolID|" };
521
                    string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
522

    
523
                    SelectionSet.Instance.UnSelect(this.dzMainMenu);
524

    
525
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
526

    
527
                    UndoData = new Undo_data()
528
                    {
529
                        IsUndo = false,
530
                        Event = Event_Type.Create,
531
                        EventTime = DateTime.Now,
532
                        Markup_List = new List<Multi_Undo_data>()
533
                    };
534

    
535
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
536
                    {
537
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
538
                    });
539

    
540
                    foreach (string parse in data)
541
                    {
542
                        if (parse != "")
543
                        {
544
                            string[] data2 = new string[2];
545
                            data2 = parse.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
546

    
547
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, data2[0], ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
548

    
549
                            var controldata = JsonSerializerHelper.UnCompressString(data2[0]);
550
                            var unkownControl = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(controldata); //복호화작업
551
                            ViewerDataModel.Instance.IsPressCtrl = false;
552

    
553
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
554
                            if (data2.Length >= 2)
555
                            {
556
                                (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1];
557
                            }
558

    
559
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
560
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
561

    
562
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
563

    
564
                            multi_Undo_Data = dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
565

    
566
                            UndoData.Markup_List.Add(multi_Undo_Data);
567
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
568
                        }
569
                    }
570

    
571
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
572

    
573
                    double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
574
                    double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
575
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
576

    
577
                    if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
578
                    {
579
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001));
580
                    }
581

    
582
                    this.dzMainMenu.SelectLayer.Children.Add(final);
583

    
584
                }
585
                else if (Clipboard.GetImage() != null) //외부 이미지 붙여넣기
586
                {
587
                    try
588
                    {
589
                        Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
590

    
591
                        //Undo/Redo 보류
592
                        UndoData = new Undo_data()
593
                        {
594
                            IsUndo = false,
595
                            Event = Event_Type.Create,
596
                            EventTime = DateTime.Now,
597
                            Markup_List = new List<Multi_Undo_data>()
598
                        };
599

    
600
                        string temppath = System.IO.Path.GetTempPath();
601
                        //string filename = KCOM.Events.Save.shortCommentKey();
602
                        string filename = Commons.shortFileKey();
603

    
604
                        System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
605
                        clipboardImage.Save(temppath + "\\" + filename);
606

    
607
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
608
                        String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
609
                        long numByte = fileInfo.Length;
610
                        double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
611
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
612

    
613
                        if (dLen < 4)
614
                        {
615
                            System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
616
                            System.IO.FileMode.Open, System.IO.FileAccess.Read);
617
                            System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
618
                            byte[] data = br.ReadBytes((int)numByte);
619

    
620
                            filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
621
                            Check_Uri.UriCheck(filename);
622

    
623
                            br.Close();
624
                            fStream.Close();
625
                            fStream.Dispose();
626
                        }
627
                        else
628
                        {
629
                            dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
630
                            return;
631
                        }
632

    
633
                        fileInfo.Delete();
634

    
635
                        //System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
636
                        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
637
                        IntPtr hBitmap = bmp.GetHbitmap();
638
                        System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
639
                        Image img = new Image();
640
                        img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(filename));
641

    
642
                        var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
643
                        {
644
                            PointSet = new List<Point>(),
645
                            FilePath = img.Source.ToString(),
646
                            ImageData = img.Source,
647
                            StartPoint = new Point(100, 100),
648
                            EndPoint = new Point(200, 200),
649
                            TopRightPoint = new Point(100, 200),
650
                            LeftBottomPoint = new Point(200, 100)
651
                        };
652

    
653
                        currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
654
                        currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
655
                        currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
656

    
657
                        currentControl.PointSet = new List<Point>
658
                                        {
659
                                            currentControl.StartPoint,
660
                                            currentControl.LeftBottomPoint,
661
                                            currentControl.EndPoint,
662
                                            currentControl.TopRightPoint,
663
                                        };
664

    
665
                        multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
666
                        UndoData.Markup_List.Add(multi_Undo_Data);
667
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
668

    
669
                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
670
                        currentControl.CommentID = Commons.shortGuid();
671

    
672
                        currentControl.ApplyTemplate();
673
                        currentControl.SetImage();
674

    
675
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
676
                        Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
677
                        this.dzMainMenu.SelectLayer.Children.Add(final);
678

    
679
                        double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
680
                        double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
681
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
682
                    }
683
                    catch(Exception ex)
684
                    {
685
                        DialogMessage_Alert("" + ex, "Alert");
686
                    }
687
                }
688
            }
689
        }
690
    }
691
}
클립보드 이미지 추가 (최대 크기: 500 MB)