markus / KCOM / MainWindow.xaml.cs @ 5c5e04cc
이력 | 보기 | 이력해설 | 다운로드 (19.7 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 | 68302e9d | taeseongkim | public partial class MainWindow : KCOM.Controls.CustomizedWindow.CustomWindow |
41 | 787a4489 | KangIngu | { |
42 | 32af2c3b | djkim | bool isSaveCheck = false; |
43 | d33ef543 | taeseongkim | |
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 | c362d2a5 | taeseongkim | |
51 | 787a4489 | KangIngu | this.Loaded += MainWindow_Loaded; |
52 | eeb0a39c | taeseongkim | this.Unloaded += MainWindow_Unloaded; |
53 | d97dbc7f | taeseongkim | this.Activated += MainWindow_Activated; |
54 | } |
||
55 | 9d5b4bc2 | taeseongkim | |
56 | 2007ecaa | taeseongkim | |
57 | d97dbc7f | taeseongkim | private void MainWindow_Activated(object sender, EventArgs e) |
58 | { |
||
59 | this.Topmost = true; |
||
60 | 448c5399 | taeseongkim | this.Topmost = false; |
61 | 787a4489 | KangIngu | } |
62 | ca16abb2 | ljiyeon | |
63 | eeb0a39c | taeseongkim | private void MainWindow_Unloaded(object sender, RoutedEventArgs e) |
64 | { |
||
65 | } |
||
66 | |||
67 | 787a4489 | KangIngu | public void DialogMessage_Alert(string content, string header) |
68 | { |
||
69 | c362d2a5 | taeseongkim | App.splashScreen.Close(); |
70 | |||
71 | 787a4489 | KangIngu | Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters() |
72 | { |
||
73 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
74 | 0d32593b | ljiyeon | Content = new TextBlock() |
75 | d33ef543 | taeseongkim | { |
76 | 0d32593b | ljiyeon | MinWidth = 400, |
77 | FontSize = 12, |
||
78 | Text = content, |
||
79 | TextWrapping = System.Windows.TextWrapping.Wrap |
||
80 | }, |
||
81 | 787a4489 | KangIngu | Header = header, |
82 | Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(), |
||
83 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
84 | }; |
||
85 | Telerik.Windows.Controls.RadWindow.Alert(parameters); |
||
86 | } |
||
87 | 7e2d29a0 | ljiyeon | |
88 | a197bf6f | taeseongkim | private async void MainWindow_Loaded(object sender, RoutedEventArgs e) |
89 | 787a4489 | KangIngu | { |
90 | 0c997b99 | ljiyeon | InitializeComponent(); |
91 | f44e0cd0 | 이지연 | //Loaded 이벤트에서 MaxHeight를 설정 모니터가 1개일때만 |
92 | //MaxHeight = SystemParameters.WorkArea.Height; |
||
93 | //LocationChanged : 모니터가 2개 이상이고, 모니터의 해상도가 다를 때에 설정 |
||
94 | e550eccb | 이지연 | //20240610 LJY 화면 넘어갈때 이슈로 주석 |
95 | //this.LocationChanged += Window_LocationChanged; |
||
96 | ca16abb2 | ljiyeon | //cursor change |
97 | 902faaea | taeseongkim | this.Cursor = new Cursor(App.DefaultArrowCursorStream); |
98 | ca16abb2 | ljiyeon | |
99 | d33ef543 | taeseongkim | var point = GetScreenCenter(); |
100 | |||
101 | c362d2a5 | taeseongkim | //this.Left = point.X; |
102 | //this.Top = point.Y; |
||
103 | 787a4489 | KangIngu | |
104 | ViewerDataModel.Instance.SystemMain = this; |
||
105 | |||
106 | if (!App.ParameterMode) |
||
107 | { |
||
108 | //App.ViewInfo = new IKCOM.ViewInfo |
||
109 | //{ |
||
110 | // DocumentItemID = "11111112", |
||
111 | // //DocumentItemID = "10001", |
||
112 | // bPartner = false, |
||
113 | // CreateFinalPDFPermission = true, |
||
114 | // NewCommentPermission = true, |
||
115 | // ProjectNO = "000000", |
||
116 | // UserID = "H2011357", |
||
117 | // //UserID = "H2009115", |
||
118 | // //Mode = 0 , 1 , 2 |
||
119 | //}; |
||
120 | //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내"); |
||
121 | |||
122 | 7e2d29a0 | ljiyeon | //#if DEBUG |
123 | // App.ViewInfo = new IKCOM.ViewInfo |
||
124 | // { |
||
125 | // DocumentItemID = "11111112", |
||
126 | // //DocumentItemID = "10001", |
||
127 | // bPartner = false, |
||
128 | // CreateFinalPDFPermission = true, |
||
129 | // NewCommentPermission = true, |
||
130 | // ProjectNO = "000000", |
||
131 | // UserID = "H2011357", |
||
132 | // //UserID = "H2009115", |
||
133 | // //Mode = 0 , 1 , 2 |
||
134 | // }; |
||
135 | // App.ParameterMode = true; |
||
136 | // this.dzMainMenu.ServiceOn(); |
||
137 | // this.dzMainMenu.SetView(App.ViewInfo); |
||
138 | //#else |
||
139 | 787a4489 | KangIngu | |
140 | DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내"); |
||
141 | this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed; |
||
142 | this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed; |
||
143 | this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed; |
||
144 | this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed; |
||
145 | this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed; |
||
146 | 7e2d29a0 | ljiyeon | //#endif |
147 | 787a4489 | KangIngu | } |
148 | else |
||
149 | { |
||
150 | 43e1d368 | taeseongkim | this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed; |
151 | 787a4489 | KangIngu | this.dzMainMenu.ServiceOn(); |
152 | 992a98b4 | KangIngu | |
153 | if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) |
||
154 | { |
||
155 | this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed; |
||
156 | var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList(); |
||
157 | list.ForEach(item => item.Visibility = Visibility.Collapsed); |
||
158 | this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible; |
||
159 | this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly; |
||
160 | } |
||
161 | a197bf6f | taeseongkim | else |
162 | { |
||
163 | string signData = await this.dzMainMenu.BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID); |
||
164 | string signStrokes = await this.dzMainMenu.BaseTaskClient.GetSignStrokesAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID); |
||
165 | |||
166 | if (signData != null && signStrokes != null) |
||
167 | { |
||
168 | MarkupToPDF.MarkupContext.SetUserSignItem(App.ViewInfo.UserID, signData, signStrokes); |
||
169 | } |
||
170 | else |
||
171 | { |
||
172 | SignManager signManager = new SignManager(); |
||
173 | |||
174 | RadWindow signManagerPop = new RadWindow |
||
175 | { |
||
176 | MinWidth = 1200, |
||
177 | MinHeight = 500, |
||
178 | //Header = "My Check List", |
||
179 | Header = "", |
||
180 | Content = signManager, |
||
181 | Owner = this, |
||
182 | //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip, |
||
183 | cda7efcc | taeseongkim | ResizeMode = System.Windows.ResizeMode.NoResize, |
184 | a197bf6f | taeseongkim | WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen, |
185 | }; |
||
186 | StyleManager.SetTheme(signManagerPop, new Office2013Theme()); |
||
187 | |||
188 | //CheckPop.ShowDialog(); |
||
189 | signManagerPop.Show(); |
||
190 | } |
||
191 | } |
||
192 | 3d31db34 | 송근호 | |
193 | try |
||
194 | { |
||
195 | ff01c725 | humkyung | ///this.dzMainMenu.HubSet(); |
196 | 3d31db34 | 송근호 | this.dzMainMenu.SetView(App.ViewInfo); |
197 | } |
||
198 | 5a6493ad | humkyung | catch (Exception ex) |
199 | 3d31db34 | 송근호 | { |
200 | 5a6493ad | humkyung | MessageBox.Show(string.Format("웹 서비스 접속시 에러가 발생했습니다.\n{0}", ex.StackTrace)); |
201 | 3724d2a2 | 송근호 | |
202 | System.Environment.Exit(0); |
||
203 | 3d31db34 | 송근호 | } |
204 | 787a4489 | KangIngu | } |
205 | } |
||
206 | f44e0cd0 | 이지연 | /// <summary> |
207 | /// 멤버 변수로 현 사용자의 모든 모니터들의 상태를 가져온다. |
||
208 | /// Window의 LocationChanged Event를 통해 Window가 이동할 때마다 어떤 모니터에 있는지를 확인 |
||
209 | /// Window가 어떤 모니터에 있는지의 기준은 각 Window의 중앙 부분 |
||
210 | /// Sum 은 모니터들의 왼쪽 끝 부터 오른쪽 끝까지의 합 |
||
211 | /// 현재 Window의 중앙은 Left 값 + Width의 반 |
||
212 | /// um보다 작다면 현재 더하게 된 Screen 안에 있다는 뜻이므로 현재 더한 item의 WorkingArea의 Height를MaxHeight로 설정 |
||
213 | /// </summary> |
||
214 | System.Windows.Forms.Screen[] screens = System.Windows.Forms.Screen.AllScreens; |
||
215 | private void Window_LocationChanged(object sender, EventArgs e) |
||
216 | 0d2d2a08 | 이지연 | { |
217 | int sum = 0; |
||
218 | foreach (var item in screens) |
||
219 | { |
||
220 | sum += item.WorkingArea.Width; |
||
221 | if (sum >= this.Left + this.Width / 2) |
||
222 | { |
||
223 | f44e0cd0 | 이지연 | this.MaxHeight = item.WorkingArea.Height; |
224 | 0d2d2a08 | 이지연 | this.MaxWidth = item.WorkingArea.Width; |
225 | if (this.Left < 0) |
||
226 | { |
||
227 | this.Left = 0; |
||
228 | } |
||
229 | |||
230 | if (this.Top < 0) |
||
231 | { |
||
232 | this.Top = 0; |
||
233 | } |
||
234 | // if(this.Tag.Equals("Normal")) |
||
235 | //{ |
||
236 | // this.WindowState = WindowState.Normal; |
||
237 | // this.CustomState = WindowState.Maximized; |
||
238 | //} |
||
239 | //if (this.CustomState == WindowState.Maximized) |
||
240 | //{ |
||
241 | // this.WindowState = WindowState.Normal; |
||
242 | // this.CustomState = WindowState.Normal; |
||
243 | |||
244 | |||
245 | //} |
||
246 | //else |
||
247 | //{ |
||
248 | // this.WindowState = WindowState.Normal; |
||
249 | // this.CustomState = WindowState.Maximized; |
||
250 | // this.NomalWindowArea = new Rect(this.Left, this.Top, this.Width, this.Height); |
||
251 | |||
252 | //} |
||
253 | break; |
||
254 | } |
||
255 | f44e0cd0 | 이지연 | } |
256 | } |
||
257 | |||
258 | d33ef543 | taeseongkim | private Point GetScreenCenter() |
259 | 787a4489 | KangIngu | { |
260 | d33ef543 | taeseongkim | Point result = new Point(); |
261 | 3933072f | ljiyeon | |
262 | d33ef543 | taeseongkim | //first get all the screens |
263 | System.Drawing.Rectangle ret; |
||
264 | int ScreenWidth = 0; |
||
265 | 787a4489 | KangIngu | |
266 | d33ef543 | taeseongkim | var mousePosition = System.Windows.Forms.Cursor.Position; |
267 | 71bfd53e | ljiyeon | |
268 | d33ef543 | taeseongkim | for (int i = 1; i <= System.Windows.Forms.Screen.AllScreens.Count(); i++) |
269 | 71bfd53e | ljiyeon | { |
270 | d33ef543 | taeseongkim | ret = System.Windows.Forms.Screen.AllScreens[i - 1].Bounds; |
271 | 3933072f | ljiyeon | |
272 | d33ef543 | taeseongkim | if (ret.Contains(mousePosition)) |
273 | { |
||
274 | result.X = ScreenWidth + (ret.Width / 2 - this.Width / 2); |
||
275 | result.Y = (ret.Height / 2 - this.Height / 2); |
||
276 | 71bfd53e | ljiyeon | |
277 | d33ef543 | taeseongkim | break; |
278 | } |
||
279 | else |
||
280 | { |
||
281 | ScreenWidth += ret.Width; |
||
282 | 71bfd53e | ljiyeon | } |
283 | |||
284 | d33ef543 | taeseongkim | } |
285 | 71bfd53e | ljiyeon | |
286 | |||
287 | d33ef543 | taeseongkim | return result; |
288 | 71bfd53e | ljiyeon | } |
289 | |||
290 | d33ef543 | taeseongkim | protected override void OnStateChanged(EventArgs e) |
291 | 71bfd53e | ljiyeon | { |
292 | d33ef543 | taeseongkim | base.OnStateChanged(e); |
293 | 71bfd53e | ljiyeon | } |
294 | |||
295 | d33ef543 | taeseongkim | protected override void OnClosing(CancelEventArgs e) |
296 | 787a4489 | KangIngu | { |
297 | d33ef543 | taeseongkim | base.OnClosing(e); |
298 | cf1cc862 | taeseongkim | |
299 | bae83c92 | taeseongkim | if(!ViewerDataModel.Instance.SaveCheck()) |
300 | 75f6ff19 | taeseongkim | { |
301 | c362d2a5 | taeseongkim | var IsConfirm = SaveConfirm(); |
302 | |||
303 | if (IsConfirm == null) |
||
304 | 75f6ff19 | taeseongkim | { |
305 | e.Cancel = true; |
||
306 | } |
||
307 | c362d2a5 | taeseongkim | else if(IsConfirm == true) |
308 | { |
||
309 | dzTopMenu.SaveEventCallback(null, null); |
||
310 | } |
||
311 | 75f6ff19 | taeseongkim | } |
312 | 787a4489 | KangIngu | |
313 | bae83c92 | taeseongkim | if (App.ViewInfo.CreateFinalPDFPermission) |
314 | { |
||
315 | if (!ViewerDataModel.Instance.FinalPDFCheck()) |
||
316 | { |
||
317 | var result = FinalConfirm(); |
||
318 | |||
319 | 9380813b | swate0609 | if(result == null) |
320 | e.Cancel = true; |
||
321 | |||
322 | bae83c92 | taeseongkim | if (result == false) |
323 | { |
||
324 | e.Cancel = true; |
||
325 | } |
||
326 | else |
||
327 | { |
||
328 | 6a19b48d | taeseongkim | //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveLog(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID, "최종 Merged PDF 안됨."); |
329 | bae83c92 | taeseongkim | } |
330 | } |
||
331 | } |
||
332 | |||
333 | d33ef543 | taeseongkim | //Update Check 를 통해 update url 을 Get 하고 결과값이 있을 경우에는 SmartUpdater 실행. |
334 | 9d5b4bc2 | taeseongkim | //KeyValuePair<bool, string> updatecheck = UpdateCheck(); |
335 | //if (updatecheck.Key && !string.IsNullOrEmpty(updatecheck.Value)) |
||
336 | //{ |
||
337 | // CallUpdateProcess(updatecheck.Value); |
||
338 | //} |
||
339 | 787a4489 | KangIngu | } |
340 | d33ef543 | taeseongkim | |
341 | bae83c92 | taeseongkim | |
342 | private bool? SaveConfirm() |
||
343 | 264c9309 | ljiyeon | { |
344 | bae83c92 | taeseongkim | bool? result = null; |
345 | |||
346 | EventHandler<WindowClosedEventArgs> Closedhandler = null; |
||
347 | 75f6ff19 | taeseongkim | |
348 | bae83c92 | taeseongkim | Closedhandler = (snd, evt) => |
349 | 32af2c3b | djkim | { |
350 | bae83c92 | taeseongkim | result = evt.DialogResult; |
351 | }; |
||
352 | 264c9309 | ljiyeon | |
353 | bae83c92 | taeseongkim | DialogParameters parameters = new DialogParameters() |
354 | { |
||
355 | Content = new TextBlock() |
||
356 | 32af2c3b | djkim | { |
357 | bae83c92 | taeseongkim | MinWidth = 300, |
358 | FontSize = 11, |
||
359 | Text = "Found unsaved comments. Save now?", |
||
360 | TextWrapping = System.Windows.TextWrapping.Wrap |
||
361 | }, |
||
362 | |||
363 | Header = "Confirm", |
||
364 | Theme = new VisualStudio2013Theme(), |
||
365 | ContentStyle = Application.Current.Resources["RadConfirmYNCStyle"] as Style, |
||
366 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
367 | |||
368 | Owner = Application.Current.MainWindow, |
||
369 | Opened = (s, openedEvent) => |
||
370 | 32af2c3b | djkim | { |
371 | bae83c92 | taeseongkim | RadWindow confirm = s as RadWindow; |
372 | //Button Cancel = confirm.ChildrenOfType<Button>()[5]; |
||
373 | //FocusManager.SetIsFocusScope(confirm, true); |
||
374 | //FocusManager.SetFocusedElement(confirm, Cancel); |
||
375 | }, |
||
376 | |||
377 | Closed = Closedhandler |
||
378 | }; |
||
379 | |||
380 | RadWindow.Confirm(parameters); |
||
381 | 75f6ff19 | taeseongkim | |
382 | return result; |
||
383 | 264c9309 | ljiyeon | } |
384 | 75f6ff19 | taeseongkim | |
385 | bae83c92 | taeseongkim | private bool? FinalConfirm() |
386 | 32af2c3b | djkim | { |
387 | bae83c92 | taeseongkim | bool? result = false; |
388 | 75f6ff19 | taeseongkim | |
389 | EventHandler<WindowClosedEventArgs> Closedhandler = null; |
||
390 | |||
391 | Closedhandler = (snd, evt) => |
||
392 | 32af2c3b | djkim | { |
393 | c362d2a5 | taeseongkim | result = evt.DialogResult; |
394 | 75f6ff19 | taeseongkim | }; |
395 | |||
396 | DialogParameters parameters = new DialogParameters() |
||
397 | { |
||
398 | Content = new TextBlock() |
||
399 | { |
||
400 | c362d2a5 | taeseongkim | MinWidth = 300, |
401 | 75f6ff19 | taeseongkim | FontSize = 11, |
402 | bae83c92 | taeseongkim | Text = "Merged PDF가 수행되지 않았습니다. 창을 닫으시겠습니까?", |
403 | 75f6ff19 | taeseongkim | TextWrapping = System.Windows.TextWrapping.Wrap |
404 | }, |
||
405 | c362d2a5 | taeseongkim | |
406 | 75f6ff19 | taeseongkim | Header = "Confirm", |
407 | Theme = new VisualStudio2013Theme(), |
||
408 | 90d1dee0 | swate0609 | ContentStyle = Application.Current.Resources["RadConfirmYCStyle"] as Style, |
409 | 75f6ff19 | taeseongkim | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
410 | c362d2a5 | taeseongkim | |
411 | Owner = Application.Current.MainWindow, |
||
412 | Opened = (s, openedEvent) => |
||
413 | { |
||
414 | RadWindow confirm = s as RadWindow; |
||
415 | }, |
||
416 | |||
417 | 75f6ff19 | taeseongkim | Closed = Closedhandler |
418 | }; |
||
419 | |||
420 | RadWindow.Confirm(parameters); |
||
421 | |||
422 | return result; |
||
423 | 32af2c3b | djkim | } |
424 | d33ef543 | taeseongkim | |
425 | 32af2c3b | djkim | private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) |
426 | { |
||
427 | Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
428 | { |
||
429 | double bytesIn = double.Parse(e.BytesReceived.ToString()); |
||
430 | double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); |
||
431 | double percentage = bytesIn / totalBytes * 100; |
||
432 | progressControl.splashText.Text = "Download : " + Math.Truncate(percentage).ToString() + " %"; |
||
433 | d33ef543 | taeseongkim | progressControl.progressBar.Value = int.Parse(Math.Truncate(percentage).ToString()); |
434 | 32af2c3b | djkim | })); |
435 | 310eff8b | djkim | } |
436 | |||
437 | /// <summary> |
||
438 | /// KCOM_API 를 통해 업데이트 URL 을 가져옴. |
||
439 | /// false : 업데이트 불필요. |
||
440 | /// true : 업데이트 필요. url 을 같이 Return. |
||
441 | /// </summary> |
||
442 | /// <returns></returns> |
||
443 | private KeyValuePair<bool, string> UpdateCheck() |
||
444 | 264c9309 | ljiyeon | { |
445 | 310eff8b | djkim | bool isUpdateCheck = false; |
446 | string updateurl = string.Empty; |
||
447 | 264c9309 | ljiyeon | try |
448 | { |
||
449 | ffddbe4e | djkim | bool is64bit = Environment.Is64BitProcess; |
450 | string clientversion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
||
451 | updateurl = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetVersionData(is64bit, clientversion); |
||
452 | d33ef543 | taeseongkim | |
453 | ffddbe4e | djkim | if (Check_Uri.isUri(updateurl)) |
454 | d33ef543 | taeseongkim | { |
455 | 32af2c3b | djkim | DialogParameters parameters = new DialogParameters() |
456 | 264c9309 | ljiyeon | { |
457 | 32af2c3b | djkim | Owner = Application.Current.MainWindow, |
458 | 97cde7e3 | ljiyeon | Content = new TextBlock() |
459 | { |
||
460 | MinWidth = 400, |
||
461 | FontSize = 11, |
||
462 | eeb0a39c | taeseongkim | Text = "Update is available. \n Update now?", |
463 | 97cde7e3 | ljiyeon | TextWrapping = System.Windows.TextWrapping.Wrap |
464 | }, |
||
465 | 32af2c3b | djkim | Header = "Confirm", |
466 | Theme = new VisualStudio2013Theme(), |
||
467 | d33ef543 | taeseongkim | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
468 | 32af2c3b | djkim | Closed = delegate (object windowSender, WindowClosedEventArgs e) |
469 | 264c9309 | ljiyeon | { |
470 | 32af2c3b | djkim | if (e.DialogResult == true) |
471 | d33ef543 | taeseongkim | { |
472 | isUpdateCheck = true; |
||
473 | 97cde7e3 | ljiyeon | } |
474 | else |
||
475 | 32af2c3b | djkim | { |
476 | 310eff8b | djkim | isUpdateCheck = false; |
477 | d33ef543 | taeseongkim | } |
478 | } |
||
479 | 32af2c3b | djkim | }; |
480 | d33ef543 | taeseongkim | RadWindow.Confirm(parameters); |
481 | |||
482 | 264c9309 | ljiyeon | } |
483 | else |
||
484 | { |
||
485 | 310eff8b | djkim | isUpdateCheck = false; |
486 | 264c9309 | ljiyeon | } |
487 | } |
||
488 | 5a6493ad | humkyung | catch (Exception ex) |
489 | 264c9309 | ljiyeon | { |
490 | 5a6493ad | humkyung | throw ex; |
491 | 310eff8b | djkim | } |
492 | return new KeyValuePair<bool, string>(isUpdateCheck, updateurl); |
||
493 | 264c9309 | ljiyeon | } |
494 | |||
495 | 310eff8b | djkim | /// <summary> |
496 | /// SmartUpdate 를 호출. |
||
497 | /// </summary> |
||
498 | /// <param name="updateurl">Download 할 설치파일 경로</param> |
||
499 | private void CallUpdateProcess(string updateurl) |
||
500 | { |
||
501 | ProcessStartInfo proInfo = new ProcessStartInfo(); |
||
502 | string smartupdaterpath = string.Empty; |
||
503 | smartupdaterpath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SmartUpdate.exe"); |
||
504 | Process.Start(smartupdaterpath, updateurl); |
||
505 | } |
||
506 | d04e8ee9 | taeseongkim | private async void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) |
507 | 32af2c3b | djkim | { |
508 | 264c9309 | ljiyeon | try |
509 | { |
||
510 | d33ef543 | taeseongkim | await Dispatcher.InvokeAsync(() => progressControl.splashText.Text = "Download Completed"); |
511 | d04e8ee9 | taeseongkim | |
512 | d33ef543 | taeseongkim | if (progressControl != null) |
513 | 32af2c3b | djkim | { |
514 | progressControl.Close(); |
||
515 | progressControl = null; |
||
516 | } |
||
517 | d33ef543 | taeseongkim | if (File.Exists(destfilepath)) |
518 | 32af2c3b | djkim | { |
519 | ProcessStartInfo update_msi = new ProcessStartInfo(); |
||
520 | update_msi.FileName = destfilepath; |
||
521 | Process.Start(update_msi); |
||
522 | d33ef543 | taeseongkim | } |
523 | 32af2c3b | djkim | this.Close(); |
524 | 264c9309 | ljiyeon | } |
525 | 32af2c3b | djkim | catch (Exception) |
526 | 69ef0800 | KangIngu | { |
527 | 32af2c3b | djkim | throw; |
528 | 69ef0800 | KangIngu | } |
529 | 7e2d29a0 | ljiyeon | |
530 | } |
||
531 | 787a4489 | KangIngu | } |
532 | } |