private async void OpenFile() { SearchResultItemViewModel <T> selectedItem = SelectedItem; if (selectedItem == null) { return; } LibgenObject selectedLibgenObject = selectedItem.LibgenObject; if (selectedLibgenObject == null || !selectedLibgenObject.FileId.HasValue) { return; } LibraryFile file = await MainModel.LoadFileAsync(selectedLibgenObject.FileId.Value); string filePath = file.FilePath; if (File.Exists(filePath)) { Process.Start(filePath); } else { ShowMessage(Localization.ErrorMessageTitle, Localization.GetFileNotFoundErrorText(filePath)); } }
private void Download() { LibgenObject selectedLibgenObject = GetSelectedLibgenObject(); if (selectedLibgenObject == null || selectedLibgenObject.FileId.HasValue) { return; } if (MainModel.AppSettings.Network.OfflineMode) { ShowMessage(Localization.OfflineModeIsOnMessageTitle, Localization.OfflineModeIsOnMessageText); return; } string downloadMirrorName = GetDownloadMirrorName(); if (downloadMirrorName == null) { ShowMessage(Localization.ErrorMessageTitle, Localization.NoDownloadMirrorError); return; } string downloadUrl = GenerateDownloadUrl(MainModel.Mirrors[downloadMirrorName]); if (MainModel.AppSettings.Download.UseDownloadManager) { Mirrors.MirrorConfiguration mirror = MainModel.Mirrors[downloadMirrorName]; MainModel.Downloader.EnqueueDownloadItem(downloadUrl, FileNameWithoutExtension, FileExtension.ToLower(), Md5Hash, GetDownloadTransformations(mirror), mirror.RestartSessionOnTimeout); } else { Process.Start(downloadUrl); } }