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