mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
add fluent progress dialog
This commit is contained in:
parent
9622a5d6ee
commit
298de8e8dc
@ -7,6 +7,7 @@
|
||||
LegacyDialog2011,
|
||||
ProgressDialog,
|
||||
FluentDialog,
|
||||
ByfronDialog
|
||||
ByfronDialog,
|
||||
ProgressFluentDialog,
|
||||
}
|
||||
}
|
||||
|
68
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml
Normal file
68
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml
Normal file
@ -0,0 +1,68 @@
|
||||
<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="520"
|
||||
Height="280"
|
||||
MinHeight="0"
|
||||
d:DataContext="{d:DesignInstance vms:BootstrapperDialogViewModel,
|
||||
IsDesignTimeCreatable=True}"
|
||||
AllowsTransparency="True"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
Closing="UiWindow_Closing"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
ResizeMode="NoResize"
|
||||
WindowBackdropType="Acrylic"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
mc:Ignorable="d">
|
||||
<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>
|
||||
</base:WpfUiWindow>
|
117
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml.cs
Normal file
117
Bloxstrap/UI/Elements/Bootstrapper/ProgressFluentDialog.xaml.cs
Normal file
@ -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 BootstrapperDialogViewModel _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()
|
||||
{
|
||||
InitializeComponent();
|
||||
ApplyTheme();
|
||||
|
||||
_viewModel = new FluentDialogViewModel(this);
|
||||
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
|
||||
}
|
||||
}
|
@ -57,6 +57,7 @@ namespace Bloxstrap.UI
|
||||
BootstrapperStyle.ProgressDialog => new ProgressDialog(),
|
||||
BootstrapperStyle.FluentDialog => new FluentDialog(),
|
||||
BootstrapperStyle.ByfronDialog => new ByfronDialog(),
|
||||
BootstrapperStyle.ProgressFluentDialog => new ProgressFluentDialog(),
|
||||
_ => new FluentDialog()
|
||||
};
|
||||
}
|
||||
|
@ -22,6 +22,12 @@ namespace Bloxstrap.UI.ViewModels.Bootstrapper
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user