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"
|
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">
|
||||||
<Grid ColumnDefinitions="Auto, Auto, 300" RowDefinitions="20, 20, 20">
|
<Grid RowDefinitions="Auto" ColumnDefinitions="140, 100, 140, 100">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" x:Name="ResourceName"/>
|
<TextBlock Grid.Column="0" VerticalAlignment="Center" Margin="4, 0" x:Name="ResourceName"></TextBlock>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="1" >Total Throughput:</TextBlock>
|
<TextBox Grid.Column="1" Text="32" Margin="4, 0" x:Name="MaxTasks"></TextBox>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="2" x:Name="CurrentThrougput"/>
|
<TextBox Grid.Column="2" Margin="4, 0" x:Name="MaxThroughput"></TextBox>
|
||||||
<TextBlock Grid.Row="1" Grid.Column="1">Tasks:</TextBlock>
|
<TextBlock Grid.Column="3" Text="42GB" VerticalAlignment="Center" Margin="4, 0" x:Name="CurrentThroughput"></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>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -15,9 +15,10 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
|
|||||||
this.OneWayBind(ViewModel, vm => vm.Name, view => view.ResourceName.Text)
|
this.OneWayBind(ViewModel, vm => vm.Name, view => view.ResourceName.Text)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
//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(),
|
l => l is 0 or long.MaxValue ? "∞" : (l / 1024 / 1024).ToString(),
|
||||||
v =>
|
v =>
|
||||||
{
|
{
|
||||||
@ -28,9 +29,9 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
|
|||||||
}
|
}
|
||||||
return long.TryParse(v, out var l) ? l * 1024 * 1024 : 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);
|
||||||
});
|
});
|
||||||
|
@ -34,6 +34,7 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
|||||||
_timer.Elapsed -= TimerElapsed;
|
_timer.Elapsed -= TimerElapsed;
|
||||||
}).DisposeWith(disposables);
|
}).DisposeWith(disposables);
|
||||||
|
|
||||||
|
/*
|
||||||
this.WhenAnyValue(vm => vm.MaxThroughput)
|
this.WhenAnyValue(vm => vm.MaxThroughput)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables);
|
.Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables);
|
||||||
@ -41,6 +42,10 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
|||||||
this.WhenAnyValue(vm => vm.MaxTasks)
|
this.WhenAnyValue(vm => vm.MaxTasks)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables);
|
.Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables);
|
||||||
|
*/
|
||||||
|
|
||||||
|
MaxTasks = _resource.MaxTasks;
|
||||||
|
MaxThroughput = _resource.MaxThroughput;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,17 +35,23 @@
|
|||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border x:Name="ResourcesBorder" Margin="5" BorderThickness="1" Classes="ResourceSettings StandardBorder">
|
<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="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="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="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="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="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>
|
<ItemsRepeater Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" x:Name="ResourcesList" Margin="0, 4">
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="32" Margin="4, 0"></TextBox>
|
<ItemsRepeater.Layout>
|
||||||
<TextBox Grid.Row="2" Grid.Column="2" Margin="4, 0"></TextBox>
|
<StackLayout></StackLayout>
|
||||||
<TextBlock Grid.Row="2" Grid.Column="3" Text="42GB" VerticalAlignment="Center" Margin="4, 0"></TextBlock>
|
</ItemsRepeater.Layout>
|
||||||
|
<ItemsRepeater.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<controls:ResourceView></controls:ResourceView>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsRepeater.ItemTemplate>
|
||||||
|
</ItemsRepeater>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
@ -27,6 +27,9 @@ public partial class SettingsView : ScreenBase<SettingsViewModel>
|
|||||||
this.BindCommand(ViewModel, vm => vm.VectorPlexusLogout, view => view.VectorPlexusLogOut)
|
this.BindCommand(ViewModel, vm => vm.VectorPlexusLogout, view => view.VectorPlexusLogOut)
|
||||||
.DisposeWith(disposables);
|
.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)
|
public Resource(string humanName, Func<Task<(int MaxTasks, long MaxThroughput)>> settingGetter)
|
||||||
{
|
{
|
||||||
|
Name = humanName;
|
||||||
_tasks = new ConcurrentDictionary<ulong, Job<T>>();
|
_tasks = new ConcurrentDictionary<ulong, Job<T>>();
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
@ -103,7 +104,7 @@ public class Resource<T> : IResource<T>
|
|||||||
await foreach (var item in _channel.Reader.ReadAllAsync(token))
|
await foreach (var item in _channel.Reader.ReadAllAsync(token))
|
||||||
{
|
{
|
||||||
Interlocked.Add(ref _totalUsed, item.Size);
|
Interlocked.Add(ref _totalUsed, item.Size);
|
||||||
if (MaxThroughput == long.MaxValue)
|
if (MaxThroughput is long.MaxValue or 0)
|
||||||
{
|
{
|
||||||
item.Result.TrySetResult();
|
item.Result.TrySetResult();
|
||||||
sw.Restart();
|
sw.Restart();
|
||||||
|
Loading…
Reference in New Issue
Block a user