프로젝트

일반

사용자정보

개정판 32af2c3b

ID32af2c3be33fb87b4cae6d51b07f20310e15f3c1
상위 cd988cd8
하위 1f472c13, 882f0fcf

김동진이(가) 5년 이상 전에 추가함

issue #660: progressBar window 추가. 종료시 SaveCheck, UpdateCheck 로직 수정.

Change-Id: I598378d41dac389fa2055d46f9d6e67b2eca2cf1

차이점 보기:

KCOM/MainWindow.xaml.cs
1 1
using KCOM.Common;
2
using KCOM.Controls;
2 3
using KCOM.Views;
3 4
using KCOMDataModel;
4 5
using KCOMDataModel.DataModel;
......
38 39
    /// </summary>
39 40
    public partial class MainWindow : Window
40 41
    {
42
        bool isSaveCheck = false;
43
        bool isUpdateCheck = false;
44
        ProgressControl progressControl = null;
45
        string destfilepath = string.Empty;
46

  
41 47
        public MainWindow()
42 48
        {
43 49
            App.splashString(ISplashMessage.MAINWINDOW);
......
45 51
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
46 52
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
47 53
            this.SourceInitialized += new EventHandler(win_SourceInitialized);
48
            this.Closed += MainWindow_Closed;
49
            
50 54
        }
51 55

  
52 56
        public static BitmapImage CursorChange()
......
176 180

  
177 181
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
178 182
        {
179
            if(filename == null)
183
            if(string.IsNullOrEmpty(destfilepath))
180 184
            {
181 185
                if (e.ClickCount == 2)
182 186
                {
......
319 323
                    break;
320 324
                case ("Win_Close"):
321 325
                    {
322
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
326
                        SaveCheck();
327
                        UpdateCheck();
328
                        if(isSaveCheck && isUpdateCheck)
323 329
                        {
324
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
325
                            DateTime updatetime = DateTime.Now.AddDays(-1);
326
                            if (ViewerDataModel.Instance._markupInfoList.Count > 0)
327
                            {
328
                                updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
329
                            }
330

  
331
                            if (undoTime > updatetime)
332
                            {
333
                                var box = new TextBlock();
334
                                box.MinWidth = 400;
335
                                box.FontSize = 11;
336
                                box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
337
                                box.TextWrapping = System.Windows.TextWrapping.Wrap;
338

  
339
                                DialogParameters parameters = new DialogParameters()
340
                                {
341
                                    Owner = Application.Current.MainWindow,
342
                                    Content = box,
343
                                    Header = "Confirm",
344
                                    Theme = new VisualStudio2013Theme(),
345
                                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
346
                                    Closed = Onclose,
347
                                };
348
                                RadWindow.Confirm(parameters);
349
                            }
330
                            this.Close();
350 331
                        }
351
                        
352
                        MainWindow_Close();
332

  
333
                        //MainWindow_Close();
353 334
                    }
354 335
                    break;
355 336
            }
356 337
        }
357

  
358
        private void MainWindow_Closed(object sender, EventArgs e)
338
        
339
        private void SaveCheck()
359 340
        {
360
            splashScreen.Close();
361
            ProcessStartInfo proInfo = new ProcessStartInfo();
362
            proInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + filename;
363
            Process.Start(proInfo);
364
        }
341
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
342
            {
343
                DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
344
                DateTime updatetime = DateTime.Now.AddDays(-1);
345
                if (ViewerDataModel.Instance._markupInfoList.Count > 0)
346
                {
347
                    updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
348
                }
365 349

  
366
        //파일 다운로드 상황을 반영(수정 필요)
367
        private void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
368
        {
350
                if (undoTime > updatetime)
351
                {
352
                    var box = new TextBlock();
353
                    box.MinWidth = 400;
354
                    box.FontSize = 11;
355
                    box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
356
                    box.TextWrapping = System.Windows.TextWrapping.Wrap;
369 357

  
370
            if (i <= 100)
358
                    DialogParameters parameters = new DialogParameters()
359
                    {
360
                        Owner = Application.Current.MainWindow,
361
                        Content = box,
362
                        Header = "Confirm",
363
                        Theme = new VisualStudio2013Theme(),
364
                        ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
365
                        Closed = OnClosingSave,
366
                    };
367
                    RadWindow.Confirm(parameters);
368
                }
369
                else
370
                {
371
                    isSaveCheck = true;
372
                }                    
373
            }else
371 374
            {
372
                i++;
375
                isSaveCheck = true;
373 376
            }
374
            Thread.Sleep(3);
375
            splashScreen.Progress = i;
376
            splashScreen.Close();
377

  
378
            //splashScreen.Close();
379 377
        }
380
        private Thread theProgBarThread;
381
        string filename = null;
382
        int i = 1;
383

  
384

  
385
        public static SplashScreenWindow splashScreen = new SplashScreenWindow();
386
        private void MainWindow_Close()
378
        private void OnClosingSave(object sender, WindowClosedEventArgs e)
379
        {
380
            if (e.DialogResult == true)
381
            {
382
                dzTopMenu.SaveEventCallback(null, null);
383
            }
384
            isSaveCheck = true;
385
        }
386
                
387
        private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
388
        {
389
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
390
            {
391
                double bytesIn = double.Parse(e.BytesReceived.ToString());
392
                double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
393
                double percentage = bytesIn / totalBytes * 100;
394
                progressControl.splashText.Text = "Download : " + Math.Truncate(percentage).ToString() + " %";
395
                progressControl.progressBar.Value = int.Parse(Math.Truncate(percentage).ToString());                
396
            }));
397
        }        
398
        
399
        private void UpdateCheck()
387 400
        {
388 401
            try
389 402
            {
390 403
                string url = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetVersionData(Environment.Is64BitProcess, Assembly.GetExecutingAssembly().GetName().Version.ToString());
391 404
                if (!string.IsNullOrEmpty(url))
392 405
                {
393
                    if (MessageBox.Show("새로운 버전이 있습니다. \n업데이트 하시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
406
                    var box = new TextBlock();
407
                    box.MinWidth = 400;
408
                    box.FontSize = 11;
409
                    box.Text = "새로운 버전이 있습니다. \n업데이트 하시겠습니까?";
410
                    box.TextWrapping = System.Windows.TextWrapping.Wrap;                    
411
                    DialogParameters parameters = new DialogParameters()
394 412
                    {
395
                        //splashScreen.splashText.Text = "  DownLoad...";                        
396

  
397
                        splashScreen.Show();
398
                        WebClient theDownloadThread = new WebClient();
399
                        //Uri url = new Uri(itemInfoList[i].FileName);
400
                        theDownloadThread.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
401
                        theDownloadThread.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
402
                        filename = System.IO.Path.GetFileName(url);
403

  
404
                        if (!File.Exists(TempFile.TempFolder))
413
                        Owner = Application.Current.MainWindow,
414
                        Content = box,
415
                        Header = "Confirm",
416
                        Theme = new VisualStudio2013Theme(),
417
                        ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },                        
418
                        Closed = delegate (object windowSender, WindowClosedEventArgs e)
405 419
                        {
406
                            Directory.CreateDirectory(TempFile.TempFolder);
407
                        }
408

  
409
                        theDownloadThread.DownloadFileAsync(new Uri(url), System.IO.Path.Combine(TempFile.TempFolder, filename));
410
                       
411
                    }
412
                    else
413
                    {
414
                        this.Close();
415
                    }
420
                            if (e.DialogResult == true)
421
                            {
422
                                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
423
                                {
424
                                    destfilepath = System.IO.Path.Combine(TempFile.TempFolder, System.IO.Path.GetFileName(url));                                    
425
                                    progressControl = new ProgressControl();
426
                                    progressControl.splashText.Text = "Update Download Start...";
427
                                    progressControl.WindowStartupLocation = WindowStartupLocation.CenterScreen;
428
                                    progressControl.Show();
429
                                    WebClient client = new WebClient();
430
                                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
431
                                    client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
432
                                    client.DownloadFileAsync(new Uri(url), destfilepath);
433
                                }));
434
                                                                                              
435
                            }else
436
                            {
437
                                isUpdateCheck = true;
438
                            }                            
439
                        }                    
440
                    };
441
                    RadWindow.Confirm(parameters);                    
416 442
                }
417 443
                else
418 444
                {
419
                    this.Close();
445
                    isUpdateCheck = true;
420 446
                }
421

  
422 447
            }
423 448
            catch (Exception)
424 449
            {
425
                this.Close();
450
                throw;
426 451
            }            
427 452
        }
428 453

  
429
        private void Completed(object sender, AsyncCompletedEventArgs e)
430
        {            
454
        private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
455
        {
431 456
            try
432 457
            {
433
                this.Close();                
458
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
459
                {
460
                    progressControl.splashText.Text = "Download Completed";
461
                }));                
462
                if(progressControl != null)
463
                {
464
                    progressControl.Close();
465
                    progressControl = null;
466
                }
467
                if(File.Exists(destfilepath))
468
                {
469
                    ProcessStartInfo update_msi = new ProcessStartInfo();
470
                    update_msi.FileName = destfilepath;
471
                    Process.Start(update_msi);
472
                }                
473
                this.Close();
434 474
            }
435
            catch (Exception ee)
436
            {
437
            }       
438

  
439
        }
440

  
441
        private void Onclose(object sender, WindowClosedEventArgs e)
442
        {
443
            if (e.DialogResult == true)
475
            catch (Exception)
444 476
            {
445
                dzTopMenu.SaveEventCallback(null, null);
477
                throw;
446 478
            }
479
            
447 480
        }
448 481

  
449 482
        void win_SourceInitialized(object sender, EventArgs e)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)