public void DownloadOrInstall(HomebrewStoreItem item) { try { if (item.FileDownloaded()) { // We're extracting MessageBox.Show("Extracting is sadly not implemented yet :("); } else { // We're downloading/updating if (item.FileDirectoryExists()) Directory.Delete(item.GetDirectoryPath(), true); Directory.CreateDirectory(item.GetDirectoryPath()); using (var client = new WebClient()) { client.DownloadFile(item.DownloadLink, item.GetFilePath()); } Application.Current.Dispatcher.Invoke(() => { OnPropertyChanged("CurrentState"); OnPropertyChanged(item.CurrentState); OnPropertyChanged(nameof(SelectItemCommand)); }); OnPropertyChanged("CurrentState"); OnPropertyChanged(item.CurrentState); OnPropertyChanged(nameof(SelectItemCommand)); } } catch (Exception ex) { MessageBox.Show("An error occured while performing this operation!\n" + "If this persists, please report this issue!"); } }
public bool CanDownload(HomebrewStoreItem item) { return item.FileDownloaded() || !string.IsNullOrWhiteSpace(item.DownloadLink); }