Exemplo n.º 1
0
        private async Task <bool> CreateOrUpdateSecondaryTileAsync(SecondaryTile tile, TileVisualOptions options)
        {
            if (tile == null)
            {
                return(false);
            }

            tile.VisualElements.ShowNameOnSquare150x150Logo = true;

            tile.VisualElements.Square71x71Logo   = options.Square71x71Logo ?? null;
            tile.VisualElements.Square150x150Logo = options.Square150x150Logo ?? null;

            if (!(ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
            {
                tile.VisualElements.Wide310x150Logo             = options.Wide310x150Logo ?? null;
                tile.VisualElements.Square310x310Logo           = options.Square310x310Logo ?? null;
                tile.VisualElements.ShowNameOnWide310x150Logo   = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            }

            if (SecondaryTile.Exists(tile.TileId))
            {
                return(await tile.UpdateAsync());
            }
            else
            {
                if (!ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))
                {
                    if (options.Rect == null)
                    {
                        return(await tile.RequestCreateAsync());
                    }
                    else
                    {
                        return(await tile.RequestCreateForSelectionAsync(options.Rect, options.PopupPlacement));
                    }
                }
                else if (ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))
                {
                    // OK, the tile is created and we can now attempt to pin the tile.
                    // Since pinning a secondary tile on Windows Phone will exit the app and take you to the start screen, any code after
                    // RequestCreateForSelectionAsync or RequestCreateAsync is not guaranteed to run.  For an example of how to use the OnSuspending event to do
                    // work after RequestCreateForSelectionAsync or RequestCreateAsync returns, see Scenario9_PinTileAndUpdateOnSuspend in the SecondaryTiles.WindowsPhone project.
                    return(await tile.RequestCreateAsync());
                }
            }

            return(false);
        }
        private async Task<bool> CreateOrUpdateSecondaryTileAsync(SecondaryTile tile, TileVisualOptions options)
        {
            if (tile == null)
                return false;

            tile.VisualElements.ShowNameOnSquare150x150Logo = true;

            tile.VisualElements.Square71x71Logo = options.Square71x71Logo ?? null;
            tile.VisualElements.Square150x150Logo = options.Square150x150Logo ?? null;

            if (!(ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
            {
                tile.VisualElements.Wide310x150Logo = options.Wide310x150Logo ?? null;
                tile.VisualElements.Square310x310Logo = options.Square310x310Logo ?? null;
                tile.VisualElements.ShowNameOnWide310x150Logo = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            }

            if (SecondaryTile.Exists(tile.TileId))
            {
                return await tile.UpdateAsync();
            }
            else
            {
                if (!ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))
                {
                    if (options.Rect == null)
                        return await tile.RequestCreateAsync();
                    else
                        return await tile.RequestCreateForSelectionAsync(options.Rect, options.PopupPlacement);
                }
                else if (ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))
                {
                    // OK, the tile is created and we can now attempt to pin the tile.
                    // Since pinning a secondary tile on Windows Phone will exit the app and take you to the start screen, any code after 
                    // RequestCreateForSelectionAsync or RequestCreateAsync is not guaranteed to run.  For an example of how to use the OnSuspending event to do
                    // work after RequestCreateForSelectionAsync or RequestCreateAsync returns, see Scenario9_PinTileAndUpdateOnSuspend in the SecondaryTiles.WindowsPhone project.
                    return await tile.RequestCreateAsync();
                }
            }

            return false;
        }