public void setTile(Exercise ex) { string imagePath_Wide = "ms-appx:///assets/tiles_images/wide_tile/" + ex.Title + ".jpg"; string imagePath_Square = "ms-appx:///assets/tiles_images/square_tile/" + ex.Title + ".jpg";; string title = ex.Title; string reps = "Reps: " + ex.Reps; string sets = "Sets: " + ex.Sets; ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image(); tileContent.Image.Src = imagePath_Square; tileContent.Image.Alt = "image"; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150PeekImage02 wideTile = TileContentFactory.CreateTileWide310x150PeekImage02(); wideTile.TextHeading.Text = title; wideTile.TextBody2.Text = reps; wideTile.TextBody3.Text = sets; wideTile.Image.Src = imagePath_Wide; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150PeekImageAndText01 square150x150Content = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); square150x150Content.Image.Src = imagePath_Square; square150x150Content.TextBody1.Text = title; square150x150Content.TextBody2.Text = reps; square150x150Content.TextBody3.Text = sets; // Create a notification for the Square71x71 tile using one of the available templates for the size. //ITileSquare71x71Image square71x71Content = TileContentFactory.CreateTileSquare71x71Image(); //square71x71Content.Image.Src = imagePath; // Attach the Square71x71 template to the Square150x150 template. //square150x150Content.Square71x71Content = square71x71Content; // Attach the Square150x150 template to the Wide310x150 template. wideTile.Square150x150Content = square150x150Content; // Attach the Wide310x150 to the Square310x310 template. tileContent.Wide310x150Content = wideTile; // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); }
//public static CreateSecondaryTile(string tileId) //{ //} /// <summary> /// 更新默认磁贴内容(不通用) /// </summary> /// <param name="tileModel"></param> public static void UpdateTileNotifications(string ImageSrc, string TextHeading, string TextBody1, string TextBody2, string TextBody3) { ITileWide310x150ImageAndText01 tileWide310x150ImageAndText01 = TileContentFactory.CreateTileWide310x150ImageAndText01(); ITileSquare150x150PeekImageAndText01 tileSquare150x150PeekImageAndText01 = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); //磁铁内容赋值 tileSquare150x150PeekImageAndText01.Image.Src = ImageSrc; tileSquare150x150PeekImageAndText01.TextHeading.Text = TextHeading; tileSquare150x150PeekImageAndText01.TextBody1.Text = TextBody1; tileSquare150x150PeekImageAndText01.TextBody2.Text = TextBody2; tileSquare150x150PeekImageAndText01.TextBody3.Text = TextBody3; tileWide310x150ImageAndText01.Square150x150Content = tileSquare150x150PeekImageAndText01; tileWide310x150ImageAndText01.Image.Src = "ms-appx:///Assets/WideLogo.scale-100.png"; tileWide310x150ImageAndText01.TextCaptionWrap.Text = TextHeading + TextBody1 + TextBody2 + TextBody3; //更新至磁贴 TileUpdateManager.CreateTileUpdaterForApplication().Update(tileWide310x150ImageAndText01.CreateNotification()); }
/// <summary> /// Sets the MainTile with new Information /// </summary> /// <param name="income">Income of these month</param> /// <param name="spending">Spending of these month</param> /// <param name="earnings">Earnings of these month </param> public void UpdateMainTile(string income, string spending, string earnings) { TileUpdateManager.CreateTileUpdaterForApplication().Clear(); if (ServiceLocator.Current.GetInstance <TileSettingsViewModel>().ShowInfoOnMainTile) { ITileSquare310x310SmallImagesAndTextList04 tileContent = TileContentFactory.CreateTileSquare310x310SmallImagesAndTextList04(); tileContent.Image1.Src = "ms-appx:///Assets/Logo.png"; tileContent.TextHeading1.Text = Translation.GetTranslation("CashflowTileLabel"); tileContent.TextWrap1.Text = income; tileContent.TextWrap2.Text = spending; tileContent.TextWrap3.Text = earnings; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150SmallImageAndText02 wide310x150Content = TileContentFactory.CreateTileWide310x150SmallImageAndText02(); wide310x150Content.Image.Src = "ms-appx:///Assets/Logo.png"; wide310x150Content.TextHeading.Text = Translation.GetTranslation("CashflowTileLabel"); wide310x150Content.TextBody1.Text = income; wide310x150Content.TextBody2.Text = spending; wide310x150Content.TextBody3.Text = earnings; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150PeekImageAndText01 square150x150Content = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); square150x150Content.Image.Src = "ms-appx:///Assets/Logo.png"; square150x150Content.TextHeading.Text = Translation.GetTranslation("CashflowTileLabel"); square150x150Content.TextBody1.Text = income; square150x150Content.TextBody2.Text = spending; square150x150Content.TextBody3.Text = earnings; // Attach the Square150x150 template to the Wide310x150 template. wide310x150Content.Square150x150Content = square150x150Content; // Attach the Wide310x150 template to the Square310x310 template. tileContent.Wide310x150Content = wide310x150Content; // Send the notification to the application? tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); } }