markus / KCOM / MainWindow.xaml.cs @ df2e7646
이력 | 보기 | 이력해설 | 다운로드 (23.6 KB)
1 |
using KCOM.Common; |
---|---|
2 |
using KCOM.Controls; |
3 |
using KCOM.Views; |
4 |
using KCOMDataModel; |
5 |
using KCOMDataModel.DataModel; |
6 |
using MarkupToPDF.Common; |
7 |
using MarkupToPDF.Controls.Parsing; |
8 |
using MarkupToPDF.Serialize.Core; |
9 |
using MarkupToPDF.Serialize.S_Control; |
10 |
using System; |
11 |
using System.Collections.Generic; |
12 |
using System.ComponentModel; |
13 |
using System.Diagnostics; |
14 |
using System.IO; |
15 |
using System.Linq; |
16 |
using System.Net; |
17 |
using System.Reflection; |
18 |
using System.Runtime.InteropServices; |
19 |
using System.Text; |
20 |
using System.Threading; |
21 |
using System.Threading.Tasks; |
22 |
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 |
using System.Xml; |
32 |
using Telerik.Windows.Controls; |
33 |
using WinInterop = System.Windows.Interop; |
34 | |
35 |
namespace KCOM |
36 |
{ |
37 |
/// <summary> |
38 |
/// MainWindow.xaml에 대한 상호 작용 논리 |
39 |
/// </summary> |
40 |
public partial class MainWindow : Window |
41 |
{ |
42 |
bool isSaveCheck = false; |
43 |
|
44 |
ProgressControl progressControl = null; |
45 |
string destfilepath = string.Empty; |
46 |
static MainWindow() |
47 |
{ |
48 |
StyleManager.ApplicationTheme = new VisualStudio2013Theme(); |
49 |
RadRibbonWindow.IsWindowsThemeEnabled = false; |
50 |
} |
51 | |
52 |
public MainWindow() |
53 |
{ |
54 |
App.splashString(ISplashMessage.MAINWINDOW); |
55 |
this.Loaded += MainWindow_Loaded; |
56 |
this.KeyDown += new KeyEventHandler(KeyEventDownAction); |
57 |
this.SourceInitialized += new EventHandler(win_SourceInitialized); |
58 |
} |
59 | |
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 |
public void DialogMessage_Alert(string content, string header) |
69 |
{ |
70 |
Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters() |
71 |
{ |
72 |
Owner = Application.Current.MainWindow, |
73 |
Content = new TextBlock() |
74 |
{ |
75 |
MinWidth = 400, |
76 |
FontSize = 12, |
77 |
Text = content, |
78 |
TextWrapping = System.Windows.TextWrapping.Wrap |
79 |
}, |
80 |
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 | |
87 |
private void MainWindow_Loaded(object sender, RoutedEventArgs e) |
88 |
{ |
89 |
InitializeComponent(); |
90 |
|
91 |
//cursor change |
92 |
this.Cursor = new Cursor(CursorChange().StreamSource); |
93 | |
94 |
double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; |
95 |
double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight; |
96 |
//this.Width += 40; |
97 |
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 |
//#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 | |
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 |
//#endif |
145 |
} |
146 |
else |
147 |
{ |
148 |
this.dzMainMenu.ServiceOn(); |
149 | |
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 |
//this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed; |
158 |
//this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed; |
159 |
//this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false; |
160 |
} |
161 | |
162 |
try |
163 |
{ |
164 |
this.dzMainMenu.HubSet(); |
165 |
this.dzMainMenu.SetView(App.ViewInfo); |
166 |
} |
167 |
catch (Exception) |
168 |
{ |
169 |
MessageBox.Show("웹 서비스에 연결을 할 수 없습니다."); |
170 | |
171 |
System.Environment.Exit(0); |
172 |
} |
173 |
} |
174 | |
175 |
//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 | |
192 |
|
193 |
bool restoreIfMove = false; |
194 | |
195 |
private void WindowDragEvent(object sender, MouseButtonEventArgs e) |
196 |
{ |
197 |
if(string.IsNullOrEmpty(destfilepath)) |
198 |
{ |
199 |
if (e.ClickCount == 2) |
200 |
{ |
201 |
if ((ResizeMode == ResizeMode.CanResize) || |
202 |
(ResizeMode == ResizeMode.CanResizeWithGrip)) |
203 |
{ |
204 |
SwitchState(); |
205 |
} |
206 |
} |
207 |
else |
208 |
{ |
209 |
if (WindowState == WindowState.Maximized) |
210 |
{ |
211 |
restoreIfMove = true; |
212 |
} |
213 | |
214 |
this.DragMove(); |
215 |
} |
216 |
} |
217 |
} |
218 | |
219 |
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 |
//this.WindowState = WindowState.Normal; |
231 | |
232 |
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 |
GetCursorPos(out lMousePosition); |
242 | |
243 |
Left = lMousePosition.X - targetHorizontal; |
244 |
double top = lMousePosition.Y - targetVertical; |
245 |
if(top < 10) |
246 |
{ |
247 |
top = 10; |
248 |
} |
249 |
Top = lMousePosition.Y; |
250 | |
251 | |
252 |
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 |
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 |
switch ((e.Source as Image).Name) |
320 |
{ |
321 |
case ("Win_min"): |
322 |
{ |
323 |
WindowState = WindowState.Minimized; |
324 |
} |
325 |
break; |
326 |
case ("Win_max"): |
327 |
{ |
328 |
if (WindowState == WindowState.Maximized) |
329 |
{ |
330 |
WindowState = WindowState.Normal; |
331 |
} |
332 |
else |
333 |
{ |
334 |
WindowState = WindowState.Maximized; |
335 |
} |
336 |
} |
337 |
break; |
338 |
case ("Win_Close"): |
339 |
{ |
340 |
SaveCheck(); |
341 |
//Update Check 를 통해 update url 을 Get 하고 결과값이 있을 경우에는 SmartUpdater 실행. |
342 |
KeyValuePair<bool, string> updatecheck = UpdateCheck(); |
343 |
if (updatecheck.Key && !string.IsNullOrEmpty(updatecheck.Value)) |
344 |
{ |
345 |
CallUpdateProcess(updatecheck.Value); |
346 |
} |
347 |
this.Close(); |
348 |
} |
349 |
break; |
350 |
} |
351 |
} |
352 |
|
353 |
private void SaveCheck() |
354 |
{ |
355 |
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 | |
364 |
if (undoTime > updatetime) |
365 |
{ |
366 |
DialogParameters parameters = new DialogParameters() |
367 |
{ |
368 |
Owner = Application.Current.MainWindow, |
369 |
Content = new TextBlock() |
370 |
{ |
371 |
MinWidth = 400, |
372 |
FontSize = 11, |
373 |
Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?", |
374 |
TextWrapping = System.Windows.TextWrapping.Wrap |
375 |
}, |
376 |
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 |
{ |
389 |
isSaveCheck = true; |
390 |
} |
391 |
} |
392 |
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 |
} |
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 |
{ |
421 |
bool isUpdateCheck = false; |
422 |
string updateurl = string.Empty; |
423 |
try |
424 |
{ |
425 |
bool is64bit = Environment.Is64BitProcess; |
426 |
string clientversion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
427 |
updateurl = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetVersionData(is64bit, clientversion); |
428 |
|
429 |
if (Check_Uri.isUri(updateurl)) |
430 |
{ |
431 |
DialogParameters parameters = new DialogParameters() |
432 |
{ |
433 |
Owner = Application.Current.MainWindow, |
434 |
Content = new TextBlock() |
435 |
{ |
436 |
MinWidth = 400, |
437 |
FontSize = 11, |
438 |
Text = "새로운 버전이 있습니다. \n업데이트 하시겠습니까?", |
439 |
TextWrapping = System.Windows.TextWrapping.Wrap |
440 |
}, |
441 |
Header = "Confirm", |
442 |
Theme = new VisualStudio2013Theme(), |
443 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
444 |
Closed = delegate (object windowSender, WindowClosedEventArgs e) |
445 |
{ |
446 |
if (e.DialogResult == true) |
447 |
{ |
448 |
isUpdateCheck = true; |
449 |
} |
450 |
else |
451 |
{ |
452 |
isUpdateCheck = false; |
453 |
} |
454 |
} |
455 |
}; |
456 |
RadWindow.Confirm(parameters); |
457 |
|
458 |
} |
459 |
else |
460 |
{ |
461 |
isUpdateCheck = false; |
462 |
} |
463 |
} |
464 |
catch (Exception) |
465 |
{ |
466 |
throw; |
467 |
} |
468 |
return new KeyValuePair<bool, string>(isUpdateCheck, updateurl); |
469 |
} |
470 | |
471 |
/// <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 |
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) |
483 |
{ |
484 |
try |
485 |
{ |
486 |
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 |
} |
503 |
catch (Exception) |
504 |
{ |
505 |
throw; |
506 |
} |
507 |
|
508 |
} |
509 | |
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 |
handled = true; |
523 |
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 |
{ |
573 |
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); |
574 |
public RECT rcMonitor = new RECT(); |
575 |
public RECT rcWork = new RECT(); |
576 |
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 |
public int right; |
585 |
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 |
} |
651 |
} |