GetXml() public method

Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local tile notification's constructor on either Windows.UI.Notifications.TileNotification or Windows.UI.Notifications.ScheduledTileNotification.
public GetXml ( ) : XmlDocument
return Windows.Data.Xml.Dom.XmlDocument
        private async void UpdateMedium(TileBindingContentAdaptive mediumContent)
        {
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = mediumContent
                    }
                }
            };

            try
            {
                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }

            catch
            {
                SecondaryTile tile = new SecondaryTile("SecondaryTile", "Example", "args", new Uri("ms-appx:///Assets/Logo.png"), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo = true;
                tile.VisualElements.BackgroundColor = Colors.Transparent;
                await tile.RequestCreateAsync();

                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }
        }
Beispiel #2
0
 public static void CreateScheduledTileNotification(TileContent content, DateTime dueTime, string id)
 {
     ScheduledTileNotification scheduledTile = new ScheduledTileNotification(content.GetXml(), dueTime);
     scheduledTile.Id = id;
     RemoveSpecScheduledTileNotification(id);
     TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile);
 }
Beispiel #3
0
 public static void CreateSubTileNotification(TileContent content, string tileName, TimeSpan duration)
 {
     if (SecondaryTile.Exists(tileName))
     {
         var notification = new TileNotification(content.GetXml());
         notification.ExpirationTime = DateTimeOffset.UtcNow + duration;
         var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileName);
         updater.Update(notification);
     }
 }
        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);   
            }

        }
Beispiel #5
0
        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);
        }
        /// <summary>
        ///     Sets the MainTile with new Information
        /// </summary>
        /// <param name="income">Income of these month</param>
        /// <param name="spending">Expense of these month</param>
        /// <param name="earnings">Earnings of these month </param>
        public void UpdateMainTile(string income, string spending, string earnings)
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();

            var content = new TileContent
            {
                Visual = new TileVisual
                {
                    TileMedium = GetBindingMediumContent(income, spending, earnings),
                    TileWide = GetBindingWideContent(income, spending, earnings),
                    TileLarge = GetBindingLargeContent(income, spending, earnings)
                } 
            };

            // Update Tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));
        }
        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();
        }
        /// <summary>
        ///     Sets the MainTile with new Information
        /// </summary>
        /// <param name="income">Income of these month</param>
        /// <param name="spending">Expense 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<SettingsShortcutsViewModel>().ShowInfoOnMainTile)
            {
                var content = new TileContent
                {
                    Visual = new TileVisual
                    {
                        TileMedium = GetBindingMediumContent(income, spending, earnings),
                        TileWide = GetBindingWideContent(income, spending, earnings),
                        TileLarge = GetBindingLargeContent(income, spending, earnings)
                    }
                };
                // Update Tile
                TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));
            }
        }
        private void ButtonUpdatePrimary_Click(object sender, RoutedEventArgs e)
        {
            // Create the notification content
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    // Recommended to use 9 photos on Medium
                    TileMedium = GeneratePeopleBinding(9),

                    // Recommended to use 15 photos on Wide
                    TileWide = GeneratePeopleBinding(15),

                    // Recommended to use 20 photos on Large
                    TileLarge = GeneratePeopleBinding(20)
                }
            };

            // And then update the primary tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));
        }
        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);
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Random rnd = new Random(DateTime.Now.Second);

            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding = TileBranding.NameAndLogo,

                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Small" + rnd.Next(30) }
                    
                }
                           
                        }
                    },

                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Medium" + rnd.Next(30) }
                }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Wide" + rnd.Next(30) }
                }
                        }
                    },

                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Large" + rnd.Next(30) }
                }
                        }
                    }
                }
            };

            var stn = new Windows.UI.Notifications.ScheduledTileNotification(content.GetXml(), new DateTimeOffset(DateTime.Now.AddSeconds(10)));

            var updater =  Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();

            updater.AddToSchedule(stn);
        }
        public void ModifyTile(string from, string subject, string body)
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();

            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                new TileText()
                                {
                                    Text = from
                                },

                                new TileText()
                                {
                                    Text = subject,
                                    Style = TileTextStyle.CaptionSubtle
                                },

                                new TileText()
                                {
                                    Text = body,
                                    Style = TileTextStyle.CaptionSubtle
                                }
                            }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                new TileText()
                                {
                                    Text = from,
                                    Style = TileTextStyle.Subtitle
                                },

                                new TileText()
                                {
                                    Text = subject,
                                    Style = TileTextStyle.CaptionSubtle
                                },

                                new TileText()
                                {
                                    Text = body,
                                    Style = TileTextStyle.CaptionSubtle
                                }
                            }
                        }
                    },

                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                new TileText()
                                {
                                    Text = from,
                                    Style = TileTextStyle.Subtitle
                                },

                                new TileText()
                                {
                                    Text = subject,
                                    Style = TileTextStyle.CaptionSubtle
                                },

                                new TileText()
                                {
                                    Text = body,
                                    Style = TileTextStyle.CaptionSubtle
                                }
                            }
                        }
                    }
                }
            };

            var notification = new TileNotification(content.GetXml());

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
Beispiel #13
0
        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);
                }
            }
        }
Beispiel #14
0
 public static void CreateMainTileNotification(TileContent content, TimeSpan duration)
 {
     var notification = new TileNotification(content.GetXml());
     notification.ExpirationTime = DateTimeOffset.UtcNow + duration;
     TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
 }
        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();
        }
 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);
 }
Beispiel #17
0
        /// <summary>
        /// ライブタイルの画像を生成しタイルに設定し直す
        /// </summary>
        /// <returns></returns>
        private static async Task updateTile()
        {
            //最新のレーダー画像を取得
            RadameItem item = await RadameDataTask.GetLatestItem(getSettingAreaCode());
            string nowTime = DateTime.Now.ToString("HH:mm") + "更新";
            StorageFile imageFile = await RadameDataTask.GetHttpFile(item.ImageUrl, getLocalFolder(), RADAR_LOCAL_FILE_NAME);
            if (imageFile == null)
            {
                return;
            }

            //設定された位置の画像を生成する
            Debug.WriteLine("updateTile imageFile.Path=" + imageFile.Path);
            StorageFile mediumImage = await resizeBitmap(imageFile, 150, 150
                , getSettingMiddleTilePosition());
            StorageFile wideImage = await resizeBitmap(imageFile, 310, 150
                , getSettingWideTilePosition());

            //タイルXML作成
            Debug.WriteLine("updateTile time=" + nowTime + " url=" + item.ImageUrl);
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding = TileBranding.None,
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = new TileImageSource(mediumImage.Path),
                                Overlay = 0,
                            },
                            Children =
                            {
                                new TileText() { Text = nowTime }
                            },
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = new TileImageSource(wideImage.Path),
                                Overlay = 0,
                            },
                            Children =
                            {
                                new TileText() { Text = nowTime }
                            },
                        }
                    },

                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = new TileImageSource(imageFile.Path),
                                Overlay = 0,
                            },
                            Children =
                            {
                                new TileText() { Text = nowTime }
                            },
                        }
                    }
                }
            };

            //更新設定
            XmlDocument doc = content.GetXml();
            TileNotification tileNotification = new TileNotification(doc);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
        void Update_Tile()
        {
            if (Player != null)
            {
                TileContent content = new TileContent()
                {
                    Visual = new TileVisual()
                    {
                        Branding = TileBranding.Name,
                        TileSmall = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                            {
                                new TileText()
                                {
                                    Text = Player.HighestScore + "",
                                    Style = TileTextStyle.Subtitle
                                },
                                new TileText()
                                {
                                    Text = Player.HighestScore+"",
                                    Style = TileTextStyle.CaptionSubtle
                                },
                            },
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = new TileImageSource("Assets/1.jpg"),
                                    Overlay = 20
                                },
                            }
                        },
                        TileMedium = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                            {
                                new TileText()
                                {
                                    Text = Player.HighestScore+"",
                                    Style = TileTextStyle.Subtitle
                                },
                                new TileText()
                                {
                                    Text = Player.HighestScore+"",
                                    Style = TileTextStyle.CaptionSubtle
                                },
                            },
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = new TileImageSource("Assets/1.jpg"),
                                    Overlay = 40
                                },
                            }
                        },
                        TileWide = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                            {
                                new TileText()
                                {
                                    Text = Player.HighestScore+"",
                                    Style = TileTextStyle.Subtitle
                                },
                                new TileText()
                                {
                                    Text = Player.HighestScore+"",
                                    Style = TileTextStyle.CaptionSubtle
                                }
                            },
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = new TileImageSource("Assets/1.jpg"),
                                    Overlay = 60
                                },
                            }
                        }
                    }

                };
                var notifi = new TileNotification(content.GetXml());
                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.Update(notifi);
            }
        }
Beispiel #19
0
        public static void Update()
        {
            string from = "Jennifer Parker";
            string subject = "Photos from our trip";
            string body = "Check out these awesome photos I took while in New Zealand!";

            var content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText()
                    {
                        Text = from
                    },

                    new TileText()
                    {
                        Text = subject,
                        Style = TileTextStyle.CaptionSubtle
                    },

                    new TileText()
                    {
                        Text = body,
                        Style = TileTextStyle.CaptionSubtle
                    }
                }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText()
                    {
                        Text = from,
                        Style = TileTextStyle.Subtitle
                    },

                    new TileText()
                    {
                        Text = subject,
                        Style = TileTextStyle.CaptionSubtle
                    },

                    new TileText()
                    {
                        Text = body,
                        Style = TileTextStyle.CaptionSubtle
                    }
                }
                        }
                    }
                }
            };

            var notification = new TileNotification(content.GetXml());
            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);

        }
 void Update_Tile()
 {
     TileContent content = new TileContent()
     {
         Visual = new TileVisual()
         {
             Branding = TileBranding.Name,
             TileSmall = new TileBinding()
             {
                 Content = new TileBindingContentAdaptive()
                 {
                     Children =
                     {
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].title : "BY SplendidSky",
                             Style = TileTextStyle.Subtitle
                         },
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].description : "",
                             Style = TileTextStyle.CaptionSubtle
                         },
                     },
                     BackgroundImage = new TileBackgroundImage()
                     {
                         Source = new TileImageSource(AllItems.Count > 0 ? Models.TodoItem.ImagePath + AllItems[AllItems.Count - 1].ImageName : Models.TodoItem.ImagePath + "background.jpg"),
                         Overlay = 20
                     },
                 }
             },
             TileMedium = new TileBinding()
             {
                 Content = new TileBindingContentAdaptive()
                 {
                     Children =
                     {
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].title : "BY SplendidSky",
                             Style = TileTextStyle.Subtitle
                         },
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].description : "",
                             Style = TileTextStyle.CaptionSubtle
                         },
                     },
                     BackgroundImage = new TileBackgroundImage()
                     {
                         Source = new TileImageSource(AllItems.Count > 0 ? Models.TodoItem.ImagePath + AllItems[AllItems.Count - 1].ImageName : Models.TodoItem.ImagePath + "background.jpg"),
                         Overlay = 40
                     },
                 }
             },
             TileWide = new TileBinding()
             {
                 Content = new TileBindingContentAdaptive()
                 {
                     Children =
                     {
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].title : "BY SplendidSky",
                             Style = TileTextStyle.Subtitle
                         },
                         new TileText()
                         {
                             Text = AllItems.Count > 0 ? AllItems[AllItems.Count - 1].description : "",
                             Style = TileTextStyle.CaptionSubtle
                         }
                     },
                     BackgroundImage = new TileBackgroundImage()
                     {
                         Source = new TileImageSource(AllItems.Count > 0 ? Models.TodoItem.ImagePath + AllItems[AllItems.Count - 1].ImageName : Models.TodoItem.ImagePath + "background.jpg"),
                         Overlay = 60
                     },
                 }
             }
         }
     };
     var notifi = new TileNotification(content.GetXml());
     var updater = TileUpdateManager.CreateTileUpdaterForApplication();
     updater.Update(notifi);
 }
Beispiel #21
0
        protected override async void OnRun(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            // Create instance of the control that contains the layout of the Live Tile
            MediumTileControl control = new MediumTileControl();
            control.Width = TileWidth;
            control.Height = TileHeight;

            // If we have received a message in the parameters, overwrite the default "Hello, Live Tile!" one
            var triggerDetails = taskInstance.TriggerDetails as ApplicationTriggerDetails;
            if (triggerDetails != null)
            {
                object tileMessage = null;
                if (triggerDetails.Arguments.TryGetValue("Message", out tileMessage))
                {
                    if (tileMessage is string)
                    {
                        control.Message = (string)tileMessage;
                    }
                }
            }            

            // Render the tile control to a RenderTargetBitmap
            RenderTargetBitmap bitmap = new RenderTargetBitmap();
            await bitmap.RenderAsync(control, TileWidth, TileHeight);

            // Now we are going to save it to a PNG file, so create/open it on local storage
            var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(TileImageFilename, CreationCollisionOption.ReplaceExisting);
            using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                // Create a BitmapEncoder for encoding to PNG
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);

                // Create a SoftwareBitmap from the RenderTargetBitmap, as it will be easier to save to disk
                using (var softwareBitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, TileWidth, TileHeight, BitmapAlphaMode.Premultiplied))
                {
                    // Copy bitmap data
                    softwareBitmap.CopyFromBuffer(await bitmap.GetPixelsAsync());

                    // Encode and save to file
                    encoder.SetSoftwareBitmap(softwareBitmap);
                    await encoder.FlushAsync();
                }
            }

            // Use the NotificationsExtensions library to easily configure a tile update
            TileContent mediumTileContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Overlay = 0,
                                Source = new TileImageSource("ms-appdata:///local/" + TileImageFilename),
                            }
                        }
                    }
                }
            };

            // Clean previous update from Live Tile and update with the new parameters
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            tileUpdater.Clear();
            tileUpdater.Update(new TileNotification(mediumTileContent.GetXml()));
            
            deferral.Complete();
        }
 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);
 }
        public MainPage()
        {
            this.InitializeComponent();


            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding = TileBranding.NameAndLogo,

                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Small" }
                }
                        }
                    },

                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Medium" }
                }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Wide" }
                }
                        }
                    },

                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                {
                    new TileText() { Text = "Large" }
                }
                        }
                    }
                }
            };


            var tn = new Windows.UI.Notifications.TileNotification(content.GetXml());

            var updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();
            updater.Update(tn);
        }
Beispiel #24
0
        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();
        }
Beispiel #25
0
        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;
        }
Beispiel #26
0
        public void SendEventTileNotification(EventTileModel etm)
        {
            var content = new TileBindingContentAdaptive();
            TileGroup firstGroup = new TileGroup();

            TileSubgroup sgroup = new TileSubgroup();
            sgroup.Weight = 22;
            TileImage imgOrganizer = new TileImage();
            var uriImageOrganizer = etm.OrganizerImageAbsoluteUri;

            if (string.IsNullOrEmpty(uriImageOrganizer))
                uriImageOrganizer = unknownPersonImageUri.AbsoluteUri;

            imgOrganizer.Source = new TileImageSource(uriImageOrganizer);
            sgroup.Children.Add(imgOrganizer);
            firstGroup.Children.Add(sgroup);

            sgroup = new TileSubgroup();
            TileText organizerName = new TileText();
            organizerName.Text = etm.OrganizerName;
            sgroup.Children.Add(organizerName);
            TileText timeEvent = new TileText();
            timeEvent.Text = etm.TimeDelta;
            timeEvent.Style = TileTextStyle.CaptionSubtle;
            sgroup.Children.Add(timeEvent);
            TileText eventBdy = new TileText();
            eventBdy.Text = etm.Subject;
            sgroup.Children.Add(eventBdy);
            firstGroup.Children.Add(sgroup);

            content.Children.Add(firstGroup);

            foreach (var driveItem in etm.Items.Take(2))
            {

                TileGroup secondGroup = new TileGroup();
                sgroup = new TileSubgroup();
                TileImage imgExt = new TileImage();
                imgExt.Source = new TileImageSource(driveItem.IconAbsoluteUri);
                sgroup.Children.Add(imgExt);
                sgroup.Weight = 5;
                secondGroup.Children.Add(sgroup);
                sgroup = new TileSubgroup();
                TileText tt = new TileText();
                tt.Text = driveItem.Title;
                sgroup.Children.Add(tt);
                secondGroup.Children.Add(sgroup);
                content.Children.Add(secondGroup);

            }
            TileContent tileContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileWide = new TileBinding()
                    {
                        Content = content
                    },
                    TileMedium = new TileBinding()
                    {
                        Content = content
                    },
                }
            };
            try
            {
                var tileContentxml = tileContent.ToString();
                TileNotification notification = new TileNotification(tileContent.GetXml());
                TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);

            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #27
0
 public static void CreateMainTileNotification(TileContent content)
 {
     var notification = new TileNotification(content.GetXml());
     TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
 }
Beispiel #28
0
        /// <summary>
        /// Makes sure the main app tile is an icon tile type
        /// </summary>
        public void UpdateMainTile(int unreadCount)
        {
            // Setup the main tile as iconic for small and medium
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentIconic()
                        {
                            Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic144.png"),
                        }
                    },
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentIconic()
                        {
                            Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic200.png"),
                        }
                    },                    
                }
            };

            // If the user is signed in we will do more for large and wide.
            if(m_baconMan.UserMan.IsUserSignedIn && m_baconMan.UserMan.CurrentUser != null && !String.IsNullOrWhiteSpace(m_baconMan.UserMan.CurrentUser.Name))
            {
                content.Visual.TileWide = new TileBinding()
                {
                    Content = new TileBindingContentAdaptive()
                    {
                        Children =
                        {
                            new TileText()
                            {
                                Text = m_baconMan.UserMan.CurrentUser.Name,
                                Style = TileTextStyle.Caption
                            },
                            new TileText()
                            {
                                Text = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.CommentKarma) + " comment karma",
                                Style = TileTextStyle.CaptionSubtle
                            },
                            new TileText()
                            {
                                Text = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.LinkKarma) + " link karma",
                                Style = TileTextStyle.CaptionSubtle
                            },                           
                        }
                    },
                };

                // If we have messages replace the user name with the message string.
                if (unreadCount != 0)
                {
                    TileText unreadCountText = new TileText()
                    {
                        Text = unreadCount + " Unread Inbox Message" + (unreadCount == 1 ? "" : "s"),
                        Style = TileTextStyle.Body
                    };
                    ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = unreadCountText;
                }

                // Also set the cake day if it is today
                DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                DateTime userCreationTime = origin.AddSeconds(m_baconMan.UserMan.CurrentUser.CreatedUtc).ToLocalTime();
                TimeSpan elapsed = DateTime.Now - userCreationTime;
                double fullYears = Math.Floor((elapsed.TotalDays / 365));
                int daysUntil = (int)(elapsed.TotalDays - (fullYears * 365));

                if(daysUntil == 0)
                {
                    // Make the text
                    TileText cakeDayText = new TileText()
                    {
                        Text = "Today is your cake day!",
                        Style = TileTextStyle.Body
                    };
                    ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = cakeDayText;
                }
            }  

            // Set large to the be same as wide.
            content.Visual.TileLarge = content.Visual.TileWide;

            // Update the tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));

            // Update the badge
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent();
            badgeContent.Number = (uint)unreadCount;
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeContent.GetXml()));
        }
        /// <summary>
        /// Creates or updates one or multiple live tiles on the executing platform. How it is manifests itself is determined by the class that
        /// implements this interface. If the platform does not support this feature, then the implementation should do nothing.
        /// </summary>
        /// <param name="model">Model which contains the data necessary to create a new tile or to find the tile to update</param>
        public async Task<bool> CreateOrUpdateTileAsync(IModel model)
        {
            if (model == null)
                return false;

            await Task.CompletedTask;

            // Do custom tile creation based on the type of the model passed into this method.
            if (model is QueueViewModel)
            {
                var list = (model as QueueViewModel)?.Queue;

                // Get the blank badge XML payload for a badge number
                XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

                // Set the value of the badge in the XML to our number
                XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;
                badgeElement.SetAttribute("value", list?.Count.ToString());

                // Create the badge notification
                BadgeNotification badge = new BadgeNotification(badgeXml);

                // Create the badge updater for the application
                BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

                // And update the badge
                badgeUpdater.Update(badge);
            }
            else if (model is ContentItemBase)
            {
                var item = model as ContentItemBase;

                var tile = new SecondaryTile();
                tile.TileId = Platform.Current.GenerateModelTileID(item);
                tile.Arguments = Platform.Current.GenerateModelArguments(model);
                tile.DisplayName = item.Title;
                var status = await this.CreateOrUpdateSecondaryTileAsync(tile, new TileVisualOptions());

                if (status)
                {
                    #region Create ItemModel TileContent

                    // Construct the tile content
                    TileContent content = new TileContent()
                    {
                        Visual = new TileVisual()
                        {
                            TileMedium = new TileBinding()
                            {
                                Content = new TileBindingContentAdaptive()
                                {
                                    BackgroundImage = new TileBackgroundImage() { Source = item.ImageThumbLandscapeSmall },
                                    Children =
                                    {
                                        new AdaptiveText(){ Text = item.Title },
                                        new AdaptiveText(){ Text = item.Description, HintStyle = AdaptiveTextStyle.CaptionSubtle }
                                    }
                                }
                            },

                            TileWide = new TileBinding()
                            {
                                Content = new TileBindingContentAdaptive()
                                {
                                    BackgroundImage = new TileBackgroundImage() { Source = item.ImageThumbLandscapeSmall },
                                    Children =
                                    {
                                        new AdaptiveText(){ Text = item.Title, HintStyle = AdaptiveTextStyle.Subtitle },
                                        new AdaptiveText(){ Text = item.Description, HintStyle = AdaptiveTextStyle.CaptionSubtle }
                                    }
                                }
                            },

                            TileLarge = new TileBinding()
                            {
                                Content = new TileBindingContentAdaptive()
                                {
                                    BackgroundImage = new TileBackgroundImage() { Source = item.ImageThumbLandscapeSmall },
                                    Children =
                                    {
                                        new AdaptiveText(){ Text = item.Title, HintStyle = AdaptiveTextStyle.Subtitle },
                                        new AdaptiveText(){ Text = item.Description, HintStyle = AdaptiveTextStyle.CaptionSubtle }
                                    }
                                }
                            }
                        }
                    };

                    #endregion

                    var notification = new TileNotification(content.GetXml());
                    notification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notification);
                }

                return status;
            }

            return false;
        }