RequestDeleteForSelectionAsync() 개인적인 메소드

private RequestDeleteForSelectionAsync ( [ selection ) : IAsyncOperation
selection [
리턴 IAsyncOperation
예제 #1
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;
            
        }
예제 #2
0
 /// <summary>
 /// This is the click handler for the 'Unpin' button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void UnpinSecondaryTile_Click(object sender, RoutedEventArgs e)
 {
     Button button = sender as Button;
     if (button != null)
     {
         if (Windows.UI.StartScreen.SecondaryTile.Exists(MainPage.logoSecondaryTileId))
         {
             // First prepare the tile to be unpinned
             SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId);
             // Now make the delete request.
             bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
             if (isUnpinned)
             {
                 rootPage.NotifyUser("Secondary tile successfully unpinned.", NotifyType.StatusMessage);
             }
             else
             {
                 rootPage.NotifyUser("Secondary tile not unpinned.", NotifyType.ErrorMessage);
             }
         }
         else
         {
             rootPage.NotifyUser(MainPage.logoSecondaryTileId + " is not currently pinned.", NotifyType.ErrorMessage);
         }
     }
 }
예제 #3
0
 public async Task<bool> Unpin(TileInfo info)
 {
     System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
     if (!SecondaryTile.Exists(info.TileId))
         return true;
     var tile = new SecondaryTile(info.TileId);
     var result = await tile.RequestDeleteForSelectionAsync(info.Rect(), info.RequestPlacement);
     return result;
 }
예제 #4
0
        public async Task<bool> UnpinAsync(string tileId, Rect selection, Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above)
        {
            System.Diagnostics.Contracts.Contract.Requires(tileId != null, "TileId");

            if (!SecondaryTile.Exists(tileId))
                return true;
            var tile = new SecondaryTile(tileId);
            var result = await tile.RequestDeleteForSelectionAsync(selection, placement);
            return result;
        }
예제 #5
0
		public async Task<bool> Unpin(TileInfo tileInfo)
		{
			var wasUnpinned = false;

			if (SecondaryTile.Exists(tileInfo.TileId))
			{
				var secondaryTile = new SecondaryTile(tileInfo.TileId);
				wasUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(
					GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
			}

			return wasUnpinned;
		}
예제 #6
0
		public async Task<bool> UnpinPoll(FrameworkElement anchorElement, int pollId)
		{
			var wasUnpinned = false;

			var tileId = string.Format(SecondaryPinner.TileIdFormat, pollId);
			if (SecondaryTile.Exists(tileId))
			{
				var secondaryTile = new SecondaryTile(tileId);
				wasUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(
					GetElementRect(anchorElement), Placement.Above);
			}

			return wasUnpinned;
		}
        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);
 
            }

        }
        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;
        }
예제 #9
0
        private async void Unpin(object sender)
        {
            // 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);

            ToggleAppBarButton(isUnpinned);
        }
예제 #10
0
 public async Task<bool> RemoveSecondaryTile(Category category, Rect rect)
 {
     SecondaryTile secondaryTile = new SecondaryTile(category.TileId);
     return await secondaryTile.RequestDeleteForSelectionAsync(rect, Placement.Above);
 }
예제 #11
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"); 
                }
            }
        }
예제 #12
0
파일: Tasks.xaml.cs 프로젝트: bdecori/win8
          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;
          }
        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);
           */

        }
예제 #14
0
 public static async void CreateOrReplaceSecondaryTile(VLCItemType type, int id, string title)
 {
     string tileId = "SecondaryTile-" + type.ToString() + "-" + id;
     if (!SecondaryTile.Exists(tileId))
     {
         var tileData = new SecondaryTile()
         {
             TileId = tileId,
             DisplayName = title,
             Arguments = tileId
         };
         string subfolder = null;
         switch (type)
         {
             case VLCItemType.Album:
                 subfolder = "albumPic";
                 break;
             case VLCItemType.Artist:
                 subfolder = "artistPic";
                 break;
         }
         tileData.VisualElements.ShowNameOnSquare150x150Logo = true;
         tileData.DisplayName = title;
         tileData.VisualElements.Square150x150Logo =
             new Uri("ms-appdata:///local/" + subfolder + "/" + id + ".jpg");
         await tileData.RequestCreateAsync();
     }
     else
     {
         SecondaryTile secondaryTile = new SecondaryTile(tileId);
         await secondaryTile.RequestDeleteForSelectionAsync(Window.Current.Bounds, Placement.Default);
         ToastHelper.Basic("Tile removed !");
     }
 }
예제 #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);
            }
        }
예제 #16
0
        /// <summary>
        /// This method unpins the existing secondary tile. 
        /// The user is showna  message informing whether the tile is unpinned successfully
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="appbarTileId">The appbar tile id.</param>
        /// <returns></returns>
        private async Task UnpinSecondaryTile(object sender, string appbarTileId)
        {
            SecondaryTile secondaryTile = new SecondaryTile(appbarTileId);
            bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender),
                                                                                 Windows.UI.Popups.Placement.Above);

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

            ToggleAppBarButton(isUnpinned, sender as AppBarButton);
        }
        /// <summary>
        /// It pins the app to the StartPage.
        /// </summary>
        /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param>
        /// <param name="e">RoutedEventArgs e is a parameter called e that contains the event data, see the RoutedEventArgs MSDN page for more information.</param>
        async void pinToAppBar_Click(object sender, RoutedEventArgs e)
        {
            if (SecondaryTile.Exists(AppInstance.app.Name.Replace(" ", "")))
            {
                SecondaryTile secondaryTile = new SecondaryTile(AppInstance.app.Name.Replace(" ", ""));
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
                if (isUnpinned)
                {
                    ToggleAppBarButton(isUnpinned);
                }
            }
            else
            {
                Uri square150x150Logo = new Uri("ms-appx:///Assets/Logo.scale-100.png");
                string tileActivationArguments = AppInstance.app.Name;
                SecondaryTile secondaryTile = new SecondaryTile(AppInstance.app.Name.Replace(" ", ""),
                                                                AppInstance.app.Name,
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
                secondaryTile.RoamingEnabled = false;
                ToggleAppBarButton(false);
                await secondaryTile.RequestCreateAsync();

            }
        }
        /// <summary>
        /// This method unpins the existing secondary tile. 
        /// The user is shown a message informing whether the tile is unpinned successfully
        /// </summary>
        private async Task UnpinSecondaryTile(object sender, string appbarTileId)
        {
            SecondaryTile secondaryTile = new SecondaryTile(appbarTileId);
            bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync( GetElementRect((FrameworkElement)sender), Placement.Above);

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

            ToggleAppBarButton(isUnpinned, sender as AppBarButton);
        }
예제 #19
0
        private async void PinCommandExecute(Button button)
        {
            appBar.IsSticky = true;

            if (SecondaryTile.Exists(this.Child.Id))
            {
                var secondaryTile = new SecondaryTile(this.Child.Id);
                ShowPinButton = await secondaryTile.RequestDeleteForSelectionAsync(
                    GetElementRect((FrameworkElement)button),
                    Windows.UI.Popups.Placement.Above);
            }
            else
            {
                Uri logo = new Uri("ms-appx:///Assets/logo.png");
                string tileActivationArguments = this.Child.Id + " was pinned at " + DateTime.Now.ToLocalTime().ToString();

                var secondaryTile = new SecondaryTile(this.Child.Id,
                                                                this.Child.Title,
                                                                this.Child.Description,
                                                                tileActivationArguments,
                                                                TileOptions.ShowNameOnLogo,
                                                                logo);

                secondaryTile.ForegroundText = ForegroundText.Light;
                secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/smalllogo.png");
                // if we wanted the large tile
                //secondaryTile.WideLogo = new Uri("ms-appx:///Assets/widelogo.png");

                ShowPinButton = !await secondaryTile.RequestCreateForSelectionAsync(
                    GetElementRect((FrameworkElement)button),
                    Windows.UI.Popups.Placement.Above);
            }

            appBar.IsSticky = false;
        }