public void DownloadImageAsync(ModDatabaseMod mod, Action <byte[]> callback) { var url = new Uri(ModDatabaseUrl, mod.Screenshot); var client = CreateClient(); client.DownloadDataCompleted += (o, e) => callback(e.Result); client.DownloadDataAsync(url); }
public void DownloadImageAsync(ModDatabaseMod mod, Action<byte[]> callback) { var url = new Uri(ModDatabaseUrl, mod.Screenshot); var client = CreateClient(); client.DownloadDataCompleted += (o, e) => callback(e.Result); client.DownloadDataAsync(url); }
public void DownloadModAsync(ModDatabaseMod mod, Action <byte[]> callback, DownloadProgressChangedEventHandler progressChanged = null) { var url = new Uri(ModDatabaseUrl, mod.DownloadLink); var client = CreateClient(); client.DownloadDataCompleted += (o, e) => callback(e.Result); client.DownloadProgressChanged += progressChanged; client.DownloadDataAsync(url); }
public void DownloadModAsync(ModDatabaseMod mod, Action<byte[]> callback, DownloadProgressChangedEventHandler progressChanged = null ) { var url = new Uri(ModDatabaseUrl, mod.DownloadLink); var client = CreateClient(); client.DownloadDataCompleted += (o, e) => callback(e.Result); client.DownloadProgressChanged += progressChanged; client.DownloadDataAsync(url); }
public ModDatabaseModViewModel(ModDatabaseMod mod, ModDatabase database) { this.mod = mod; this.timer = new Timer(); this.database = database; this.saver = new DownloadedModSaver(); this.extractor = new ModExtracter(); DownloadModCommand = new Command(DownloadMod, x => !IsDownloading); timer.AutoReset = false; timer.Elapsed += (o, e) => { ModHasBeenDownloaded = false; timer.Stop(); }; timer.Interval = TimeSpan.FromSeconds(5).TotalMilliseconds; }
public FileInfo Save(ModDatabaseMod mod, byte[] fileData) { AssertTempDirectoryExists(); var fileName = Regex.Replace(mod.Title.Replace(' ', '_'), "[^a-zA-Z0-9]", "") + ".downloaded"; var filePath = Path.Combine(TempDirectory, fileName); if (File.Exists(filePath)) File.Delete(filePath); using (var stream = File.Create(filePath)) { var writer = new BinaryWriter(stream); writer.Write(fileData); } return new FileInfo(filePath); }