示例#1
0
        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();
        }
示例#2
0
        public string CreateAdaptiveTile(string prefix, string leftTitle, string leftValue, string rightTitle, string rightValuevalue, string dateTitle, string dateContent)
        {
            // Create a TileBinding for Large and Wide
            var bigTilebinding = new TileBinding();

            bigTilebinding.Content = CreateTileContent(prefix, leftTitle, leftValue, rightTitle, rightValuevalue, dateTitle, dateContent);

            var mediumTileBinding = new TileBinding();

            mediumTileBinding.Content = CreateTileContent(string.Empty, leftTitle, leftValue, rightTitle, rightValuevalue, string.Empty, dateContent);

            //Create visual object
            var tileVisual = new TileVisual();

            tileVisual.TileLarge = tileVisual.TileWide = bigTilebinding;

            tileVisual.TileMedium = mediumTileBinding;

            //Create tile object
            var tileObject = new TileContent();

            tileObject.Visual = tileVisual;

            return(tileObject.GetContent());
        }
        public static XmlDocument GenerateTextTile(string text)
        {
            TileContent tile = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding   = TileBranding.None,
                    TileMedium = new TileBinding()
                    {
                        Content = CreateMediumAdaptiveTextContent(text)
                    },
                    TileWide = new TileBinding()
                    {
                        Content = CreateLargeAdaptiveTextContent(text)
                    },
                    TileLarge = new TileBinding()
                    {
                        Content = CreateLargeAdaptiveTextContent(text)
                    },
                }
            };

            var xdoc = new XmlDocument();

            xdoc.LoadXml(tile.GetContent());

            return(xdoc);
        }
示例#4
0
        public static void AssertTile(string expected, TileContent tile)
        {
            AssertHelper.AssertXml(expected, tile.GetContent());

#if WINDOWS_UWP
            // For WinRT, we'll test the XmlDocument method too, make sure it works.
            AssertHelper.AssertXml(expected, tile.GetXml().GetXml());
#endif
        }
示例#5
0
        /// <summary>
        /// Generates tile notification of gold notification using the receiver's picture
        /// </summary>
        /// <param name="thumbnailUrl">Image that received gold.</param>
        /// <returns>String representation of tile object.</returns>
        private string GenerateTileNotification(string thumbnailUrl)
        {
            var content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = thumbnailUrl
                            }
                        }
                    },

                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = thumbnailUrl
                            }
                        }
                    },

                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage()
                            {
                                Source = thumbnailUrl
                            }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = new TileBackgroundImage
                            {
                                Source = thumbnailUrl
                            }
                        }
                    }
                }
            };

            return(content.GetContent());
        }
示例#6
0
 private static void UpdateTileNotificationContent(TileContent tile)
 {
     try
     {
         XmlDocument xml = new XmlDocument();
         xml.LoadXml(tile.GetContent());
         var updater = TileUpdateManager.CreateTileUpdaterForApplication();
         if (updater != null)
         {
             updater.EnableNotificationQueue(true);
             updater.Update(new TileNotification(xml)
             {
                 Tag            = tile.Visual.ContentId.GetHashCode().ToString(),
                 ExpirationTime = DateTimeOffset.Now.AddDays(TileExpiryInDays)
             });
         }
     }
     catch (Exception)
     { }
 }
示例#7
0
        private static void AssertAdaptiveChildInTile(string expectedAdaptiveChildXml, IAdaptiveChild child)
        {
            var content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                child
                            }
                        }
                    }
                }
            };

            AssertHelper.AssertXml(
                "<tile><visual><binding template='TileMedium'>" + expectedAdaptiveChildXml + "</binding></visual></tile>",
                content.GetContent());
        }
示例#8
0
        public void TestWeatherTile()
        {
            TileImageSource backgroundImage = new TileImageSource(BACKGROUND_IMAGE_MOSTLY_CLOUDY);
            int             overlay         = 30;

            TileBindingContentAdaptive smallContent = new TileBindingContentAdaptive()
            {
                TextStacking    = TileTextStacking.Center,
                BackgroundImage = new TileBackgroundImage()
                {
                    Source = backgroundImage, Overlay = overlay
                },
                Children =
                {
                    new TileText()
                    {
                        Text  = "Mon",
                        Style = TileTextStyle.Body,
                        Align = TileTextAlign.Center
                    },

                    new TileText()
                    {
                        Text  = "63°",
                        Style = TileTextStyle.Base,
                        Align = TileTextAlign.Center
                    }
                }
            };


            TileBindingContentAdaptive mediumContent = new TileBindingContentAdaptive()
            {
                BackgroundImage = new TileBackgroundImage()
                {
                    Source = backgroundImage, Overlay = overlay
                },
                Children =
                {
                    new TileGroup()
                    {
                        Children =
                        {
                            GenerateMediumSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42),

                            GenerateMediumSubgroup("Tue", IMAGE_CLOUDY,        57, 38)
                        }
                    }
                }
            };



            TileBindingContentAdaptive wideContent = new TileBindingContentAdaptive()
            {
                BackgroundImage = new TileBackgroundImage()
                {
                    Source = backgroundImage, Overlay = overlay
                },
                Children =
                {
                    new TileGroup()
                    {
                        Children =
                        {
                            GenerateWideSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42),

                            GenerateWideSubgroup("Tue", IMAGE_CLOUDY,        57, 38),

                            GenerateWideSubgroup("Wed", IMAGE_SUNNY,         59, 43),

                            GenerateWideSubgroup("Thu", IMAGE_SUNNY,         62, 42),

                            GenerateWideSubgroup("Fri", IMAGE_SUNNY,         71, 66)
                        }
                    }
                }
            };



            TileBindingContentAdaptive largeContent = new TileBindingContentAdaptive()
            {
                BackgroundImage = new TileBackgroundImage()
                {
                    Source = backgroundImage, Overlay = overlay
                },
                Children =
                {
                    new TileGroup()
                    {
                        Children =
                        {
                            new TileSubgroup()
                            {
                                Weight   = 30,
                                Children =
                                {
                                    new TileImage()
                                    {
                                        Source = new TileImageSource(IMAGE_MOSTLY_CLOUDY)
                                    }
                                }
                            },

                            new TileSubgroup()
                            {
                                Children =
                                {
                                    new TileText()
                                    {
                                        Text  = "Monday",
                                        Style = TileTextStyle.Base
                                    },

                                    new TileText()
                                    {
                                        Text = "63° / 42°"
                                    },

                                    new TileText()
                                    {
                                        Text  = "20% chance of rain",
                                        Style = TileTextStyle.CaptionSubtle
                                    },

                                    new TileText()
                                    {
                                        Text  = "Winds 5 mph NE",
                                        Style = TileTextStyle.CaptionSubtle
                                    }
                                }
                            }
                        }
                    },

                    // For spacing
                    new TileText(),

                    new TileGroup()
                    {
                        Children =
                        {
                            GenerateLargeSubgroup("Tue", IMAGE_CLOUDY, 57, 38),

                            GenerateLargeSubgroup("Wed", IMAGE_SUNNY,  59, 43),

                            GenerateLargeSubgroup("Thu", IMAGE_SUNNY,  62, 42),

                            GenerateLargeSubgroup("Fri", IMAGE_SUNNY,  71, 66)
                        }
                    }
                }
            };



            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    DisplayName = "Seattle",

                    TileSmall = new TileBinding()
                    {
                        Content = smallContent
                    },

                    TileMedium = new TileBinding()
                    {
                        Content  = mediumContent,
                        Branding = TileBranding.Name
                    },

                    TileWide = new TileBinding()
                    {
                        Content  = wideContent,
                        Branding = TileBranding.NameAndLogo
                    },

                    TileLarge = new TileBinding()
                    {
                        Content  = largeContent,
                        Branding = TileBranding.NameAndLogo
                    }
                }
            };



            string expectedPayload = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual displayName=""Seattle""><binding template=""TileSmall"" hint-overlay=""30"" hint-textStacking=""center"">{GenerateStringBackgroundImage()}<text hint-align=""center"" hint-style=""body"">Mon</text><text hint-align=""center"" hint-style=""base"">63°</text></binding><binding template=""TileMedium"" branding=""name"" hint-overlay=""30"">{GenerateStringBackgroundImage()}<group>";

            // Medium tile subgroups
            expectedPayload += GenerateStringMediumSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42);
            expectedPayload += GenerateStringMediumSubgroup("Tue", IMAGE_CLOUDY, 57, 38);

            expectedPayload += "</group></binding>";


            // Wide tile
            expectedPayload += @"<binding template=""TileWide"" branding=""nameAndLogo"" hint-overlay=""30"">";
            expectedPayload += GenerateStringBackgroundImage();
            expectedPayload += "<group>";

            // Wide tile subgroups
            expectedPayload += GenerateStringWideSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42);
            expectedPayload += GenerateStringWideSubgroup("Tue", IMAGE_CLOUDY, 57, 38);
            expectedPayload += GenerateStringWideSubgroup("Wed", IMAGE_SUNNY, 59, 43);
            expectedPayload += GenerateStringWideSubgroup("Thu", IMAGE_SUNNY, 62, 42);
            expectedPayload += GenerateStringWideSubgroup("Fri", IMAGE_SUNNY, 71, 66);

            expectedPayload += "</group></binding>";



            // Large tile
            expectedPayload += @"<binding template=""TileLarge"" branding=""nameAndLogo"" hint-overlay=""30"">";
            expectedPayload += GenerateStringBackgroundImage();
            expectedPayload += $@"<group><subgroup hint-weight=""30""><image src=""{IMAGE_MOSTLY_CLOUDY}"" /></subgroup><subgroup><text hint-style=""base"">Monday</text><text>63° / 42°</text><text hint-style=""captionSubtle"">20% chance of rain</text><text hint-style=""captionSubtle"">Winds 5 mph NE</text></subgroup></group>";

            expectedPayload += "<text />";
            expectedPayload += "<group>";

            // Large tile subgroups
            expectedPayload += GenerateStringLargeSubgroup("Tue", IMAGE_CLOUDY, 57, 38);
            expectedPayload += GenerateStringLargeSubgroup("Wed", IMAGE_SUNNY, 59, 43);
            expectedPayload += GenerateStringLargeSubgroup("Thu", IMAGE_SUNNY, 62, 42);
            expectedPayload += GenerateStringLargeSubgroup("Fri", IMAGE_SUNNY, 71, 66);

            expectedPayload += "</group></binding></visual></tile>";


            string actualPayload = content.GetContent();

            AssertHelper.AssertXml(expectedPayload, actualPayload);
            //Assert.AreEqual(expectedPayload, actualPayload);
        }
        public void TestXboxModernTileLegacy()
        {
            TileBinding medium = new TileBinding()
            {
                Content = new TileBindingContentAdaptive()
                {
                    TextStacking = TileTextStacking.Center,

                    Children =
                    {
                        new TileText()
                        {
                            Text  = "Hi,",
                            Style = TileTextStyle.Base,
                            Align = TileTextAlign.Center
                        },

                        new TileText()
                        {
                            Text  = "MasterHip",
                            Style = TileTextStyle.CaptionSubtle,
                            Align = TileTextAlign.Center
                        }
                    }
                }
            };


            TileBinding wide = new TileBinding()
            {
                Content = new TileBindingContentAdaptive()
                {
                    Children =
                    {
                        new TileGroup()
                        {
                            Children =
                            {
                                new TileSubgroup()
                                {
                                    Weight   = 33,
                                    Children =
                                    {
                                        new TileImage()
                                        {
                                            Source = new TileImageSource("http://xbox.com/MasterHip/profile.jpg"),
                                            Crop   = TileImageCrop.Circle
                                        }
                                    }
                                },

                                new TileSubgroup()
                                {
                                    TextStacking = TileTextStacking.Center,
                                    Children     =
                                    {
                                        new TileText()
                                        {
                                            Text  = "Hi,",
                                            Style = TileTextStyle.Title
                                        },

                                        new TileText()
                                        {
                                            Text  = "MasterHip",
                                            Style = TileTextStyle.SubtitleSubtle
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };



            TileBinding large = new TileBinding()
            {
                Content = new TileBindingContentAdaptive()
                {
                    TextStacking = TileTextStacking.Center,
                    Children     =
                    {
                        new TileGroup()
                        {
                            Children =
                            {
                                new TileSubgroup()
                                {
                                    Weight = 1
                                },
                                new TileSubgroup()
                                {
                                    Weight   = 2,
                                    Children =
                                    {
                                        new TileImage()
                                        {
                                            Source = new TileImageSource("http://xbox.com/MasterHip/profile.jpg"),
                                            Crop   = TileImageCrop.Circle
                                        }
                                    }
                                },
                                new TileSubgroup()
                                {
                                    Weight = 1
                                }
                            }
                        },

                        new TileText()
                        {
                            Text  = "Hi,",
                            Style = TileTextStyle.Title,
                            Align = TileTextAlign.Center
                        },

                        new TileText()
                        {
                            Text  = "MasterHip",
                            Style = TileTextStyle.SubtitleSubtle,
                            Align = TileTextAlign.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);
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pokemonList"></param>
        /// <remarks>
        /// advancedrei: The LiveTileUpdater is on teh App class, so this has to stay here for now. Might refactor later.
        /// </remarks>
        internal static void UpdateLiveTile(IList <PokemonData> pokemonList)
        {
            // Let's run this on a separate thread.
            Task.Run(() => {
                try
                {
                    TileContent tile = null;
                    var images       = new List <string>();
                    var mode         = SettingsService.Instance.LiveTileMode;

                    // Generate the images list for multi-image modes.
                    if (mode == LiveTileModes.People || mode == LiveTileModes.Photo)
                    {
                        images.AddRange(pokemonList.Select(c => new PokemonDataWrapper(c).ImageFileName));
                    }

                    foreach (ScheduledTileNotification scheduled in LiveTileUpdater.GetScheduledTileNotifications())
                    {
                        LiveTileUpdater.RemoveFromSchedule(scheduled);
                    }

                    if (mode != LiveTileModes.Peek)
                    {
                        LiveTileUpdater.EnableNotificationQueue(true);
                    }
                    else
                    {
                        LiveTileUpdater.EnableNotificationQueue(false);
                        LiveTileUpdater.Clear();
                    }

                    switch (mode)
                    {
                    case LiveTileModes.Off:
                        tile = LiveTileHelper.GetImageTile("Normal");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Official:
                        tile = LiveTileHelper.GetImageTile("Official");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Transparent:
                        tile = LiveTileHelper.GetImageTile("Transparent");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Peek:
                        foreach (PokemonData pokemonData in pokemonList)
                        {
                            if (LiveTileUpdater.GetScheduledTileNotifications().Count >= 300)
                            {
                                return;
                            }
                            var peekTile  = LiveTileHelper.GetPeekTile(new PokemonDataWrapper(pokemonData));
                            var scheduled = new ScheduledTileNotification(peekTile.GetXml(),
                                                                          DateTimeOffset.Now.AddSeconds((pokemonList.IndexOf(pokemonData) * 30) + 1));
                            LiveTileUpdater.AddToSchedule(scheduled);
                        }
                        break;

                    case LiveTileModes.People:
                        tile = LiveTileHelper.GetPeopleTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Photo:
                        tile = LiveTileHelper.GetPhotosTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;
                    }
                    if (tile != null)
                    {
                        GameClient.CurrentSession.Logger.Debug(tile.GetContent());
                    }
                }
                catch (Exception ex)
                {
                    GameClient.CurrentSession.Logger.Debug(ex.Message);
                    HockeyClient.Current.TrackException(ex);
                }
            });
        }
示例#11
0
        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);
        }