Esempio n. 1
0
        private void upgrade_device(string disk_name, ModelInfo model, LanguageInfo lan)
        {
            try
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                string        source_dir   = $@"{DOWNLOAD_PATH}\{Path.GetFileNameWithoutExtension(lan.file)}";
                DirectoryInfo source_total = new DirectoryInfo(source_dir);
                upgrade_total = source_total.GetFiles("*.*", SearchOption.AllDirectories).Length;
                upgrade_count = 0;

                Application.Current.Dispatcher.Invoke(() => {
                    prgbUpgrade.Maximum  = upgrade_total;
                    prgbUpgrade.Value    = 0;
                    prgbUpgradeText.Text = string.Format("{0:N0} / {1:N0}", 0, upgrade_total);
                });

                foreach (var item in model.paths)
                {
                    string source_path = $@"{source_dir}{item.Key.Replace("/", @"\")}";
                    string target_path = $@"{disk_name}{item.Value.Replace("/", @"\")}";
                    directory_copy(source_path, target_path, true);
                }

                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

                Application.Current.Dispatcher.Invoke(() => {
                    prgbUpgrade.Value    = upgrade_count;
                    prgbUpgradeText.Text = $"Completed({elapsedTime})";
                    load_manual($"{model.id}.ko.complete.html");
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Application.Current.Dispatcher.Invoke(() => {
                    prgbUpgradeText.Text = e.Message;
                });
                throw new Exception(e.Message);
            }
        }
Esempio n. 2
0
        private void BtnDownload_Click(object sender, RoutedEventArgs e)
        {
            string download_file = "";

            if (cbbLanguage.SelectedItem != null)
            {
                LanguageInfo item = (LanguageInfo)cbbLanguage.SelectedItem;
                download_file = item.file;
            }

            if (download_file != "")
            {
                download_process(download_file);
            }
            else
            {
                MessageBox.Show("Select Language");
            }
        }
Esempio n. 3
0
        private async void upgrade_process()
        {
            if (lstDevice.Items.Count == 1)
            {
                lstDevice.SelectAll();
            }

            if (lstDevice.SelectedItem != null)
            {
                upgrade_status = UPGRADE_STATUS.start;
                update_ui();

                bool bFormat = false;

                USBDeviceInfo item = (USBDeviceInfo)lstDevice.SelectedItems[0];
                if (cbxUpgradeFormat.IsChecked == true)
                {
                    await Task.Run(() => {
                        bFormat = format_device(item.DiskName);
                    });
                }
                else
                {
                    bFormat = true;
                }

                if (bFormat == true)
                {
                    if (cbbModels.SelectedItem != null && cbbLanguage.SelectedItem != null)
                    {
                        ModelInfo    model = (ModelInfo)cbbModels.SelectedItem;
                        LanguageInfo lan   = (LanguageInfo)cbbLanguage.SelectedItem;

                        try
                        {
                            await Task.Run(() => {
                                upgrade_device(item.DiskName, model, lan);
                            });

                            MessageBoxResult messageBoxResult = MessageBox.Show("업그레이드가 완료되었습니다, 안전하게 장치를 꺼내시겠습니까?", "Remove device confirmation", System.Windows.MessageBoxButton.YesNo);
                            if (messageBoxResult == MessageBoxResult.Yes)
                            {
                                bool remove_safe = RemoveDriveTools.RemoveDrive(item.DiskName);
                                if (remove_safe)
                                {
                                    MessageBox.Show("연결된 장치를 분리하셔도 됩니다.");
                                    // dispatch_usbList();
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Select Model and Langauge");
                    }
                }

                upgrade_status = UPGRADE_STATUS.end;
                update_ui();
            }
            else
            {
                MessageBox.Show("Select device!");
            }
        }
Esempio n. 4
0
        private async void upgrade_task()
        {
            ModelInfo    model = (ModelInfo)cbbModels.SelectedItem;
            LanguageInfo lan   = (LanguageInfo)cbbLanguage.SelectedItem;

            load_manual($"{model.id}.{LanguageResources.Instance.CultureName.Substring(0, 2)}.html");

            try
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                upgrade_status = UPGRADE_STATUS.start;
                update_ui();

                USBDeviceInfo item    = (USBDeviceInfo)lstDevice.SelectedItems[0];
                bool          bFormat = false;
                if (cbxUpgradeFormat.IsChecked == true)
                {
                    await Task.Run(() => {
                        bFormat = format_device(item.DiskName, model.id, model.fileSystem, model.quickFormat, model.clusterSize);
                    });
                }

                // Check Drive size

                /*
                 * DriveInfo drive_info = new DriveInfo(item.DiskName);
                 * if (model.size != drive_info.TotalSize)
                 * {
                 *  Application.Current.Dispatcher.Invoke(() => {
                 *      prgbUpgrade.Value = 0;
                 *      prgbUpgradeText.Foreground = Brushes.Red;
                 *      prgbUpgradeText.Text = "Upgrade Fail: Invalid disk drive size! retry Format";
                 *  });
                 * }
                 */

                await Task.Run(() => {
                    upgrade_device(item.DiskName, model, lan);
                });

                /*
                 * MessageBoxResult messageBoxResult = MessageBox.Show("Upgrade completed, do you want to safely eject your device?", "Remove device confirmation", System.Windows.MessageBoxButton.YesNo);
                 * if (messageBoxResult == MessageBoxResult.Yes)
                 * {
                 *  bool remove_safe = RemoveDriveTools.RemoveDrive(item.DiskName);
                 *  if (remove_safe)
                 *  {
                 *      MessageBox.Show("You can also disconnect the connected device.");
                 *      // dispatch_usbList();
                 *  }
                 * }
                 */
                if (stopWatch.IsRunning)
                {
                    stopWatch.Stop();
                }
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

                Application.Current.Dispatcher.Invoke(() => {
                    prgbUpgrade.Value    = upgrade_count;
                    prgbUpgradeText.Text = $"Completed({elapsedTime})";
                    load_manual($"{model.id}.{LanguageResources.Instance.CultureName.Substring(0, 2)}.complete.html");
                });
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                Application.Current.Dispatcher.Invoke(() => {
                    prgbUpgrade.Value          = 0;
                    prgbUpgradeText.Foreground = Brushes.Red;
                    prgbUpgradeText.Text       = "Upgrade Fail:" + e.Message;
                });
            }
            finally
            {
                upgrade_status = UPGRADE_STATUS.end;
                update_ui();
            }
        }