Add extra bootstrapper customization (#94/#95)

Added support for customizing bootstrapper title and icon
This commit is contained in:
pizzaboxer 2023-02-19 16:59:11 +00:00
parent b5250e29dc
commit 1e46aaa929
9 changed files with 102 additions and 9 deletions

View File

@ -81,7 +81,7 @@ namespace Bloxstrap.Dialogs
public void SetupDialog()
{
this.Text = App.ProjectName;
this.Text = App.Settings.Prop.BootstrapperTitle;
this.Icon = App.Settings.Prop.BootstrapperIcon.GetIcon();
}

View File

@ -17,7 +17,7 @@
WindowCornerPreference="Round"
WindowStartupLocation="CenterScreen">
<StackPanel>
<ui:TitleBar Background="{ui:ThemeResource ApplicationBackgroundBrush}" Padding="15,15,0,10" x:Name="RootTitleBar" Grid.Row="0" ForceShutdown="False" MinimizeToTray="False" ShowHelp="False" UseSnapLayout="False" ShowClose="False" ShowMinimize="False" ShowMaximize="False" Title="Bloxstrap" />
<ui:TitleBar Background="{ui:ThemeResource ApplicationBackgroundBrush}" Title="{Binding Title, Mode=OneTime}" Padding="15,15,0,10" x:Name="RootTitleBar" Grid.Row="0" ForceShutdown="False" MinimizeToTray="False" ShowHelp="False" UseSnapLayout="False" ShowClose="False" ShowMinimize="False" ShowMaximize="False" />
<Grid Margin="16,0,16,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />

View File

@ -69,7 +69,7 @@ namespace Bloxstrap.Dialogs
{
_viewModel = new FluentDialogViewModel(this);
DataContext = _viewModel;
Title = App.ProjectName;
Title = App.Settings.Prop.BootstrapperTitle;
Icon = App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);

View File

@ -63,7 +63,7 @@ namespace Bloxstrap.Dialogs
_dialogPage = new TaskDialogPage()
{
Icon = new TaskDialogIcon(App.Settings.Prop.BootstrapperIcon.GetIcon()),
Caption = App.ProjectName,
Caption = App.Settings.Prop.BootstrapperTitle,
Buttons = { TaskDialogButton.Cancel },
ProgressBar = new TaskDialogProgressBar()
@ -91,7 +91,7 @@ namespace Bloxstrap.Dialogs
TaskDialogPage successDialog = new()
{
Icon = TaskDialogIcon.ShieldSuccessGreenBar,
Caption = App.ProjectName,
Caption = App.Settings.Prop.BootstrapperTitle,
Heading = message,
Buttons = { TaskDialogButton.OK }
};
@ -114,7 +114,7 @@ namespace Bloxstrap.Dialogs
TaskDialogPage errorDialog = new()
{
Icon = TaskDialogIcon.Error,
Caption = App.ProjectName,
Caption = App.Settings.Prop.BootstrapperTitle,
Heading = "An error occurred while starting Roblox",
Buttons = { TaskDialogButton.Close },
Expander = new TaskDialogExpander()

View File

@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@ -14,7 +15,8 @@ namespace Bloxstrap.Enums
IconLate2015,
Icon2017,
Icon2019,
Icon2022
Icon2022,
IconCustom
}
public static class BootstrapperIconEx
@ -25,6 +27,23 @@ namespace Bloxstrap.Enums
public static Icon GetIcon(this BootstrapperIcon icon)
{
// load the custom icon file
if (icon == BootstrapperIcon.IconCustom)
{
Icon? customIcon = null;
try
{
customIcon = new Icon(App.Settings.Prop.BootstrapperIconCustomLocation);
}
catch (Exception ex)
{
App.Logger.WriteLine($"[BootstrapperIconEx::GetIcon] Failed to load custom icon! {ex}");
}
return customIcon ?? Properties.Resources.IconBloxstrap;
}
return icon switch
{
BootstrapperIcon.IconBloxstrap => Properties.Resources.IconBloxstrap,

View File

@ -11,6 +11,8 @@ namespace Bloxstrap.Models
// bloxstrap configuration
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.FluentDialog;
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
public string BootstrapperTitle { get; set; } = App.ProjectName;
public string BootstrapperIconCustomLocation { get; set; } = "";
public Theme Theme { get; set; } = Theme.Default;
public bool CheckForUpdates { get; set; } = true;
public bool CreateDesktopIcon { get; set; } = true;

View File

@ -3,6 +3,7 @@ using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using CommunityToolkit.Mvvm.Input;
@ -22,6 +23,7 @@ namespace Bloxstrap.ViewModels
private readonly Page _page;
public ICommand PreviewBootstrapperCommand => new RelayCommand(PreviewBootstrapper);
public ICommand BrowseCustomIconLocationCommand => new RelayCommand(BrowseCustomIconLocation);
private void PreviewBootstrapper()
{
@ -31,6 +33,18 @@ namespace Bloxstrap.ViewModels
dialog.ShowBootstrapper();
}
private void BrowseCustomIconLocation()
{
using var dialog = new OpenFileDialog();
dialog.Filter = "Icon files (*.ico)|*.ico|All files (*.*)|*.*";
if (dialog.ShowDialog() == DialogResult.OK)
{
CustomIconLocation = dialog.FileName;
OnPropertyChanged(nameof(CustomIconLocation));
}
}
public AppearanceViewModel(Page page)
{
_page = page;
@ -78,6 +92,7 @@ namespace Bloxstrap.ViewModels
{ "Early 2015", BootstrapperIcon.IconEarly2015 },
{ "2011", BootstrapperIcon.Icon2011 },
{ "2009", BootstrapperIcon.Icon2009 },
{ "Custom", BootstrapperIcon.IconCustom },
};
public string Icon
@ -91,5 +106,21 @@ namespace Bloxstrap.ViewModels
}
public ImageSource IconPreviewSource => App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
public string Title
{
get => App.Settings.Prop.BootstrapperTitle;
set => App.Settings.Prop.BootstrapperTitle = value;
}
public string CustomIconLocation
{
get => App.Settings.Prop.BootstrapperIconCustomLocation;
set
{
App.Settings.Prop.BootstrapperIconCustomLocation = value;
OnPropertyChanged(nameof(IconPreviewSource));
}
}
}
}

View File

@ -22,6 +22,7 @@ namespace Bloxstrap.ViewModels
public ICommand CancelInstallCommand => new RelayCommand(CancelInstall);
public string Title => App.Settings.Prop.BootstrapperTitle;
public ImageSource Icon { get; set; } = App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
public string Message { get; set; } = "Please wait...";
public bool ProgressIndeterminate { get; set; } = true;

View File

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Bloxstrap.Views.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DesignHeight="520" d:DesignWidth="800"
Title="AppearancePage"
Scrollable="True">
<StackPanel Margin="0,0,14,14">
@ -50,6 +50,46 @@
<ComboBox Grid.Column="1" Margin="5,0,0,0" Padding="10,5,10,5" ItemsSource="{Binding Icons.Keys, Mode=OneTime}" Text="{Binding Icon, Mode=TwoWay}" />
</Grid>
</ui:CardControl>
<ui:CardExpander Margin="0,8,0,0" Padding="16,13,16,12" IsExpanded="False">
<ui:CardExpander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock FontSize="14" Text="Bootstrapper customization" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Configure other customizable Bootstrapper options." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</Grid>
</ui:CardExpander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Title" VerticalAlignment="Center" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<ui:TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Title, Mode=TwoWay}" />
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0,4,0,0" FontSize="12" Text="The text that shows as the title of the bootstrapper." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,12,0,0" Text="Custom Icon" VerticalAlignment="Center" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<Grid Grid.Row="2" Grid.Column="1" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Margin="0,0,4,0" Text="{Binding CustomIconLocation, Mode=TwoWay}" />
<ui:Button Grid.Column="1" Margin="4,0,0,0" Height="35" Icon="Folder24" Content="Browse" Command="{Binding BrowseCustomIconLocationCommand}" />
</Grid>
<TextBlock Grid.Row="3" Grid.Column="1" Margin="0,4,0,0" FontSize="12" Text="Must be a multi-size .ico file with sizes 16px to 128px. Set Icon as 'Custom' to use it." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</Grid>
</ui:CardExpander>
<ui:Button Content="Preview" HorizontalAlignment="Stretch" Margin="0,8,0,0" Command="{Binding PreviewBootstrapperCommand}" />
</StackPanel>
</ui:UiPage>