mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
|
using Alphaleonis.Win32.Filesystem;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Collections.ObjectModel;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Wabbajack.Common;
|
|||
|
using Wabbajack.Lib;
|
|||
|
using Wabbajack.Lib.ModListRegistry;
|
|||
|
|
|||
|
namespace Wabbajack.UI
|
|||
|
{
|
|||
|
public class ModeSelectionWindowViewModel : ViewModel
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
public ModeSelectionWindowViewModel()
|
|||
|
{
|
|||
|
_modLists = new ObservableCollection<ModlistMetadata>(ModlistMetadata.LoadFromGithub());
|
|||
|
}
|
|||
|
|
|||
|
private ObservableCollection<ModlistMetadata> _modLists;
|
|||
|
|
|||
|
public ObservableCollection<ModlistMetadata> ModLists
|
|||
|
{
|
|||
|
get => _modLists;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private ModlistMetadata _selectedModList;
|
|||
|
public ModlistMetadata SelectedModList
|
|||
|
{
|
|||
|
get => _selectedModList;
|
|||
|
set => RaiseAndSetIfChanged(ref _selectedModList, value);
|
|||
|
}
|
|||
|
|
|||
|
internal string Download()
|
|||
|
{
|
|||
|
if (!Directory.Exists(Consts.ModListDownloadFolder))
|
|||
|
Directory.CreateDirectory(Consts.ModListDownloadFolder);
|
|||
|
|
|||
|
string dest = Path.Combine(Consts.ModListDownloadFolder, SelectedModList.Links.MachineURL);
|
|||
|
|
|||
|
string result = null;
|
|||
|
var window = new DownloadWindow(SelectedModList.Links.Download, SelectedModList.Title, dest,
|
|||
|
complete =>
|
|||
|
{
|
|||
|
if (complete == DownloadWindow.WindowResult.Completed)
|
|||
|
result = dest;
|
|||
|
});
|
|||
|
window.ShowDialog();
|
|||
|
|
|||
|
if (window.Result == DownloadWindow.WindowResult.Completed)
|
|||
|
return dest;
|
|||
|
return null;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|