Skip to content

Commit

Permalink
Merge pull request #1242 from bluepilledgreat/feature/fluent-progress
Browse files Browse the repository at this point in the history
Fluent progress dialogs
  • Loading branch information
pizzaboxer authored Feb 8, 2024
2 parents 62ae4c3 + c37d12c commit 9d50ffc
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Bloxstrap/Enums/BootstrapperStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public enum BootstrapperStyle
LegacyDialog2011,
ProgressDialog,
FluentDialog,
ByfronDialog
ByfronDialog,
ProgressFluentDialog,
ProgressFluentAeroDialog
}
}
11 changes: 11 additions & 0 deletions Bloxstrap/Extensions/BootstrapperStyleEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@
static class BootstrapperStyleEx
{
public static IBootstrapperDialog GetNew(this BootstrapperStyle bootstrapperStyle) => Frontend.GetBootstrapperDialog(bootstrapperStyle);

public static IReadOnlyCollection<BootstrapperStyle> Selections => new BootstrapperStyle[]
{
BootstrapperStyle.FluentDialog,
BootstrapperStyle.ProgressFluentDialog,
BootstrapperStyle.ProgressFluentAeroDialog,
BootstrapperStyle.ByfronDialog,
BootstrapperStyle.LegacyDialog2011,
BootstrapperStyle.LegacyDialog2008,
BootstrapperStyle.VistaDialog
};
}
}
18 changes: 18 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ Your ReShade configuration files will still be saved, and you can locate them by
<data name="Enums.BootstrapperStyle.ProgressDialog" xml:space="preserve">
<value>Progress (~2014)</value>
</data>
<data name="Enums.BootstrapperStyle.ProgressFluentAeroDialog" xml:space="preserve">
<value>Fluent Progress (Aero)</value>
</data>
<data name="Enums.BootstrapperStyle.ProgressFluentDialog" xml:space="preserve">
<value>Fluent Progress</value>
</data>
<data name="Enums.BootstrapperStyle.VistaDialog" xml:space="preserve">
<value>Vista (2008 - 2011)</value>
</data>
Expand Down
80 changes: 80 additions & 0 deletions Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<base:WpfUiWindow
x:Class="Bloxstrap.UI.Elements.Bootstrapper.ProgressFluentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resources="clr-namespace:Bloxstrap.Resources"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:vms="clr-namespace:Bloxstrap.UI.ViewModels.Bootstrapper"
Width="500"
Height="280"
MinHeight="0"
d:DataContext="{d:DesignInstance vms:ProgressFluentDialogViewModel,
IsDesignTimeCreatable=True}"
AllowsTransparency="True"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
Closing="UiWindow_Closing"
ExtendsContentIntoTitleBar="True"
ResizeMode="NoResize"
WindowBackdropType="{Binding Path=WindowBackdropType, Mode=OneTime}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

<!-- Background is for Aero theme only -->
<Grid Background="{Binding Path=BackgroundColourBrush, Mode=OneTime}">
<!-- Allow for drag -->
<ui:TitleBar
VerticalAlignment="Top"
CanMaximize="False"
ShowClose="False"
ShowMaximize="False"
ShowMinimize="False" />

<Grid Margin="32,16">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Image
Grid.Row="0"
Width="80"
Height="80"
Margin="0,30,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality"
Source="{Binding Icon, Mode=OneWay}" />

<TextBlock
Grid.Row="1"
Margin="0,0,0,8"
HorizontalAlignment="Center"
FontSize="18"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="{Binding Message, Mode=OneWay}" />

<ProgressBar
Grid.Row="2"
Margin="0,0,0,16"
IsIndeterminate="{Binding ProgressIndeterminate, Mode=OneWay}"
Maximum="{Binding ProgressMaximum, Mode=OneWay}"
Value="{Binding ProgressValue, Mode=OneWay}" />

<Button
Grid.Row="3"
Width="120"
Padding="4"
HorizontalAlignment="Center"
Command="{Binding CancelInstallCommand}"
Content="{x:Static resources:Strings.Common_Cancel}"
FontSize="14"
IsEnabled="{Binding CancelEnabled, Mode=OneWay}" />
</Grid>
</Grid>
</base:WpfUiWindow>
117 changes: 117 additions & 0 deletions Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using Bloxstrap.UI.Elements.Bootstrapper.Base;
using Bloxstrap.UI.ViewModels.Bootstrapper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace Bloxstrap.UI.Elements.Bootstrapper
{
/// <summary>
/// Interaction logic for ProgressFluentDialog.xaml
/// </summary>
public partial class ProgressFluentDialog : IBootstrapperDialog
{
private readonly ProgressFluentDialogViewModel _viewModel;

public Bloxstrap.Bootstrapper? Bootstrapper { get; set; }

private bool _isClosing;

#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 ProgressMaximum
{
get => _viewModel.ProgressMaximum;
set
{
_viewModel.ProgressMaximum = value;
_viewModel.OnPropertyChanged(nameof(_viewModel.ProgressMaximum));
}
}

public int ProgressValue
{
get => _viewModel.ProgressValue;
set
{
_viewModel.ProgressValue = value;
_viewModel.OnPropertyChanged(nameof(_viewModel.ProgressValue));
}
}

public bool CancelEnabled
{
get => _viewModel.CancelEnabled;
set
{
_viewModel.CancelEnabled = value;

_viewModel.OnPropertyChanged(nameof(_viewModel.CancelButtonVisibility));
_viewModel.OnPropertyChanged(nameof(_viewModel.CancelEnabled));
}
}
#endregion

public ProgressFluentDialog(bool aero)
{
InitializeComponent();
ApplyTheme();

_viewModel = new ProgressFluentDialogViewModel(this, aero);
DataContext = _viewModel;
Title = App.Settings.Prop.BootstrapperTitle;
Icon = App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
}

private void UiWindow_Closing(object sender, CancelEventArgs e)
{
if (!_isClosing)
Bootstrapper?.CancelInstall();
}

#region IBootstrapperDialog Methods
public void ShowBootstrapper() => this.ShowDialog();

public void CloseBootstrapper()
{
_isClosing = true;
Dispatcher.BeginInvoke(this.Close);
}

public void ShowSuccess(string message, Action? callback) => BaseFunctions.ShowSuccess(message, callback);
#endregion
}
}
2 changes: 2 additions & 0 deletions Bloxstrap/UI/Frontend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public static IBootstrapperDialog GetBootstrapperDialog(BootstrapperStyle style)
BootstrapperStyle.ProgressDialog => new ProgressDialog(),
BootstrapperStyle.FluentDialog => new FluentDialog(),
BootstrapperStyle.ByfronDialog => new ByfronDialog(),
BootstrapperStyle.ProgressFluentDialog => new ProgressFluentDialog(false),
BootstrapperStyle.ProgressFluentAeroDialog => new ProgressFluentDialog(true),
_ => new FluentDialog()
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class BootstrapperDialogViewModel : NotifyPropertyChangedViewModel
public bool CancelEnabled { get; set; } = false;
public Visibility CancelButtonVisibility => CancelEnabled ? Visibility.Visible : Visibility.Collapsed;

[Obsolete("Do not use this! This is for the designer only.", true)]
public BootstrapperDialogViewModel()
{
_dialog = null!;
}

public BootstrapperDialogViewModel(IBootstrapperDialog dialog)
{
_dialog = dialog;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Wpf.Ui.Appearance;

namespace Bloxstrap.UI.ViewModels.Bootstrapper
{
public class ProgressFluentDialogViewModel : BootstrapperDialogViewModel
{
public BackgroundType WindowBackdropType { get; set; } = BackgroundType.Mica;
public SolidColorBrush BackgroundColourBrush { get; set; } = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

[Obsolete("Do not use this! This is for the designer only.", true)]
public ProgressFluentDialogViewModel() : base()
{ }

public ProgressFluentDialogViewModel(IBootstrapperDialog dialog, bool aero) : base(dialog)
{
const int alpha = 128;

WindowBackdropType = aero ? BackgroundType.Aero : BackgroundType.Mica;

if (aero)
BackgroundColourBrush = App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Light ?
new SolidColorBrush(Color.FromArgb(alpha, 225, 225, 225)) :
new SolidColorBrush(Color.FromArgb(alpha, 30, 30, 30));
}
}
}
2 changes: 1 addition & 1 deletion Bloxstrap/UI/ViewModels/Menu/AppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Theme Theme
}
}

public IEnumerable<BootstrapperStyle> Dialogs { get; } = Enum.GetValues(typeof(BootstrapperStyle)).Cast<BootstrapperStyle>();
public IEnumerable<BootstrapperStyle> Dialogs { get; } = BootstrapperStyleEx.Selections;

public BootstrapperStyle Dialog
{
Expand Down
2 changes: 1 addition & 1 deletion wpfui
Submodule wpfui updated from 2a50f3 to 8f6154

0 comments on commit 9d50ffc

Please sign in to comment.