-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1242 from bluepilledgreat/feature/fluent-progress
Fluent progress dialogs
- Loading branch information
Showing
11 changed files
with
277 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
117
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Bloxstrap/UI/ViewModels/Bootstrapper/ProgressFluentDialogViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule wpfui
updated
from 2a50f3 to 8f6154