Revert "Reformatting"

This reverts commit 6a85a3e7
This commit is contained in:
Timothy Baldridge 2021-11-10 16:12:29 -07:00
parent 383c6f5059
commit 81d775ddca
5 changed files with 38 additions and 23 deletions

View File

@ -9,6 +9,7 @@
<Application.Styles> <Application.Styles>
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" /> <StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" />
<FluentTheme Mode="Dark" /> <FluentTheme Mode="Dark" />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
<StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml" /> <StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml" />
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter"> <Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />

View File

@ -41,6 +41,12 @@
<Setter Property="CornerRadius" Value="4"></Setter> <Setter Property="CornerRadius" Value="4"></Setter>
</Style> </Style>
<Style Selector="Border.StandardBorder">
<Setter Property="BorderThickness" Value="2"></Setter>
<Setter Property="BorderBrush" Value="DarkGray"></Setter>
<Setter Property="CornerRadius" Value="4"></Setter>
</Style>
<Style Selector="Border.Settings Grid"> <Style Selector="Border.Settings Grid">
<Setter Property="Margin" Value="4"></Setter> <Setter Property="Margin" Value="4"></Setter>
</Style> </Style>

View File

@ -4,13 +4,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Wabbajack.App.Controls.ResourceView"> x:Class="Wabbajack.App.Controls.ResourceView">
<StackPanel Orientation="Horizontal"> <Grid RowDefinitions="Auto" ColumnDefinitions="140, 100, 140, 100">
<TextBlock x:Name="ResourceName" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBlock Grid.Column="0" VerticalAlignment="Center" Margin="4, 0" x:Name="ResourceName"></TextBlock>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Tasks:</Label> <TextBox Grid.Column="1" Text="32" Margin="4, 0" x:Name="MaxTasks"></TextBox>
<TextBox x:Name="MaxTasks" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBox Grid.Column="2" Margin="4, 0" x:Name="MaxThroughput"></TextBox>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Throughput:</Label> <TextBlock Grid.Column="3" Text="42GB" VerticalAlignment="Center" Margin="4, 0" x:Name="CurrentThroughput"></TextBlock>
<TextBox x:Name="MaxThroughput" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" /> </Grid>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Status:</Label>
<TextBlock x:Name="CurrentThrougput" Width="50" HorizontalAlignment="Left" VerticalAlignment="Center" />
</StackPanel>
</UserControl> </UserControl>

View File

@ -17,10 +17,21 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text) this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text)
.DisposeWith(disposables); .DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text)
this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text,
l => l is 0 or long.MaxValue ? "∞" : (l / 1024 / 1024).ToString(),
v =>
{
v = v.Trim();
if (v is "0" or "∞" || v == long.MaxValue.ToString())
{
return long.MaxValue;
}
return long.TryParse(v, out var l) ? l * 1024 * 1024 : long.MaxValue;
})
.DisposeWith(disposables); .DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text, this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThroughput.Text,
val => val.FileSizeToString()) val => val.FileSizeToString())
.DisposeWith(disposables); .DisposeWith(disposables);
}); });

View File

@ -2,9 +2,11 @@ using System;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Timers; using System.Timers;
using Avalonia.Threading;
using ReactiveUI; using ReactiveUI;
using ReactiveUI.Fody.Helpers; using ReactiveUI.Fody.Helpers;
using Wabbajack.App.ViewModels; using Wabbajack.App.ViewModels;
using Wabbajack.Common;
using Wabbajack.RateLimiter; using Wabbajack.RateLimiter;
namespace Wabbajack.App.Controls; namespace Wabbajack.App.Controls;
@ -18,7 +20,7 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
{ {
Activator = new ViewModelActivator(); Activator = new ViewModelActivator();
_resource = resource; _resource = resource;
_timer = new Timer(1.0); _timer = new Timer(250);
Name = resource.Name; Name = resource.Name;
@ -32,14 +34,9 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
_timer.Stop(); _timer.Stop();
_timer.Elapsed -= TimerElapsed; _timer.Elapsed -= TimerElapsed;
}).DisposeWith(disposables); }).DisposeWith(disposables);
this.WhenAnyValue(vm => vm.MaxThroughput) MaxTasks = _resource.MaxTasks;
.Skip(1) MaxThroughput = _resource.MaxThroughput;
.Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables);
this.WhenAnyValue(vm => vm.MaxTasks)
.Skip(1)
.Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables);
}); });
} }
@ -50,6 +47,8 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
[Reactive] public long CurrentThroughput { get; set; } [Reactive] public long CurrentThroughput { get; set; }
[Reactive] public string Name { get; set; } [Reactive] public string Name { get; set; }
[Reactive] public string ThroughputHumanFriendly { get; set; }
public void Dispose() public void Dispose()
@ -59,8 +58,9 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
private void TimerElapsed(object? sender, ElapsedEventArgs e) private void TimerElapsed(object? sender, ElapsedEventArgs e)
{ {
MaxTasks = _resource.MaxTasks; Dispatcher.UIThread.Post(() => {
MaxThroughput = _resource.MaxThroughput; CurrentThroughput = _resource.StatusReport.Transferred;
CurrentThroughput = _resource.StatusReport.Transferred; ThroughputHumanFriendly = _resource.StatusReport.Transferred.ToFileSizeString();
});
} }
} }