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