Removed vestigial DownloadWindow view

This commit is contained in:
Justin Swanson 2019-12-03 17:48:08 -06:00
parent 299ee0041d
commit dc94b571c0
3 changed files with 0 additions and 131 deletions

View File

@ -1,22 +0,0 @@
<Window x:Class="Wabbajack.DownloadWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wabbajack"
Style="{StaticResource {x:Type Window}}" Icon="../Resources/Icons/wabbajack.ico" WindowStyle="ToolWindow"
mc:Ignorable="d"
Title="Downloading Modlist" Height="200" Width="800">
<StackPanel Margin="20">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="30" Margin="0, 10">Downloading:</TextBlock>
<TextBlock FontSize="30" Margin="10, 10" Text="{Binding DownloadName}"></TextBlock>
</StackPanel>
<ProgressBar Margin="0, 10" Minimum="0" Maximum="100" Height="20" Value="{Binding DownloadProgress}"></ProgressBar>
<StackPanel HorizontalAlignment="Right">
<Button>
<TextBlock TextAlignment="Center" FontSize="20" Width="100">Cancel</TextBlock>
</Button>
</StackPanel>
</StackPanel>
</Window>

View File

@ -1,102 +0,0 @@
using System.IO;
using System.Threading;
using System.Windows;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.Lib.Downloaders;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for DownloadWindow.xaml
/// </summary>
public partial class DownloadWindow : Window
{
public enum WindowResult
{
Undefined,
Completed,
Canceled
}
public WindowResult Result { get; internal set; } = WindowResult.Undefined;
public DownloadWindow(string url, string name, long size, string destination)
{
InitializeComponent();
DataContext = new DownloadWindowViewModel(this, url, name, size, destination);
}
}
public class DownloadWindowViewModel : ViewModel
{
private readonly string _destination;
private readonly DownloadWindow _parent;
private long _size;
public DownloadWindowViewModel(DownloadWindow parent, string url, string name, long size, string destination)
{
_parent = parent;
_url = url;
_downloadName = name;
_destination = destination;
_size = size;
Start();
}
private void Start()
{
_downloadThread = new Thread(() =>
{
var state = DownloadDispatcher.ResolveArchive(_url);
state.Download(new Archive {Name = _downloadName, Size = _size}, _destination);
_destination.FileHash();
_parent.Result = DownloadWindow.WindowResult.Completed;
_parent.Dispatcher.Invoke(() => _parent.Close());
});
_downloadThread.Start();
}
public void Cancel()
{
if (_downloadThread != null && _downloadThread.IsAlive)
{
_downloadThread.Abort();
}
File.Delete(_destination);
_parent.Result = DownloadWindow.WindowResult.Canceled;
}
private int _downloadProgress;
public int DownloadProgress
{
get => _downloadProgress;
set => RaiseAndSetIfChanged(ref _downloadProgress, value);
}
private string _url;
public string Url
{
get => _url;
set => RaiseAndSetIfChanged(ref _url, value);
}
private string _downloadName;
private Thread _downloadThread;
public string DownloadName
{
get => _downloadName;
set => RaiseAndSetIfChanged(ref _downloadName, value);
}
}
}

View File

@ -219,9 +219,6 @@
</Compile>
<Compile Include="Converters\IsNotNullVisibilityConverter.cs" />
<Compile Include="Extensions\ReactiveUIExt.cs" />
<Compile Include="Views\DownloadWindow.xaml.cs">
<DependentUpon>DownloadWindow.xaml</DependentUpon>
</Compile>
<Compile Include="View Models\ModeSelectionVM.cs" />
<Compile Include="Views\Common\FilePicker.xaml.cs">
<DependentUpon>FilePicker.xaml</DependentUpon>
@ -290,10 +287,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DownloadWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Common\FilePicker.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>