public static void UpdateDefaultTile(bool transparentTile = false) { var tileSubFolder = transparentTile ? "Transparent" : "Solid"; var tileSquare71Content = TileContentFactory.CreateTileSquare71x71Image(); ITileNotificationContent biggerTile; tileSquare71Content.Image.Src = String.Format("ms-appx:///Assets/Tiles/{0}/Square71x71Logo.png", tileSubFolder); var tileSquare150Content = TileContentFactory.CreateTileSquare150x150Image(); tileSquare150Content.Image.Src = String.Format("ms-appx:///Assets/Tiles/{0}/Square150x150Logo.png", tileSubFolder); tileSquare150Content.Square71x71Content = tileSquare71Content; var tileWideContent = TileContentFactory.CreateTileWide310x150Image(); tileWideContent.Image.Src = String.Format("ms-appx:///Assets/Tiles/{0}/Wide310x150Logo.png", tileSubFolder); tileWideContent.Square150x150Content = tileSquare150Content; #if WINDOWS_PHONE_APP biggerTile = tileWideContent; #else var tileSquare310Content = TileContentFactory.CreateTileSquare310x310Image(); tileSquare310Content.Image.Src = String.Format("ms-appx:///Assets/Tiles/{0}/Square310x310Logo.png", tileSubFolder); tileSquare310Content.Wide310x150Content = tileWideContent; biggerTile = tileSquare310Content; #endif TileUpdateManager.CreateTileUpdaterForApplication().Update(biggerTile.CreateNotification()); }
public async Task <ISquare310x310TileNotificationContent> clearLiveTiles(string siteName) { await genTileImages(siteName); // Large tile. var largeContent = TileContentFactory.CreateTileSquare310x310Image(); largeContent.Image.Src = $"ms-appdata:///local/{siteName}LargeTile.png"; largeContent.Branding = NotificationsExtensions.TileContent.TileBranding.None; // Wide tile. var wideContent = TileContentFactory.CreateTileWide310x150Image(); wideContent.Image.Src = $"ms-appdata:///local/{siteName}WideTile.png"; wideContent.Branding = NotificationsExtensions.TileContent.TileBranding.None; // Square tile. var squareContent = TileContentFactory.CreateTileSquare150x150Image(); squareContent.Image.Src = $"ms-appdata:///local/{siteName}MedTile.png"; squareContent.Branding = NotificationsExtensions.TileContent.TileBranding.None; // Smaill tile. var smallContent = TileContentFactory.CreateTileSquare71x71Image(); smallContent.Image.Src = $"ms-appdata:///local/{siteName}SmallTile.png"; smallContent.Branding = NotificationsExtensions.TileContent.TileBranding.None; largeContent.Wide310x150Content = wideContent; wideContent.Square150x150Content = squareContent; squareContent.Square71x71Content = smallContent; return(largeContent); }
private void SendTileNotification_Click(object sender, RoutedEventArgs e) { IWide310x150TileNotificationContent wide310x150TileContent = null; if (ProtocolList.SelectedItem == package) //using the ms-appx:/// protocol { ITileWide310x150ImageAndText01 wide310x150ImageAndTextContent = TileContentFactory.CreateTileWide310x150ImageAndText01(); wide310x150ImageAndTextContent.RequireSquare150x150Content = false; wide310x150ImageAndTextContent.TextCaptionWrap.Text = "The image is in the appx package"; wide310x150ImageAndTextContent.Image.Src = "ms-appx:///images/redWide310x150.png"; wide310x150ImageAndTextContent.Image.Alt = "Red image"; wide310x150TileContent = wide310x150ImageAndTextContent; } else if (ProtocolList.SelectedItem == appdata) //using the appdata:///local/ protocol { ITileWide310x150Image wide310x150ImageContent = TileContentFactory.CreateTileWide310x150Image(); wide310x150ImageContent.RequireSquare150x150Content = false; wide310x150ImageContent.Image.Src = "ms-appdata:///local/" + this.imageRelativePath; wide310x150ImageContent.Image.Alt = "App data"; wide310x150TileContent = wide310x150ImageContent; } else if (ProtocolList.SelectedItem == http) //using http:// protocol { // Important - The Internet (Client) capability must be checked in the manifest in the Capabilities tab ITileWide310x150PeekImageCollection04 wide310x150PeekImageCollectionContent = TileContentFactory.CreateTileWide310x150PeekImageCollection04(); wide310x150PeekImageCollectionContent.RequireSquare150x150Content = false; try { wide310x150PeekImageCollectionContent.BaseUri = HTTPBaseURI.Text; } catch (ArgumentException exception) { OutputTextBlock.Text = exception.Message; return; } wide310x150PeekImageCollectionContent.TextBodyWrap.Text = "The base URI is " + HTTPBaseURI.Text; wide310x150PeekImageCollectionContent.ImageMain.Src = HTTPImage1.Text; wide310x150PeekImageCollectionContent.ImageSmallColumn1Row1.Src = HTTPImage2.Text; wide310x150PeekImageCollectionContent.ImageSmallColumn1Row2.Src = HTTPImage3.Text; wide310x150PeekImageCollectionContent.ImageSmallColumn2Row1.Src = HTTPImage4.Text; wide310x150PeekImageCollectionContent.ImageSmallColumn2Row2.Src = HTTPImage5.Text; wide310x150TileContent = wide310x150PeekImageCollectionContent; } wide310x150TileContent.RequireSquare150x150Content = false; TileUpdateManager.CreateTileUpdaterForApplication().Update(wide310x150TileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(wide310x150TileContent.GetContent()); rootPage.NotifyUser("Tile notification sent", NotifyType.StatusMessage); }
public async void UpdateAsync(long count) { try { var wideImage = await RenderAsync(new StartTileWide(count), 310, 150); if (wideImage == null) { return; } var wideName = await SaveFileAsync(wideImage, WideFileName, 310U, 150U); var squareImage = await RenderAsync(new StartTileSquare(count), 150, 150); if (squareImage == null) { return; } var squareName = await SaveFileAsync(squareImage, SquareFileName, 150U, 150U); var squareSmallImage = await RenderAsync(new StartTileSquareSmall(count), 71, 71); if (squareSmallImage == null) { return; } var squareSmallName = await SaveFileAsync(squareSmallImage, SquareSmallFileName, 71U, 71U); var tileWide = TileContentFactory.CreateTileWide310x150Image(); tileWide.StrictValidation = true; tileWide.Branding = TileBranding.Name; tileWide.Image.Src = "ms-appdata:///local/" + wideName; var tileSquare = TileContentFactory.CreateTileSquare150x150Image(); tileSquare.Branding = TileBranding.Name; tileSquare.Image.Src = "ms-appdata:///local/" + squareName; tileWide.Square150x150Content = tileSquare; var tileSquareSmall = TileContentFactory.CreateTileSquare71x71Image(); tileSquareSmall.Branding = TileBranding.None; tileSquareSmall.Image.Src = "ms-appdata:///local/" + squareSmallName; tileSquare.Square71x71Content = tileSquareSmall; var tileNotification = tileWide.CreateNotification(); tileNotification.ExpirationTime = DateTimeOffset.Now.AddDays(1D); var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Clear(); tileUpdater.Update(tileNotification); } catch (Exception ex) { _telemetryClient.TrackException(ex); } }
/// <summary> /// 支持大/宽/中/小磁贴的更新 /// </summary> /// <param name="largeTileGrid"></param> /// <param name="wideTileGrid"></param> /// <param name="mediumTileGrid"></param> /// <param name="smallTileGrid"></param> /// <returns></returns> public async static Task <bool> UpdateTileForWindows(UIElement largeTileGrid, UIElement wideTileGrid, UIElement mediumTileGrid, UIElement smallTileGrid) { try { string largename = await SaveUIElementToFile(largeTileGrid, TileCategory.Large); string widename = await SaveUIElementToFile(wideTileGrid, TileCategory.Wide); string mediumname = await SaveUIElementToFile(mediumTileGrid, TileCategory.Medium); string smallname = await SaveUIElementToFile(smallTileGrid, TileCategory.Small); if (String.IsNullOrEmpty(widename) || String.IsNullOrEmpty(mediumname) || String.IsNullOrEmpty(smallname) || String.IsNullOrEmpty(largename)) { throw new NullReferenceException(); } //small var smallTileContent = TileContentFactory.CreateTileSquare71x71Image(); smallTileContent.Image.Src = "ms-appdata:///local/" + smallname; //medium var mediumTileContent = TileContentFactory.CreateTileSquare150x150Image(); mediumTileContent.RequireSquare71x71Content = true; mediumTileContent.Square71x71Content = smallTileContent; mediumTileContent.Image.Src = "ms-appdata:///local/" + mediumname; mediumTileContent.Branding = TileBranding.None; //wide var wideTileContent = TileContentFactory.CreateTileWide310x150Image(); wideTileContent.RequireSquare150x150Content = true; wideTileContent.Square150x150Content = mediumTileContent; wideTileContent.Image.Src = "ms-appdata:///local/" + widename; wideTileContent.Branding = TileBranding.None; var largeTileContent = TileContentFactory.CreateTileSquare310x310Image(); largeTileContent.RequireWide310x150Content = true; largeTileContent.Wide310x150Content = wideTileContent; largeTileContent.Image.Src = "ms-appdata:///local/" + largename; largeTileContent.Branding = TileBranding.None; var notification = largeTileContent.CreateNotification(); //TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); return(true); } catch (Exception) { return(false); } }
/// <summary> /// 支持宽/中/小磁贴的更新 /// </summary> /// <param name="wideTileGrid"></param> /// <param name="mediumTileGrid"></param> /// <param name="smallTileGrid"></param> /// <returns></returns> public async static Task <bool> UpdatePersonalTile(UIElement wideTileGrid, UIElement mediumTileGrid, UIElement smallTileGrid, bool isAddToSchedule = false) { try { string widename = await SaveUIElementToFile(wideTileGrid, TileCategory.Wide); string mediumname = await SaveUIElementToFile(mediumTileGrid, TileCategory.Medium); string smallname = await SaveUIElementToFile(smallTileGrid, TileCategory.Small); if (string.IsNullOrEmpty(widename) || string.IsNullOrEmpty(mediumname) || string.IsNullOrEmpty(smallname)) { throw new NullReferenceException(); } //small var smallTileContent = TileContentFactory.CreateTileSquare71x71Image(); smallTileContent.Image.Src = "ms-appdata:///local/" + smallname; //medium var mediumTileContent = TileContentFactory.CreateTileSquare150x150Image(); mediumTileContent.RequireSquare71x71Content = true; mediumTileContent.Square71x71Content = smallTileContent; mediumTileContent.Image.Src = "ms-appdata:///local/" + mediumname; mediumTileContent.Branding = TileBranding.None; //wide var wideTileContent = TileContentFactory.CreateTileWide310x150Image(); wideTileContent.RequireSquare150x150Content = true; wideTileContent.Square150x150Content = mediumTileContent; wideTileContent.Image.Src = "ms-appdata:///local/" + widename; wideTileContent.Branding = TileBranding.None; TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(isAddToSchedule); var notification = wideTileContent.CreateNotification(); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); return(true); } catch (Exception) { return(false); } }
private void EnsureDefaultTile() { var wideTile = TileContentFactory.CreateTileWide310x150Image(); var squareTile = TileContentFactory.CreateTileSquare150x150Image(); wideTile.Square150x150Content = squareTile; squareTile.Branding = TileBranding.Name; squareTile.Image.Src = "ms-appx:///resources/images/square150.png"; wideTile.Branding = TileBranding.Name; wideTile.Image.Src = "ms-appx:///resources/images/wide.png"; var notification = wideTile.CreateNotification(); notification.Tag = "default"; var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Update(notification); }