diff --git a/Bloxstrap/Dialogs/HyperionDialog.xaml b/Bloxstrap/Dialogs/HyperionDialog.xaml new file mode 100644 index 0000000..bc271a4 --- /dev/null +++ b/Bloxstrap/Dialogs/HyperionDialog.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Bloxstrap/Dialogs/HyperionDialog.xaml.cs b/Bloxstrap/Dialogs/HyperionDialog.xaml.cs new file mode 100644 index 0000000..a8514fc --- /dev/null +++ b/Bloxstrap/Dialogs/HyperionDialog.xaml.cs @@ -0,0 +1,100 @@ +using System; +using System.Windows; +using System.Windows.Forms; + +using Bloxstrap.Enums; +using Bloxstrap.Extensions; +using Bloxstrap.ViewModels; + +namespace Bloxstrap.Dialogs +{ + /// + /// Interaction logic for HyperionDialog.xaml + /// + public partial class HyperionDialog : IBootstrapperDialog + { + private readonly HyperionDialogViewModel _viewModel; + + public Bootstrapper? Bootstrapper { get; set; } + + #region UI Elements + public string Message + { + get => _viewModel.Message; + set + { + _viewModel.Message = value; + _viewModel.OnPropertyChanged(nameof(_viewModel.Message)); + } + } + + public ProgressBarStyle ProgressStyle + { + get => _viewModel.ProgressIndeterminate ? ProgressBarStyle.Marquee : ProgressBarStyle.Continuous; + set + { + _viewModel.ProgressIndeterminate = (value == ProgressBarStyle.Marquee); + _viewModel.OnPropertyChanged(nameof(_viewModel.ProgressIndeterminate)); + } + } + + public int ProgressValue + { + get => _viewModel.ProgressValue; + set + { + _viewModel.ProgressValue = value; + _viewModel.OnPropertyChanged(nameof(_viewModel.ProgressValue)); + } + } + + public bool CancelEnabled + { + get => _viewModel.CancelButtonVisibility == Visibility.Visible; + set + { + _viewModel.CancelButtonVisibility = (value ? Visibility.Visible : Visibility.Collapsed); + _viewModel.OnPropertyChanged(nameof(_viewModel.CancelButtonVisibility)); + } + } + #endregion + + public HyperionDialog() + { + _viewModel = new HyperionDialogViewModel(this); + DataContext = _viewModel; + InitializeComponent(); + } + + #region IBootstrapperDialog Methods + // Referencing FluentDialog + public void ShowBootstrapper() => this.ShowDialog(); + + public void CloseBootstrapper() => Dispatcher.BeginInvoke(this.Close); + + public void ShowSuccess(string message) + { + App.ShowMessageBox(message, MessageBoxImage.Information); + App.Terminate(); + } + + public void ShowError(string message) + { + App.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error); + App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE); + } + + public void PromptShutdown() + { + MessageBoxResult result = App.ShowMessageBox( + "Roblox is currently running, but needs to close. Would you like close Roblox now?", + MessageBoxImage.Information, + MessageBoxButton.OKCancel + ); + + if (result != MessageBoxResult.OK) + Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); + } + #endregion + } +} diff --git a/Bloxstrap/Resources/CancelButtonSmall.png b/Bloxstrap/Resources/CancelButtonSmall.png new file mode 100644 index 0000000..77e6a39 Binary files /dev/null and b/Bloxstrap/Resources/CancelButtonSmall.png differ diff --git a/Bloxstrap/Resources/WordmarkRoblox.png b/Bloxstrap/Resources/WordmarkRoblox.png new file mode 100644 index 0000000..b7a23c8 Binary files /dev/null and b/Bloxstrap/Resources/WordmarkRoblox.png differ diff --git a/Bloxstrap/ViewModels/HyperionDialogViewModel.cs b/Bloxstrap/ViewModels/HyperionDialogViewModel.cs new file mode 100644 index 0000000..6a5c452 --- /dev/null +++ b/Bloxstrap/ViewModels/HyperionDialogViewModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using CommunityToolkit.Mvvm.Input; +using Bloxstrap.Dialogs; +using Bloxstrap.Enums; +using Bloxstrap.Extensions; + +namespace Bloxstrap.ViewModels +{ + public class HyperionDialogViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + private readonly IBootstrapperDialog _dialog; + + public ICommand CancelInstallCommand => new RelayCommand(CancelInstall); + + public string Title => App.Settings.Prop.BootstrapperTitle; + public string Message { get; set; } = "Please wait..."; + public bool ProgressIndeterminate { get; set; } = true; + public int ProgressValue { get; set; } = 0; + + public Visibility CancelButtonVisibility { get; set; } = Visibility.Collapsed; + + public string Version => $"Bloxstrap v{App.Version}"; + + public HyperionDialogViewModel(IBootstrapperDialog dialog) + { + _dialog = dialog; + } + + private void CancelInstall() + { + _dialog.Bootstrapper?.CancelInstall(); + _dialog.CloseBootstrapper(); + } + } +}