mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add loading of modlist folders & files, still very slow
This commit is contained in:
parent
9af6e8a4c8
commit
a4df16628b
@ -28,6 +28,8 @@ using Wabbajack.Paths;
|
||||
using Wabbajack.Paths.IO;
|
||||
using Wabbajack.RateLimiter;
|
||||
using Wabbajack.Services.OSIntegrated;
|
||||
using NexusMods.Paths.FileTree;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -42,6 +44,8 @@ namespace Wabbajack
|
||||
private readonly Client _wjClient;
|
||||
|
||||
[Reactive] public CompilerSettingsVM Settings { get; set; } = new();
|
||||
public IEnumerable<TreeViewItem> Files { get; set; }
|
||||
|
||||
|
||||
public CompilerFileManagerVM(ILogger<CompilerFileManagerVM> logger, DTOSerializer dtos, SettingsManager settingsManager,
|
||||
IServiceProvider serviceProvider, LogStream loggerProvider, ResourceMonitor resourceMonitor,
|
||||
@ -61,6 +65,42 @@ namespace Wabbajack
|
||||
Settings = csVm;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
var fileTree = GetDirectoryContents(new DirectoryInfo(Settings.Source.ToString()));
|
||||
Files = LoadFileTree(new DirectoryInfo(Settings.Source.ToString()));
|
||||
Disposable.Create(() => { }).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerable<TreeViewItem> LoadFileTree(DirectoryInfo parent)
|
||||
{
|
||||
var parentTreeItem = new TreeViewItem()
|
||||
{
|
||||
Header = parent,
|
||||
IsExpanded = true,
|
||||
ItemsSource = GetRecursiveFileTree(parent)
|
||||
};
|
||||
return [parentTreeItem];
|
||||
|
||||
}
|
||||
|
||||
private IEnumerable<TreeViewItem> GetRecursiveFileTree(DirectoryInfo parent)
|
||||
{
|
||||
return parent.EnumerateDirectories()
|
||||
.OrderBy(dir => dir.Name)
|
||||
.Select(dir => new TreeViewItem() { Header = dir, ItemsSource = GetRecursiveFileTree(dir) })
|
||||
.Concat(parent.EnumerateFiles()
|
||||
.OrderBy(file => file.Name)
|
||||
.Select(file => new TreeViewItem() { Header = file }));
|
||||
}
|
||||
|
||||
private IEnumerable<FileSystemInfo> GetDirectoryContents(DirectoryInfo dir)
|
||||
{
|
||||
var directories = dir.EnumerateDirectories();
|
||||
var items = dir.EnumerateFiles();
|
||||
return directories.OrderBy(x => x.Name).Concat<FileSystemInfo>(items.OrderBy(y => y.Name));
|
||||
}
|
||||
|
||||
private async Task NextPage()
|
||||
|
@ -80,7 +80,7 @@ namespace Wabbajack
|
||||
|
||||
public MainWindowVM(ILogger<MainWindowVM> logger, Client wjClient,
|
||||
IServiceProvider serviceProvider, HomeVM homeVM, ModListGalleryVM modListGalleryVM, ResourceMonitor resourceMonitor,
|
||||
InstallerVM installerVM, CompilerHomeVM compilerHomeVM, CompilerDetailsVM compilerVM, CompilerFileManagerVM compilerFileManagerVM, SettingsVM settingsVM, WebBrowserVM webBrowserVM, NavigationVM navigationVM)
|
||||
InstallerVM installerVM, CompilerHomeVM compilerHomeVM, CompilerDetailsVM compilerDetailsVM, CompilerFileManagerVM compilerFileManagerVM, SettingsVM settingsVM, WebBrowserVM webBrowserVM, NavigationVM navigationVM)
|
||||
{
|
||||
_logger = logger;
|
||||
_wjClient = wjClient;
|
||||
@ -89,7 +89,7 @@ namespace Wabbajack
|
||||
ConverterRegistration.Register();
|
||||
InstallerVM = installerVM;
|
||||
CompilerHomeVM = compilerHomeVM;
|
||||
CompilerDetailsVM = compilerVM;
|
||||
CompilerDetailsVM = compilerDetailsVM;
|
||||
CompilerFileManagerVM = compilerFileManagerVM;
|
||||
SettingsPaneVM = settingsVM;
|
||||
GalleryVM = modListGalleryVM;
|
||||
|
@ -16,7 +16,6 @@
|
||||
d:DesignWidth="800"
|
||||
x:TypeArguments="local:CompilerFileManagerVM"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
<TreeView x:Name="FileTreeView">
|
||||
</TreeView>
|
||||
</rxui:ReactiveUserControl>
|
@ -27,11 +27,13 @@ namespace Wabbajack
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
/*
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.WhenAny(x => x.ViewModel.Files)
|
||||
.BindToStrict(this, v => v.FileTreeView.ItemsSource)
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -79,6 +79,9 @@
|
||||
<DataTemplate DataType="{x:Type local:CompilerDetailsVM}">
|
||||
<local:CompilerDetailsView ViewModel="{Binding}" />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:CompilerFileManagerVM}">
|
||||
<local:CompilerFileManagerView ViewModel="{Binding}" />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:InstallerVM}">
|
||||
<local:InstallationView ViewModel="{Binding}" />
|
||||
</DataTemplate>
|
||||
|
Loading…
Reference in New Issue
Block a user