private async void btn_SaveImage_Click(object sender, RoutedEventArgs e) { FileSavePicker save = new FileSavePicker(); save.SuggestedStartLocation = PickerLocationId.PicturesLibrary; save.FileTypeChoices.Add("图片", new List <string>() { ".jpg" }); save.SuggestedFileName = "bili_img_" + _aid; StorageFile file = await save.PickSaveFileAsync(); if (file != null) { //img_Image IBuffer bu = await WebClientClass.GetBuffer(new Uri((this.DataContext as VideoInfoModels).pic)); CachedFileManager.DeferUpdates(file); await FileIO.WriteBufferAsync(file, bu); FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); messShow.Show("保存成功", 3000); } }
private async void btn_Save_Click(object sender, RoutedEventArgs e) { try { FileSavePicker save = new FileSavePicker(); save.SuggestedStartLocation = PickerLocationId.PicturesLibrary; save.FileTypeChoices.Add("图片", new List <string>() { ".jpg" }); save.SuggestedFileName = "bilibili_img_" + DateTime.Now.ToString(); StorageFile file = await save.PickSaveFileAsync(); if (file != null) { //img_Image var u = (imgs.SelectedItem as ImageModel).url.Replace("@300w_300h_1e_1c.jpg", "").Replace("@300w.jpg", ""); IBuffer bu = await WebClientClass.GetBuffer(new Uri(u)); CachedFileManager.DeferUpdates(file); await FileIO.WriteBufferAsync(file, bu); FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); Utils.ShowMessageToast("保存成功"); } } catch (Exception ex) { Utils.ShowMessageToast("保存失败"); } }
public static async Task <string> DownThumb(string url, string aid, StorageFolder folder) { try { StorageFile file = await folder.CreateFileAsync(aid + ".jpg", CreationCollisionOption.OpenIfExists); IBuffer bu = await WebClientClass.GetBuffer(new Uri(url)); CachedFileManager.DeferUpdates(file); await FileIO.WriteBufferAsync(file, bu); FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); if (status == FileUpdateStatus.Complete) { return(file.Path); } else { return(url); } } catch (Exception) { return(url); //return null; } }
private async void btn_Pin_Click(object sender, RoutedEventArgs e) { try { //SettingHelper.PinTile(_aid, _aid, txt_title.Text, (this.DataContext as VideoInfoModels).pic); string appbarTileId = _aid; var str = (this.DataContext as VideoInfoModels).pic; StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile file = await localFolder.CreateFileAsync(_aid + ".jpg", CreationCollisionOption.OpenIfExists); if (file != null) { //img_Image IBuffer bu = await WebClientClass.GetBuffer(new Uri((str))); CachedFileManager.DeferUpdates(file); await FileIO.WriteBufferAsync(file, bu); FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); if (status == FileUpdateStatus.Complete) { Uri logo = new Uri("ms-appdata:///local/" + _aid + ".jpg"); string tileActivationArguments = _aid; string displayName = (this.DataContext as VideoInfoModels).title; TileSize newTileDesiredSize = TileSize.Wide310x150; SecondaryTile secondaryTile = new SecondaryTile(appbarTileId, displayName, tileActivationArguments, logo, newTileDesiredSize); secondaryTile.VisualElements.Square44x44Logo = logo; secondaryTile.VisualElements.Wide310x150Logo = logo; secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; await secondaryTile.RequestCreateAsync(); btn_Pin.Visibility = Visibility.Collapsed; btn_unPin.Visibility = Visibility.Visible; } else { Utils.ShowMessageToast("创建失败", 3000); } } } catch (Exception) { Utils.ShowMessageToast("创建失败", 3000); } }
private async void GetCaptcha() { try { var m = await WebClientClass.GetBuffer(new Uri("https://passport.bilibili.com/captcha?ts=" + ApiHelper.TimeStamp)); var steam = m.AsStream(); var img = new BitmapImage(); await img.SetSourceAsync(steam.AsRandomAccessStream()); img_Captcha.Source = img; } catch (Exception) { Utils.ShowMessageToast("无法加载验证码"); } }
private async void GetCaptcha() { try { needCaptcha.Visibility = Visibility.Visible; var m = await WebClientClass.GetBuffer(new Uri("https://passport.bilibili.com/captcha")); var steam = m.AsStream(); var img = new BitmapImage(); await img.SetSourceAsync(steam.AsRandomAccessStream()); img_Captcha.Source = img; } catch (Exception) { await new MessageDialog("无法显示验证码").ShowAsync(); } }
private static async Task DownThumb(string url, StorageFolder folder) { try { if (await ExistsFile(folder.Path + @"\thumb.jpg")) { return; } StorageFile file = await folder.CreateFileAsync("thumb.jpg", CreationCollisionOption.OpenIfExists); IBuffer bu = await WebClientClass.GetBuffer(new Uri(url)); CachedFileManager.DeferUpdates(file); await FileIO.WriteBufferAsync(file, bu); await CachedFileManager.CompleteUpdatesAsync(file); } catch (Exception) { //return null; } }