示例#1
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;
            }
        }
 private static void AssertAdaptiveImage(string expectedImageXml, TileImage image)
 {
     AssertBindingMedium("<binding template='TileMedium'>" + expectedImageXml + "</binding>", new TileBinding()
     {
         Content = new TileBindingContentAdaptive()
         {
             Children =
             {
                 image
             }
         }
     });
 }