/// <summary>
        /// Unpins a secondary tile from the start screen.
        /// </summary>
        private async Task OnUnPinStopToStartPageCommandExecuted(object arg1, object arg2)
        {
            IPinablePageControl pinnablePageControl = arg2 as IPinablePageControl;

            if (pinnablePageControl != null)
            {
                this.IsCurrentControlPinned = !await ServiceRepository.TileService.UnPinSecondaryTileAsync(pinnablePageControl);
            }
        }
        /// <summary>
        /// Returns true if the page control is currently pinned.
        /// </summary>
        public async Task <bool> PageControlIsCurrentlyPinned(IPageControl pageControl)
        {
            IPinablePageControl pinnablePageControl = pageControl as IPinablePageControl;

            if (pinnablePageControl != null)
            {
                // See if we're pinned to start:
                var query = from tile in await SecondaryTile.FindAllAsync()
                                where string.Equals(pinnablePageControl.TileId, tile.TileId, StringComparison.OrdinalIgnoreCase)
                            select tile;

                return(query.Count() > 0);
            }

            return(false);
        }
        /// <summary>
        /// Unpins a secondary tile to the start screen.
        /// </summary>
        public async Task <bool> UnPinSecondaryTileAsync(IPinablePageControl pinnablePageControl)
        {
            var secondaryTile = (from tile in await SecondaryTile.FindAllAsync()
                                 where string.Equals(pinnablePageControl.TileId, tile.TileId, StringComparison.OrdinalIgnoreCase)
                                 select tile).FirstOrDefault();

            if (secondaryTile != null)
            {
                if (await secondaryTile.RequestDeleteAsync())
                {
                    await pinnablePageControl.UpdateTileAsync(false);

                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Pins a secondary tile to the start screen.
        /// </summary>
        public async Task<bool> PinSecondaryTileAsync(IPinablePageControl pinnablePageControl)
        {
            Uri logoUri = new Uri("ms-appx:///Assets/Logo.scale-100.png");
            Uri smallLogoUri = new Uri("ms-appx:///Assets/SmallLogo.scale-100.png");
            Uri wideLogoUri = new Uri("ms-appx:///Assets/WideLogo.scale-100.png");
            Uri largeLogoUri = new Uri("ms-appx:///Assets/Square310x310Logo.scale-100.png");

            SecondaryTile secondaryTile = new SecondaryTile();
            secondaryTile.TileId = pinnablePageControl.TileId;
            secondaryTile.DisplayName = pinnablePageControl.TileName;
            secondaryTile.Arguments = pinnablePageControl.GetParameters().ToQueryString();

            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
            secondaryTile.VisualElements.Square30x30Logo = smallLogoUri;
            secondaryTile.VisualElements.Square150x150Logo = logoUri;
            secondaryTile.VisualElements.Wide310x150Logo = wideLogoUri;
            secondaryTile.VisualElements.Square310x310Logo = largeLogoUri;
            secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;

            if (await secondaryTile.RequestCreateAsync())
            {
                try
                {
                    await pinnablePageControl.UpdateTileAsync(true);
                    
                }
                catch
                {
                    // In case of network error, don't bring down the app. Nothing we can do here...
                    return false;
                }
            }

            return true;
        }
        /// <summary>
        /// Pins a secondary tile to the start screen.
        /// </summary>
        public async Task <bool> PinSecondaryTileAsync(IPinablePageControl pinnablePageControl)
        {
            Uri logoUri      = new Uri("ms-appx:///Assets/Logo.scale-100.png");
            Uri smallLogoUri = new Uri("ms-appx:///Assets/SmallLogo.scale-100.png");
            Uri wideLogoUri  = new Uri("ms-appx:///Assets/WideLogo.scale-100.png");
            Uri largeLogoUri = new Uri("ms-appx:///Assets/Square310x310Logo.scale-100.png");

            SecondaryTile secondaryTile = new SecondaryTile();

            secondaryTile.TileId      = pinnablePageControl.TileId;
            secondaryTile.DisplayName = pinnablePageControl.TileName;
            secondaryTile.Arguments   = pinnablePageControl.GetParameters().ToQueryString();

            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo   = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
            secondaryTile.VisualElements.Square30x30Logo             = smallLogoUri;
            secondaryTile.VisualElements.Square150x150Logo           = logoUri;
            secondaryTile.VisualElements.Wide310x150Logo             = wideLogoUri;
            secondaryTile.VisualElements.Square310x310Logo           = largeLogoUri;
            secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;

            if (await secondaryTile.RequestCreateAsync())
            {
                try
                {
                    await pinnablePageControl.UpdateTileAsync(true);
                }
                catch
                {
                    // In case of network error, don't bring down the app. Nothing we can do here...
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Unpins a secondary tile to the start screen.
        /// </summary>
        public async Task<bool> UnPinSecondaryTileAsync(IPinablePageControl pinnablePageControl)
        {
            var secondaryTile = (from tile in await SecondaryTile.FindAllAsync()
                                 where string.Equals(pinnablePageControl.TileId, tile.TileId, StringComparison.OrdinalIgnoreCase)
                                 select tile).FirstOrDefault();

            if (secondaryTile != null)
            {
                if (await secondaryTile.RequestDeleteAsync())
                {
                    await pinnablePageControl.UpdateTileAsync(false);
                    return true;
                }
            }

            return false;
        }
 public Task <bool> UnPinSecondaryTileAsync(IPinablePageControl pinnablePageControl)
 {
     return(Task.FromResult <bool>(false));
 }