mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add resourse settings grid that doesn't look like crap
This commit is contained in:
parent
9663ecb9ea
commit
b4f84a1fb0
@ -4,14 +4,10 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Wabbajack.App.Controls.ResourceView">
|
||||
<Grid ColumnDefinitions="Auto, Auto, 300" RowDefinitions="20, 20, 20">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" x:Name="ResourceName"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" >Total Throughput:</TextBlock>
|
||||
<TextBlock Grid.Row="0" Grid.Column="2" x:Name="CurrentThrougput"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1">Tasks:</TextBlock>
|
||||
<ButtonSpinner Grid.Row="1" Grid.Column="2"></ButtonSpinner>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1">Throughput:</TextBlock>
|
||||
<Slider Grid.Row="2" Grid.Column="2" Minimum="0" Maximum="16384"></Slider>
|
||||
|
||||
<Grid RowDefinitions="Auto" ColumnDefinitions="140, 100, 140, 100">
|
||||
<TextBlock Grid.Column="0" VerticalAlignment="Center" Margin="4, 0" x:Name="ResourceName"></TextBlock>
|
||||
<TextBox Grid.Column="1" Text="32" Margin="4, 0" x:Name="MaxTasks"></TextBox>
|
||||
<TextBox Grid.Column="2" Margin="4, 0" x:Name="MaxThroughput"></TextBox>
|
||||
<TextBlock Grid.Column="3" Text="42GB" VerticalAlignment="Center" Margin="4, 0" x:Name="CurrentThroughput"></TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
@ -15,9 +15,10 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
|
||||
this.OneWayBind(ViewModel, vm => vm.Name, view => view.ResourceName.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
//this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text)
|
||||
// .DisposeWith(disposables);
|
||||
/*this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text,
|
||||
this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text,
|
||||
l => l is 0 or long.MaxValue ? "∞" : (l / 1024 / 1024).ToString(),
|
||||
v =>
|
||||
{
|
||||
@ -28,9 +29,9 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
|
||||
}
|
||||
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())
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
@ -34,6 +34,7 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
||||
_timer.Elapsed -= TimerElapsed;
|
||||
}).DisposeWith(disposables);
|
||||
|
||||
/*
|
||||
this.WhenAnyValue(vm => vm.MaxThroughput)
|
||||
.Skip(1)
|
||||
.Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables);
|
||||
@ -41,6 +42,10 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
||||
this.WhenAnyValue(vm => vm.MaxTasks)
|
||||
.Skip(1)
|
||||
.Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables);
|
||||
*/
|
||||
|
||||
MaxTasks = _resource.MaxTasks;
|
||||
MaxThroughput = _resource.MaxThroughput;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,17 +35,23 @@
|
||||
</Border>
|
||||
|
||||
<Border x:Name="ResourcesBorder" Margin="5" BorderThickness="1" Classes="ResourceSettings StandardBorder">
|
||||
<Grid RowDefinitions="Auto, Auto, Auto" ColumnDefinitions="Auto, Auto, Auto, Auto">
|
||||
<Grid RowDefinitions="Auto, Auto, Auto" ColumnDefinitions="140, 100, 140, 100">
|
||||
<TextBlock Grid.Row="0" Text="Resources" FontSize="20" Grid.ColumnSpan="4" Margin="4"></TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Name" FontWeight="Bold" Margin="4, 4"></TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="Max Tasks" FontWeight="Bold" Margin="4, 4"></TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Text="Max Throughput" FontWeight="Bold" Margin="4, 4"></TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="3" Text="Transferred" FontWeight="Bold" Margin="4, 4"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Compiler" VerticalAlignment="Center" Margin="4, 0"></TextBlock>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="32" Margin="4, 0"></TextBox>
|
||||
<TextBox Grid.Row="2" Grid.Column="2" Margin="4, 0"></TextBox>
|
||||
<TextBlock Grid.Row="2" Grid.Column="3" Text="42GB" VerticalAlignment="Center" Margin="4, 0"></TextBlock>
|
||||
<ItemsRepeater Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" x:Name="ResourcesList" Margin="0, 4">
|
||||
<ItemsRepeater.Layout>
|
||||
<StackLayout></StackLayout>
|
||||
</ItemsRepeater.Layout>
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<controls:ResourceView></controls:ResourceView>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
|
@ -27,6 +27,9 @@ public partial class SettingsView : ScreenBase<SettingsViewModel>
|
||||
this.BindCommand(ViewModel, vm => vm.VectorPlexusLogout, view => view.VectorPlexusLogOut)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
|
||||
this.OneWayBind(ViewModel, vm => vm.Resources, view => view.ResourcesList.Items)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class Resource<T> : IResource<T>
|
||||
|
||||
public Resource(string humanName, Func<Task<(int MaxTasks, long MaxThroughput)>> settingGetter)
|
||||
{
|
||||
Name = humanName;
|
||||
_tasks = new ConcurrentDictionary<ulong, Job<T>>();
|
||||
|
||||
Task.Run(async () =>
|
||||
@ -103,7 +104,7 @@ public class Resource<T> : IResource<T>
|
||||
await foreach (var item in _channel.Reader.ReadAllAsync(token))
|
||||
{
|
||||
Interlocked.Add(ref _totalUsed, item.Size);
|
||||
if (MaxThroughput == long.MaxValue)
|
||||
if (MaxThroughput is long.MaxValue or 0)
|
||||
{
|
||||
item.Result.TrySetResult();
|
||||
sw.Restart();
|
||||
|
Loading…
Reference in New Issue
Block a user