public static void CreateTileNotification(ClassInstance classInstance, DateTime next) { var tile = AdaptiveTile.CreateTile(); var binding = TileBinding.Create(TemplateType.TileWide); binding.Branding = Branding.None; var subgroup = new SubGroup(); if (classInstance.classData != null) { var header = new Text(classInstance.classData.ToString()) { Style = TextStyle.Body }; subgroup.AddText(header); } if (classInstance.from != null) { var dateTime = new Text(Data.loader.GetString(classInstance.weekDay.ToString()) + " " + classInstance.from) { Style = TextStyle.Body }; subgroup.AddText(dateTime); } if (classInstance.room != null) { var classRoom = new Text(classInstance.room) { Style = TextStyle.Caption }; subgroup.AddText(classRoom); } if (classInstance.teacher != null) { var teacher = new Text(classInstance.teacher.ToString()) { Style = TextStyle.Caption }; subgroup.AddText(teacher); } binding.Add(subgroup); tile.Tiles.Add(binding); TileNotification tn = tile.GetNotification(); tn.ExpirationTime = new DateTimeOffset(next); TileUpdateManager.CreateTileUpdaterForApplication().Update(tn); }
public static void CreateTileNotification(Task taskInstance) { var tile = AdaptiveTile.CreateTile(); var binding = TileBinding.Create(TemplateType.TileWide); binding.Branding = Branding.None; var subgroup = new SubGroup(); if (!string.IsNullOrWhiteSpace(taskInstance.title)) { var header = new Text(taskInstance.title) { Style = TextStyle.Body }; subgroup.AddText(header); } if (taskInstance.deadline != null) { var dateTime = new Text(taskInstance.deadline.ToString()) { Style = TextStyle.Body, IsNumeralStyle = true }; subgroup.AddText(dateTime); } if (taskInstance.classTarget != null) { var classRoom = new Text(taskInstance.classTarget.ToString()) { Style = TextStyle.Caption, IsSubtleStyle = true }; subgroup.AddText(classRoom); } if (taskInstance.description != null) { var description = new Text(taskInstance.description); subgroup.AddText(description); } binding.Add(subgroup); tile.Tiles.Add(binding); TileNotification tn = tile.GetNotification(); tn.ExpirationTime = new DateTimeOffset(taskInstance.deadline); TileUpdateManager.CreateTileUpdaterForApplication().Update(tn); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { var tile = AdaptiveTile.CreateTile(); var binding = TileBinding.Create(TemplateType.TileWide); binding.Branding = Branding.None; var header = new Text("You have mail") { Style = TextStyle.Body }; var content = new Text("Someone likes you!") { Style = TextStyle.Caption }; var logo = new TileImage(ImagePlacement.Inline) { Source = "http://fc02.deviantart.net/fs71/i/2013/359/a/4/deadpool_logo_1_fill_by_mr_droy-d5q6y5u.png" }; var logoSubGroup = new SubGroup { Width = 40 }; logoSubGroup.AddImage(logo); var subgroup = new SubGroup(); subgroup.AddText(header); subgroup.AddText(content); binding.Add(logoSubGroup); binding.Add(subgroup); tile.Tiles.Add(binding); var xml = tile.GetXml(); if (string.IsNullOrEmpty(xml)) { } }
private static TileBinding CreateTile(TemplateType size, Place place, int limit = 10) { var tileBinding = TileBinding.Create(size); tileBinding.DisplayName = place.PlaceName; tileBinding.Branding = Branding.Name; tileBinding.OverlayOpacity = 20; tileBinding.Add(new TileImage(ImagePlacement.Background) { Source = string.Format(WallpaperUriTemplate, place.OverallForecast) }); foreach (var forecast in place.Forecast.Take(limit)) { var subGroup = new SubGroup { Width = 1 }; subGroup.AddText(new Text(forecast.Day) { Alignment = Alignment.Center }); subGroup.AddImage(new TileImage(ImagePlacement.Inline) { RemoveMargin = true, Source = string.Format(UriTemplate, forecast.Forecast) }); subGroup.AddText(new Text($"{forecast.TemperatureHigh}°") { Alignment = Alignment.Center }); subGroup.AddText(new Text($"{forecast.TemperatureLow}°") { Alignment = Alignment.Center, Style = TextStyle.Caption, IsSubtleStyle = true }); tileBinding.AddSubgroup(subGroup); } return(tileBinding); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { var tile = AdaptiveTile.CreateTile(); #region for wide tile with background var wideBinding = TileBinding.Create(TemplateType.TileWide); wideBinding.Branding = Branding.NameAndLogo; var wideLogo = new TileImage(ImagePlacement.Background) { Source = "http://fc02.deviantart.net/fs71/i/2013/359/a/4/deadpool_logo_1_fill_by_mr_droy-d5q6y5u.png" }; //background/peek images need to be at the root of the binding; wideBinding.BackgroundImage = wideLogo; var wideHeader = new Text("You have mail") { Style = TextStyle.Body }; var wideContent = new Text("Someone likes you!") { Style = TextStyle.Caption }; var wideSubgroup = new SubGroup(); wideSubgroup.AddText(wideHeader); wideSubgroup.AddText(wideContent); wideBinding.AddSubgroup(wideSubgroup, true); #endregion #region square tile var binding = TileBinding.Create(TemplateType.TileMedium); binding.Branding = Branding.None; var header = new Text("You have mail") { Style = TextStyle.Body, WrapText = true }; var content = new Text("Someone likes you!") { Style = TextStyle.Caption, IsSubtleStyle = true, WrapText = true, Alignment = Alignment.Center }; var logo = new TileImage(ImagePlacement.Inline) { Source = "http://fc02.deviantart.net/fs71/i/2013/359/a/4/deadpool_logo_1_fill_by_mr_droy-d5q6y5u.png" }; var imageSubgroup = new SubGroup() { Width = 20 }; imageSubgroup.AddImage(logo); var subgroup = new SubGroup(); subgroup.AddText(header); subgroup.AddText(content); binding.AddSubgroup(imageSubgroup); binding.AddSubgroup(subgroup); #endregion // Add the types of tile bindings to the tile. tile.Tiles.Add(wideBinding); tile.Tiles.Add(binding); var notification = tile.GetNotification(); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); }
internal async Task <bool> PinAsync(DetailPageViewModel detailPageViewModel) { // prepare content var header = new Text("Template 10") { Style = TextStyle.Subtitle }; var content = new Text(detailPageViewModel.Value) { Style = TextStyle.Caption, WrapText = true }; var logo = new TileImage(ImagePlacement.Inline) { Source = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png" }; // build tile var tile = AdaptiveTile.CreateTile(string.Empty); var binding = TileBinding.Create(TemplateType.TileWide); binding.Branding = Branding.Name; var sub1 = new SubGroup { Width = 33 }; binding.Add(sub1); sub1.AddImage(logo); var sub2 = new SubGroup(); binding.Add(sub2); sub2.AddText(header); sub2.AddText(content); tile.Tiles.Add(binding); // show tile var tileId = detailPageViewModel.ToString(); if (!await IsPinned(detailPageViewModel)) { // initial pin var secondaryTile = new SecondaryTile(tileId) { Arguments = detailPageViewModel.Value, DisplayName = "Detail page", VisualElements = { Square44x44Logo = new Uri("ms-appx:///Assets/Logo.png"), Square150x150Logo = new Uri("ms-appx:///Assets/Logo.png"), Wide310x150Logo = new Uri("ms-appx:///Assets/Logo.png"), Square310x310Logo = new Uri("ms-appx:///Assets/Logo.png"), ShowNameOnSquare150x150Logo = true, }, }; if (!await secondaryTile.RequestCreateAsync()) { System.Diagnostics.Debugger.Break(); return(false); } } // update pin var xml = tile.GetNotification().Content; xml.DocumentElement.RemoveAttribute("version"); var value = xml.GetXml(); var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId); var tileNotification = new TileNotification(xml); tileUpdater.Update(tileNotification); return(true); }