private TileNotification CreateLiveTile(SimpleLaunchData simpleLaunchDataInformation)
        {
            var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);

            var tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = simpleLaunchDataInformation.Name;
            tileTextAttributes[1].InnerText = simpleLaunchDataInformation.Description ?? "No mission description";
            tileTextAttributes[2].InnerText = $"{simpleLaunchDataInformation.Net.Day}-{simpleLaunchDataInformation.Net.Month}-{simpleLaunchDataInformation.Net.Year} {simpleLaunchDataInformation.Net.Hour}:{simpleLaunchDataInformation.Net.Minute}";


            var tileImageAttributes = tileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/Square150x150Logo.scale-200.png");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");

            var wideTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02);

            var wideTileTextAttributes = wideTileXml.GetElementsByTagName("text");
            wideTileTextAttributes[0].AppendChild(wideTileXml.CreateTextNode(simpleLaunchDataInformation.Name));
            wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode(simpleLaunchDataInformation.Description ?? "No mission description"));
            wideTileTextAttributes[2].AppendChild(wideTileXml.CreateTextNode(simpleLaunchDataInformation.Net.ToString(CultureInfo.CurrentCulture)));

            var wideTileImageAttributes = wideTileXml.GetElementsByTagName("image");
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/Wide310x150Logo.scale-200.png");
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("alt", "red graphic");

            var node = tileXml.ImportNode(wideTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual")?.Item(0)?.AppendChild(node);

            return new TileNotification(tileXml) { ExpirationTime = simpleLaunchDataInformation.Net };
        }
        private TileNotification CreateLiveTile(SimpleLaunchData launchData)
        {
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding
                    {
                        Branding = TileBranding.None,
                        Content = new TileBindingContentAdaptive
                        {
                            PeekImage = new TilePeekImage()
                            {
                                Source = "Assets/Square150x150Logo.scale-200.png"
                            },
                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = "Next Launch:",
                                    HintWrap = true,
                                    HintStyle = AdaptiveTextStyle.Caption
                                },
                                new AdaptiveText(),
                                new AdaptiveText()
                                {
                                    Text = launchData.LaunchNet,
                                    HintWrap = true,
                                    HintStyle = AdaptiveTextStyle.Caption
                                }
                            }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        Branding = TileBranding.NameAndLogo,
                        DisplayName = "LaunchPal",
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = launchData.Name,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.Body
                                },

                                new AdaptiveText()
                                {
                                    Text = launchData.LaunchNet,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                },

                                new AdaptiveText()
                                {
                                    Text = "Status: " + launchData.Status,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.Body
                                },                                
                            }
                        }
                    },

                    TileLarge = new TileBinding
                    {
                        Branding = TileBranding.NameAndLogo,
                        DisplayName = "LaunchPal",
                        Content = new TileBindingContentAdaptive()
                        {
                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = launchData.Name,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.Body
                                },

                                new AdaptiveText()
                                {
                                    Text = launchData.LaunchNet,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle
                                },

                                new AdaptiveText()
                                {
                                    Text = "Status - " + launchData.Status,
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.Body
                                },

                                new AdaptiveText(),

                                new AdaptiveText
                                {
                                    Text = "Mission Description",
                                    HintWrap = false,
                                    HintStyle = AdaptiveTextStyle.Body
                                },

                                new AdaptiveText()
                                {
                                    Text = launchData.Description,
                                    HintWrap = true,
                                    HintStyle = AdaptiveTextStyle.Caption
                                },
                            }
                        }
                    }

                }
            };

            return new TileNotification(content.GetXml())
            {
                ExpirationTime = launchData.Net.AddMinutes(30)
            };
        }
示例#3
0
            internal static Button GenerateTileTrackingButton()
            {
                var setTile = new Button
                {
                    Text = "Follow Launch",
                    BackgroundColor = Theme.ButtonBackgroundColor,
                    BorderColor = Theme.FrameBorderColor,
                    TextColor = Theme.ButtonTextColor
                };

                setTile.Clicked += async (sender, args) =>
                {
                    await LaunchPage.DisplayAlert("Launch followed", "You are now following this launch on your homescreen", "Confirm");
                    var trackedLaunch = new SimpleLaunchData(CacheManager.TryGetLaunchById(LaunchPage.Context.Id).Result);
                    App.Settings.TrackedLaunchOnHomescreen = trackedLaunch;
                    DependencyService.Get<ICreateTile>().SetLaunch();
                };

                return setTile;
            }
 public void SetLaunch()
 {
     _launchSimpleLaunchDataData = App.Settings.TrackedLaunchOnHomescreen;
     return;
 }