RequestCreateForSelectionAsync() private method

private RequestCreateForSelectionAsync ( [ selection ) : IAsyncOperation
selection [
return IAsyncOperation
Exemplo n.º 1
0
		public async Task<bool> Pin(TileInfo tileInfo)
		{
			if (tileInfo == null)
			{
				throw new ArgumentNullException("tileInfo");
			}

			var isPinned = false;

			if (!SecondaryTile.Exists(tileInfo.TileId))
			{
				var secondaryTile = new SecondaryTile(
					tileInfo.TileId,
					tileInfo.DisplayName,
					tileInfo.Arguments,
					tileInfo.LogoUri,
					tileInfo.TileSize);

				if (tileInfo.WideLogoUri != null)
				{
					secondaryTile.VisualElements.Wide310x150Logo = tileInfo.WideLogoUri;
				}

				secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
				secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
				secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

				isPinned = await secondaryTile.RequestCreateForSelectionAsync(
						GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
			}

			return isPinned;
		}
        private async void CreateBadgeAndTextTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(TEXT_TILE_ID))
            {
                SecondaryTile secondTile = new SecondaryTile(
                    TEXT_TILE_ID,
                    "LockScreen CS - Badge and tile text",
                    "TEXT_ARGS",
                    new Uri("ms-appx:///images/squareTile-sdk.png"),
                    TileSize.Wide310x150
                );
                secondTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///images/tile-sdk.png");
                secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///images/badgelogo-sdk.png");
                secondTile.LockScreenDisplayBadgeAndTileText = true;

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Above);
                if (isPinned)
                {
                    ITileWide310x150Text03 tileContent = TileContentFactory.CreateTileWide310x150Text03();
                    tileContent.TextHeadingWrap.Text = "Text for the lock screen";
                    tileContent.RequireSquare150x150Content = false;
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(TEXT_TILE_ID).Update(tileContent.CreateNotification());
                    rootPage.NotifyUser("Secondary tile created and updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }

            }
            else
            {
                rootPage.NotifyUser("Badge and text secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
Exemplo n.º 3
0
        public async Task<bool> Pin(TileInfo info)
        {
            System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
            if (Exists(info))
                return true;

            var tile = new SecondaryTile()
            {
                TileId = info.TileId,
                DisplayName = info.DisplayName,
                Arguments = info.Arguments,
                PhoneticName = info.PhoneticName,
                LockScreenDisplayBadgeAndTileText = info.LockScreenDisplayBadgeAndTileText,
                LockScreenBadgeLogo = info.LockScreenBadgeLogo,
            };

            tile.VisualElements.BackgroundColor = info.VisualElements.BackgroundColor;
            tile.VisualElements.ForegroundText = info.VisualElements.ForegroundText;
            tile.VisualElements.ShowNameOnSquare150x150Logo = info.VisualElements.ShowNameOnSquare150x150Logo;
            tile.VisualElements.ShowNameOnSquare310x310Logo = info.VisualElements.ShowNameOnSquare310x310Logo;
            tile.VisualElements.ShowNameOnWide310x150Logo = info.VisualElements.ShowNameOnWide310x150Logo;
            tile.VisualElements.Square150x150Logo = info.VisualElements.Square150x150Logo;
            tile.VisualElements.Square30x30Logo = info.VisualElements.Square30x30Logo;
            tile.VisualElements.Square310x310Logo = info.VisualElements.Square310x310Logo;
            tile.VisualElements.Square70x70Logo = info.VisualElements.Square70x70Logo;
            tile.VisualElements.Wide310x150Logo = info.VisualElements.Wide310x150Logo;

            var result = await tile.RequestCreateForSelectionAsync(info.Rect(), info.RequestPlacement);
            return result;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create and pin a secondary square Tile.
        /// </summary>
        /// <param name="tileId"></param>
        /// <param name="shortName"></param>
        /// <param name="image"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public async Task<bool> PinToStart(string tileId, string shortName, Uri image, string arguments)
        {
            // Create the unique tileId
            var id = Regex.Replace(tileId, @"[^\d\w\s]", "-").
                     Replace(" ", string.Empty) + ".LiveTile";

            //Check first if Tile exists
            if (!SecondaryTileExists(id))
            {
                //Create a secondary Tile
                var secondaryTile = new SecondaryTile(id, shortName, shortName, image, TileSize.Default);

#if WINDOWS_PHONE_APP     
                bool isPinned = await secondaryTile.RequestCreateAsync();
#else
                // Position of the modal dialog 
                GeneralTransform buttonTransform = App.Frame.TransformToVisual(null);
                Point point = buttonTransform.TransformPoint(new Point());
                var rect = new Rect(point, new Size(App.Frame.ActualWidth, App.Frame.ActualHeight));

                //Pin
                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Placement.Below);
#endif

                return isPinned;
            }

            return true;
        }
        private async void CreateBadgeTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(BADGE_TILE_ID)) {
                SecondaryTile secondTile = new SecondaryTile(
                    BADGE_TILE_ID,
                    "LockScreen CS - Badge only",
                    "BADGE_ARGS",
                    new Uri("ms-appx:///images/squareTile-sdk.png"),
                    TileSize.Square150x150
                );
                secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///images/badgelogo-sdk.png");

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Above);
                if (isPinned)
                {
                    BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(BADGE_TILE_ID).Update(badgeContent.CreateNotification());
                    rootPage.NotifyUser("Secondary tile created and badge updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else 
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }
                
            } else {
                rootPage.NotifyUser("Badge secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
Exemplo n.º 6
0
		public async Task<bool> Pin(TileInfo tileInfo)
		{
			if (tileInfo == null)
			{
				throw new ArgumentNullException("tileInfo");
			}

			var isPinned = false;

			if (!SecondaryTile.Exists(tileInfo.TileId))
			{
				var secondaryTile = new SecondaryTile(
					tileInfo.TileId,
					tileInfo.ShortName,
					tileInfo.DisplayName,
					tileInfo.Arguments,
					tileInfo.TileOptions,
					tileInfo.LogoUri);

				if (tileInfo.WideLogoUri != null)
				{
					secondaryTile.WideLogo = tileInfo.WideLogoUri;
				}

				isPinned = await secondaryTile.RequestCreateForSelectionAsync(
						GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
			}

			return isPinned;
		}
Exemplo n.º 7
0
        public async Task<bool> CreateSecondaryTile(Category category, Rect rect)
        {
            var firstProduct = category.Products.First();
            var tile = new SecondaryTile(category.TileId, "ShopNow", 
                category.Name, "category=" + category.Name, 
                TileOptions.ShowNameOnLogo, new Uri(firstProduct.ThumbnailImage));

            tile.ForegroundText = ForegroundText.Dark;

            return await tile.RequestCreateForSelectionAsync(rect, Placement.Above);
        }
Exemplo n.º 8
0
        public async Task<bool> PinAsync(TileInfo info, string tileId, string arguments)
        {
            System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
            System.Diagnostics.Contracts.Contract.Requires(!string.IsNullOrEmpty(tileId), "TileId");

            if (Exists(tileId))
            {
                var existings = await SecondaryTile.FindAllAsync();
                var existing = existings.FirstOrDefault(x => x.Arguments.Equals(arguments));
            }

            var tile = new SecondaryTile()
            {
                TileId = tileId,
                DisplayName = info.DisplayName,
                Arguments = arguments,
                PhoneticName = info.PhoneticName,
                LockScreenDisplayBadgeAndTileText = info.LockScreenDisplayBadgeAndTileText,
            };

            if (info.LockScreenBadgeLogo != null)
            {
                tile.LockScreenBadgeLogo = info.LockScreenBadgeLogo;
            }

            tile.VisualElements.BackgroundColor = info.VisualElements.BackgroundColor;
            tile.VisualElements.ForegroundText = info.VisualElements.ForegroundText;
            tile.VisualElements.ShowNameOnSquare150x150Logo = info.VisualElements.ShowNameOnSquare150x150Logo;
            tile.VisualElements.ShowNameOnSquare310x310Logo = info.VisualElements.ShowNameOnSquare310x310Logo;
            tile.VisualElements.ShowNameOnWide310x150Logo = info.VisualElements.ShowNameOnWide310x150Logo;

            if (info.VisualElements.Square150x150Logo != null)
            {
                tile.VisualElements.Square150x150Logo = info.VisualElements.Square150x150Logo;
            }

            if (info.VisualElements.Square30x30Logo != null)
            {
                tile.VisualElements.Square30x30Logo = info.VisualElements.Square30x30Logo;
            }

            if (info.VisualElements.Square310x310Logo != null)
            {
                tile.VisualElements.Square310x310Logo = info.VisualElements.Square310x310Logo;
            }

            if (info.VisualElements.Wide310x150Logo != null)
            {
                tile.VisualElements.Wide310x150Logo = info.VisualElements.Wide310x150Logo;
            }

            var result = await tile.RequestCreateForSelectionAsync(info.Rect(), info.RequestPlacement);
            return result;
        }
Exemplo n.º 9
0
        async private void btnPin_Click(object sender, RoutedEventArgs e)
        {
            this.bottomAppBar.IsSticky = true;
            string shortName = "Testing";
            string displayName = "Description";
            string tileActivationArguments = "Item=1";
            Uri logo = new Uri("ms-appx:///Assets/TestPin.jpg");

            int uniqueId = 1; //Assign an unique id for the tile. Suggestion: Use the Pk of your base table

            SecondaryTile secondaryTile = new SecondaryTile("Pin_" + uniqueId.ToString(),
                                                shortName,
                                                displayName,
                                                tileActivationArguments,
                                                TileOptions.ShowNameOnWideLogo,
                                                logo,
                                                logo);

            secondaryTile.ForegroundText = ForegroundText.Light;
            secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");

            FrameworkElement internalSender = (FrameworkElement)this.btnPin;
            Windows.UI.Xaml.Media.GeneralTransform buttonTransform = internalSender.TransformToVisual(null);
            Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
            Windows.Foundation.Rect rect = new Rect(point, new Size(250, 250));

            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
            this.bottomAppBar.IsSticky = false;

            if (isPinned)
            {
                // Note: This sample contains an additional reference, NotificationsExtensions, which you can use in your apps
                ITileWideText04 tileContent = TileContentFactory.CreateTileWideText04();
                tileContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationsExtensions!";

                ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
                squareContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationExtensions!";
                tileContent.SquareContent = squareContent;

                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile("Pin_" + uniqueId.ToString()).Update(tileContent.CreateNotification());

                this.btnPin.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                this.btnUnpin.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
        }
Exemplo n.º 10
0
		public async Task<bool> PinPoll(FrameworkElement anchorElement, int pollId, string question)
		{
			var isPinned = false;
			Uri logoUri = new Uri("ms-appx:///Assets/Logo.png");

			var tileId = string.Format(SecondaryPinner.TileIdFormat, pollId);
			if (!SecondaryTile.Exists(tileId))
			{
				var secondaryTile = new SecondaryTile(
					tileId,
					question,
					pollId.ToString(),
					logoUri,
					TileSize.Default);

				isPinned = await secondaryTile.RequestCreateForSelectionAsync(
						GetElementRect(anchorElement), Placement.Above);
			}

			return isPinned;
		}
Exemplo n.º 11
0
        async private void btnPin_Click(object sender, RoutedEventArgs e)
        {
            if (selectedTrip.LocalPathImage == loader.GetString("DefaultParentImage"))
            {
                await App.ShowSimpleMessage("Please, select a custom image for your trip.", "Default Image");
            }
            else
            {
                this.bottomAppBar.IsSticky = true;
                string shortName = selectedTrip.Title;
                string displayName = selectedTrip.Description;
                string tileActivationArguments = "Trip=" + selectedTrip.Identifier.ToString();
                Uri logo = new Uri(selectedTrip.LocalPathImage);

                SecondaryTile secondaryTile = new SecondaryTile("SuggesMePin_" + selectedTrip.Identifier.ToString(),
                                                    shortName,
                                                    displayName,
                                                    tileActivationArguments,
                                                    TileOptions.ShowNameOnWideLogo,
                                                    logo,
                                                    logo);

                secondaryTile.ForegroundText = ForegroundText.Light;
                secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/SmallLogoWithBackground.png");

                FrameworkElement internalSender = (FrameworkElement)this.btnPin;
                Windows.UI.Xaml.Media.GeneralTransform buttonTransform = internalSender.TransformToVisual(null);
                Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
                Windows.Foundation.Rect rect = new Rect(point, new Size(250, 250));

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
                this.bottomAppBar.IsSticky = false;

                if (isPinned)
                    this.btnPin.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }
        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;
        }
Exemplo n.º 13
0
        private async void ButtonPin_Click(object sender, RoutedEventArgs e)
        {
            BottomAppBar.IsSticky = true;

            var button = (FrameworkElement)sender;
            var buttonTransform = button.TransformToVisual(null);
            var point = buttonTransform.TransformPoint(new Point(0, -20));
            var rect = new Rect(point, new Size(button.ActualWidth, button.ActualHeight));

            if (SecondaryTile.Exists(SelectedItem.Key))
            {
                var tiles = await SecondaryTile.FindAllAsync();
                var secondaryTile = tiles.FirstOrDefault(tile => tile.TileId == SelectedItem.Key);
                if (secondaryTile != null) await secondaryTile.RequestDeleteForSelectionAsync(rect, Placement.Above);
            }
            else
            {
                var logo = new Uri(SelectedItem.Image);
                var tileActivationArguments = SelectedItem.Key + " was pinned at " + DateTime.Now.ToLocalTime();
                var secondaryTile = new SecondaryTile(SelectedItem.Key, SelectedItem.Name, tileActivationArguments, logo, TileSize.Default);
                var result = await secondaryTile.RequestCreateForSelectionAsync(rect, Placement.Above);

                if (result)
                {
                    var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText04);
                    var notification = new TileNotification(tileXml);

                    // Set notification text.
                    XmlNodeList nodes = tileXml.GetElementsByTagName("image");
                    nodes[0].Attributes[1].NodeValue = SelectedItem.Image;
                    nodes = tileXml.GetElementsByTagName("text");
                    nodes[0].InnerText = SelectedItem.Name;

                    // Update Live Tile.
                    var upd = TileUpdateManager.CreateTileUpdaterForSecondaryTile(SelectedItem.Key);
                    upd.Update(notification);
                }
            }

            UpdatePinnedStatus();
            BottomAppBar.IsSticky = false;
        }
Exemplo n.º 14
0
        private async void PinUnpinNoteFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            var pinFlyout = (MenuFlyoutItem)sender;
            var note = (Note)(e.OriginalSource as FrameworkElement).DataContext;
            string SecondaryTileId = note.Id + "NoteTile";
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

            if (SecondaryTile.Exists(SecondaryTileId))
            {
                // Unpin
                SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId);

                Windows.Foundation.Rect rect = MainPage.GetElementRect((FrameworkElement)sender);
                Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above;

                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, placement);

                pinFlyout.Text = loader.GetString("pin_text");
                note.PinText = loader.GetString("pin_text");
            }
            else
            {
                //Pin
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
                Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
                Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
                Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");

                string tileActivationArguments = note.Id.ToString();

                SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId,
                                                                note.Title,
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);

                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;
                }

                secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;

                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
                    secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
                }

                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
                secondaryTile.VisualElements.BackgroundColor = note.Color;

                secondaryTile.RoamingEnabled = false;

                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
                    SecondaryTiles.UpdateTile(SecondaryTileId, note);

                    if (isPinned)
                    {
                        pinFlyout.Text = loader.GetString("unpin_text"); ;
                        note.PinText = loader.GetString("unpin_text"); ;
                    }
                    else
                    {
                        var dialog = new MessageDialog(loader.GetString("pin_error_text"), loader.GetString("pin_error_title"));
                        dialog.Commands.Add(new UICommand("OK"));
                        await dialog.ShowAsync();
                    }
                }
                else
                {
                    await secondaryTile.RequestCreateAsync();
                    SecondaryTiles.UpdateTile(SecondaryTileId, note);

                    note.PinText = loader.GetString("unpin_text");
                    pinFlyout.Text = loader.GetString("unpin_text"); 
                }
            }
        }
Exemplo n.º 15
0
        private async void AppBarPin_Click(object sender, RoutedEventArgs e)
        {

            FrameworkElement pinElement = (FrameworkElement)sender;
            Windows.UI.Xaml.Media.GeneralTransform buttonTransform = pinElement.TransformToVisual(null);
            Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
            Windows.Foundation.Rect rect = new Rect(point, new Size(pinElement.ActualWidth, pinElement.ActualHeight));

            if (SecondaryTile.Exists(appbarTileId))
            {

                SecondaryTile secondaryTile = new SecondaryTile(appbarTileId);
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton((Button) sender, isUnpinned);
            }
            else
            {
                Uri logo = new Uri("ms-appx:///Assets/badge_01.png");
                string tileActivationArguments = appbarTileId + " was pinned at " + DateTime.Now.ToLocalTime().ToString();

                SecondaryTile secondaryTile = new SecondaryTile(appbarTileId,
                                                                "Secondary tile pinned via AppBar",
                                                                tileActivationArguments,
                                                                logo, 
                                                                TileSize.Square150x150);

                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
                secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/badge_01.png");
                secondaryTile.VisualElements.Square70x70Logo = new Uri("ms-appx:///Assets/badge_02.png");
                secondaryTile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/badge_03.png");

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton((Button)sender, !isPinned);
            }
        }
        /// <summary>
        /// This is the click handler for the 'PinButton' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PinButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                // Prepare package images for our tile to be pinned
                Uri square70x70Logo = new Uri("ms-appx:///Assets/square70x70Tile-sdk.png");
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
                Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
                Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
                Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");

                // During creation of the secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
                // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
                string tileActivationArguments = MainPage.logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                // Create a Secondary tile with all the required arguments and set the preferred size to be the medium tile size.
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId,
                                                                "Title text shown on the tile",
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);

                // Only support of the small and medium tile sizes is mandatory.
                // To have the larger tile sizes available the assets must be provided.
                secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;
                secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;

                // If the asset for the small tile size is not provided, it will be created by scaling down the medium tile size asset.
                // Thus, providing the asset for the small tile size is not mandatory, though is recommended to avoid scaling artifacts and can be overridden as shown below. 
                // Note that the asset for the small tile size must be explicitly provided if alternates for the small tile size are also explicitly provided.
                secondaryTile.VisualElements.Square70x70Logo = square70x70Logo;

                // Like the background color, the square30x30 logo is inherited from the parent application tile by default. 
                // Let's override it, just to see how that's done.
                secondaryTile.VisualElements.Square30x30Logo = square30x30Logo;
                
                // The display of the secondary tile name can be controlled for each tile size.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = false;
                secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
                secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

                // Add the handler for the VisualElemets request.
                // This is needed to add alternate tile options for a user to choose from for the supported tile sizes.
                secondaryTile.VisualElementsRequested += VisualElementsRequestedHandler;

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // OK, the tile is created and we can now attempt to pin the tile.
                // Note that the status message is updated when the async operation to pin the tile completes.
                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);

                if (isPinned)
                {
                    rootPage.NotifyUser("Secondary tile successfully pinned.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Secondary tile not pinned.", NotifyType.ErrorMessage);
                }
            }
        }
        /// <summary>
        /// This is the click handler for the 'PinButton' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PinButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                // Prepare package images for all four tile sizes in our tile to be pinned as well as for the square30x30 logo used in the Apps view.  
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
                Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
                Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
                Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");

                // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
                // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
                string tileActivationArguments = MainPage.logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                // Create a Secondary tile with all the required arguments.
                // Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out.
                // It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default.  
                // If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well.
                // TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise. 
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId,
                                                                "Title text shown on the tile",
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);

                if(!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;
                    secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;
                }

                // Like the background color, the square30x30 logo is inherited from the parent application tile by default. 
                // Let's override it, just to see how that's done.
                secondaryTile.VisualElements.Square30x30Logo = square30x30Logo;

                // The display of the secondary tile name can be controlled for each tile size.
                // The default is false.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
                    secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
                }

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // Set this to false if roaming doesn't make sense for the secondary tile.
                // The default is true;
                secondaryTile.RoamingEnabled = false;

                // OK, the tile is created and we can now attempt to pin the tile.
                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    // Note that the status message is updated when the async operation to pin the tile completes.
                    bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);

                    if (isPinned)
                    {
                        rootPage.NotifyUser("Secondary tile successfully pinned.", NotifyType.StatusMessage);
                    }
                    else
                    {
                        rootPage.NotifyUser("Secondary tile not pinned.", NotifyType.ErrorMessage);
                    }
                }
                if (Windows.Foundation.Metadata.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.
                    await secondaryTile.RequestCreateAsync();
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// This method pins the secondary tile. The secondary tile is created using the required parameters
        /// and pinned. The user is showna  message informing whether the tile is pinned successfully
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="appbarTileId">The appbar tile id.</param>
        /// <returns></returns>
        private async Task PinSecondaryTile(object sender, string appbarTileId)
        {
            // Prepare package images for use as the Tile Logo in our tile to be pinned
            Uri smallLogo = new Uri("ms-appx:///Assets/Tile_150X150.png");
            Uri wideLogo = new Uri("ms-appx:///Assets/Tile_310X150.png");

            // Create a Secondary tile
            string tileActivationArguments = appbarTileId;
            string subTitle = job.JobNumber + " - " + job.JobId;
            //Tile ID is set to current job Id. when user clicks on seconday job tile, the same  will be passed as LaunchActivatedEventArgs to 
            //OnLaunched method of App.XAML.cs
            SecondaryTile secondaryTile = new SecondaryTile(appbarTileId, "Field Engineer - Job " + job.JobNumber, subTitle,
                                                            tileActivationArguments,
                                                            TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
                                                            smallLogo, wideLogo);

            secondaryTile.ForegroundText = ForegroundText.Light;
            bool isPinned =
                await
                secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender),
                                                             Windows.UI.Popups.Placement.Above);

            if (isPinned)
            {
                MessageDialog dialog =
                    new MessageDialog("Job " + job.JobNumber + " (" + job.Title + ") successfully pinned.");
                await dialog.ShowAsync();
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Job " + job.JobNumber + " (" + job.Title + ") not pinned.");
                await dialog.ShowAsync();
            }

            ToggleAppBarButton(!isPinned, sender as AppBarButton);
        }
        async void pinToAppBar_Click(object sender, RoutedEventArgs e)
        {
            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                this.SecondaryTileCommandBar.IsSticky = true;

            // Let us first verify if we need to pin or unpin
            if (SecondaryTile.Exists(MainPage.appbarTileId))
            {
                // First prepare the tile to be unpinned
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId);

                // Now make the delete request.
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
                if (isUnpinned)
                {
                    rootPage.NotifyUser(MainPage.appbarTileId + " unpinned.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser(MainPage.appbarTileId + " not unpinned.", NotifyType.ErrorMessage);
                }

                ToggleAppBarButton(isUnpinned);
            }
            else
            {
                // Prepare package images for the medium tile size in our tile to be pinned
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");

                // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
                // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
                string tileActivationArguments = MainPage.appbarTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                // Create a Secondary tile with all the required arguments.
                // Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out.
                // It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default.  
                // If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well.  
                // TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise. 
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId,
                                                                "Secondary tile pinned via AppBar",
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);

                // Whether or not the app name should be displayed on the tile can be controlled for each tile size.  The default is false.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // OK, the tile is created and we can now attempt to pin the tile.
                if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    // Note that the status message is updated when the async operation to pin the tile completes.
                    bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
                    if (isPinned)
                    {
                        rootPage.NotifyUser(MainPage.appbarTileId + " successfully pinned.", NotifyType.StatusMessage);
                    }
                    else
                    {
                        rootPage.NotifyUser(MainPage.appbarTileId + " not pinned.", NotifyType.ErrorMessage);
                    }

                    ToggleAppBarButton(!isPinned);
                }

                if ((Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                {
                    // 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.
                    await secondaryTile.RequestCreateAsync();
                }
            }

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
                this.BottomAppBar.IsSticky = false;
        }
        private async void pinButton_Click_1(object sender, RoutedEventArgs e)
        {

            pageRoot.BottomAppBar.IsSticky = true;
            string shortName = appName;
            string displayName = appName;
            string tileActivationArguments = appName + "|" + appPlatform + "|" + apiKey + "|" + appApiKey;
            Uri logo = new Uri("ms-appx:///Assets/Logo.png");


            SecondaryTile secondaryTile = new SecondaryTile(appApiKey,
                                                            shortName,
                                                            displayName,
                                                            tileActivationArguments,
                                                            TileOptions.ShowNameOnLogo,
                                                            logo);

            secondaryTile.ForegroundText = ForegroundText.Dark;
            secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");
            Windows.UI.Xaml.Media.GeneralTransform buttonTransform = ((FrameworkElement)sender).TransformToVisual(null);
            Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point());
            Windows.Foundation.Rect rect = new Rect(point, new Size(((FrameworkElement)sender).ActualWidth, ((FrameworkElement)sender).ActualHeight));

            if (!SecondaryTile.Exists(appApiKey))
            { // add
                //FrameworkElement sender2 = (FrameworkElement)pinToAppBar;
                bool x = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
                Debug.WriteLine("secondaryTile creation: " + x);
                
            }
            else
            { // remove
                bool x = await secondaryTile.RequestDeleteForSelectionAsync(rect);
                Debug.WriteLine("secondaryTile removal: " + x);
            }
            pageRoot.BottomAppBar.IsSticky = false;
            pageRoot.BottomAppBar.IsOpen = false;
            ToggleAppBarButton(!SecondaryTile.Exists(appApiKey));

            /*
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = appName;
            tileTextAttributes[1].InnerText = appPlatform;

            // create a tile notification
            TileNotification tile = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile("1").Update(tile);
           */

        }
Exemplo n.º 21
0
        private async void Pin(object sender)
        {
            Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
            Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
            Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");
            Uri square30x30Logo = new Uri("ms-appx:///Assets/square30x30Tile-sdk.png");

            string tileActivationArguments = editNote.Id.ToString();

            SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileId,
                                                            editNote.Title,
                                                            tileActivationArguments,
                                                            square150x150Logo,
                                                            TileSize.Square150x150);

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
            {
                secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;
            }
            secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;

            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
            {
                secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;
            }

            secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;

            secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
            secondaryTile.VisualElements.BackgroundColor = editNote.Color;

            secondaryTile.RoamingEnabled = false;

            if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))))
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
                SecondaryTiles.UpdateTile(SecondaryTileId, editNote);

                if (isPinned)
                {
                    ToggleAppBarButton(!isPinned);
                }
                else
                {
                    var dialog = new MessageDialog(loader.GetString("pin_error_text"), loader.GetString("pin_error_title"));
                    dialog.Commands.Add(new UICommand("OK"));
                    await dialog.ShowAsync();
                }
            }
            else
            {
                ToggleAppBarButton(!await secondaryTile.RequestCreateAsync());
                SecondaryTiles.UpdateTile(SecondaryTileId, editNote);
            }
        }
Exemplo n.º 22
0
 public async static void CreateSecondaryTile(string title, string id, Uri image, Rect TileProptRect, string navigateUri)
 {
     SecondaryTile secondaryTile = new SecondaryTile(id, title, navigateUri, image, Windows.UI.StartScreen.TileSize.Square150x150);
     secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
     secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;
     await secondaryTile.RequestCreateForSelectionAsync(TileProptRect, Windows.UI.Popups.Placement.Above);
 }
        private async void btnSecTile_Click(object sender, RoutedEventArgs e)
        {

            Windows.Foundation.Rect rect = GetElementRect((FrameworkElement)sender);

            if (SecondaryTile.Exists("MyUnicTileID"))
            {
                SecondaryTile secondaryTile = new SecondaryTile("MyUnicTileID");

                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
                ToggleAppBarButton(isUnpinned);
            }
            else
            {
                // Pin
                Uri square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.png");
                string tileActivationArguments = "Secondary tile was pinned at = " + DateTime.Now.ToLocalTime().ToString();
                string displayName = "App Template";

                TileSize newTileDesiredSize = TileSize.Square150x150;
                SecondaryTile secondaryTile = new SecondaryTile("MyUnicTileID",
                                                                displayName,
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                newTileDesiredSize);

                secondaryTile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png");
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);
                ToggleAppBarButton(!isPinned);
 
            }

        }
Exemplo n.º 24
0
        /// <summary>
        /// Pin a tile for the event in the start menu.
        /// </summary>
        public async void PinToStartCommandExecute(Rect rect)
        {

            Uri logo = new Uri("ms-appx:///Assets/EventTileSmall.png");
            Uri wideLogo = new Uri("ms-appx:///Assets/EventTileWide.png");

            SecondaryTile tile = new SecondaryTile(TileHelper.SetEventTileId(Event.EventDefinitionId),
                                                    Event.Name,
                                                    Event.Name,
                                                    TileHelper.SetEventTileActivationArguments(Event.EventDefinitionId),
                                                    TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
                                                    logo,
                                                    wideLogo);

            bool isPinned = await tile.RequestCreateForSelectionAsync((Rect)rect, Placement.Above);
        }
        /// <summary>
        /// This is the click handler for the 'Pin Tile' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PinLiveTile_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                // Prepare the images for our tile to be pinned.
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
                Uri wide310x150Logo = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");

                // During creation of the secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
                // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
                string tileActivationArguments = MainPage.dynamicTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                // Create a Secondary tile with all the required properties and sets perfered size to Wide310x150.
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.dynamicTileId,
                                                                "A Live Secondary Tile",
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Wide310x150);

                // Adding the wide tile logo.
                secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;

                // The display of the app name can be controlled for each tile size.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // OK, the tile is created and we can now attempt to pin the tile.
#if WINDOWS_APP
                // Note that the status message is updated when the async operation to pin the tile completes.
                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);

                if (isPinned)
                {
                    rootPage.NotifyUser("Secondary tile successfully pinned.", NotifyType.StatusMessage);
                    ToggleButtons(true);
                }
                else
                {
                    rootPage.NotifyUser("Secondary tile not pinned.", NotifyType.ErrorMessage);
                }
#endif

#if WINDOWS_PHONE_APP
                // 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.
                await secondaryTile.RequestCreateAsync();
#endif
            }
        }
        private async void BtnPinSecondaryTile_OnClick(object sender, RoutedEventArgs e)
        {
            var logo = new Uri("ms-appx:///Assets/Images/150x150.png");
            var smallLogo = new Uri("ms-appx:///Assets/Images/310x150.png");

            // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
            // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
            string tileActivationArguments = logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime();
            counter++;
            // Create a 1x1 Secondary tile
            var s = new SecondaryTile(logoSecondaryTileId.ToString(),
                "Hidden Truth Blog page",
                "Hidden Truth Blog page",
                tileActivationArguments,
                TileOptions.ShowNameOnLogo,
                logo);
            s.DisplayName = "Hidden Truth";
            // Specify a foreground text value.
            s.ForegroundText = ForegroundText.Dark;
            bool isPinned =
                await s.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Below);
            // OK, the tile is created and we can now attempt to pin the tile.
            // Note that the status message is updated when the async operation to pin the tile completes.
        }
Exemplo n.º 27
0
          async void PintoStart_Click(object sender, RoutedEventArgs e)
          {

      
              this.BottomAppBar.IsSticky = true;
              // Let us first verify if we need to pin or unpin
              if (SecondaryTile.Exists(TileID))
              {
                  // First prepare the tile to be unpinned
                  SecondaryTile secondaryTile = new SecondaryTile(TileID);
                  // Now make the delete request.
                  bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(Tasks.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
                  if (isUnpinned)
                  {
                    //  rootPage.NotifyUser(MainPage.appbarTileId + " unpinned.", NotifyType.StatusMessage);
                      
                  }
                  else
                  {
                     // rootPage.NotifyUser(MainPage.appbarTileId + " not unpinned.", NotifyType.ErrorMessage);
                  }

                  ToggleAppBarButton(isUnpinned);
              }
              else
              {

                  // Prepare package images for use as the Tile Logo in our tile to be pinned
                  Uri logo = new Uri("ms-appx:///Assets/logo.png");

                  // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
                  // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
                  string tileActivationArguments = TileID + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                  // Create a 1x1 Secondary tile
                  SecondaryTile secondaryTile = new SecondaryTile(TileID,
                                                                  "WandTask",
                                                                  "Wand Appbar Task",
                                                                  tileActivationArguments,
                                                                  TileOptions.ShowNameOnLogo,
                                                                  logo);

                  // Specify a foreground text value.
                  // The tile background color is inherited from the parent unless a separate value is specified.
                  secondaryTile.ForegroundText = ForegroundText.Dark;

                  // OK, the tile is created and we can now attempt to pin the tile.
                  // Note that the status message is updated when the async operation to pin the tile completes.
                  bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);
                  if (isPinned)
                  {
                    //  rootPage.NotifyUser(MainPage.appbarTileId + " successfully pinned.", NotifyType.StatusMessage);
                  }
                  else
                  {
                   //   rootPage.NotifyUser(MainPage.appbarTileId + " not pinned.", NotifyType.ErrorMessage);
                  }

                  ToggleAppBarButton(!isPinned);
              }
              BottomAppBar.IsSticky = false;
          }
        /// <summary>
        /// This method pins the secondary tile. The secondary tile is created using the required /// parameters and pinned. The user is shown a message informing whether the tile is pinned /// successfully
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="appbarTileId">The appbar tile id.</param>
        /// <returns></returns>
        private async Task PinSecondaryTile(object sender, string appbarTileId)
        {
            // Prepare package images for use as the Tile Logo in our tile to be pinned
            Uri smallLogo = new Uri("ms-appx:///" + product.ProductImageLarge);
            //Uri wideLogo = new Uri("ms-appx:///Assets/Tile_310X150.png");
            Uri wideLogo = new Uri("ms-appx:///" + product.ProductImage);

            string tileActivationArguments = appbarTileId;
            // Create a 1x1 Secondary tile
            string subTitle = product.ProductName;
            SecondaryTile secondaryTile = new SecondaryTile(appbarTileId, product.ProductName, subTitle, tileActivationArguments,
                TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo, smallLogo, wideLogo);

            secondaryTile.ForegroundText = ForegroundText.Light;
            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);

            if (isPinned)
            {
                MessageDialog dialog = new MessageDialog("Product " + product.ProductName + " successfully pinned.");
                await dialog.ShowAsync();
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Product " + product.ProductName + " not pinned.");
                await dialog.ShowAsync();
            }

            ToggleAppBarButton(!isPinned, sender as AppBarButton);
        }
Exemplo n.º 29
0
        public static async Task<bool> CreateSecondaryTile(Rect confirmationRectShownAt, TileType type, string shortName, string displayName, string tileIdToUse)
        {

            string logoImage = "";

            switch (type)
            {
                case TileType.Contact: logoImage = "contact"; break;
                case TileType.Attachment: logoImage = "attachment"; break;
                case TileType.Form: logoImage = "form"; break;
                case TileType.Message: logoImage = "message"; break;
                case TileType.Project: logoImage = "project"; break;
                case TileType.Company: logoImage = "company"; break;
                case TileType.User: logoImage = "user"; break;
            }

            Uri logo = new Uri("ms-appx:///Assets/logo-" + logoImage + ".png");
            Uri wideLogo = new Uri("ms-appx:///Assets/Logo-wide-" + logoImage + ".png");


            string dynamicTileId = Guid.NewGuid().ToString();

            if (!string.IsNullOrEmpty(tileIdToUse)) dynamicTileId = tileIdToUse;

            string tileActivationArguments = dynamicTileId +
                " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

            var secondaryTile = new SecondaryTile(dynamicTileId,
             shortName,
             displayName,
             tileActivationArguments,
             TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
             logo,
             wideLogo);

            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(confirmationRectShownAt, Windows.UI.Popups.Placement.Below);

            return isPinned;
        }
Exemplo n.º 30
0
        /*string displayName = "Secondary tile pinned through app bar";
        string tileActivationArguments = MainPage.appbarTileId + " was pinned at=" + DateTime.Now.ToLocalTime().ToString();
        Uri square150x150Logo = new Windows.Foundation.Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
        TileSize newTileDesiredSize = TileSize.Square150x150;
        */


        private async void PinUnPinCommandButton_Click(object sender, RoutedEventArgs e)
        {

            this.SecondaryTileCommandBar.IsSticky = true;
            if (SecondaryTile.Exists("Amr"))
            {
                //UnPin
                SecondaryTile secTile = new SecondaryTile("Amr");
                Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
                var placment = Windows.UI.Popups.Placement.Above;
                bool IsUnPinned = await secTile.RequestDeleteForSelectionAsync(rect, placment);
                ToggleAppBarButton(IsUnPinned);
            }
            else
            {
                //Pin
                SecondaryTile secTile = new SecondaryTile("Amr", "Amr Alaa", "AAA", new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png"), TileSize.Square150x150);
                secTile.VisualElements.Square30x30Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");
                secTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secTile.VisualElements.ShowNameOnSquare310x310Logo = true;

                secTile.VisualElements.ForegroundText = ForegroundText.Dark;
                
                Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
                var placment = Windows.UI.Popups.Placement.Above;
                bool isPinned = await secTile.RequestCreateForSelectionAsync(rect,placment);
                ToggleAppBarButton(isPinned);

            }

            this.BottomAppBar.IsSticky = false;
            
        }