Add view model and assets for "Hyperion" mockup bootstrapper

This commit is contained in:
1011025m 2023-05-09 21:09:34 +08:00
parent 15d81cf8a7
commit 48ebf758a0
5 changed files with 181 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<Window x:Class="Bloxstrap.Dialogs.HyperionDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Bloxstrap.Dialogs"
mc:Ignorable="d"
Width="600"
Height="400"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
AllowsTransparency="True"
Background="Transparent">
<Border
CornerRadius="10"
Background="Black">
<Grid>
<Button Margin="12,12,12,12" VerticalAlignment="Top" HorizontalAlignment="Right" Width="20" Height="20" BorderThickness="0" Padding="0" Background="Transparent" BorderBrush="Transparent" Visibility="{Binding CancelButtonVisibility, Mode=OneWay}" Command="{Binding CancelInstallCommand}">
<Image Source="/Resources/CancelButtonSmall.png"/>
</Button>
<Border Margin="12,12,36,12" VerticalAlignment="Top" Height="20">
<TextBlock VerticalAlignment="Center" TextAlignment="Left" Foreground="#FFECECEC" FontSize="12" FontWeight="Bold" Text="{Binding Version}" />
</Border>
<Image Width="300" Height="60" Source="/Resources/WordmarkRoblox.png"/>
<Grid Margin="0,0,0,30" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock TextAlignment="Center" Grid.Row="0" FontSize="16" Text="{Binding Message}" Foreground="#FFECECEC" FontFamily="Source Sans Pro" Margin="0,0,0,28" />
<ProgressBar Grid.Row="1" Width="480" Height="10" Foreground="#FFECECEC" Background="#FF565656" IsIndeterminate="{Binding ProgressIndeterminate}" Value="{Binding ProgressValue}"></ProgressBar>
</Grid>
</Grid>
</Border>
</Window>

View File

@ -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
{
/// <summary>
/// Interaction logic for HyperionDialog.xaml
/// </summary>
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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -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();
}
}
}