프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ a70b7d46

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

1 787a4489 KangIngu
using KCOM.Common;
2 32af2c3b djkim
using KCOM.Controls;
3 264c9309 ljiyeon
using KCOM.Views;
4 787a4489 KangIngu
using KCOMDataModel;
5
using KCOMDataModel.DataModel;
6 b0fb3ad7 ljiyeon
using MarkupToPDF.Common;
7 5529d2a2 humkyung
using MarkupToPDF.Controls.Parsing;
8 b0fb3ad7 ljiyeon
using MarkupToPDF.Serialize.Core;
9
using MarkupToPDF.Serialize.S_Control;
10 787a4489 KangIngu
using System;
11
using System.Collections.Generic;
12 264c9309 ljiyeon
using System.ComponentModel;
13
using System.Diagnostics;
14 6707a5c7 ljiyeon
using System.IO;
15 787a4489 KangIngu
using System.Linq;
16 264c9309 ljiyeon
using System.Net;
17
using System.Reflection;
18 71bfd53e ljiyeon
using System.Runtime.InteropServices;
19 787a4489 KangIngu
using System.Text;
20 264c9309 ljiyeon
using System.Threading;
21
using System.Threading.Tasks;
22 787a4489 KangIngu
using System.Windows;
23
using System.Windows.Controls;
24
using System.Windows.Data;
25
using System.Windows.Documents;
26
using System.Windows.Input;
27
using System.Windows.Media;
28
using System.Windows.Media.Imaging;
29
using System.Windows.Navigation;
30
using System.Windows.Shapes;
31 6707a5c7 ljiyeon
using System.Xml;
32 992a98b4 KangIngu
using Telerik.Windows.Controls;
33 7e2d29a0 ljiyeon
using WinInterop = System.Windows.Interop;
34 787a4489 KangIngu
35
namespace KCOM
36
{
37
    /// <summary>
38
    /// MainWindow.xaml에 대한 상호 작용 논리
39
    /// </summary>
40
    public partial class MainWindow : Window
41
    {
42 32af2c3b djkim
        bool isSaveCheck = false;
43 310eff8b djkim
        
44 32af2c3b djkim
        ProgressControl progressControl = null;
45
        string destfilepath = string.Empty;
46 b10671a4 taeseongkim
        static MainWindow()
47
        {
48
            StyleManager.ApplicationTheme = new VisualStudio2013Theme();
49
            RadRibbonWindow.IsWindowsThemeEnabled = false;
50
        }
51 32af2c3b djkim
52 787a4489 KangIngu
        public MainWindow()
53
        {
54 e0cfc73c ljiyeon
            App.splashString(ISplashMessage.MAINWINDOW);
55 787a4489 KangIngu
            this.Loaded += MainWindow_Loaded;
56
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
57 7e2d29a0 ljiyeon
            this.SourceInitialized += new EventHandler(win_SourceInitialized);
58 787a4489 KangIngu
        }
59 ca16abb2 ljiyeon
60
        public static BitmapImage CursorChange()
61
        {
62
            BitmapImage bmp = new BitmapImage();
63
            bmp.BeginInit();
64
            bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
65
            return bmp;
66
        }
67
68 787a4489 KangIngu
        public void DialogMessage_Alert(string content, string header)
69
        {
70
            Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
71
            {
72 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
73 0d32593b ljiyeon
                Content = new TextBlock()
74
                { 
75
                    MinWidth = 400,
76
                    FontSize = 12,
77
                    Text = content,
78
                    TextWrapping = System.Windows.TextWrapping.Wrap
79
                },
80 787a4489 KangIngu
                Header = header,
81
                Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
82
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
83
            };
84
            Telerik.Windows.Controls.RadWindow.Alert(parameters);
85
        }
86 7e2d29a0 ljiyeon
87 787a4489 KangIngu
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
88
        {
89 0c997b99 ljiyeon
            InitializeComponent();
90 3d31db34 송근호
            
91 ca16abb2 ljiyeon
            //cursor change  
92
            this.Cursor = new Cursor(CursorChange().StreamSource);
93
94 787a4489 KangIngu
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
95
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
96 9f473fb7 KangIngu
            //this.Width += 40;
97 787a4489 KangIngu
            double windowWidth = this.Width;
98
            double windowHeight = this.Height;
99
            this.Left = (screenWidth / 2) - (windowWidth / 2);
100
            this.Top = (screenHeight / 2) - (windowHeight / 2);
101
102
            ViewerDataModel.Instance.SystemMain = this;
103
104
            if (!App.ParameterMode)
105
            {
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
                //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
119
120 7e2d29a0 ljiyeon
                //#if DEBUG
121
                //                App.ViewInfo = new IKCOM.ViewInfo
122
                //                {
123
                //                    DocumentItemID = "11111112",
124
                //                    //DocumentItemID = "10001",
125
                //                    bPartner = false,
126
                //                    CreateFinalPDFPermission = true,
127
                //                    NewCommentPermission = true,
128
                //                    ProjectNO = "000000",
129
                //                    UserID = "H2011357",
130
                //                    //UserID = "H2009115",
131
                //                    //Mode = 0 , 1 , 2
132
                //                };
133
                //                App.ParameterMode = true;
134
                //                this.dzMainMenu.ServiceOn();
135
                //                this.dzMainMenu.SetView(App.ViewInfo);
136
                //#else
137 787a4489 KangIngu
138
                DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
139
                this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
140
                this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
141
                this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
142
                this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
143
                this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
144 7e2d29a0 ljiyeon
                //#endif
145 787a4489 KangIngu
            }
146
            else
147
            {
148
                this.dzMainMenu.ServiceOn();
149 992a98b4 KangIngu
150
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
151
                {
152
                    this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
153
                    var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
154
                    list.ForEach(item => item.Visibility = Visibility.Collapsed);
155
                    this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
156
                    this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
157 e0204db0 djkim
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
158
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
159
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
160 992a98b4 KangIngu
                }
161 3d31db34 송근호
162
                try
163
                {
164
                    this.dzMainMenu.HubSet();
165
                    this.dzMainMenu.SetView(App.ViewInfo);
166
                }
167 3724d2a2 송근호
                catch (Exception)
168 3d31db34 송근호
                {
169 3724d2a2 송근호
                    MessageBox.Show("웹 서비스에 연결을 할 수 없습니다.");
170
171
                    System.Environment.Exit(0);
172 3d31db34 송근호
                }
173 787a4489 KangIngu
            }
174 6707a5c7 ljiyeon
175 787a4489 KangIngu
            //App.ViewInfo = new IKCOM.ViewInfo
176
            //{
177
            //    DocumentItemID = "11111112",
178
            //    //DocumentItemID = "10001",
179
            //    bPartner = false,
180
            //    CreateFinalPDFPermission = true,
181
            //    NewCommentPermission = true,
182
            //    ProjectNO = "000000",
183
            //    UserID = "H2011357",
184
            //    //UserID = "H2009115",
185
            //    //Mode = 0 , 1 , 2
186
            //};
187
188
            //this.dzMainMenu.ServiceOn();
189
            //this.dzMainMenu.SetView(App.ViewInfo);
190
        }
191 6707a5c7 ljiyeon
192 3d31db34 송근호
      
193 7e2d29a0 ljiyeon
        bool restoreIfMove = false;
194 71bfd53e ljiyeon
195 787a4489 KangIngu
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
196
        {
197 32af2c3b djkim
            if(string.IsNullOrEmpty(destfilepath))
198 787a4489 KangIngu
            {
199 264c9309 ljiyeon
                if (e.ClickCount == 2)
200 787a4489 KangIngu
                {
201 264c9309 ljiyeon
                    if ((ResizeMode == ResizeMode.CanResize) ||
202
                        (ResizeMode == ResizeMode.CanResizeWithGrip))
203
                    {
204
                        SwitchState();
205
                    }
206 787a4489 KangIngu
                }
207 264c9309 ljiyeon
                else
208 71bfd53e ljiyeon
                {
209 264c9309 ljiyeon
                    if (WindowState == WindowState.Maximized)
210
                    {
211
                        restoreIfMove = true;
212
                    }
213 3933072f ljiyeon
214 264c9309 ljiyeon
                    this.DragMove();
215
                }
216
            }            
217 3d31db34 송근호
        }   
218 787a4489 KangIngu
219 71bfd53e ljiyeon
        private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
220
        {
221
            restoreIfMove = false;
222
        }
223
224
        private void WindowDragEventMove(object sender, MouseEventArgs e)
225
        {
226
            if (restoreIfMove)
227
            {
228
                if (Mouse.LeftButton == MouseButtonState.Pressed)
229
                {
230 3933072f ljiyeon
                    //this.WindowState = WindowState.Normal;
231
232 71bfd53e ljiyeon
                    restoreIfMove = false;
233
234
                    double percentHorizontal = e.GetPosition(this).X / ActualWidth;
235
                    double targetHorizontal = RestoreBounds.Width * percentHorizontal;
236
237
                    double percentVertical = e.GetPosition(this).Y / ActualHeight;
238
                    double targetVertical = RestoreBounds.Height * percentVertical;
239
240
                    POINT lMousePosition;
241 7e2d29a0 ljiyeon
                    GetCursorPos(out lMousePosition);
242 71bfd53e ljiyeon
243
                    Left = lMousePosition.X - targetHorizontal;
244 7e2d29a0 ljiyeon
                    double top = lMousePosition.Y - targetVertical;
245
                    if(top < 10)
246
                    {
247
                        top = 10;
248
                    }
249
                    Top = lMousePosition.Y;
250 71bfd53e ljiyeon
251 3933072f ljiyeon
252 71bfd53e ljiyeon
                    WindowState = WindowState.Normal;
253
254
                    this.DragMove();
255
                }
256
            }
257
        }
258
259
        [DllImport("user32.dll")]
260
        [return: MarshalAs(UnmanagedType.Bool)]
261
        static extern bool GetCursorPos(out POINT lpPoint);
262
263
        [StructLayout(LayoutKind.Sequential)]
264
        public struct POINT
265
        {
266
            public int X;
267
            public int Y;
268
269
            public POINT(int x, int y)
270
            {
271
                this.X = x;
272
                this.Y = y;
273
            }
274
        }
275
276
        private void SwitchState()
277
        {
278
            switch (WindowState)
279
            {
280
                case WindowState.Normal:
281
                    {
282
                        WindowState = WindowState.Maximized;
283
                        break;
284
                    }
285
                case WindowState.Maximized:
286
                    {
287
                        WindowState = WindowState.Normal;
288
                        break;
289
                    }
290
            }
291
        }
292
293 787a4489 KangIngu
        private void RadButton_Click(object sender, RoutedEventArgs e)
294
        {
295
            Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
296
297
            switch (button.CommandParameter.ToString())
298
            {
299
                case ("Min"):
300
                    {
301
                        WindowState = WindowState.Minimized;
302
                    }
303
                    break;
304
                case ("Max"):
305
                    {
306
                        WindowState = WindowState.Maximized;
307
                    }
308
                    break;
309
                case ("Exit"):
310
                    {
311
312
                    }
313
                    break;
314
            }
315
        }
316
317
        private void WinState(object sender, MouseButtonEventArgs e)
318
        {
319 af177ca1 djkim
            switch ((e.Source as Image).Name)
320 787a4489 KangIngu
            {
321 af177ca1 djkim
                case ("Win_min"):
322 787a4489 KangIngu
                    {
323
                        WindowState = WindowState.Minimized;
324
                    }
325
                    break;
326 af177ca1 djkim
                case ("Win_max"):
327 787a4489 KangIngu
                    {
328 af177ca1 djkim
                        if (WindowState == WindowState.Maximized)
329
                        {
330 787a4489 KangIngu
                            WindowState = WindowState.Normal;
331 af177ca1 djkim
                        }
332 787a4489 KangIngu
                        else
333 af177ca1 djkim
                        {
334 787a4489 KangIngu
                            WindowState = WindowState.Maximized;
335 af177ca1 djkim
                        }
336 787a4489 KangIngu
                    }
337
                    break;
338 af177ca1 djkim
                case ("Win_Close"):
339 787a4489 KangIngu
                    {
340 32af2c3b djkim
                        SaveCheck();
341 310eff8b djkim
                        //Update Check 를 통해 update url 을 Get 하고 결과값이 있을 경우에는 SmartUpdater 실행.
342
                        KeyValuePair<bool, string> updatecheck = UpdateCheck();
343
                        if (updatecheck.Key && !string.IsNullOrEmpty(updatecheck.Value))
344 69ef0800 KangIngu
                        {
345 310eff8b djkim
                            CallUpdateProcess(updatecheck.Value);
346 316d0f5c KangIngu
                        }
347 310eff8b djkim
                        this.Close();
348 787a4489 KangIngu
                    }
349
                    break;
350
            }
351
        }
352 32af2c3b djkim
        
353
        private void SaveCheck()
354 264c9309 ljiyeon
        {
355 32af2c3b djkim
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
356
            {
357
                DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
358
                DateTime updatetime = DateTime.Now.AddDays(-1);
359
                if (ViewerDataModel.Instance._markupInfoList.Count > 0)
360
                {
361
                    updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
362
                }
363 264c9309 ljiyeon
364 32af2c3b djkim
                if (undoTime > updatetime)
365
                {
366
                    DialogParameters parameters = new DialogParameters()
367
                    {
368
                        Owner = Application.Current.MainWindow,
369 0d32593b ljiyeon
                        Content = new TextBlock()
370
                        {
371
                            MinWidth = 400,
372
                            FontSize = 11,
373
                            Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?",
374
                            TextWrapping = System.Windows.TextWrapping.Wrap
375
                        },
376 32af2c3b djkim
                        Header = "Confirm",
377
                        Theme = new VisualStudio2013Theme(),
378
                        ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
379
                        Closed = OnClosingSave,
380
                    };
381
                    RadWindow.Confirm(parameters);
382
                }
383
                else
384
                {
385
                    isSaveCheck = true;
386
                }                    
387
            }else
388 264c9309 ljiyeon
            {
389 32af2c3b djkim
                isSaveCheck = true;
390 264c9309 ljiyeon
            }
391
        }
392 32af2c3b djkim
        private void OnClosingSave(object sender, WindowClosedEventArgs e)
393
        {
394
            if (e.DialogResult == true)
395
            {
396
                dzTopMenu.SaveEventCallback(null, null);
397
            }
398
            isSaveCheck = true;
399
        }
400
                
401
        private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
402
        {
403
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
404
            {
405
                double bytesIn = double.Parse(e.BytesReceived.ToString());
406
                double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
407
                double percentage = bytesIn / totalBytes * 100;
408
                progressControl.splashText.Text = "Download : " + Math.Truncate(percentage).ToString() + " %";
409
                progressControl.progressBar.Value = int.Parse(Math.Truncate(percentage).ToString());                
410
            }));
411 310eff8b djkim
        }
412
413
        /// <summary>
414
        /// KCOM_API 를 통해 업데이트 URL 을 가져옴.
415
        /// false : 업데이트 불필요.
416
        /// true : 업데이트 필요. url 을 같이 Return.
417
        /// </summary>
418
        /// <returns></returns>
419
        private KeyValuePair<bool, string> UpdateCheck()
420 264c9309 ljiyeon
        {
421 310eff8b djkim
            bool isUpdateCheck = false;
422
            string updateurl = string.Empty;
423 264c9309 ljiyeon
            try
424
            {
425 ffddbe4e djkim
                bool is64bit = Environment.Is64BitProcess;
426
                string clientversion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
427
                updateurl = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetVersionData(is64bit, clientversion);
428 d71b4688 ljiyeon
                
429 ffddbe4e djkim
                if (Check_Uri.isUri(updateurl))
430 97cde7e3 ljiyeon
                {                          
431 32af2c3b djkim
                    DialogParameters parameters = new DialogParameters()
432 264c9309 ljiyeon
                    {
433 32af2c3b djkim
                        Owner = Application.Current.MainWindow,
434 97cde7e3 ljiyeon
                        Content = new TextBlock()
435
                        {
436
                            MinWidth = 400,
437
                            FontSize = 11,
438
                            Text = "새로운 버전이 있습니다. \n업데이트 하시겠습니까?",
439
                            TextWrapping = System.Windows.TextWrapping.Wrap
440
                        },
441 32af2c3b djkim
                        Header = "Confirm",
442
                        Theme = new VisualStudio2013Theme(),
443
                        ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },                        
444
                        Closed = delegate (object windowSender, WindowClosedEventArgs e)
445 264c9309 ljiyeon
                        {
446 32af2c3b djkim
                            if (e.DialogResult == true)
447 310eff8b djkim
                            {   
448 ffddbe4e djkim
                                isUpdateCheck = true;                                
449 97cde7e3 ljiyeon
                            }
450
                            else
451 32af2c3b djkim
                            {
452 310eff8b djkim
                                isUpdateCheck = false;
453 32af2c3b djkim
                            }                            
454
                        }                    
455
                    };
456 97cde7e3 ljiyeon
                    RadWindow.Confirm(parameters);       
457
                    
458 264c9309 ljiyeon
                }
459
                else
460
                {
461 310eff8b djkim
                    isUpdateCheck = false;
462 264c9309 ljiyeon
                }
463
            }
464
            catch (Exception)
465
            {
466 32af2c3b djkim
                throw;
467 310eff8b djkim
            }
468
            return new KeyValuePair<bool, string>(isUpdateCheck, updateurl);
469 264c9309 ljiyeon
        }
470
471 310eff8b djkim
        /// <summary>
472
        /// SmartUpdate 를 호출.
473
        /// </summary>
474
        /// <param name="updateurl">Download 할 설치파일 경로</param>
475
        private void CallUpdateProcess(string updateurl)
476
        {
477
            ProcessStartInfo proInfo = new ProcessStartInfo();
478
            string smartupdaterpath = string.Empty;
479
            smartupdaterpath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SmartUpdate.exe");
480
            Process.Start(smartupdaterpath, updateurl);
481
        }
482 32af2c3b djkim
        private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
483
        {
484 264c9309 ljiyeon
            try
485
            {
486 32af2c3b djkim
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
487
                {
488
                    progressControl.splashText.Text = "Download Completed";
489
                }));                
490
                if(progressControl != null)
491
                {
492
                    progressControl.Close();
493
                    progressControl = null;
494
                }
495
                if(File.Exists(destfilepath))
496
                {
497
                    ProcessStartInfo update_msi = new ProcessStartInfo();
498
                    update_msi.FileName = destfilepath;
499
                    Process.Start(update_msi);
500
                }                
501
                this.Close();
502 264c9309 ljiyeon
            }
503 32af2c3b djkim
            catch (Exception)
504 69ef0800 KangIngu
            {
505 32af2c3b djkim
                throw;
506 69ef0800 KangIngu
            }
507 32af2c3b djkim
            
508 69ef0800 KangIngu
        }
509 7e2d29a0 ljiyeon
510
        void win_SourceInitialized(object sender, EventArgs e)
511
        {
512
            System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle;
513
            WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc));
514
        }
515
516
        private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
517
        {
518
            switch (msg)
519
            {
520
                case 0x0024:
521
                    WmGetMinMaxInfo(hwnd, lParam);
522 b0fb3ad7 ljiyeon
                    handled = true;
523 7e2d29a0 ljiyeon
                    break;
524
            }
525
            return (System.IntPtr)0;
526
        }
527
528
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
529
        {
530
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
531
            int MONITOR_DEFAULTTONEAREST = 0x00000002;
532
            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
533
534
            if (monitor != System.IntPtr.Zero)
535
            {
536
                MONITORINFO monitorInfo = new MONITORINFO();
537
                GetMonitorInfo(monitor, monitorInfo);
538
                RECT rcWorkArea = monitorInfo.rcWork;
539
                RECT rcMonitorArea = monitorInfo.rcMonitor;
540
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
541
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
542
                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
543
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
544
            }
545
            Marshal.StructureToPtr(mmi, lParam, true);
546
        }
547
548
        [StructLayout(LayoutKind.Sequential)]
549
        public struct POINT2
550
        {
551
            public int x;
552
            public int y;
553
            public POINT2(int x, int y)
554
            {
555
                this.x = x;
556
                this.y = y;
557
            }
558
        }
559
560
        [StructLayout(LayoutKind.Sequential)]
561
        public struct MINMAXINFO
562
        {
563
            public POINT2 ptReserved;
564
            public POINT2 ptMaxSize;
565
            public POINT2 ptMaxPosition;
566
            public POINT2 ptMinTrackSize;
567
            public POINT2 ptMaxTrackSize;
568
        };
569
570
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
571
        public class MONITORINFO
572 b0fb3ad7 ljiyeon
        {
573
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
574
            public RECT rcMonitor = new RECT();
575
            public RECT rcWork = new RECT();
576 7e2d29a0 ljiyeon
            public int dwFlags = 0;
577
        }
578
579
        [StructLayout(LayoutKind.Sequential, Pack = 0)]
580
        public struct RECT
581
        {
582
            public int left;
583
            public int top;
584 b0fb3ad7 ljiyeon
            public int right;
585 7e2d29a0 ljiyeon
            public int bottom;
586
587
            public static readonly RECT Empty = new RECT();
588
589
            public int Width
590
            {
591
                get { return Math.Abs(right - left); }  // Abs needed for BIDI OS
592
            }
593
594
            public int Height
595
            {
596
                get { return bottom - top; }
597
            }
598
599
            public RECT(int left, int top, int right, int bottom)
600
            {
601
                this.left = left;
602
                this.top = top;
603
                this.right = right;
604
                this.bottom = bottom;
605
            }
606
607
            public RECT(RECT rcSrc)
608
            {
609
                this.left = rcSrc.left;
610
                this.top = rcSrc.top;
611
                this.right = rcSrc.right;
612
                this.bottom = rcSrc.bottom;
613
            }
614
615
            public bool IsEmpty
616
            {
617
                get
618
                {
619
                    // BUGBUG : On Bidi OS (hebrew arabic) left > right
620
                    return left >= right || top >= bottom;
621
                }
622
            }
623
624
            public override bool Equals(object obj)
625
            {
626
                if (!(obj is Rect)) { return false; }
627
                return (this == (RECT)obj);
628
            }
629
630
            public override int GetHashCode()
631
            {
632
                return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode();
633
            }
634
635
            public static bool operator ==(RECT rect1, RECT rect2)
636
            {
637
                return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom);
638
            }
639
640
            public static bool operator !=(RECT rect1, RECT rect2)
641
            {
642
                return !(rect1 == rect2);
643
            }
644
        }
645
646
        [DllImport("user32")]
647
        internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
648
        [DllImport("User32")]
649
        internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
650 787a4489 KangIngu
    }
651
}