2019-10-20 11:26:42 +00:00
|
|
|
|
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;
|
2019-10-22 12:05:57 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CanInstall = true;
|
|
|
|
|
RaiseAndSetIfChanged(ref _selectedModList, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _canInstall;
|
|
|
|
|
|
|
|
|
|
public bool CanInstall
|
|
|
|
|
{
|
|
|
|
|
get => _canInstall;
|
|
|
|
|
set => RaiseAndSetIfChanged(ref _canInstall, value);
|
2019-10-20 11:26:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal string Download()
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(Consts.ModListDownloadFolder))
|
|
|
|
|
Directory.CreateDirectory(Consts.ModListDownloadFolder);
|
|
|
|
|
|
2019-10-20 19:30:39 +00:00
|
|
|
|
string dest = Path.Combine(Consts.ModListDownloadFolder, SelectedModList.Links.MachineURL + Consts.ModlistExtension);
|
2019-10-20 11:26:42 +00:00
|
|
|
|
|
2019-10-20 19:30:39 +00:00
|
|
|
|
var window = new DownloadWindow(SelectedModList.Links.Download, SelectedModList.Title, dest);
|
2019-10-20 11:26:42 +00:00
|
|
|
|
window.ShowDialog();
|
|
|
|
|
|
|
|
|
|
if (window.Result == DownloadWindow.WindowResult.Completed)
|
|
|
|
|
return dest;
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|