From dc94b571c0669313aef9aea0940700a5f53a6b3d Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Tue, 3 Dec 2019 17:48:08 -0600 Subject: [PATCH] Removed vestigial DownloadWindow view --- Wabbajack/Views/DownloadWindow.xaml | 22 ------ Wabbajack/Views/DownloadWindow.xaml.cs | 102 ------------------------- Wabbajack/Wabbajack.csproj | 7 -- 3 files changed, 131 deletions(-) delete mode 100644 Wabbajack/Views/DownloadWindow.xaml delete mode 100644 Wabbajack/Views/DownloadWindow.xaml.cs diff --git a/Wabbajack/Views/DownloadWindow.xaml b/Wabbajack/Views/DownloadWindow.xaml deleted file mode 100644 index cf61035d..00000000 --- a/Wabbajack/Views/DownloadWindow.xaml +++ /dev/null @@ -1,22 +0,0 @@ - - - - Downloading: - - - - - - - - diff --git a/Wabbajack/Views/DownloadWindow.xaml.cs b/Wabbajack/Views/DownloadWindow.xaml.cs deleted file mode 100644 index 004f8cff..00000000 --- a/Wabbajack/Views/DownloadWindow.xaml.cs +++ /dev/null @@ -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 -{ - /// - /// Interaction logic for DownloadWindow.xaml - /// - 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); - } - } -} diff --git a/Wabbajack/Wabbajack.csproj b/Wabbajack/Wabbajack.csproj index d67b08f0..7d0ad83c 100644 --- a/Wabbajack/Wabbajack.csproj +++ b/Wabbajack/Wabbajack.csproj @@ -219,9 +219,6 @@ - - DownloadWindow.xaml - FilePicker.xaml @@ -290,10 +287,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer