コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is Item item)
            {
                return(NotificationHandler.DisplayContent(item.Content));
            }

            return("");
        }
コード例 #2
0
        // More about Live Tiles Notifications at https://docs.microsoft.com/windows/uwp/controls-and-patterns/tiles-and-notifications-sending-a-local-tile-notification
        public async Task SampleUpdate(TodoistService todoist)
        {
            var today = await todoist.GetLabel("today");

            List <Item> allTodos = await todoist.GetItems();

            List <Item> todos = allTodos.Where(i => i.Labels.Contains(today.Id)).OrderBy(i => i.Priority).ToList();

            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Clear();
            updater.EnableNotificationQueue(true);



            for (int i = 0; i < todos.Count; i += 4)
            {
                var content = new TileContent()
                {
                    Visual = new TileVisual()
                    {
                        TileMedium = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = $"DailyTodo ({todos.Count})",
                                    }
                                }
                            }
                        },

                        TileWide = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text      = $"DailyTodo ({todos.Count})",
                                        HintStyle = AdaptiveTextStyle.Base,
                                    }
                                }
                            }
                        },

                        TileLarge = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text      = $"DailyTodo ({todos.Count})",
                                        HintStyle = AdaptiveTextStyle.Base,
                                    }
                                }
                            }
                        }
                    }
                };

                var todoText = todos.Skip(i).Take(4).Select(j => new AdaptiveText()
                {
                    Text      = $" - {NotificationHandler.DisplayContent(j.Content)}",
                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                }).ToList();

                todoText.ForEach(j => (content.Visual.TileMedium.Content as TileBindingContentAdaptive).Children.Add(j));

                todoText.ForEach(j => (content.Visual.TileWide.Content as TileBindingContentAdaptive).Children.Add(j));

                todoText.ForEach(j => (content.Visual.TileLarge.Content as TileBindingContentAdaptive).Children.Add(j));

                // Then create the tile notification
                var notification = new TileNotification(content.GetXml());
                notification.Tag = "item" + i;

                try
                {
                    updater.Update(notification);
                }
                catch (Exception)
                {
                    // TODO WTS: Updating LiveTile can fail in rare conditions, please handle exceptions as appropriate to your scenario.
                }
            }

            // Construct the tile content
        }