mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
add taskbar progress bar
does not support winform bootstrappers
This commit is contained in:
parent
1eac672a22
commit
bcb5fc3791
@ -6,6 +6,7 @@ using Microsoft.Win32;
|
||||
using Bloxstrap.Integrations;
|
||||
using Bloxstrap.Resources;
|
||||
using Bloxstrap.AppData;
|
||||
using System.Windows.Shell;
|
||||
|
||||
namespace Bloxstrap
|
||||
{
|
||||
@ -13,6 +14,7 @@ namespace Bloxstrap
|
||||
{
|
||||
#region Properties
|
||||
private const int ProgressBarMaximum = 10000;
|
||||
private const double TaskbarProgressMaximum = 1; // this can not be changed. keep it at 1.
|
||||
|
||||
private const string AppSettings =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
|
||||
@ -71,6 +73,7 @@ namespace Bloxstrap
|
||||
|
||||
private bool _isInstalling = false;
|
||||
private double _progressIncrement;
|
||||
private double _taskbarProgressIncrement;
|
||||
private long _totalDownloadedBytes = 0;
|
||||
private int _packagesExtracted = 0;
|
||||
private bool _cancelFired = false;
|
||||
@ -106,6 +109,7 @@ namespace Bloxstrap
|
||||
if (Dialog is null)
|
||||
return;
|
||||
|
||||
// UI progress
|
||||
int progressValue = (int)Math.Floor(_progressIncrement * _totalDownloadedBytes);
|
||||
|
||||
// bugcheck: if we're restoring a file from a package, it'll incorrectly increment the progress beyond 100
|
||||
@ -113,6 +117,12 @@ namespace Bloxstrap
|
||||
progressValue = Math.Clamp(progressValue, 0, ProgressBarMaximum);
|
||||
|
||||
Dialog.ProgressValue = progressValue;
|
||||
|
||||
// taskbar progress
|
||||
double taskbarProgressValue = _taskbarProgressIncrement * _totalDownloadedBytes;
|
||||
taskbarProgressValue = Math.Clamp(taskbarProgressValue, 0, TaskbarProgressMaximum);
|
||||
|
||||
Dialog.TaskbarProgressValue = taskbarProgressValue;
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
@ -614,11 +624,14 @@ namespace Bloxstrap
|
||||
{
|
||||
Dialog.CancelEnabled = true;
|
||||
Dialog.ProgressStyle = ProgressBarStyle.Continuous;
|
||||
Dialog.TaskbarProgressState = TaskbarItemProgressState.Normal;
|
||||
|
||||
Dialog.ProgressMaximum = ProgressBarMaximum;
|
||||
|
||||
// compute total bytes to download
|
||||
_progressIncrement = (double)ProgressBarMaximum / _versionPackageManifest.Sum(package => package.PackedSize);
|
||||
int totalSize = _versionPackageManifest.Sum(package => package.PackedSize);
|
||||
_progressIncrement = (double)ProgressBarMaximum / totalSize;
|
||||
_taskbarProgressIncrement = (double)TaskbarProgressMaximum / totalSize;
|
||||
}
|
||||
|
||||
foreach (Package package in _versionPackageManifest)
|
||||
@ -647,6 +660,7 @@ namespace Bloxstrap
|
||||
if (Dialog is not null)
|
||||
{
|
||||
Dialog.ProgressStyle = ProgressBarStyle.Marquee;
|
||||
Dialog.TaskbarProgressState = TaskbarItemProgressState.Indeterminate;
|
||||
SetStatus(Strings.Bootstrapper_Status_Configuring);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using Bloxstrap.UI.Utility;
|
||||
|
||||
@ -15,6 +16,8 @@ namespace Bloxstrap.UI.Elements.Bootstrapper.Base
|
||||
protected virtual ProgressBarStyle _progressStyle { get; set; }
|
||||
protected virtual int _progressValue { get; set; }
|
||||
protected virtual int _progressMaximum { get; set; }
|
||||
protected virtual TaskbarItemProgressState _taskbarProgressState { get; set; }
|
||||
protected virtual double _taskbarProgressValue { get; set; }
|
||||
protected virtual bool _cancelEnabled { get; set; }
|
||||
|
||||
public string Message
|
||||
@ -65,6 +68,30 @@ namespace Bloxstrap.UI.Elements.Bootstrapper.Base
|
||||
}
|
||||
}
|
||||
|
||||
public TaskbarItemProgressState TaskbarProgressState
|
||||
{
|
||||
get => _taskbarProgressState;
|
||||
set
|
||||
{
|
||||
if (InvokeRequired)
|
||||
Invoke(() => _taskbarProgressState = value);
|
||||
else
|
||||
_taskbarProgressState = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double TaskbarProgressValue
|
||||
{
|
||||
get => _taskbarProgressValue;
|
||||
set
|
||||
{
|
||||
if (InvokeRequired)
|
||||
Invoke(() => _taskbarProgressValue = value);
|
||||
else
|
||||
_taskbarProgressValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CancelEnabled
|
||||
{
|
||||
get => _cancelEnabled;
|
||||
|
@ -12,6 +12,11 @@
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Closing="Window_Closing">
|
||||
|
||||
<Window.TaskbarItemInfo>
|
||||
<TaskbarItemInfo ProgressState="{Binding Path=TaskbarProgressState}" ProgressValue="{Binding Path=TaskbarProgressValue}" />
|
||||
</Window.TaskbarItemInfo>
|
||||
|
||||
<Border CornerRadius="10" BorderBrush="#33393B3D" Background="{Binding Background}" BorderThickness="{Binding DialogBorder}">
|
||||
<Grid>
|
||||
<Image Source="{Binding ByfronLogoLocation}" RenderOptions.BitmapScalingMode="HighQuality" Width="114" Height="108" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="17,13,0,0" />
|
||||
|
@ -3,6 +3,7 @@ using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using Bloxstrap.UI.Elements.Bootstrapper.Base;
|
||||
using Bloxstrap.UI.ViewModels.Bootstrapper;
|
||||
@ -65,6 +66,26 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
||||
}
|
||||
}
|
||||
|
||||
public TaskbarItemProgressState TaskbarProgressState
|
||||
{
|
||||
get => _viewModel.TaskbarProgressState;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressState = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressState));
|
||||
}
|
||||
}
|
||||
|
||||
public double TaskbarProgressValue
|
||||
{
|
||||
get => _viewModel.TaskbarProgressValue;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressValue = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressValue));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CancelEnabled
|
||||
{
|
||||
get => _viewModel.CancelEnabled;
|
||||
|
@ -19,6 +19,10 @@
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.TaskbarItemInfo>
|
||||
<TaskbarItemInfo ProgressState="{Binding Path=TaskbarProgressState}" ProgressValue="{Binding Path=TaskbarProgressValue}" />
|
||||
</Window.TaskbarItemInfo>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
@ -1,9 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Mvvm.Contracts;
|
||||
using Wpf.Ui.Mvvm.Services;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using Bloxstrap.UI.ViewModels.Bootstrapper;
|
||||
using Bloxstrap.UI.Elements.Bootstrapper.Base;
|
||||
@ -62,6 +59,26 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
||||
}
|
||||
}
|
||||
|
||||
public TaskbarItemProgressState TaskbarProgressState
|
||||
{
|
||||
get => _viewModel.TaskbarProgressState;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressState = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressState));
|
||||
}
|
||||
}
|
||||
|
||||
public double TaskbarProgressValue
|
||||
{
|
||||
get => _viewModel.TaskbarProgressValue;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressValue = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressValue));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CancelEnabled
|
||||
{
|
||||
get => _viewModel.CancelEnabled;
|
||||
|
@ -22,6 +22,10 @@
|
||||
WindowStyle="None"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.TaskbarItemInfo>
|
||||
<TaskbarItemInfo ProgressState="{Binding Path=TaskbarProgressState}" ProgressValue="{Binding Path=TaskbarProgressValue}" />
|
||||
</Window.TaskbarItemInfo>
|
||||
|
||||
<!-- Background is for Aero theme only -->
|
||||
<Grid Background="{Binding Path=BackgroundColourBrush, Mode=OneTime}">
|
||||
<!-- Allow for drag -->
|
||||
|
@ -16,6 +16,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Shell;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Bloxstrap.UI.Elements.Bootstrapper
|
||||
@ -72,6 +73,26 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
||||
}
|
||||
}
|
||||
|
||||
public TaskbarItemProgressState TaskbarProgressState
|
||||
{
|
||||
get => _viewModel.TaskbarProgressState;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressState = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressState));
|
||||
}
|
||||
}
|
||||
|
||||
public double TaskbarProgressValue
|
||||
{
|
||||
get => _viewModel.TaskbarProgressValue;
|
||||
set
|
||||
{
|
||||
_viewModel.TaskbarProgressValue = value;
|
||||
_viewModel.OnPropertyChanged(nameof(_viewModel.TaskbarProgressValue));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CancelEnabled
|
||||
{
|
||||
get => _viewModel.CancelEnabled;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Shell;
|
||||
|
||||
namespace Bloxstrap.UI
|
||||
{
|
||||
@ -10,6 +11,8 @@ namespace Bloxstrap.UI
|
||||
ProgressBarStyle ProgressStyle { get; set; }
|
||||
int ProgressValue { get; set; }
|
||||
int ProgressMaximum { get; set; }
|
||||
TaskbarItemProgressState TaskbarProgressState { get; set; }
|
||||
double TaskbarProgressValue { get; set; }
|
||||
bool CancelEnabled { get; set; }
|
||||
|
||||
void ShowBootstrapper();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
@ -19,6 +20,9 @@ namespace Bloxstrap.UI.ViewModels.Bootstrapper
|
||||
public int ProgressMaximum { get; set; } = 0;
|
||||
public int ProgressValue { get; set; } = 0;
|
||||
|
||||
public TaskbarItemProgressState TaskbarProgressState { get; set; } = TaskbarItemProgressState.Indeterminate;
|
||||
public double TaskbarProgressValue { get; set; } = 0;
|
||||
|
||||
public bool CancelEnabled { get; set; } = false;
|
||||
public Visibility CancelButtonVisibility => CancelEnabled ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user