private async void ShareToSinaWeibo() { IsBusy = true; try { var url = _wallpaperService.GetUrl(Wallpaper.Image, _settings.SelectedWallpaperSize); var bytes = await _imageLoader.GetBytesAsync(url); var isSuccess = await _bingoShareService.ShareToSinaWeiboAsync(bytes, Wallpaper.Archive.Info + url); if (isSuccess) { _appToastService.ShowMessage(LocalizedStrings.ShareSuccess); } } catch (UserCancelAuthorizeException) { _appToastService.ShowInformation(LocalizedStrings.CancelAuthorize); } catch (Exception ex) { _appToastService.ShowError(ex.Message); } finally { IsBusy = false; } }
public void UpdatePrimaryTile(IImage image, string text) { var document = new XmlDocument(); // tile 根节点。 var tileElement = document.CreateElement("tile"); document.AppendChild(tileElement); // visual 元素。 var visualeElement = document.CreateElement("visual"); tileElement.AppendChild(visualeElement); // Medium, 150x150。 { // binding。 var bindingElement = document.CreateElement("binding"); bindingElement.SetAttribute("template", "TileMedium"); visualeElement.AppendChild(bindingElement); // image。 var imageElement = document.CreateElement("image"); imageElement.SetAttribute("src", _wallpaperService.GetUrl(image, new WallpaperSize(150, 150))); imageElement.SetAttribute("placement", "background"); bindingElement.AppendChild(imageElement); // text。 var textElement = document.CreateElement("text"); textElement.AppendChild(document.CreateTextNode(text)); textElement.SetAttribute("hint-wrap", "true"); bindingElement.AppendChild(textElement); } // Wide,310x150。 { // binding。 var bindingElement = document.CreateElement("binding"); bindingElement.SetAttribute("template", "TileWide"); visualeElement.AppendChild(bindingElement); // image。 var imageElement = document.CreateElement("image"); imageElement.SetAttribute("src", _wallpaperService.GetUrl(image, new WallpaperSize(310, 150))); imageElement.SetAttribute("placement", "background"); bindingElement.AppendChild(imageElement); // text。 var textElement = document.CreateElement("text"); textElement.AppendChild(document.CreateTextNode(text)); textElement.SetAttribute("hint-wrap", "true"); bindingElement.AppendChild(textElement); } var tileNotification = new TileNotification(document); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public object Convert(object value, Type targetType, object parameter, string language) { var image = value as IImage ?? (value as Wallpaper)?.Image; var args = (parameter as string)?.Split('x', ','); if (image != null && args != null && args.Length == 2) { return(_wallpaperService.GetUrl(image, new WallpaperSize(int.Parse(args[0]), int.Parse(args[1])))); } return(value); }