private async void SaveTemp(DRequestCompletedEventArgs e, DownloadBookContext Context) { StorageFile ISF = await AppStorage.MkTemp( Context.Id + ". " + (string.IsNullOrEmpty(Context.Title) ? "[ Parse Needed ]" : Context.Title) + ".txt" ); await ISF.WriteBytes(e.ResponseBytes); ViewSource.BSData.ImportItem(new LocalBook(ISF)); }
private async void OpenUrl_Click(object sender, RoutedEventArgs e) { StringResources stx = StringResources.Load("AdvDM"); DownloadBookContext Context = new DownloadBookContext(); wenku10.Pages.Dialogs.Rename UrlBox = new wenku10.Pages.Dialogs.Rename(Context, stx.Text("Download_Location")) { Placeholder = "http://example.com/NN. XXXX.txt" }; await Popups.ShowDialog(UrlBox); if (UrlBox.Canceled) { return; } TaskCompletionSource <bool> TCS = new TaskCompletionSource <bool>(); RuntimeCache rCache = new RuntimeCache(); MessageBus.Send(GetType(), string.Format("{0}. {1}", Context.Id, Context.Title)); rCache.GET(Context.Url, (DArgs, url) => { SaveTemp(DArgs, Context); TCS.SetResult(true); } , (id, url, ex) => { Logger.Log(ID, ex.Message, LogType.WARNING); MessageBus.Send(GetType(), "Cannot download: " + id); TCS.SetResult(true); }, false); await PageExtOperations.Run(TCS.Task); }
private async void LoadUrl( object sender, RoutedEventArgs e ) { StringResources stx = new StringResources( "AdvDM" ); DownloadBookContext UrlC = new DownloadBookContext(); Dialogs.Rename UrlBox = new Dialogs.Rename( UrlC, stx.Text( "Download_Location" ) ); UrlBox.Placeholder = "http://example.com/NN. XXXX.txt"; await Popups.ShowDialog( UrlBox ); if ( UrlBox.Canceled ) return; FileListContext.LoadUrl( UrlC ); }