Esempio n. 1
0
        //Set tile to failed update
        XmlDocument RenderTileLiveFailed(string TileId)
        {
            try
            {
                Debug.WriteLine("Set tile to failed: " + TileId);

                //Reset primary tile
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();

                Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId);
                Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                {
                    try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                }
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(TileId).Clear();

                Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoFailed.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoFailed.png\"/></binding></visual></tile>");
                Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
            }
            catch { }
            return(Tile_XmlContent);
        }
Esempio n. 2
0
        //Set weather tile to disabled
        XmlDocument RenderTileWeatherDisabled()
        {
            try
            {
                //Reset secondary weather tile
                if (TileWeather_Pinned)
                {
                    Debug.WriteLine("Set weather tile to disabled.");

                    Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile");
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                    foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                    {
                        try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                    }
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeWeatherTile").Clear();

                    Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoWeatherDisabled.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoWeatherDisabled.png\"/></binding></visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
            }
            catch { }
            return(Tile_XmlContent);
        }
Esempio n. 3
0
        //Set battery tile to disabled
        XmlDocument RenderTileBatteryDisabled()
        {
            try
            {
                //Reset secondary battery tile
                if (TileBattery_Pinned)
                {
                    Debug.WriteLine("Set battery tile to disabled.");

                    Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile");
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                    foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                    {
                        try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                    }
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeBatteryTile").Clear();

                    string TileImage         = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryVerNoBattery.png\"/></subgroup></group>";
                    string BatterySmallTile  = "<binding template=\"TileSmall\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";
                    string BatteryMediumTile = "<binding template=\"TileMedium\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";
                    string BatteryWideTile   = "<binding template=\"TileWide\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
            }
            catch { }
            return(Tile_XmlContent);
        }
Esempio n. 4
0
        //Render Battery tile front
        void RenderBatteryTile()
        {
            try
            {
                Debug.WriteLine("Started rendering the battery tile.");

                //Render icon battery tile
                if (setBatteryTileSizeName == "BatteryIcon")
                {
                    //Set Multi Variables
                    string TileImage = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryVer" + BatteryIcon + ".png\"/></subgroup></group>";

                    //Set Small Tile Texts
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    //Set Medium Tile Texts
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    //Set Wide Tile Texts
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render text battery tile
                else if (setBatteryTileSizeName == "BatteryText")
                {
                    //Set Multi Variables
                    string TileImageText = "<subgroup><image src=\"ms-appx:///Assets/Battery/BatteryVer" + BatteryIcon + ".png\"/></subgroup>";

                    //Set Small Tile Texts
                    string SmallTileFontSize = "subtitle";
                    if (BatteryLevel.Length > 2)
                    {
                        SmallTileFontSize = "base";
                    }
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BatteryLevel + "%</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"base\" hint-align=\"left\">" + BatteryLevel + "%</text><text hint-style=\"baseSubtle\" hint-align=\"left\">Left</text></subgroup></group></binding>";

                    //Set Wide Tile Texts
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BatteryLevel + "%</text><text hint-style=\"titleNumeralSubtle\" hint-align=\"left\">Left</text></subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render text left battery tile
                else if (setBatteryTileSizeName == "BatteryTextLeft")
                {
                    //Set Multi Variables
                    string TileImageText = "<subgroup><image src=\"ms-appx:///Assets/Battery/BatteryVer" + BatteryIcon + ".png\"/></subgroup>";

                    //Set Small Tile Texts
                    string SmallTileFontSize = "subtitle";
                    if (BatteryLevel.Length > 2)
                    {
                        SmallTileFontSize = "base";
                    }
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BatteryLevel + "%</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"base\" hint-align=\"right\">" + BatteryLevel + "%</text><text hint-style=\"baseSubtle\" hint-align=\"right\">Left</text></subgroup>" + TileImageText + "</group></binding>";

                    //Set Wide Tile Texts
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"titleNumeral\" hint-align=\"right\">" + BatteryLevel + "%</text><text hint-style=\"titleNumeralSubtle\" hint-align=\"right\">Left</text></subgroup>" + TileImageText + "</group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render text vert battery tile
                else if (setBatteryTileSizeName == "BatteryTextVert")
                {
                    //Set Multi Variables
                    string TileImage = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryHor" + BatteryIcon + ".png\"/></subgroup></group>";

                    //Set Small Tile Texts
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    //Set Medium Tile Texts
                    string TileImageText     = "<group><subgroup hint-weight=\"1\"/><subgroup><image src=\"ms-appx:///Assets/Battery/BatteryHor" + BatteryIcon + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImageText + "<text hint-style=\"subtitle\" hint-align=\"center\">" + BatteryLevel + "%</text></binding>";

                    //Set Wide Tile Texts
                    TileImageText = "<group><subgroup hint-weight=\"1\"/><subgroup hint-weight=\"2\"><image src=\"ms-appx:///Assets/Battery/BatteryHor" + BatteryIcon + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImageText + "<text hint-style=\"subtitle\" hint-align=\"center\">" + BatteryLevel + "%</text></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render text vert top battery tile
                else if (setBatteryTileSizeName == "BatteryTextVertTop")
                {
                    //Set Multi Variables
                    string TileImage = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryHor" + BatteryIcon + ".png\"/></subgroup></group>";

                    //Set Small Tile Texts
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>";

                    //Set Medium Tile Texts
                    string TileImageText     = "<group><subgroup hint-weight=\"1\"/><subgroup><image src=\"ms-appx:///Assets/Battery/BatteryHor" + BatteryIcon + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<text hint-style=\"subtitle\" hint-align=\"center\">" + BatteryLevel + "%</text>" + TileImageText + "</binding>";

                    //Set Wide Tile Texts
                    TileImageText = "<group><subgroup hint-weight=\"1\"/><subgroup hint-weight=\"2\"><image src=\"ms-appx:///Assets/Battery/BatteryHor" + BatteryIcon + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<text hint-style=\"subtitle\" hint-align=\"center\">" + BatteryLevel + "%</text>" + TileImageText + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render perc battery tile
                else if (setBatteryTileSizeName == "BatteryPerc")
                {
                    //Set Small Tile Texts
                    string SmallTileFontSize = "subtitle";
                    if (BatteryLevel.Length > 2)
                    {
                        SmallTileFontSize = "base";
                    }
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BatteryLevel + "%</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"title\" hint-align=\"center\">🗲 " + BatteryLevel + "%</text></subgroup></group></binding>";

                    //Set Wide Tile Texts
                    string BatteryWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"header\" hint-align=\"center\">🗲 " + BatteryLevel + "%</text></subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }
                //Render summ battery tile
                else if (setBatteryTileSizeName == "BatterySumm")
                {
                    //Set Multi Variables
                    string TileImageText = "<subgroup><image src=\"ms-appx:///Assets/Battery/BatteryVer" + BatteryIcon + ".png\"/></subgroup>";

                    //Set Small Tile Texts
                    string BatterySmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "</group></binding>";

                    //Set Medium and Wide Tile Texts
                    string BatteryMediumTile = "";
                    string BatteryWideTile   = "";
                    if (BatteryCharging)
                    {
                        BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BatteryLevel + "%</text><text hint-style=\"captionSubtle\" hint-align=\"left\">Charg</text></subgroup></group></binding>";
                        BatteryWideTile   = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"body\" hint-align=\"left\">" + BatteryLevel + " Percent</text><text hint-style=\"bodySubtle\" hint-align=\"left\">Charging</text></subgroup></group></binding>";
                    }
                    else
                    {
                        BatteryMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BatteryLevel + "%</text><text hint-style=\"caption\" hint-align=\"left\">" + BatteryTime + "</text><text hint-style=\"captionSubtle\" hint-align=\"left\">Remain</text></subgroup></group></binding>";
                        BatteryWideTile   = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileBattery_BackgroundPhotoXml + "<group>" + TileImageText + "<subgroup hint-textStacking=\"center\"><text hint-style=\"body\" hint-align=\"left\">" + BatteryLevel + " Percent</text><text hint-style=\"body\" hint-align=\"left\">" + BatteryTime + "</text><text hint-style=\"bodySubtle\" hint-align=\"left\">Remaining</text></subgroup></group></binding>";
                    }

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                Debug.WriteLine("The battery tile has been updated.");
            }
            catch { }
        }
Esempio n. 5
0
        //Plan and render future live tiles
        async Task PlanLiveTiles()
        {
            try
            {
                //Show render start debug message
                if (setAppDebug)
                {
                    Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Renderstart: " + taskInstanceName + "</text><text id=\"2\">" + DateTimeNow.ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>");
                    Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent)
                    {
                        SuppressPopup = true, Tag = "T1", Group = "G3"
                    });
                }

                //Remove old planned live tiles
                Debug.WriteLine("Removing " + Tile_PlannedUpdates.Count + " older live task updates.");
                foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                {
                    try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                }

                //Render future live tile back
                if (TileLive_BackRender)
                {
                    Debug.WriteLine("Started rendering back live tile.");
                    await RenderLiveTileBack();
                }

                //Render future live tiles front
                Debug.WriteLine("Started rendering front live tiles.");
                TileTimeNow = DateTime.Now;
                TileTimeMin = TileTimeNow.AddSeconds(-TileTimeNow.Second).AddMinutes(-1);
                for (int LiveTileRenderId = 0; LiveTileRenderId < 18; LiveTileRenderId++)
                {
                    try
                    {
                        TileTimeNow    = DateTime.Now;
                        TileTimeMin    = TileTimeMin.AddMinutes(1);
                        TileContentId  = TileTimeMin.Minute.ToString();
                        TileRenderName = LiveTileRenderId.ToString();

                        if (TileTimeNow.Minute == TileTimeMin.Minute)
                        {
                            Tile_UpdateManager.Update(new TileNotification(await RenderLiveTile()));
                        }
                        else
                        {
                            Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(await RenderLiveTile(), new DateTimeOffset(TileTimeMin)));
                        }
                        if (TileLive_BackRender)
                        {
                            Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoSize.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appdata:///local/TimeMeBack.png\"/></binding></visual></tile>");
                            if (TileTimeNow < TileTimeMin.AddSeconds(12))
                            {
                                Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(12))));
                            }
                            if (TileTimeNow < TileTimeMin.AddSeconds(32))
                            {
                                Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(32))));
                            }
                            if (TileTimeNow < TileTimeMin.AddSeconds(52))
                            {
                                Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(52))));
                            }
                            Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoSize.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appdata:///local/TimeMe" + TileRenderName + ".png\"/></binding></visual></tile>");
                            if (TileTimeNow < TileTimeMin.AddSeconds(20))
                            {
                                Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(20))));
                            }
                            if (TileTimeNow < TileTimeMin.AddSeconds(40))
                            {
                                Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(TileTimeMin.AddSeconds(40))));
                            }
                        }

                        //Show live tile render debug message
                        if (setAppDebug)
                        {
                            Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Renderedtile: " + taskInstanceName + "</text><text id=\"2\">" + TileRenderName + "/17 at " + DateTimeNow.ToString() + " Mem " + (MemoryManager.AppMemoryUsage / 1024f / 1024f).ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>");
                            Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent)
                            {
                                SuppressPopup = true, Tag = "T2", Group = "G3"
                            });
                        }
                    }
                    catch { }
                }

                ////Add tile will be updated shortly on the end
                //Tile_DateTimeMin = Tile_DateTimeMin.AddMinutes(1);
                //Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoUpdate.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoUpdate.png\"/></binding></visual></tile>");
                //Tile_UpdateManager.AddToSchedule(new ScheduledTileNotification(Tile_XmlContent, new DateTimeOffset(Tile_DateTimeMin)));

                Debug.WriteLine("Finished rendering live tiles batch.");
            }
            catch { Debug.WriteLine("Failed rendering live tiles batch."); }
        }
Esempio n. 6
0
        //Render weather tile front
        void RenderWeatherTile()
        {
            try
            {
                Debug.WriteLine("Started rendering the weather tile.");

                //Render lite flip weather tile
                if (setWeatherTileSizeName == "WeatherLiteFlip")
                {
                    //Set the peek image
                    string PeekImage = "<image placement=\"peek\" src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/>";

                    //Set Small Tile Texts
                    string SmallTileFontSize = "title";
                    if (BgStatusWeatherCurrentTemp.Length > 3)
                    {
                        SmallTileFontSize = "subtitle";
                    }
                    string WeatherSmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + PeekImage + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string WeatherMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + PeekImage + "<group><subgroup><text hint-style=\"header\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group></binding>";

                    //Set Wide Tile Texts
                    string WeatherWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + PeekImage + "<group><subgroup><text hint-style=\"header\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherSmallTile + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render grey weather tile
                else if (setWeatherTileSizeName == "WeatherGrey")
                {
                    //Set Multi Variables
                    string WeatherMultiDetails = WeatherDetailed;
                    if (setDisplayWeatherTileUpdateTime)
                    {
                        WeatherMultiDetails = WeatherLastUpdate;
                    }

                    //Set Small Tile Texts
                    string WeatherSmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<image src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/></binding>";

                    //Set Medium Tile Texts
                    string GroupWeatherText  = "<group><subgroup><text hint-style=\"captionSubtle\" hint-align=\"center\">" + WeatherMultiDetails + "</text></subgroup></group>";
                    string GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\"><text hint-style=\"title\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group>";
                    string WeatherMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + "</binding>";

                    //Set Wide Tile Texts
                    GroupWeatherText  = "<group><subgroup><text hint-style=\"titleNumeralSubtle\">" + WeatherMultiDetails + "</text></subgroup></group>";
                    GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"35\"><image src=\"ms-appx:///Assets/WeatherSquare" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\"><text hint-style=\"title\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group>";
                    string WeatherWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherSmallTile + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render icon weather tile
                else if (setWeatherTileSizeName == "WeatherIcon")
                {
                    //Set Small Tile Texts
                    string SmallTileFontSize = "title";
                    if (BgStatusWeatherCurrentTemp.Length > 3)
                    {
                        SmallTileFontSize = "subtitle";
                    }
                    string WeatherSmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string WeatherTextCurrent  = "";
                    string WeatherTextDetailed = "";
                    string WeatherTextUpdate   = "";
                    string WeatherImageCurrent = "";

                    if (BgStatusWeatherCurrent.Length < 13)
                    {
                        WeatherTextCurrent = "<text hint-style=\"caption\" hint-align=\"center\">" + BgStatusWeatherCurrent + "</text>";
                    }
                    else
                    {
                        WeatherTextCurrent = "<text hint-style=\"caption\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp.Replace("°", " degrees") + "</text>";
                    }
                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider)
                    {
                        WeatherTextDetailed = "<text hint-style=\"captionSubtle\" hint-align=\"center\">" + WeatherDetailed + "</text>";
                    }
                    if (setDisplayWeatherTileUpdateTime)
                    {
                        WeatherTextUpdate = "<text hint-style=\"captionSubtle\" hint-align=\"center\">" + WeatherLastUpdate + "</text>";
                    }

                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider || setDisplayWeatherTileUpdateTime)
                    {
                        WeatherImageCurrent = "<group><subgroup hint-weight=\"1\"/><subgroup hint-weight=\"2\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    }
                    else
                    {
                        WeatherImageCurrent = "<group><subgroup hint-weight=\"1\"/><subgroup hint-weight=\"100\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"1\"/></group>";
                    }
                    string WeatherMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + WeatherImageCurrent + WeatherTextCurrent + WeatherTextDetailed + WeatherTextUpdate + "</binding>";

                    //Set Wide Tile Texts
                    WeatherTextCurrent = "<text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrent + "</text>";
                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider)
                    {
                        WeatherTextDetailed = "<text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherDetailed + "</text>";
                    }
                    if (setDisplayWeatherTileUpdateTime)
                    {
                        WeatherTextUpdate = "<text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherLastUpdate + "</text>";
                    }
                    string WeatherWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group><subgroup hint-weight=\"35\" hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-weight=\"65\" hint-textStacking=\"center\">" + WeatherTextCurrent + WeatherTextDetailed + WeatherTextUpdate + "</subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherSmallTile + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render summary weather tile
                else if (setWeatherTileSizeName == "WeatherSumm")
                {
                    //Set Multi Variables
                    string GroupWeatherText = "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentText + "</text></subgroup></group>";

                    //Set Small Tile Texts
                    string SmallTileFontSize = "title";
                    if (BgStatusWeatherCurrentTemp.Length > 3)
                    {
                        SmallTileFontSize = "subtitle";
                    }
                    string WeatherSmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group><subgroup><text hint-style=\"" + SmallTileFontSize + "\" hint-align=\"center\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group></binding>";

                    //Set Medium Tile Texts
                    string GroupWeatherTemps = "";
                    if (setDisplayWeatherTempHighLow)
                    {
                        GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"70\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup> <subgroup><text hint-align=\"right\">" + BgStatusWeatherCurrentTempHigh + "</text><text hint-style=\"captionSubtle\" hint-align=\"right\">" + BgStatusWeatherCurrentTempLow + "</text></subgroup></group>";
                    }
                    else
                    {
                        GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"1\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\" hint-weight=\"2\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group>";
                    }

                    string GroupWeatherPrecip = "<group><subgroup hint-weight=\"17\" hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/WeatherOther/tab_Precipitation.png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentRainChance + "</text></subgroup></group>";
                    string GroupWeatherWind   = "<group><subgroup hint-weight=\"17\" hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/WeatherOther/tab_WindSpeed.png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentWindSpeed + "</text></subgroup></group>";
                    string WeatherMediumTile  = "<binding template=\"TileMedium\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + GroupWeatherWind + GroupWeatherPrecip + "</binding>";

                    //Set Wide Tile Texts
                    string WeatherTextDetailed = "";
                    string WeatherTextUpdate   = "";
                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider)
                    {
                        if (setDisplayWeatherTempHighLow)
                        {
                            WeatherTextDetailed = "<text hint-align=\"left\">" + WeatherDetailed + "</text>";
                        }
                        else
                        {
                            WeatherTextDetailed = "<text hint-align=\"right\">" + WeatherDetailed + "</text>";
                        }
                    }
                    if (setDisplayWeatherTileUpdateTime)
                    {
                        if (setDisplayWeatherTempHighLow)
                        {
                            WeatherTextUpdate = "<text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherLastUpdate + "</text>";
                        }
                        else
                        {
                            WeatherTextUpdate = "<text hint-style=\"captionSubtle\" hint-align=\"right\">" + WeatherLastUpdate + "</text>";
                        }
                    }

                    if (setDisplayWeatherTempHighLow)
                    {
                        GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"1\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\" hint-weight=\"2\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup> <subgroup hint-weight=\"1\"><text hint-align=\"right\">" + BgStatusWeatherCurrentTempHigh + "</text><text hint-style=\"captionSubtle\" hint-align=\"right\">" + BgStatusWeatherCurrentTempLow + "</text></subgroup> <subgroup hint-weight=\"2\">" + WeatherTextDetailed + WeatherTextUpdate + "</subgroup></group>";
                    }
                    else
                    {
                        GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"15\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\" hint-weight=\"45\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup> <subgroup hint-weight=\"40\">" + WeatherTextDetailed + WeatherTextUpdate + "</subgroup></group>";
                    }

                    GroupWeatherPrecip = "<group><subgroup hint-weight=\"7\" hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/WeatherOther/tab_Precipitation.png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentRainChance + "</text></subgroup></group>";
                    GroupWeatherWind   = "<group><subgroup hint-weight=\"7\" hint-textStacking=\"center\"><image src=\"ms-appx:///Assets/WeatherOther/tab_WindSpeed.png\" hint-removeMargin=\"true\"/></subgroup><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentWindSpeed + "</text></subgroup></group>";

                    string WeatherWideTile = "<binding template=\"TileWide\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + GroupWeatherWind + GroupWeatherPrecip + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherSmallTile + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render forecast weather tile
                else if (setWeatherTileSizeName == "WeatherForecast")
                {
                    //Set Medium Tile Texts
                    string WeatherMediumTile = "";
                    if (setShowMoreTiles)
                    {
                        WeatherMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group>" + WeatherTile1 + WeatherTile2 + WeatherTile3 + "</group><group><subgroup><text hint-style=\"captionSubtle\">" + WeatherLastUpdate + "</text><text hint-style=\"caption\">" + WeatherDetailed + "</text></subgroup></group></binding>";
                    }
                    else
                    {
                        WeatherMediumTile = "<binding template=\"TileMedium\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group>" + WeatherTile1 + WeatherTile2 + WeatherTile3 + "</group><group><subgroup><text hint-align=\"left\" hint-style=\"caption\">" + WeatherDetailed + "</text></subgroup><subgroup><text hint-align=\"right\" hint-style=\"captionSubtle\">" + WeatherLastUpdate + "</text></subgroup></group></binding>";
                    }

                    //Set Wide Tile Texts
                    string WeatherWideTile = "<binding template=\"TileWide\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<group>" + WeatherTile1 + WeatherTile2 + WeatherTile3 + WeatherTile4 + WeatherTile5 + "</group><group><subgroup><text hint-align=\"left\" hint-style=\"caption\">" + WeatherDetailed + "</text></subgroup><subgroup><text hint-align=\"right\" hint-style=\"captionSubtle\">" + WeatherLastUpdate + "</text></subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render combo weather tile
                else if (setWeatherTileSizeName == "WeatherCombo")
                {
                    //Set Multi Variables
                    string GroupWeatherText     = "";
                    string GroupWeatherTemps    = "";
                    string GroupWeatherForecast = "";

                    //Set Small Tile Texts
                    string WeatherSmallTile = "<binding template=\"TileSmall\" hint-textStacking=\"center\">" + TileWeather_BackgroundPhotoXml + "<image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\"/></binding>";

                    //Set Medium Tile Texts
                    GroupWeatherText  = "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentText + "</text></subgroup></group>";
                    GroupWeatherTemps = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"1\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\" hint-weight=\"2\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup></group>";
                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider)
                    {
                        GroupWeatherForecast = "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherDetailed + "</text><text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherLastUpdate + "</text></subgroup></group>";
                    }
                    else
                    {
                        GroupWeatherForecast = "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"captionSubtle\" hint-align=\"left\">" + WeatherLastUpdate + "</text></subgroup></group>";
                    }
                    string WeatherMediumTile = "<binding template=\"TileMedium\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + GroupWeatherForecast + "</binding>";

                    //Set Wide Tile Texts
                    string WeatherTextDetailed = "";
                    string WeatherTextUpdate   = "";
                    if (setDisplayWeatherTileLocation || setDisplayWeatherTileProvider)
                    {
                        WeatherTextDetailed = "<text hint-align=\"right\">" + WeatherDetailed + "</text>";
                    }
                    if (setDisplayWeatherTileUpdateTime)
                    {
                        WeatherTextUpdate = "<text hint-style=\"captionSubtle\" hint-align=\"right\">" + WeatherLastUpdate + "</text>";
                    }
                    GroupWeatherText     = "<group><subgroup hint-textStacking=\"center\"><text hint-style=\"caption\" hint-align=\"left\">" + BgStatusWeatherCurrentText + "</text></subgroup> <subgroup hint-weight=\"25\"><text hint-style=\"caption\" hint-align=\"right\">" + BgStatusWeatherCurrentRainChance + " Rain</text></subgroup></group>";
                    GroupWeatherTemps    = "<group><subgroup hint-textStacking=\"center\" hint-weight=\"15\"><image src=\"ms-appx:///Assets/Weather" + WeatherIconStyle + "/" + WeatherIconCurrent + ".png\" hint-removeMargin=\"true\"/></subgroup> <subgroup hint-textStacking=\"center\" hint-weight=\"45\"><text hint-style=\"titleNumeral\" hint-align=\"left\">" + BgStatusWeatherCurrentTemp + "</text></subgroup> <subgroup hint-weight=\"40\">" + WeatherTextDetailed + WeatherTextUpdate + "</subgroup></group>";
                    GroupWeatherForecast = "<group>" + WeatherTile2 + WeatherTile3 + WeatherTile4 + "</group>";
                    string WeatherWideTile = "<binding template=\"TileWide\">" + TileWeather_BackgroundPhotoXml + GroupWeatherTemps + GroupWeatherText + GroupWeatherForecast + "</binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherSmallTile + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                //Render forecast words tile
                else if (setWeatherTileSizeName == "WeatherWords")
                {
                    //Set Medium Tile Texts
                    string WeatherMediumTile = "<binding template=\"TileMedium\">" + TileWeather_BackgroundPhotoXml + "<group><subgroup><text hint-align=\"left\" hint-wrap=\"true\" hint-style=\"caption\">" + WeatherTile1 + "</text></subgroup></group><group><subgroup><text hint-align=\"left\" hint-style=\"captionSubtle\">" + WeatherLastUpdate + "</text><text hint-align=\"left\" hint-style=\"caption\">" + WeatherDetailed + "</text></subgroup></group></binding>";

                    //Set Wide Tile Texts
                    string WeatherWideTile = "<binding template=\"TileWide\">" + TileWeather_BackgroundPhotoXml + "<group><subgroup><text hint-align=\"left\" hint-wrap=\"true\" hint-style=\"caption\">" + WeatherTile1 + "</text><text hint-align=\"left\" hint-wrap=\"true\" hint-style=\"captionSubtle\">" + WeatherTile2 + "</text></subgroup></group><group><subgroup><text hint-align=\"left\" hint-style=\"caption\">" + WeatherDetailed + "</text></subgroup><subgroup><text hint-align=\"right\" hint-style=\"captionSubtle\">" + WeatherLastUpdate + "</text></subgroup></group></binding>";

                    Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + WeatherMediumTile + WeatherWideTile + "</visual></tile>");
                    Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
                }

                Debug.WriteLine("The weather tile has been updated.");
            }
            catch { }
        }
Esempio n. 7
0
        //Force Task Agent Update
        public IAsyncOperation <bool> ForceRun()
        {
            return(Task.Run <bool>(async delegate
            {
                try
                {
                    //Load tile and application settings
                    if (!LoadAppSettings())
                    {
                        if (TileLive_Pinned)
                        {
                            RenderTileAppUpdated("TimeMeLiveTile");
                        }
                        if (TileWeather_Pinned)
                        {
                            RenderTileAppUpdated("TimeMeWeatherTile");
                        }
                        if (TileBattery_Pinned)
                        {
                            RenderTileAppUpdated("TimeMeBatteryTile");
                        }
                        DisposeVariables();
                        return false;
                    }

                    //Load other used data first
                    if (!await LoadOtherDataFirst())
                    {
                        if (TileLive_Pinned)
                        {
                            RenderTileLiveFailed("TimeMeLiveTile");
                        }
                        if (TileWeather_Pinned)
                        {
                            RenderTileLiveFailed("TimeMeWeatherTile");
                        }
                        if (TileBattery_Pinned)
                        {
                            RenderTileLiveFailed("TimeMeBatteryTile");
                        }
                        DisposeVariables();
                        return false;
                    }

                    //Download the background updates
                    await DownloadBackground();

                    //Update the lockscreen information
                    UpdateLockscreen();

                    //Check if weather tile is pinned
                    if (TileWeather_Pinned)
                    {
                        Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile");
                        Tile_UpdateManager.EnableNotificationQueue(false);
                        Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();
                        if (await LoadTileDataWeather())
                        {
                            RenderWeatherTile();
                        }
                        else
                        {
                            RenderTileWeatherDisabled();
                        }
                    }

                    //Check if battery tile is pinned
                    if (TileBattery_Pinned)
                    {
                        Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile");
                        Tile_UpdateManager.EnableNotificationQueue(false);
                        Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();
                        if (await LoadTileDataBattery())
                        {
                            RenderBatteryTile();
                        }
                        else
                        {
                            RenderTileBatteryDisabled();
                        }
                    }

                    //Check if live tile is pinned
                    if (TileLive_Pinned)
                    {
                        Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeLiveTile");
                        Tile_UpdateManager.EnableNotificationQueue(false);
                        Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                        //Load first one time live tile data
                        if (await LoadTileDataFirst())
                        {
                            //Plan and render future live tiles
                            await PlanLiveTiles();
                        }
                        else
                        {
                            RenderTileLiveFailed("TimeMeLiveTile");
                        }
                    }
                }
                catch { }
                DisposeVariables();
                return true;
            }).AsAsyncOperation());
        }
Esempio n. 8
0
        //Run Task Agent Update
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                //Set current background task info
                taskInstanceDeferral   = taskInstance.GetDeferral();
                taskInstance.Canceled += delegate { DisposeVariables(); taskInstance.Progress = 100; taskInstanceDeferral.Complete(); return; };
                taskInstanceName       = taskInstance.Task.Name;

                //Load tile and application settings
                taskInstance.Progress = 90;
                if (!LoadAppSettings())
                {
                    if (TileLive_Pinned)
                    {
                        RenderTileAppUpdated("TimeMeLiveTile");
                    }
                    if (TileWeather_Pinned)
                    {
                        RenderTileAppUpdated("TimeMeWeatherTile");
                    }
                    if (TileBattery_Pinned)
                    {
                        RenderTileAppUpdated("TimeMeBatteryTile");
                    }
                    DisposeVariables();
                    taskInstance.Progress = 100;
                    taskInstanceDeferral.Complete();
                    return;
                }

                //Show task start debug message
                if (setAppDebug)
                {
                    Tile_XmlContent.LoadXml("<toast><visual><binding template=\"ToastText02\"><text id=\"1\">Taskstart: " + taskInstanceName + "</text><text id=\"2\">" + DateTimeNow.ToString() + "</text></binding></visual><audio silent=\"true\"/></toast>");
                    Toast_UpdateManager.Show(new ToastNotification(Tile_XmlContent)
                    {
                        SuppressPopup = true, Tag = "T3", Group = "G3"
                    });
                }

                //Load other used data first
                if (!await LoadOtherDataFirst())
                {
                    if (TileLive_Pinned)
                    {
                        RenderTileLiveFailed("TimeMeLiveTile");
                    }
                    if (TileWeather_Pinned)
                    {
                        RenderTileLiveFailed("TimeMeWeatherTile");
                    }
                    if (TileBattery_Pinned)
                    {
                        RenderTileLiveFailed("TimeMeBatteryTile");
                    }
                    DisposeVariables();
                    taskInstance.Progress = 100;
                    taskInstanceDeferral.Complete();
                    return;
                }

                //Download the background updates
                taskInstance.Progress = 10;
                await DownloadBackground();

                //Update the lockscreen information
                taskInstance.Progress = 20;
                UpdateLockscreen();

                //Check if weather tile is pinned
                if (TileWeather_Pinned)
                {
                    taskInstance.Progress = 40;
                    Tile_UpdateManager    = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile");
                    Tile_UpdateManager.EnableNotificationQueue(false);
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();
                    if (await LoadTileDataWeather())
                    {
                        RenderWeatherTile();
                    }
                    else
                    {
                        RenderTileWeatherDisabled();
                    }
                }

                //Check if battery tile is pinned
                if (TileBattery_Pinned)
                {
                    taskInstance.Progress = 50;
                    Tile_UpdateManager    = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile");
                    Tile_UpdateManager.EnableNotificationQueue(false);
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();
                    if (await LoadTileDataBattery())
                    {
                        RenderBatteryTile();
                    }
                    else
                    {
                        RenderTileBatteryDisabled();
                    }
                }

                //Check if live tile is pinned
                if (TileLive_Pinned)
                {
                    taskInstance.Progress = 30;
                    Tile_UpdateManager    = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeLiveTile");
                    Tile_UpdateManager.EnableNotificationQueue(false);
                    Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                    //Delay timer task to avoid collision
                    //if (TaskInstanceName.StartsWith("TimeMeTaskTimer")) { await Task.Delay(1000); }

                    //Check if there is a live tile update needed
                    if (!FreshDeviceBoot && !TileLive_ForceUpdate && taskInstanceName != "TimeMeTaskTimeZone" && BgStatusLastRunDate != "Never" && Tile_PlannedUpdates.Any())
                    {
                        //Check if the live tile has failed to update
                        if (Tile_PlannedUpdates.Last().DeliveryTime.Subtract(DateTime.Parse(BgStatusLastRunDate, vCultureInfoEng)).TotalMilliseconds <= 960000)
                        {
                            Debug.WriteLine("Live tile has failed to render succesfully.");
                        }
                        else
                        {
                            if (taskInstanceName == "TimeMeTaskUser")
                            {
                                Debug.WriteLine("There is no user live tile update needed."); TileLive_NeedUpdate = false;
                            }
                            else if (taskInstanceName == "TimeMeTaskTimer" && Tile_PlannedUpdates.Last().DeliveryTime.Subtract(DateTimeNow).TotalMilliseconds >= 960000)
                            {
                                Debug.WriteLine("There is no timer live tile update needed."); TileLive_NeedUpdate = false;
                            }
                        }
                    }

                    //Update the live tile if needed
                    if (TileLive_NeedUpdate)
                    {
                        //Load first one time live tile data
                        if (await LoadTileDataFirst())
                        {
                            //Plan and render future live tiles
                            await PlanLiveTiles();
                        }
                        else
                        {
                            RenderTileLiveFailed("TimeMeLiveTile");
                        }
                    }
                }
            }
            catch { }
            DisposeVariables();
            taskInstance.Progress = 100;
            taskInstanceDeferral.Complete();
            return;
        }