public static void CreateRecentActvityLiveTile(Feed feed) { TileBindingContentAdaptive bindingContent; if (feed.SmallImageUrl != null) { bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Crop = TileImageCrop.None, Overlay = 0, Source = new TileImageSource(feed.SmallImageUrl) }, Children = { new TileText() { Text = feed.Caption, Wrap = true, Style = TileTextStyle.Body } } }; } else { bindingContent = new TileBindingContentAdaptive() { Children = { new TileText() { Text = feed.Caption, Wrap = true, Style = TileTextStyle.Body } } }; } var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var secondaryTile = new SecondaryTile( "tilePage", "shortname", "displayname", new Uri("ms-appx:///Assets/StoreLogo.png", UriKind.Absolute), TileSize.Default); var success = await secondaryTile.RequestCreateAsync(); if (success) { var tileBindingContentAdaptive = new TileBindingContentAdaptive { Children = { new TileText { Text = "uwp tiles", Style = TileTextStyle.Header }, new TileText { Text = "secondary", Style = TileTextStyle.Body } } }; var tileBinding = new TileBinding { Branding = TileBranding.Name, Content = tileBindingContentAdaptive, DisplayName = "my tile" }; var tileContent = new TileContent { Visual = new TileVisual { TileMedium = tileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; var xmlDoc = tileContent.GetXml(); TileNotification tileNotification = new TileNotification(xmlDoc); var tileUpdaterForSecondaryTile = TileUpdateManager.CreateTileUpdaterForSecondaryTile("tilePage"); tileUpdaterForSecondaryTile.Update(tileNotification); } }
private void Button_Tapped(object sender, TappedRoutedEventArgs e) { var dining = App.MainViewModel.HfsData.resident_dining; var term = App.MainViewModel.TermInfo; var bindingContent = new TileBindingContentAdaptive(); var items = bindingContent.Children; items.Add(new TileText() { Text = $"Balance: ${dining.balance:0.00}", Style = TileTextStyle.Body }); items.Add(new TileText() { Text = $"Days: {term.FullDaysRemaining}", Style = TileTextStyle.Caption }); items.Add(new TileText() { Text = $"Avg/Day: ${dining.balance/term.FullDaysRemaining:0.00}", Style = TileTextStyle.Caption }); var tileBinding = new TileBinding(); tileBinding.Content = bindingContent; tileBinding.DisplayName = "FoodTile"; tileBinding.Branding = TileBranding.NameAndLogo; var content = new TileContent() { Visual = new TileVisual() { TileSmall = tileBinding, TileMedium = tileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; XmlDocument doc = content.GetXml(); var note = new TileNotification(doc); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(note); }
private void ButtonSendTileNotification_Click(object sender, RoutedEventArgs e) { TileBindingContentAdaptive bindingContent = new TileBindingContentAdaptive() { Children = { GenerateEmailGroup("Jennifer Parker", "Photos from our trip"), GenerateEmailGroup("Steve Bosniak", "Want to go out for dinner after Build tonight?") } }; TileBinding binding = new TileBinding() { Content = bindingContent }; TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = binding } }; DataPackage dp = new DataPackage(); dp.SetText(content.GetContent()); Clipboard.SetContent(dp); return; string xmlAsString = content.GetContent(); TileNotification notification = new TileNotification(content.GetXml()); content.Visual.TileMedium = new TileBinding() { Branding = TileBranding.Logo, Content = new TileBindingContentAdaptive() }; ComboBox comboBox = new ComboBox(); //var tileContent = NotificationsExtensions.GenerateTileContent(); //TileNotification notif = new TileNotification(null); //ITileSquareText01 tileContent = TileContentFactory.CreateTileSquareText01(); }
public static void CreateBookmarkLiveTile(ForumThreadEntity forumThread) { var bindingContent = new TileBindingContentAdaptive() { Children = { new TileText() { Text = forumThread.Name, Style = TileTextStyle.Body }, new TileText() { Text = string.Format("Unread Posts: {0}", forumThread.RepliesSinceLastOpened), Wrap = true, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = string.Format("Killed By: {0}", forumThread.KilledBy), Wrap = true, Style = TileTextStyle.CaptionSubtle } } }; var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
private void button_Click(object sender, RoutedEventArgs e) { var bindingContent = new TileBindingContentAdaptive { PeekImage = new TilePeekImage { Source = new TileImageSource("Assets/Square150x150Logo.png") }, Children = { new TileText { Text = "Hello world", Style = TileTextStyle.Title }, new TileText { Text = "okazuki", Style = TileTextStyle.Body }, } }; var tileBinding = new TileBinding { Branding = TileBranding.NameAndLogo, Content = bindingContent, DisplayName = "Hello display name", }; var content = new TileContent { Visual = new TileVisual { TileSmall = tileBinding, TileMedium = tileBinding, TileLarge = tileBinding, TileWide = tileBinding, } }; var n = new TileNotification(content.GetXml()); TileUpdateManager.CreateTileUpdaterForApplication() .Update(n); }
public void TestMailTile() { TileBinding small = new TileBinding() { Content = new TileBindingContentIconic() { Icon = new TileImageSource("Assets\\Mail.png") } }; TileBinding medium = new TileBinding() { Branding = TileBranding.Logo, Content = new TileBindingContentAdaptive() { Children = { GenerateFirstMessage(false), GenerateSpacer(), GenerateSecondMessage(false) } } }; TileBinding wideAndLarge = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = new TileBindingContentAdaptive() { Children = { GenerateFirstMessage(true), GenerateSpacer(), GenerateSecondMessage(true) } } }; TileContent content = new TileContent() { Visual = new TileVisual() { TileSmall = small, TileMedium = medium, TileWide = wideAndLarge, TileLarge = wideAndLarge } }; string expectedXml = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual><binding template=""TileSquare71x71IconWithBadge""><image id=""1"" src=""Assets\Mail.png"" /></binding>"; // Medium expectedXml += @"<binding template=""TileMedium"" branding=""logo"">"; expectedXml += GenerateXmlGroups(false); expectedXml += "</binding>"; // Wide expectedXml += @"<binding template=""TileWide"" branding=""nameAndLogo"">"; expectedXml += GenerateXmlGroups(true); expectedXml += "</binding>"; // Large expectedXml += @"<binding template=""TileLarge"" branding=""nameAndLogo"">"; expectedXml += GenerateXmlGroups(true); expectedXml += "</binding>"; expectedXml += "</visual></tile>"; string actualXml = content.GetContent(); AssertHelper.AssertXml(expectedXml, actualXml); //Assert.AreEqual(expectedXml, actualXml); }
internal async Task<bool> PinAsync(DetailPageViewModel detailPageViewModel) { var name = "Tiles sample"; var title = "Template 10"; var body = detailPageViewModel.Value; var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png"; var bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Source = new TileImageSource(image) }, Children = { new TileText() { Text = title, Style = TileTextStyle.Body }, new TileText() { Text = body, Wrap = true, Style = TileTextStyle.CaptionSubtle } } }; var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, DisplayName = name, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var xml = content.GetXml(); // show tile var tileId = detailPageViewModel.ToString(); if (!await IsPinned(detailPageViewModel)) { // initial pin var logo = new Uri("ms-appx:///Assets/Logo.png"); var secondaryTile = new SecondaryTile(tileId) { Arguments = detailPageViewModel.Value, DisplayName = name, VisualElements = { Square44x44Logo = logo, Square150x150Logo = logo, Wide310x150Logo = logo, Square310x310Logo = logo, ShowNameOnSquare150x150Logo = true, }, }; if (!await secondaryTile.RequestCreateAsync()) { System.Diagnostics.Debugger.Break(); return false; } } // add notifications var tileNotification = new TileNotification(xml); var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId); tileUpdater.Update(tileNotification); // show toast ShowToast(detailPageViewModel); // result return true; }
public async void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral _defferal = taskInstance.GetDeferral(); var appdata = ApplicationData.Current.LocalSettings; if (!(bool) (appdata.Values["TileUpdates"] ?? false) && !(bool) (appdata.Values["UseToasts"] ?? false)) // if task isn't needed, kill it { _defferal.Complete(); return; } PasswordVault vault = new PasswordVault(); PasswordCredential cred; try { cred = vault.FindAllByResource("MYUW").First(); // Make sure this matches CredResName } catch { _defferal.Complete(); return; } var connector = new MUConnector(cred); if (await connector.Login()) { //double lastValue = (float)(appdata.Values["LastValue"] ?? -1); //shit's stored as a float... avoids invalid cast float lastValue = -1; if (appdata.Values.ContainsKey("LastValue")) { float? lv = appdata.Values["LastValue"] as float?; // stupid workarounds for float precision lastValue = lv.Value; } var hfs = await connector.GetHfsData(); var term = await connector.GetTermInfo(); double average = hfs.resident_dining.balance / term.AdjustedDaysRemaining(LoadSavedDates()); if ((bool)(appdata.Values["TileUpdates"] ?? false)) { var bindingContent = new TileBindingContentAdaptive(); var medBindingContent = new TileBindingContentAdaptive(); var items = bindingContent.Children; var medItems = medBindingContent.Children; medItems.Add(new TileText() { Text = $"{hfs.resident_dining.balance:C} remaining", Style = TileTextStyle.Body }); items.Add(new TileText() { Text = $"{hfs.resident_dining.balance:C} remaining", Style = TileTextStyle.Subtitle }); var line2 = new TileText() { Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days", Style = TileTextStyle.Caption }; var line3 = new TileText() { Text = $"${average:0.00} per day", Style = TileTextStyle.Caption }; items.Add(line2); items.Add(line3); medItems.Add(line2); medItems.Add(line3); var tileBinding = new TileBinding() { Content = bindingContent, DisplayName = "FoodTile", Branding = TileBranding.NameAndLogo }; var medTileBinding = new TileBinding() { Content = medBindingContent, DisplayName = "FoodTile", Branding = TileBranding.NameAndLogo }; var content = new TileContent() { Visual = new TileVisual { TileMedium = medTileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; var note = new TileNotification(content.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(note); } if (hfs.resident_dining.balance != lastValue) { if ((bool)(appdata.Values["UseToasts"] ?? false)) { var toastContent = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = $"Dining Balance ${hfs.resident_dining.balance:0.00}" }, BodyTextLine1 = new ToastText() { Text = $"New daily average ${average:0.00}" }, BodyTextLine2 = new ToastText() { Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days remaining in quarter" } } }; var note = ToastNotificationManager.CreateToastNotifier(); var toast = new ToastNotification(toastContent.GetXml()); note.Show(toast); } appdata.Values["LastValue"] = hfs.resident_dining.balance; } } connector.Dispose(); _defferal.Complete(); }
public void TestXboxModernTile() { TileBinding medium = new TileBinding() { Content = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Base, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintAlign = AdaptiveTextAlign.Center } } } }; TileBinding wide = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 33, Children = { new AdaptiveImage() { Source = "http://xbox.com/MasterHip/profile.jpg", HintCrop = AdaptiveImageCrop.Circle } } }, new AdaptiveSubgroup() { HintTextStacking = AdaptiveSubgroupTextStacking.Center, Children = { new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.SubtitleSubtle } } } } } } } }; TileBinding large = new TileBinding() { Content = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 1 }, new AdaptiveSubgroup() { HintWeight = 2, Children = { new AdaptiveImage() { Source = "http://xbox.com/MasterHip/profile.jpg", HintCrop = AdaptiveImageCrop.Circle } } }, new AdaptiveSubgroup() { HintWeight = 1 } } }, new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Title, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.SubtitleSubtle, HintAlign = AdaptiveTextAlign.Center } } } }; TileContent content = new TileContent() { Visual = new TileVisual() { Branding = TileBranding.NameAndLogo, TileMedium = medium, TileWide = wide, TileLarge = large } }; string expectedXml = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual branding=""nameAndLogo"">"; // Medium expectedXml += @"<binding template=""TileMedium"" hint-textStacking=""center""><text hint-align=""center"" hint-style=""base"">Hi,</text><text hint-align=""center"" hint-style=""captionSubtle"">MasterHip</text></binding>"; // Wide expectedXml += @"<binding template=""TileWide""><group><subgroup hint-weight=""33""><image src=""http://xbox.com/MasterHip/profile.jpg"" hint-crop=""circle"" /></subgroup><subgroup hint-textStacking=""center""><text hint-style=""title"">Hi,</text><text hint-style=""subtitleSubtle"">MasterHip</text></subgroup></group></binding>"; // Large expectedXml += @"<binding template=""TileLarge"" hint-textStacking=""center""><group><subgroup hint-weight=""1"" /><subgroup hint-weight=""2""><image src=""http://xbox.com/MasterHip/profile.jpg"" hint-crop=""circle"" /></subgroup><subgroup hint-weight=""1"" /></group><text hint-align=""center"" hint-style=""title"">Hi,</text><text hint-align=""center"" hint-style=""subtitleSubtle"">MasterHip</text></binding>"; expectedXml += "</visual></tile>"; string actualXml = content.GetContent(); AssertHelper.AssertXml(expectedXml, actualXml); //Assert.AreEqual(expectedXml, actualXml); }
private static void AssertBindingMedium(string expectedBindingXml, TileBinding binding) { AssertVisual("<visual>" + expectedBindingXml + "</visual>", new TileVisual() { TileMedium = binding }); }
private void EvaluateMessages(Messages obj) { if (obj == Messages.NotesChanged) { var vm = SimpleIoc.Default.GetInstance<MainViewModel>(); if (vm != null && vm.NoteCollections != null) { var newNotes = vm.NoteCollections.SelectMany(noteCollectionModel => noteCollectionModel.NewNotes).ToList(); var adap2 = new TileBindingContentAdaptive() { Children = { new AdaptiveText() { HintStyle = AdaptiveTextStyle.Title, Text = newNotes.Count + " pending" }, // For spacing new AdaptiveText() } }; foreach (var noteModel in newNotes) { adap2.Children.Add(new AdaptiveText() { Text = noteModel.Content, HintStyle = AdaptiveTextStyle.BodySubtle }); } var tileLarge = new TileBinding() { Branding = TileBranding.None, Content = adap2 }; var tileSmall = new TileBinding() { Branding = TileBranding.None, Content = new TileBindingContentAdaptive() { Children = { new AdaptiveText() { HintStyle = AdaptiveTextStyle.Header, Text = newNotes.Count.ToString("00"), HintAlign = AdaptiveTextAlign.Center } } } }; var tileVisual = new TileVisual() { TileLarge = tileLarge, TileMedium = tileLarge, TileWide = tileLarge, TileSmall = tileSmall, }; var tileContent = new TileContent() { Visual = tileVisual }; var notif = new TileNotification(tileContent.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(notif); } } }
private async void Pin() { if (this.Group == null) { return; } string tileID = $"Tile_Group_{this.GroupID}"; string argument = $"GroupDetail-{this.GroupID}"; SecondaryTile tile = new SecondaryTile(tileID, this.Group.Name, argument, new Uri("ms-appx:///Assets/logo-50.png"), TileSize.Square150x150); await tile.RequestCreateAsync(); TileBindingContentAdaptive bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Source = new TileImageSource(this.Group.LargeAvatar) } }; bindingContent.Children.Add(new TileText { Text = this.Group.Name, Wrap = true, Style = TileTextStyle.Body }); TileBinding binding = new TileBinding() { Branding = TileBranding.NameAndLogo, DisplayName = this.Group.Name, Content = bindingContent }; TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var notification = new TileNotification(content.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID); updater.Update(notification); bool result = await tile.UpdateAsync(); }