progressbar tweaks
This commit is contained in:
@@ -25,9 +25,7 @@ internal static class SharedFunctions
|
|||||||
var failed = false;
|
var failed = false;
|
||||||
var factory = new ModpackFactory();
|
var factory = new ModpackFactory();
|
||||||
|
|
||||||
api.Model.Progress.Value = 0;
|
api.Model.Progress.Start(rowsCount);
|
||||||
api.Model.Progress.MaxValue = rowsCount;
|
|
||||||
api.Model.Progress.Visible = true;
|
|
||||||
|
|
||||||
for (var i = 0; i < rowsCount; i++)
|
for (var i = 0; i < rowsCount; i++)
|
||||||
{
|
{
|
||||||
@@ -50,10 +48,10 @@ internal static class SharedFunctions
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
row.StateImage = failed ? imageSourceFailed : imageSourceSuccess;
|
row.StateImage = failed ? imageSourceFailed : imageSourceSuccess;
|
||||||
api.Model.Progress.Value = i;
|
api.Model.Progress.Set(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Model.Progress.Visible = false;
|
api.Model.Progress.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> CollectUpdates(IMainApi api, params InstallAction[] actions)
|
public static async Task<bool> CollectUpdates(IMainApi api, params InstallAction[] actions)
|
||||||
@@ -100,9 +98,7 @@ internal static class SharedFunctions
|
|||||||
{
|
{
|
||||||
var factory = new ModpackFactory();
|
var factory = new ModpackFactory();
|
||||||
|
|
||||||
api.Model.Progress.Value = 0;
|
api.Model.Progress.Start(rows.Length);
|
||||||
api.Model.Progress.MaxValue = rows.Length;
|
|
||||||
api.Model.Progress.Visible = true;
|
|
||||||
|
|
||||||
for (var i = 0; i < rows.Length; i++)
|
for (var i = 0; i < rows.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -123,17 +119,15 @@ internal static class SharedFunctions
|
|||||||
|
|
||||||
if (api.HasClosed)
|
if (api.HasClosed)
|
||||||
return;
|
return;
|
||||||
api.Model.Progress.Value = i;
|
api.Model.Progress.Set(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Model.Progress.Visible = false;
|
api.Model.Progress.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ClearDirectLinks(IMainApi api, params MainWindowGridRow[] rows)
|
public static void ClearDirectLinks(IMainApi api, params MainWindowGridRow[] rows)
|
||||||
{
|
{
|
||||||
api.Model.Progress.Value = 0;
|
api.Model.Progress.Start(rows.Length);
|
||||||
api.Model.Progress.MaxValue = rows.Length;
|
|
||||||
api.Model.Progress.Visible = true;
|
|
||||||
|
|
||||||
for (var i = 0; i < rows.Length; i++)
|
for (var i = 0; i < rows.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -141,10 +135,10 @@ internal static class SharedFunctions
|
|||||||
if (row.SourceType != SourceType.DirectLink)
|
if (row.SourceType != SourceType.DirectLink)
|
||||||
row.SourceUrl = null;
|
row.SourceUrl = null;
|
||||||
row.StateImage = null;
|
row.StateImage = null;
|
||||||
api.Model.Progress.Value = i;
|
api.Model.Progress.Set(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Model.Progress.Visible = false;
|
api.Model.Progress.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateChangelog(InstallInfos installInfos, UpdateInfo updateInfos)
|
public static string GenerateChangelog(InstallInfos installInfos, UpdateInfo updateInfos)
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
<pilz:ImageButton.Flyout>
|
<pilz:ImageButton.Flyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuFlyout.Items>
|
<MenuFlyout.Items>
|
||||||
<MenuItem x:Name="MenuItemWorkspacePreferences" Header="{x:Static langRes:GeneralLangRes.WorkspacePreferences}"/>
|
<MenuItem x:Name="MenuItemWorkspacePreferences" Header="{x:Static langRes:GeneralLangRes.WorkspacePreferences}" Click="MenuItemWorkspacePreferences_OnClick"/>
|
||||||
<MenuItem x:Name="MenuItemSaveWorkspace" Header="{x:Static langRes:GeneralLangRes.SaveWorkspace}" HotKey="Ctrl+S"/>
|
<MenuItem x:Name="MenuItemSaveWorkspace" Header="{x:Static langRes:GeneralLangRes.SaveWorkspace}" HotKey="Ctrl+S" Click="MenuItemSaveWorkspace_OnClick"/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem x:Name="MenuItemNewWorkspace" Header="{x:Static langRes:GeneralLangRes.NewWorkspace}"/>
|
<MenuItem x:Name="MenuItemNewWorkspace" Header="{x:Static langRes:GeneralLangRes.NewWorkspace}"/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
@@ -154,26 +154,15 @@
|
|||||||
</ContentControl.DataTemplates>
|
</ContentControl.DataTemplates>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
|
|
||||||
<!-- Progress -->
|
<!-- ProgressBar: Status -->
|
||||||
<Panel
|
<ProgressBar
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
IsVisible="{Binding Progress.Visible}">
|
Maximum="{Binding Progress.MaxValue}"
|
||||||
|
Value="{Binding Progress.Value}"
|
||||||
<!-- ProgressBar: Status -->
|
ShowProgressText="{Binding Progress.ShowText}"
|
||||||
<ProgressBar
|
IsIndeterminate="{Binding Progress.IsGeneric}"
|
||||||
HorizontalAlignment="Stretch"
|
IsVisible="{Binding Progress.IsVisible}"/>
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Maximum="{Binding Progress.MaxValue}"
|
|
||||||
Value="{Binding Progress.Value}"/>
|
|
||||||
|
|
||||||
<!-- TextBox: Status -->
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
TextAlignment="Center"
|
|
||||||
Text="{Binding Progress.Text}"/>
|
|
||||||
</Panel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- DataGrid -->
|
<!-- DataGrid -->
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Data;
|
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using ModpackUpdater.Apps.Manager.Api;
|
using ModpackUpdater.Apps.Manager.Api;
|
||||||
@@ -7,7 +6,6 @@ using ModpackUpdater.Apps.Manager.Api.Model;
|
|||||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Features;
|
using ModpackUpdater.Apps.Manager.Api.Plugins.Features;
|
||||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||||
using ModpackUpdater.Apps.Manager.Settings;
|
using ModpackUpdater.Apps.Manager.Settings;
|
||||||
using ModpackUpdater.Apps.Manager.Ui.Models;
|
|
||||||
using ModpackUpdater.Apps.Manager.Ui.Models.MainWindow;
|
using ModpackUpdater.Apps.Manager.Ui.Models.MainWindow;
|
||||||
using Pilz.Features;
|
using Pilz.Features;
|
||||||
using Pilz.UI.AvaloniaUI.Features;
|
using Pilz.UI.AvaloniaUI.Features;
|
||||||
@@ -20,6 +18,8 @@ public partial class MainWindow : Window, IMainApi
|
|||||||
public static IImage? ButtonImageAddAction => AppGlobals.Symbols.GetImageSource(AppSymbols.add);
|
public static IImage? ButtonImageAddAction => AppGlobals.Symbols.GetImageSource(AppSymbols.add);
|
||||||
public static IImage? ButtonImageRemoveAction => AppGlobals.Symbols.GetImageSource(AppSymbols.remove);
|
public static IImage? ButtonImageRemoveAction => AppGlobals.Symbols.GetImageSource(AppSymbols.remove);
|
||||||
|
|
||||||
|
private WorkspaceFeature? curWs;
|
||||||
|
|
||||||
public MainWindowViewModel Model { get; } = new();
|
public MainWindowViewModel Model { get; } = new();
|
||||||
Window IMainApi.MainWindow => this;
|
Window IMainApi.MainWindow => this;
|
||||||
public IMainApi MainApi => this;
|
public IMainApi MainApi => this;
|
||||||
@@ -57,19 +57,19 @@ public partial class MainWindow : Window, IMainApi
|
|||||||
insertPrioSplitters: true);
|
insertPrioSplitters: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadNewWorkspace(IWorkspace? workspace)
|
private async Task LoadNewWorkspace(IWorkspace? workspace, WorkspaceFeature feature)
|
||||||
{
|
{
|
||||||
if (workspace is null)
|
if (workspace is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!await workspace.Load())
|
if (!await workspace.Load())
|
||||||
{
|
|
||||||
// Error
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (workspace != Model.CurrentWorkspace)
|
if (workspace != Model.CurrentWorkspace)
|
||||||
|
{
|
||||||
Model.CurrentWorkspace = workspace;
|
Model.CurrentWorkspace = workspace;
|
||||||
|
curWs = feature;
|
||||||
|
}
|
||||||
|
|
||||||
AddToRecentFiles(workspace);
|
AddToRecentFiles(workspace);
|
||||||
LoadRecentWorkspaces();
|
LoadRecentWorkspaces();
|
||||||
@@ -124,14 +124,33 @@ public partial class MainWindow : Window, IMainApi
|
|||||||
|
|
||||||
var context = new WorkspaceContext(MainApi, null);
|
var context = new WorkspaceContext(MainApi, null);
|
||||||
await feature.Configure(context);
|
await feature.Configure(context);
|
||||||
if (context.Workspace != null)
|
await LoadNewWorkspace(context.Workspace, feature);
|
||||||
await LoadNewWorkspace(context.Workspace);
|
}
|
||||||
|
|
||||||
|
private async void MenuItemWorkspacePreferences_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (curWs is null || Model.CurrentWorkspace is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var context = new WorkspaceContext(MainApi, Model.CurrentWorkspace);
|
||||||
|
await curWs.Configure(context);
|
||||||
|
await LoadNewWorkspace(context.Workspace, curWs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void MenuItemSaveWorkspace_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (Model.CurrentWorkspace is not { } ws)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Model.Progress.Start();
|
||||||
|
await ws.Save();
|
||||||
|
Model.Progress.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void MenuItemRecentWorkspaceItem_Click(object? sender, RoutedEventArgs e)
|
private async void MenuItemRecentWorkspaceItem_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is MenuItem item && item.DataContext is MainWindowRecentFilesItem tag && tag.Feature.CreateFromConfig(tag.Config) is IWorkspace workspace)
|
if (sender is MenuItem item && item.DataContext is MainWindowRecentFilesItem tag && tag.Feature.CreateFromConfig(tag.Config) is IWorkspace workspace)
|
||||||
await LoadNewWorkspace(workspace);
|
await LoadNewWorkspace(workspace, tag.Feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuItemToolsItem_Click(object? sender, RoutedEventArgs e)
|
private void MenuItemToolsItem_Click(object? sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using PropertyChanged;
|
|
||||||
|
|
||||||
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
||||||
|
|
||||||
@@ -7,9 +6,43 @@ public class ProgressInfos : INotifyPropertyChanged
|
|||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
public bool Visible { get; set; }
|
public bool IsVisible { get; set; }
|
||||||
|
public bool IsGeneric { get; set; }
|
||||||
|
public bool ShowText { get; set; }
|
||||||
public double MaxValue { get; set; }
|
public double MaxValue { get; set; }
|
||||||
public double Value { get; set; }
|
public double Value { get; set; }
|
||||||
[DependsOn(nameof(Value), nameof(MaxValue))]
|
|
||||||
public string? Text => $"{Math.Round(Value / MaxValue * 100)}%";
|
public void Start(int maxValue)
|
||||||
|
{
|
||||||
|
IsGeneric = false;
|
||||||
|
Value = 0;
|
||||||
|
MaxValue = maxValue;
|
||||||
|
ShowText = true;
|
||||||
|
IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
ShowText = false;
|
||||||
|
IsGeneric = true;
|
||||||
|
IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(int value)
|
||||||
|
{
|
||||||
|
if (!IsGeneric)
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Increment()
|
||||||
|
{
|
||||||
|
if (!IsGeneric)
|
||||||
|
Value += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void End()
|
||||||
|
{
|
||||||
|
IsVisible = false;
|
||||||
|
IsGeneric = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,23 +82,15 @@
|
|||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<dialogs:AvaloniaFlyoutBase.FooterContent>
|
<dialogs:AvaloniaFlyoutBase.FooterContent>
|
||||||
<Panel
|
|
||||||
|
<!-- ProgressBar: Status -->
|
||||||
|
<ProgressBar
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
IsVisible="{Binding Progress.Visible}">
|
Maximum="{Binding Progress.MaxValue}"
|
||||||
|
Value="{Binding Progress.Value}"
|
||||||
<!-- ProgressBar: Status -->
|
ShowProgressText="{Binding Progress.ShowText}"
|
||||||
<ProgressBar
|
IsIndeterminate="{Binding Progress.IsGeneric}"
|
||||||
HorizontalAlignment="Stretch"
|
IsVisible="{Binding Progress.IsVisible}"/>
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Maximum="{Binding Progress.MaxValue}"
|
|
||||||
Value="{Binding Progress.Value}"/>
|
|
||||||
|
|
||||||
<!-- TextBox: Status -->
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Progress.Text}"/>
|
|
||||||
</Panel>
|
|
||||||
</dialogs:AvaloniaFlyoutBase.FooterContent>
|
</dialogs:AvaloniaFlyoutBase.FooterContent>
|
||||||
</dialogs:AvaloniaFlyoutBase>
|
</dialogs:AvaloniaFlyoutBase>
|
||||||
@@ -25,15 +25,13 @@ public partial class UpdatesCollectorView : AvaloniaFlyoutBase
|
|||||||
|
|
||||||
private async Task FindUpdates()
|
private async Task FindUpdates()
|
||||||
{
|
{
|
||||||
Model.Progress.Value = 0;
|
Model.Progress.Start(actions.Length);
|
||||||
Model.Progress.MaxValue = actions.Length;
|
|
||||||
Model.Progress.Visible = true;
|
|
||||||
|
|
||||||
foreach (var action in actions)
|
foreach (var action in actions)
|
||||||
{
|
{
|
||||||
var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any);
|
var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any);
|
||||||
|
|
||||||
Model.Progress.Value += 1;
|
Model.Progress.Increment();
|
||||||
|
|
||||||
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
|
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
|
||||||
continue;
|
continue;
|
||||||
@@ -44,7 +42,7 @@ public partial class UpdatesCollectorView : AvaloniaFlyoutBase
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model.Progress.Visible = false;
|
Model.Progress.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override object GetResult()
|
protected override object GetResult()
|
||||||
|
|||||||
Reference in New Issue
Block a user