프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ 29010418

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

1 787a4489 KangIngu
using KCOM.Common;
2
using KCOMDataModel;
3
using KCOMDataModel.DataModel;
4 b0fb3ad7 ljiyeon
using MarkupToPDF.Common;
5
using MarkupToPDF.Serialize.Core;
6
using MarkupToPDF.Serialize.S_Control;
7 787a4489 KangIngu
using System;
8
using System.Collections.Generic;
9 6707a5c7 ljiyeon
using System.IO;
10 787a4489 KangIngu
using System.Linq;
11 71bfd53e ljiyeon
using System.Runtime.InteropServices;
12 787a4489 KangIngu
using System.Text;
13
using System.Windows;
14
using System.Windows.Controls;
15
using System.Windows.Data;
16
using System.Windows.Documents;
17
using System.Windows.Input;
18
using System.Windows.Media;
19
using System.Windows.Media.Imaging;
20
using System.Windows.Navigation;
21
using System.Windows.Shapes;
22 6707a5c7 ljiyeon
using System.Xml;
23 992a98b4 KangIngu
using Telerik.Windows.Controls;
24 7e2d29a0 ljiyeon
using WinInterop = System.Windows.Interop;
25 787a4489 KangIngu
26
namespace KCOM
27
{
28
    /// <summary>
29
    /// MainWindow.xaml에 대한 상호 작용 논리
30
    /// </summary>
31
    public partial class MainWindow : Window
32
    {
33
        public MainWindow()
34
        {
35 0c997b99 ljiyeon
            //InitializeComponent();
36 787a4489 KangIngu
            this.Loaded += MainWindow_Loaded;
37
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
38
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
39 7e2d29a0 ljiyeon
            this.SourceInitialized += new EventHandler(win_SourceInitialized);
40 29010418 ljiyeon
            
41 787a4489 KangIngu
        }
42 ca16abb2 ljiyeon
43
        public static BitmapImage CursorChange()
44
        {
45
            BitmapImage bmp = new BitmapImage();
46
            bmp.BeginInit();
47
            bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
48
            return bmp;
49
        }
50
51 787a4489 KangIngu
        public void DialogMessage_Alert(string content, string header)
52
        {
53
            var box = new TextBlock();
54
            box.MinWidth = 400;
55
            box.FontSize = 12;
56
            box.Text = content;
57
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
58
59
            Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
60
            {
61 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
62 787a4489 KangIngu
                Content = box,
63
                Header = header,
64
                Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
65
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
66
            };
67
            Telerik.Windows.Controls.RadWindow.Alert(parameters);
68
        }
69 7e2d29a0 ljiyeon
70 787a4489 KangIngu
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
71
        {
72 0c997b99 ljiyeon
            InitializeComponent();
73 ca16abb2 ljiyeon
74
            //cursor change  
75
            this.Cursor = new Cursor(CursorChange().StreamSource);
76
77 787a4489 KangIngu
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
78
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
79 9f473fb7 KangIngu
            //this.Width += 40;
80 787a4489 KangIngu
            double windowWidth = this.Width;
81
            double windowHeight = this.Height;
82
            this.Left = (screenWidth / 2) - (windowWidth / 2);
83
            this.Top = (screenHeight / 2) - (windowHeight / 2);
84
85 3933072f ljiyeon
86 787a4489 KangIngu
            ViewerDataModel.Instance.SystemMain = this;
87
88
            if (!App.ParameterMode)
89
            {
90
                //App.ViewInfo = new IKCOM.ViewInfo
91
                //{
92
                //    DocumentItemID = "11111112",
93
                //    //DocumentItemID = "10001",
94
                //    bPartner = false,
95
                //    CreateFinalPDFPermission = true,
96
                //    NewCommentPermission = true,
97
                //    ProjectNO = "000000",
98
                //    UserID = "H2011357",
99
                //    //UserID = "H2009115",
100
                //    //Mode = 0 , 1 , 2
101
                //};
102
                //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
103
104 7e2d29a0 ljiyeon
                //#if DEBUG
105
                //                App.ViewInfo = new IKCOM.ViewInfo
106
                //                {
107
                //                    DocumentItemID = "11111112",
108
                //                    //DocumentItemID = "10001",
109
                //                    bPartner = false,
110
                //                    CreateFinalPDFPermission = true,
111
                //                    NewCommentPermission = true,
112
                //                    ProjectNO = "000000",
113
                //                    UserID = "H2011357",
114
                //                    //UserID = "H2009115",
115
                //                    //Mode = 0 , 1 , 2
116
                //                };
117
                //                App.ParameterMode = true;
118
                //                this.dzMainMenu.ServiceOn();
119
                //                this.dzMainMenu.SetView(App.ViewInfo);
120
                //#else
121 787a4489 KangIngu
122
                DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
123
                this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
124
                this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
125
                this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
126
                this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
127
                this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
128 7e2d29a0 ljiyeon
                //#endif
129 787a4489 KangIngu
            }
130
            else
131
            {
132
                this.dzMainMenu.ServiceOn();
133 992a98b4 KangIngu
134
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
135
                {
136
                    this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
137
                    var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
138
                    list.ForEach(item => item.Visibility = Visibility.Collapsed);
139
                    this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
140
                    this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
141 e0204db0 djkim
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
142
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
143
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
144 992a98b4 KangIngu
                }
145 787a4489 KangIngu
                this.dzMainMenu.SetView(App.ViewInfo);
146 7e2d29a0 ljiyeon
                this.dzMainMenu.HubSet();
147 787a4489 KangIngu
            }
148 6707a5c7 ljiyeon
149 787a4489 KangIngu
            //App.ViewInfo = new IKCOM.ViewInfo
150
            //{
151
            //    DocumentItemID = "11111112",
152
            //    //DocumentItemID = "10001",
153
            //    bPartner = false,
154
            //    CreateFinalPDFPermission = true,
155
            //    NewCommentPermission = true,
156
            //    ProjectNO = "000000",
157
            //    UserID = "H2011357",
158
            //    //UserID = "H2009115",
159
            //    //Mode = 0 , 1 , 2
160
            //};
161
162
            //this.dzMainMenu.ServiceOn();
163
            //this.dzMainMenu.SetView(App.ViewInfo);
164
        }
165 6707a5c7 ljiyeon
166 71bfd53e ljiyeon
167 7e2d29a0 ljiyeon
        bool restoreIfMove = false;
168 71bfd53e ljiyeon
169 787a4489 KangIngu
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
170
        {
171 71bfd53e ljiyeon
            if (e.ClickCount == 2)
172 787a4489 KangIngu
            {
173 71bfd53e ljiyeon
                if ((ResizeMode == ResizeMode.CanResize) ||
174
                    (ResizeMode == ResizeMode.CanResizeWithGrip))
175 787a4489 KangIngu
                {
176 71bfd53e ljiyeon
                    SwitchState();
177 787a4489 KangIngu
                }
178
            }
179
            else
180
            {
181 71bfd53e ljiyeon
                if (WindowState == WindowState.Maximized)
182
                {
183
                    restoreIfMove = true;
184
                }
185 3933072f ljiyeon
186 787a4489 KangIngu
                this.DragMove();
187
            }
188
        }
189
190 71bfd53e ljiyeon
        private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
191
        {
192
            restoreIfMove = false;
193
        }
194
195
        private void WindowDragEventMove(object sender, MouseEventArgs e)
196
        {
197
            if (restoreIfMove)
198
            {
199
                if (Mouse.LeftButton == MouseButtonState.Pressed)
200
                {
201 3933072f ljiyeon
                    //this.WindowState = WindowState.Normal;
202
203 71bfd53e ljiyeon
                    restoreIfMove = false;
204
205
                    double percentHorizontal = e.GetPosition(this).X / ActualWidth;
206
                    double targetHorizontal = RestoreBounds.Width * percentHorizontal;
207
208
                    double percentVertical = e.GetPosition(this).Y / ActualHeight;
209
                    double targetVertical = RestoreBounds.Height * percentVertical;
210
211
                    POINT lMousePosition;
212 7e2d29a0 ljiyeon
                    GetCursorPos(out lMousePosition);
213 71bfd53e ljiyeon
214
                    Left = lMousePosition.X - targetHorizontal;
215 7e2d29a0 ljiyeon
                    double top = lMousePosition.Y - targetVertical;
216
                    if(top < 10)
217
                    {
218
                        top = 10;
219
                    }
220
                    Top = lMousePosition.Y;
221 71bfd53e ljiyeon
222 3933072f ljiyeon
223 71bfd53e ljiyeon
                    WindowState = WindowState.Normal;
224
225
                    this.DragMove();
226
                }
227
            }
228
        }
229
230
        [DllImport("user32.dll")]
231
        [return: MarshalAs(UnmanagedType.Bool)]
232
        static extern bool GetCursorPos(out POINT lpPoint);
233
234
        [StructLayout(LayoutKind.Sequential)]
235
        public struct POINT
236
        {
237
            public int X;
238
            public int Y;
239
240
            public POINT(int x, int y)
241
            {
242
                this.X = x;
243
                this.Y = y;
244
            }
245
        }
246
247
        private void SwitchState()
248
        {
249
            switch (WindowState)
250
            {
251
                case WindowState.Normal:
252
                    {
253
                        WindowState = WindowState.Maximized;
254
                        break;
255
                    }
256
                case WindowState.Maximized:
257
                    {
258
                        WindowState = WindowState.Normal;
259
                        break;
260
                    }
261
            }
262
        }
263
264 787a4489 KangIngu
        private void RadButton_Click(object sender, RoutedEventArgs e)
265
        {
266
            Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
267
268
            switch (button.CommandParameter.ToString())
269
            {
270
                case ("Min"):
271
                    {
272
                        WindowState = WindowState.Minimized;
273
                    }
274
                    break;
275
                case ("Max"):
276
                    {
277
                        WindowState = WindowState.Maximized;
278
                    }
279
                    break;
280
                case ("Exit"):
281
                    {
282
283
                    }
284
                    break;
285
            }
286
        }
287
288
        private void WinState(object sender, MouseButtonEventArgs e)
289
        {
290 af177ca1 djkim
            switch ((e.Source as Image).Name)
291 787a4489 KangIngu
            {
292 af177ca1 djkim
                case ("Win_min"):
293 787a4489 KangIngu
                    {
294
                        WindowState = WindowState.Minimized;
295
                    }
296
                    break;
297 af177ca1 djkim
                case ("Win_max"):
298 787a4489 KangIngu
                    {
299 af177ca1 djkim
                        if (WindowState == WindowState.Maximized)
300
                        {
301 787a4489 KangIngu
                            WindowState = WindowState.Normal;
302 af177ca1 djkim
                        }
303 787a4489 KangIngu
                        else
304 af177ca1 djkim
                        {
305 787a4489 KangIngu
                            WindowState = WindowState.Maximized;
306 af177ca1 djkim
                        }
307 787a4489 KangIngu
                    }
308
                    break;
309 af177ca1 djkim
                case ("Win_Close"):
310 787a4489 KangIngu
                    {
311 316d0f5c KangIngu
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
312 69ef0800 KangIngu
                        {
313 316d0f5c KangIngu
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
314 d2cd1e16 djkim
                            DateTime updatetime = DateTime.Now.AddDays(-1);
315
                            if (ViewerDataModel.Instance._markupInfoList.Count > 0)
316
                            {
317
                                updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
318
                            }
319 6707a5c7 ljiyeon
320 316d0f5c KangIngu
                            if (undoTime > updatetime)
321
                            {
322 69ef0800 KangIngu
                                var box = new TextBlock();
323
                                box.MinWidth = 400;
324
                                box.FontSize = 11;
325
                                box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
326
                                box.TextWrapping = System.Windows.TextWrapping.Wrap;
327
328
                                DialogParameters parameters = new DialogParameters()
329
                                {
330 b9b01f8e ljiyeon
                                    Owner = Application.Current.MainWindow,
331 69ef0800 KangIngu
                                    Content = box,
332
                                    Header = "Confirm",
333
                                    Theme = new VisualStudio2013Theme(),
334
                                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
335
                                    Closed = Onclose,
336
                                };
337
                                RadWindow.Confirm(parameters);
338
                            }
339 316d0f5c KangIngu
                        }
340 787a4489 KangIngu
                        this.Close();
341
                    }
342
                    break;
343
            }
344
        }
345
346 69ef0800 KangIngu
        private void Onclose(object sender, WindowClosedEventArgs e)
347
        {
348
            if (e.DialogResult == true)
349
            {
350
                dzTopMenu.SaveEvent(null, null);
351
            }
352
        }
353 7e2d29a0 ljiyeon
354
        void win_SourceInitialized(object sender, EventArgs e)
355
        {
356
            System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle;
357
            WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc));
358
        }
359
360
        private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
361
        {
362
            switch (msg)
363
            {
364
                case 0x0024:
365
                    WmGetMinMaxInfo(hwnd, lParam);
366 b0fb3ad7 ljiyeon
                    handled = true;
367 7e2d29a0 ljiyeon
                    break;
368
            }
369
            return (System.IntPtr)0;
370
        }
371
372
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
373
        {
374
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
375
            int MONITOR_DEFAULTTONEAREST = 0x00000002;
376
            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
377
378
            if (monitor != System.IntPtr.Zero)
379
            {
380
                MONITORINFO monitorInfo = new MONITORINFO();
381
                GetMonitorInfo(monitor, monitorInfo);
382
                RECT rcWorkArea = monitorInfo.rcWork;
383
                RECT rcMonitorArea = monitorInfo.rcMonitor;
384
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
385
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
386
                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
387
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
388
            }
389
            Marshal.StructureToPtr(mmi, lParam, true);
390
        }
391
392
        [StructLayout(LayoutKind.Sequential)]
393
        public struct POINT2
394
        {
395
            public int x;
396
            public int y;
397
            public POINT2(int x, int y)
398
            {
399
                this.x = x;
400
                this.y = y;
401
            }
402
        }
403
404
        [StructLayout(LayoutKind.Sequential)]
405
        public struct MINMAXINFO
406
        {
407
            public POINT2 ptReserved;
408
            public POINT2 ptMaxSize;
409
            public POINT2 ptMaxPosition;
410
            public POINT2 ptMinTrackSize;
411
            public POINT2 ptMaxTrackSize;
412
        };
413
414
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
415
        public class MONITORINFO
416 b0fb3ad7 ljiyeon
        {
417
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
418
            public RECT rcMonitor = new RECT();
419
            public RECT rcWork = new RECT();
420 7e2d29a0 ljiyeon
            public int dwFlags = 0;
421
        }
422
423
        [StructLayout(LayoutKind.Sequential, Pack = 0)]
424
        public struct RECT
425
        {
426
            public int left;
427
            public int top;
428 b0fb3ad7 ljiyeon
            public int right;
429 7e2d29a0 ljiyeon
            public int bottom;
430
431
            public static readonly RECT Empty = new RECT();
432
433
            public int Width
434
            {
435
                get { return Math.Abs(right - left); }  // Abs needed for BIDI OS
436
            }
437
438
            public int Height
439
            {
440
                get { return bottom - top; }
441
            }
442
443
            public RECT(int left, int top, int right, int bottom)
444
            {
445
                this.left = left;
446
                this.top = top;
447
                this.right = right;
448
                this.bottom = bottom;
449
            }
450
451
            public RECT(RECT rcSrc)
452
            {
453
                this.left = rcSrc.left;
454
                this.top = rcSrc.top;
455
                this.right = rcSrc.right;
456
                this.bottom = rcSrc.bottom;
457
            }
458
459
            public bool IsEmpty
460
            {
461
                get
462
                {
463
                    // BUGBUG : On Bidi OS (hebrew arabic) left > right
464
                    return left >= right || top >= bottom;
465
                }
466
            }
467
468
            public override bool Equals(object obj)
469
            {
470
                if (!(obj is Rect)) { return false; }
471
                return (this == (RECT)obj);
472
            }
473
474
            public override int GetHashCode()
475
            {
476
                return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode();
477
            }
478
479
            public static bool operator ==(RECT rect1, RECT rect2)
480
            {
481
                return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom);
482
            }
483
484
            public static bool operator !=(RECT rect1, RECT rect2)
485
            {
486
                return !(rect1 == rect2);
487
            }
488
        }
489
490
        [DllImport("user32")]
491
        internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
492
        [DllImport("User32")]
493
        internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
494 b0fb3ad7 ljiyeon
495
        private void WindowKeyDown(object sender, KeyEventArgs e)
496 29010418 ljiyeon
        {
497 b0fb3ad7 ljiyeon
            if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) //Ctrl + V 
498
            {
499
                if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
500
                {
501
                    if (Clipboard.GetText().Contains("|OR||DZ|"))
502
                    {
503 29010418 ljiyeon
                        TextBox_Paste_Start();
504 b0fb3ad7 ljiyeon
                    }
505 29010418 ljiyeon
506 b0fb3ad7 ljiyeon
                }
507
            }
508
        }
509
510
        public void TextBox_Paste_Start()
511
        {
512
            if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
513
            {
514
                if (Clipboard.GetText().Contains("|OR||DZ|"))
515
                {
516
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
517
518
                    string[] delimiterChars = { "|OR|" };
519
                    string[] delimiterChars2 = { "|OR|", "|SymbolID|" };
520
                    string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
521
522
                    this.dzMainMenu.ReleaseAdorner();
523
524
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
525
526
                    UndoData = new Undo_data()
527
                    {
528
                        IsUndo = false,
529
                        Event = Event_Type.Create,
530
                        EventTime = DateTime.Now,
531
                        Markup_List = new List<Multi_Undo_data>()
532
                    };
533
534
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
535
                    {
536
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
537
                    });
538
539
                    foreach (string parse in data)
540
                    {
541
                        if (parse != "")
542
                        {
543
                            string[] data2 = new string[2];
544
                            data2 = parse.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
545
546
                            System.Windows.Controls.Control item = layer.markupParse_Paste(data2[0], ViewerDataModel.Instance.MarkupControls_USER);
547
548 29010418 ljiyeon
                            var controldata = JsonSerializerHelper.UnCompressString(data2[0]);
549 b0fb3ad7 ljiyeon
                            var unkownControl = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(controldata); //복호화작업
550 29010418 ljiyeon
                            ViewerDataModel.Instance.IsPressCtrl = false;
551 b0fb3ad7 ljiyeon
552 29010418 ljiyeon
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
553
                            if (data2.Length >= 2)
554
                            {
555
                                (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1];
556
                            }
557 b0fb3ad7 ljiyeon
558 29010418 ljiyeon
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
559
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
560 b0fb3ad7 ljiyeon
561 29010418 ljiyeon
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
562 b0fb3ad7 ljiyeon
563 29010418 ljiyeon
                            multi_Undo_Data = dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
564 b0fb3ad7 ljiyeon
565 29010418 ljiyeon
                            UndoData.Markup_List.Add(multi_Undo_Data);
566
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
567 b0fb3ad7 ljiyeon
                        }
568
                    }
569
570
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
571
572
                    double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
573
                    double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
574
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
575
576
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
577
                    {
578 29010418 ljiyeon
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001));
579 b0fb3ad7 ljiyeon
                    }
580
581
                    this.dzMainMenu.SelectLayer.Children.Add(final);
582
583 29010418 ljiyeon
                }
584 b0fb3ad7 ljiyeon
                else if (Clipboard.GetImage() != null) //외부 이미지 붙여넣기
585
                {
586
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
587
588
                    //Undo/Redo 보류
589
                    UndoData = new Undo_data()
590
                    {
591
                        IsUndo = false,
592
                        Event = Event_Type.Create,
593
                        EventTime = DateTime.Now,
594
                        Markup_List = new List<Multi_Undo_data>()
595
                    };
596
597
                    string temppath = System.IO.Path.GetTempPath();
598
                    //string filename = KCOM.Events.Save.shortCommentKey();
599
                    string filename = KCOM.Events.Save.shortFileKey();
600
601
                    System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
602
                    clipboardImage.Save(temppath + "\\" + filename);
603
604
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
605
                    String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
606
                    long numByte = fileInfo.Length;
607
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
608
                    kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
609
610
                    if (dLen < 4)
611
                    {
612
                        System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
613
                        System.IO.FileMode.Open, System.IO.FileAccess.Read);
614
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
615
                        byte[] data = br.ReadBytes((int)numByte);
616
617
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
618
                        br.Close();
619
                        fStream.Close();
620
                        fStream.Dispose();
621
                    }
622
                    else
623
                    {
624
                        dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
625
                        return;
626
                    }
627
628
                    fileInfo.Delete();
629
630
                    //System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
631
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
632
                    IntPtr hBitmap = bmp.GetHbitmap();
633
                    System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
634
                    Image img = new Image();
635
                    img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(filename));
636
637
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
638
                    {
639
                        PointSet = new List<Point>(),
640
                        FilePath = img.Source.ToString(),
641
                        ImageData = img.Source,
642
                        StartPoint = new Point(100, 100),
643
                        EndPoint = new Point(200, 200),
644
                        TopRightPoint = new Point(100, 200),
645
                        LeftBottomPoint = new Point(200, 100)
646
                    };
647
648
                    currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
649
                    currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
650
                    currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
651
652
                    currentControl.PointSet = new List<Point>
653
                                        {
654
                                            currentControl.StartPoint,
655
                                            currentControl.LeftBottomPoint,
656
                                            currentControl.EndPoint,
657
                                            currentControl.TopRightPoint,
658
                                        };
659
660
                    multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
661
                    UndoData.Markup_List.Add(multi_Undo_Data);
662
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
663
664
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
665
                    currentControl.CommentID = Events.Save.shortGuid();
666
667
                    currentControl.ApplyTemplate();
668
                    currentControl.SetImage();
669
670
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
671
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
672
                    this.dzMainMenu.SelectLayer.Children.Add(final);
673
674
                    double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
675
                    double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
676
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
677
                }
678
            }
679
        }
680 787a4489 KangIngu
    }
681
}
클립보드 이미지 추가 (최대 크기: 500 MB)