프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ b5ac6d6e

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

1 787a4489 KangIngu
using KCOM.Common;
2
using KCOMDataModel;
3
using KCOMDataModel.DataModel;
4 b0fb3ad7 ljiyeon
using MarkupToPDF.Common;
5 5529d2a2 humkyung
using MarkupToPDF.Controls.Parsing;
6 b0fb3ad7 ljiyeon
using MarkupToPDF.Serialize.Core;
7
using MarkupToPDF.Serialize.S_Control;
8 787a4489 KangIngu
using System;
9
using System.Collections.Generic;
10 6707a5c7 ljiyeon
using System.IO;
11 787a4489 KangIngu
using System.Linq;
12 71bfd53e ljiyeon
using System.Runtime.InteropServices;
13 787a4489 KangIngu
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 6707a5c7 ljiyeon
using System.Xml;
24 992a98b4 KangIngu
using Telerik.Windows.Controls;
25 7e2d29a0 ljiyeon
using WinInterop = System.Windows.Interop;
26 787a4489 KangIngu
27
namespace KCOM
28
{
29
    /// <summary>
30
    /// MainWindow.xaml에 대한 상호 작용 논리
31
    /// </summary>
32
    public partial class MainWindow : Window
33
    {
34
        public MainWindow()
35
        {
36 0c997b99 ljiyeon
            //InitializeComponent();
37 787a4489 KangIngu
            this.Loaded += MainWindow_Loaded;
38
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
39
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
40 7e2d29a0 ljiyeon
            this.SourceInitialized += new EventHandler(win_SourceInitialized);
41 29010418 ljiyeon
            
42 787a4489 KangIngu
        }
43 ca16abb2 ljiyeon
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 787a4489 KangIngu
        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 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
63 787a4489 KangIngu
                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 7e2d29a0 ljiyeon
71 787a4489 KangIngu
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
72
        {
73 0c997b99 ljiyeon
            InitializeComponent();
74 ca16abb2 ljiyeon
75
            //cursor change  
76
            this.Cursor = new Cursor(CursorChange().StreamSource);
77
78 787a4489 KangIngu
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
79
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
80 9f473fb7 KangIngu
            //this.Width += 40;
81 787a4489 KangIngu
            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 3933072f ljiyeon
87 787a4489 KangIngu
            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 7e2d29a0 ljiyeon
                //#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 787a4489 KangIngu
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 7e2d29a0 ljiyeon
                //#endif
130 787a4489 KangIngu
            }
131
            else
132
            {
133
                this.dzMainMenu.ServiceOn();
134 992a98b4 KangIngu
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 e0204db0 djkim
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
143
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
144
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
145 992a98b4 KangIngu
                }
146 787a4489 KangIngu
                this.dzMainMenu.SetView(App.ViewInfo);
147 7e2d29a0 ljiyeon
                this.dzMainMenu.HubSet();
148 787a4489 KangIngu
            }
149 6707a5c7 ljiyeon
150 787a4489 KangIngu
            //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 6707a5c7 ljiyeon
167 71bfd53e ljiyeon
168 7e2d29a0 ljiyeon
        bool restoreIfMove = false;
169 71bfd53e ljiyeon
170 787a4489 KangIngu
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
171
        {
172 71bfd53e ljiyeon
            if (e.ClickCount == 2)
173 787a4489 KangIngu
            {
174 71bfd53e ljiyeon
                if ((ResizeMode == ResizeMode.CanResize) ||
175
                    (ResizeMode == ResizeMode.CanResizeWithGrip))
176 787a4489 KangIngu
                {
177 71bfd53e ljiyeon
                    SwitchState();
178 787a4489 KangIngu
                }
179
            }
180
            else
181
            {
182 71bfd53e ljiyeon
                if (WindowState == WindowState.Maximized)
183
                {
184
                    restoreIfMove = true;
185
                }
186 3933072f ljiyeon
187 787a4489 KangIngu
                this.DragMove();
188
            }
189
        }
190
191 71bfd53e ljiyeon
        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 3933072f ljiyeon
                    //this.WindowState = WindowState.Normal;
203
204 71bfd53e ljiyeon
                    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 7e2d29a0 ljiyeon
                    GetCursorPos(out lMousePosition);
214 71bfd53e ljiyeon
215
                    Left = lMousePosition.X - targetHorizontal;
216 7e2d29a0 ljiyeon
                    double top = lMousePosition.Y - targetVertical;
217
                    if(top < 10)
218
                    {
219
                        top = 10;
220
                    }
221
                    Top = lMousePosition.Y;
222 71bfd53e ljiyeon
223 3933072f ljiyeon
224 71bfd53e ljiyeon
                    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 787a4489 KangIngu
        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 af177ca1 djkim
            switch ((e.Source as Image).Name)
292 787a4489 KangIngu
            {
293 af177ca1 djkim
                case ("Win_min"):
294 787a4489 KangIngu
                    {
295
                        WindowState = WindowState.Minimized;
296
                    }
297
                    break;
298 af177ca1 djkim
                case ("Win_max"):
299 787a4489 KangIngu
                    {
300 af177ca1 djkim
                        if (WindowState == WindowState.Maximized)
301
                        {
302 787a4489 KangIngu
                            WindowState = WindowState.Normal;
303 af177ca1 djkim
                        }
304 787a4489 KangIngu
                        else
305 af177ca1 djkim
                        {
306 787a4489 KangIngu
                            WindowState = WindowState.Maximized;
307 af177ca1 djkim
                        }
308 787a4489 KangIngu
                    }
309
                    break;
310 af177ca1 djkim
                case ("Win_Close"):
311 787a4489 KangIngu
                    {
312 316d0f5c KangIngu
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
313 69ef0800 KangIngu
                        {
314 316d0f5c KangIngu
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
315 d2cd1e16 djkim
                            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 6707a5c7 ljiyeon
321 316d0f5c KangIngu
                            if (undoTime > updatetime)
322
                            {
323 69ef0800 KangIngu
                                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 b9b01f8e ljiyeon
                                    Owner = Application.Current.MainWindow,
332 69ef0800 KangIngu
                                    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 316d0f5c KangIngu
                        }
341 787a4489 KangIngu
                        this.Close();
342
                    }
343
                    break;
344
            }
345
        }
346
347 69ef0800 KangIngu
        private void Onclose(object sender, WindowClosedEventArgs e)
348
        {
349
            if (e.DialogResult == true)
350
            {
351
                dzTopMenu.SaveEvent(null, null);
352
            }
353
        }
354 7e2d29a0 ljiyeon
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 b0fb3ad7 ljiyeon
                    handled = true;
368 7e2d29a0 ljiyeon
                    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 b0fb3ad7 ljiyeon
        {
418
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
419
            public RECT rcMonitor = new RECT();
420
            public RECT rcWork = new RECT();
421 7e2d29a0 ljiyeon
            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 b0fb3ad7 ljiyeon
            public int right;
430 7e2d29a0 ljiyeon
            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 b0fb3ad7 ljiyeon
496
        private void WindowKeyDown(object sender, KeyEventArgs e)
497 29010418 ljiyeon
        {
498 b0fb3ad7 ljiyeon
            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 29010418 ljiyeon
                        TextBox_Paste_Start();
505 b0fb3ad7 ljiyeon
                    }
506 29010418 ljiyeon
507 b0fb3ad7 ljiyeon
                }
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
                    this.dzMainMenu.ReleaseAdorner();
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 5529d2a2 humkyung
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, data2[0], ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
548 b0fb3ad7 ljiyeon
549 29010418 ljiyeon
                            var controldata = JsonSerializerHelper.UnCompressString(data2[0]);
550 b0fb3ad7 ljiyeon
                            var unkownControl = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(controldata); //복호화작업
551 29010418 ljiyeon
                            ViewerDataModel.Instance.IsPressCtrl = false;
552 b0fb3ad7 ljiyeon
553 24678e06 humkyung
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
554 29010418 ljiyeon
                            if (data2.Length >= 2)
555
                            {
556
                                (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1];
557
                            }
558 b0fb3ad7 ljiyeon
559 29010418 ljiyeon
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
560
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
561 b0fb3ad7 ljiyeon
562 29010418 ljiyeon
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
563 b0fb3ad7 ljiyeon
564 29010418 ljiyeon
                            multi_Undo_Data = dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
565 b0fb3ad7 ljiyeon
566 29010418 ljiyeon
                            UndoData.Markup_List.Add(multi_Undo_Data);
567
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
568 b0fb3ad7 ljiyeon
                        }
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.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
578
                    {
579 29010418 ljiyeon
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001));
580 b0fb3ad7 ljiyeon
                    }
581
582
                    this.dzMainMenu.SelectLayer.Children.Add(final);
583
584 29010418 ljiyeon
                }
585 b0fb3ad7 ljiyeon
                else if (Clipboard.GetImage() != null) //외부 이미지 붙여넣기
586
                {
587 c73426a9 ljiyeon
                    try
588 b0fb3ad7 ljiyeon
                    {
589 c73426a9 ljiyeon
                        Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
590 b0fb3ad7 ljiyeon
591 c73426a9 ljiyeon
                        //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 24678e06 humkyung
                        string filename = Commons.shortFileKey();
603 c73426a9 ljiyeon
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 b0fb3ad7 ljiyeon
620 c73426a9 ljiyeon
                            filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
621
                            Check_Uri.UriCheck(filename);
622 b0fb3ad7 ljiyeon
623 c73426a9 ljiyeon
                            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 b0fb3ad7 ljiyeon
633 c73426a9 ljiyeon
                        fileInfo.Delete();
634 b0fb3ad7 ljiyeon
635 c73426a9 ljiyeon
                        //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 b0fb3ad7 ljiyeon
642 c73426a9 ljiyeon
                        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 b0fb3ad7 ljiyeon
                                        {
659
                                            currentControl.StartPoint,
660
                                            currentControl.LeftBottomPoint,
661
                                            currentControl.EndPoint,
662
                                            currentControl.TopRightPoint,
663
                                        };
664
665 c73426a9 ljiyeon
                        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 b0fb3ad7 ljiyeon
669 c73426a9 ljiyeon
                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
670 24678e06 humkyung
                        currentControl.CommentID = Commons.shortGuid();
671 b0fb3ad7 ljiyeon
672 c73426a9 ljiyeon
                        currentControl.ApplyTemplate();
673
                        currentControl.SetImage();
674 b0fb3ad7 ljiyeon
675 c73426a9 ljiyeon
                        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 b0fb3ad7 ljiyeon
679 c73426a9 ljiyeon
                        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 b0fb3ad7 ljiyeon
                }
688
            }
689
        }
690 787a4489 KangIngu
    }
691
}
클립보드 이미지 추가 (최대 크기: 500 MB)