Ejemplo n.º 1
0
        private void BrowseButton_Click(object sender, RoutedEventArgs e)
        {
            BpUtility.PlaySound(Properties.Resources.Click);
            var dialog = new CommonOpenFileDialog
            {
                IsFolderPicker            = true,
                Multiselect               = false,
                DefaultDirectory          = InstallPathTextBox.Text,
                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems   = false,
                EnsurePathExists          = true,
                EnsureReadOnly            = false,
                EnsureValidNames          = true
            };

            if (dialog.ShowDialog(this) == CommonFileDialogResult.Ok)
            {
                InstallPathTextBox.Text = Path.Combine(dialog.FileName, MainWindow.GameFullName);
                string[] game_full_names = { "Honkai Impact 3rd", "Honkai Impact 3", "崩坏3", "崩壞3", "붕괴3rd", "Honkai Impact 3rd glb", "Honkai Impact 3 sea", "Honkai Impact 3rd tw", "Honkai Impact 3rd kr" };
                foreach (string game_full_name in game_full_names)
                {
                    if (dialog.FileName.Contains(game_full_name))
                    {
                        InstallPathTextBox.Text = dialog.FileName;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void PreloadDownloadStatusChanged(object sender, DownloadChangedProgress e)
 {
     if (LastTimeSpan.Elapsed.TotalMilliseconds >= RefreshRate)
     {
         Dispatcher.Invoke(() =>
         {
             double DownloadPercentage         = Math.Round(double.IsInfinity(e.ProgressPercentage) ? 0 : e.ProgressPercentage, 2);
             PreloadCircleProgressBar.Value    = DownloadPercentage / 100;
             TaskbarItemInfo.ProgressValue     = DownloadPercentage / 100;
             PreloadStatusTopRightText.Text    = $"{BpUtility.ToBytesCount(e.BytesReceived)}/{BpUtility.ToBytesCount(e.TotalBytesToReceive)}";
             PreloadStatusMiddleRightText.Text = string.Format("{0:hh\\:mm\\:ss}", e.TimeLeft);
             PreloadStatusBottomRightText.Text = $"{BpUtility.ToBytesCount(e.CurrentSpeed)}{App.TextStrings["bytes_per_second"].Substring(1)}";
             if (e.Status == DownloadState.Merging)
             {
                 PreloadPauseButton.IsEnabled     = false;
                 PreloadBottomText.Text           = string.Format(App.TextStrings["label_merged"], DownloadPercentage);
                 PreloadStatusTopLeftText.Text    = $"{App.TextStrings["label_merged"].Split(' ')[0]}:";
                 PreloadStatusBottomLeftText.Text = App.TextStrings["label_merge_speed"];
             }
             else
             {
                 PreloadBottomText.Text           = string.Format(App.TextStrings["label_downloaded_1"], DownloadPercentage);
                 PreloadStatusTopLeftText.Text    = App.TextStrings["label_downloaded_2"];
                 PreloadStatusBottomLeftText.Text = App.TextStrings["label_download_speed"];
             }
         });
         LastTimeSpan = Stopwatch.StartNew();
     }
 }
Ejemplo n.º 3
0
 private void UninstallCheckBox_Click(object sender, RoutedEventArgs e)
 {
     BpUtility.PlaySound(Properties.Resources.Click);
     if (!(bool)UninstallGameFilesCheckBox.IsChecked && !(bool)UninstallGameCacheCheckBox.IsChecked && !(bool)UninstallGameSettingsCheckBox.IsChecked)
     {
         ConfirmButton.IsEnabled = false;
     }
     else
     {
         ConfirmButton.IsEnabled = true;
     }
 }
Ejemplo n.º 4
0
        private void ShowUnhandledException(Exception e, string unhandledExceptionType)
        {
            if (unhandledExceptionType == "TaskScheduler.UnobservedTaskException")
            {
                return;
            }

            string msg = $"CRITICAL ERROR: Unhandled exception occurred. Stack trace:\n{e}";

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine('\n' + msg);
            Directory.CreateDirectory(LauncherDataPath);
            if (File.Exists(LauncherLogFile))
            {
                File.SetAttributes(LauncherLogFile, File.GetAttributes(LauncherLogFile) & ~FileAttributes.ReadOnly);
            }
            File.AppendAllText(LauncherLogFile, '\n' + msg);
            if (MessageBox.Show(TextStrings["msgbox_unhandled_exception_msg"], TextStrings["msgbox_generic_error_title"], MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
            {
                BpUtility.StartProcess(LauncherLogFile, null, null, true);
            }
            Current.Shutdown();
        }
Ejemplo n.º 5
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     BpUtility.PlaySound(Properties.Resources.Click);
     Close();
 }
Ejemplo n.º 6
0
 private void ConfirmButton_Click(object sender, RoutedEventArgs e)
 {
     BpUtility.PlaySound(Properties.Resources.Click);
     DialogResult = true;
     Close();
 }
Ejemplo n.º 7
0
        public DialogWindow(string title, string message, DialogType type = DialogType.Confirmation)
        {
            Owner = Application.Current.MainWindow;
            Left  = Application.Current.MainWindow.Left + 10;
            Top   = Application.Current.MainWindow.Top + 10;
            InitializeComponent();
            DialogTitle.Text      = title;
            DialogMessage.Text    = message;
            ConfirmButton.Content = App.TextStrings["button_confirm"];
            CancelButton.Content  = App.TextStrings["button_cancel"];
            switch (type)
            {
            case DialogType.Confirmation:
                ConfirmButton.Content   = App.TextStrings["button_ok"];
                CancelButton.Visibility = Visibility.Collapsed;
                break;

            case DialogType.Question:
                ConfirmButton.Content = App.TextStrings["button_yes"];
                CancelButton.Content  = App.TextStrings["button_no"];
                break;

            case DialogType.Install:
                DialogMessageScrollViewer.Margin = new Thickness(0, 0, 0, 75);
                DialogMessageScrollViewer.Height = 100;
                InstallStackPanel.Visibility     = Visibility.Visible;
                break;

            case DialogType.Uninstall:
                DialogMessageScrollViewer.Margin = new Thickness(0, 0, 0, 100);
                DialogMessageScrollViewer.Height = 50;
                UninstallStackPanel.Visibility   = Visibility.Visible;
                UninstallGameFilesLabel.Text     = App.TextStrings["msgbox_uninstall_game_files"];
                UninstallGameCacheLabel.Text     = App.TextStrings["msgbox_uninstall_game_cache"];
                UninstallGameSettingsLabel.Text  = App.TextStrings["msgbox_uninstall_game_settings"];
                if (!Directory.Exists(MainWindow.GameCachePath))
                {
                    UninstallGameCacheCheckBox.IsChecked = false;
                    UninstallGameCacheCheckBox.IsEnabled = false;
                }
                if (Registry.CurrentUser.OpenSubKey(MainWindow.GameRegistryPath) == null)
                {
                    UninstallGameSettingsCheckBox.IsChecked = false;
                    UninstallGameSettingsCheckBox.IsEnabled = false;
                }
                break;

            case DialogType.CustomLaunchOptions:
                DialogMessageScrollViewer.Margin         = new Thickness(0, 0, 0, 75);
                DialogMessageScrollViewer.Height         = 100;
                CustomLaunchOptionsStackPanel.Visibility = Visibility.Visible;
                break;

            case DialogType.CustomBackground:
                DialogMessageScrollViewer.Margin      = new Thickness(0, 0, 0, 75);
                DialogMessageScrollViewer.Height      = 80;
                CustomBackgroundStackPanel.Visibility = Visibility.Visible;
                CustomBackgroundEditLabel.Text        = App.TextStrings["msgbox_custom_background_edit"];
                CustomBackgroundDeleteLabel.Text      = App.TextStrings["msgbox_custom_background_delete"];
                break;
            }
            if (App.LauncherLanguage != "en" && App.LauncherLanguage != "zh-CN")
            {
                Resources["Font"] = new FontFamily("Segoe UI Bold");
            }
            Application.Current.MainWindow.WindowState = WindowState.Normal;
            BpUtility.PlaySound(Properties.Resources.Window_Open);
        }
Ejemplo n.º 8
0
 private void DialogWindow_Closing(object sender, CancelEventArgs e)
 {
     BpUtility.PlaySound(Properties.Resources.Window_Close);
 }
Ejemplo n.º 9
0
 private void CustomBackgroundRadioButton_Click(object sender, RoutedEventArgs e)
 {
     BpUtility.PlaySound(Properties.Resources.Click);
 }
Ejemplo n.º 10
0
 private void DownloadStatusChanged(object sender, DownloadChangedProgress e)
 {
     if (LastTimeSpan.Elapsed.TotalMilliseconds >= RefreshRate)
     {
         Dispatcher.Invoke(() =>
         {
             double DownloadPercentage     = Math.Round(double.IsInfinity(e.ProgressPercentage) ? 0 : e.ProgressPercentage, 2);
             DownloadProgressBar.Value     = DownloadPercentage / 100;
             TaskbarItemInfo.ProgressValue = DownloadPercentage / 100;
             DownloadETAText.Text          = string.Format(App.TextStrings["progresstext_eta"], string.Format("{0:hh\\:mm\\:ss}", e.TimeLeft));
             if (e.Status == DownloadState.Merging)
             {
                 DownloadProgressText.Text      = $"{string.Format(App.TextStrings["label_merged"], DownloadPercentage)} ({BpUtility.ToBytesCount(e.BytesReceived)}/{BpUtility.ToBytesCount(e.TotalBytesToReceive)})";
                 DownloadSpeedText.Text         = $"{App.TextStrings["label_merge_speed"]} {BpUtility.ToBytesCount(e.CurrentSpeed)}{App.TextStrings["bytes_per_second"].Substring(1)}";
                 DownloadPauseButton.Visibility = Visibility.Collapsed;
             }
             else
             {
                 DownloadProgressText.Text = $"{string.Format(App.TextStrings["label_downloaded_1"], DownloadPercentage)} ({BpUtility.ToBytesCount(e.BytesReceived)}/{BpUtility.ToBytesCount(e.TotalBytesToReceive)})";
                 DownloadSpeedText.Text    = $"{App.TextStrings["label_download_speed"]} {BpUtility.ToBytesCount(e.CurrentSpeed)}{App.TextStrings["bytes_per_second"].Substring(1)}";
             }
         });
         LastTimeSpan = Stopwatch.StartNew();
     }
 }