private void DownloadButton_Click(object sender, RoutedEventArgs e) { if (SearchResaultListView.SelectedItem == null) { MessageBox.Show("You must choose a file", "Error"); } else { var file = SearchResaultListView.SelectedItem as TransferFile; TempChoosedFile = file; _userLogic.RetrieveUserFilesLogic(MyUser); if (MyUser.OwnedFiles.Any(a => a.FileName.Equals(file?.FileName))) { MessageBox.Show("You already own that file", "Error"); } else if (file.ResourcesNumber == 0) { MessageBox.Show("No resources for this file", "Error"); } else { Task.Factory.StartNew((() => { _downloadLogic = new DownloadLogic(file.FileName, file.FileSize, downloadPath); //_downloadLogic = new DownloadLogic(file.FileName, file.FileSize, ""); _downloadLogic.MyDownloadEvent += updateDownloadTransferListView; _downloadLogic.Start(); })); } } }
private void Install_Click(object sender, RoutedEventArgs e) { try { if (!Directory.Exists(Logic.Logic.InstallDirectory)) { Directory.CreateDirectory(Logic.Logic.InstallDirectory); } else { if ( MessageBox.Show( "The directory that you are trying to install LegenadryClient into already exists. Delete?", "Install Error", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { Directory.Delete(Logic.Logic.InstallDirectory, true); } else { MessageBox.Show( "The installer will now exit because the installation directory already exists", "Install Exit", MessageBoxButton.OK, MessageBoxImage.Information); Environment.Exit(0); } } } catch { DownloadLogic.DownloadAdmin(); } Logic.Logic.SwichPage <DownloadFiles>(); }
public MainWindow() { InitializeComponent(); downloadLogic = new DownloadLogic() { filepath = $@"C:\Users\{Environment.UserName}\Downloads" }; DirectoryDisplay.Text = downloadLogic.filepath; downloadLogic.MainWindow = this; }
public DownloadLogicTests() { _httpClientFactory = new Mock <IHttpClientFactory>(); _target = new DownloadLogic(_httpClientFactory.Object); }