RequestDeleteAsync() private method

private RequestDeleteAsync ( ) : IAsyncOperation
return IAsyncOperation
 public async Task<bool> UnpinAsync(string tileId)
 {
     System.Diagnostics.Contracts.Contract.Requires(tileId != null, "TileId");
     if (!SecondaryTile.Exists(tileId))
         return true;
     var tile = new SecondaryTile(tileId);
     return await tile.RequestDeleteAsync();
 }
        public async Task<bool> UnpinTile(string tileId) {
            if (SecondaryTileExists(tileId)) {
                var secondaryTile = new SecondaryTile(tileId);
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();
                return isUnpinned;
            }

            return true;
        }
 /// <summary>
 /// 移除辅助磁贴
 /// </summary>
 /// <param name="tileId">磁贴的唯一 ID</param>
 public async static Task DeleteSecondaryTileAsync(string tileId)
 {
     if (Windows.UI.StartScreen.SecondaryTile.Exists(tileId))
     {
         // First prepare the tile to be unpinned
         SecondaryTile secondaryTile = new SecondaryTile(tileId);
         // Now make the delete request.
         await secondaryTile.RequestDeleteAsync();
     }
 }
        public async Task<bool> UnPin(string pinnedItemId)
        {
            if (IsPinned(pinnedItemId))
            {
                var tile = new SecondaryTile(pinnedItemId);
                var result = await tile.RequestDeleteAsync();

                return result;
            }

            return false;
        }
        public async Task<bool> UnpinTile(string tileId)
        {
            if (SecondaryTileExists(tileId))
            {
                // <snippet810>
                var secondaryTile = new SecondaryTile(tileId);
                // </snippet810>
                // <snippet811>
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();
                // </snippet811>
                return isUnpinned;
            }

            return true;
        }
Example #6
0
        /// <summary>
        /// UnPin a existed Tile.
        /// </summary>
        /// <param name="tileId"></param>
        /// <returns></returns>
        public async Task<bool> UnpinTile(string tileId)
        {
            // Create the unique tileId
            var id = Regex.Replace(tileId, @"[^\d\w\s]", "-").
                     Replace(" ", string.Empty) + ".LiveTile";

            //Check first if tile exists
            if (SecondaryTileExists(id))
            {
                var secondaryTile = new SecondaryTile(id);
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();

                return isUnpinned;
            }

            return true;
        }
Example #7
0
        public async Task<bool> UnPinAsync(ViewModels.DetailPageViewModel vm)
        {
            if (vm == null)
                throw new ArgumentNullException(nameof(vm));

            // already unpinned?
            if (!await IsPinned(vm))
                return true;

            try
            {
                var tile = new SecondaryTile(nameof(ViewModels.DetailPageViewModel));
                return await tile.RequestDeleteAsync();
            }
            catch (Exception)
            {
                System.Diagnostics.Debugger.Break();
                return false;
            }
        }
Example #8
0
 public static async void DeleteSecondaryTile(string guid)
 {
     if (Windows.UI.StartScreen.SecondaryTile.Exists(guid))
     {
         SecondaryTile secondaryTile = new SecondaryTile(guid);
         await secondaryTile.RequestDeleteAsync();
     }
 }
        private async void PinButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as AppBarToggleButton;
            var transform = button.TransformToVisual(pageRoot);
            Point location = transform.TransformPoint(new Point(0, 0));
            if (!SecondaryTile.Exists(ViewModel.SeriesId.ToString()))
            {
                Size size = new Size(150, 150);
                var bookmark = ViewModel.CreateBookmark();
                //ViewModel.IsLoading = true;
                var imageUri = await AppGlobal.CreateTileImageAsync(new Uri(bookmark.DescriptionImageUri));
                //ViewModel.IsLoading = false;
                string args = bookmark.Position.ToString();
                var tile = new SecondaryTile(ViewModel.SeriesId.ToString(), ViewModel.SeriesData.Title, args, imageUri, TileSize.Default);
                //var tile = new SecondaryTile(ViewModel.SeriesId.ToString(), "LightNovel", ViewModel.SeriesData.Title, args, TileOptions.ShowNameOnLogo, imageUri);
                try
                {
                    button.IsChecked = await tile.RequestCreateAsync(location);
                }
                catch (Exception)
                {
                }

                SyncPinButtonView();
            }
            else
            {
                var tile = new SecondaryTile(ViewModel.SeriesId.ToString());
                button.IsChecked = !await tile.RequestDeleteAsync(location);
                SyncPinButtonView();
            }
        }
Example #10
0
        public static async Task<bool> PinToggleAsync(Album album)
        {
            bool created;
            var id = "album." + album.Id;

            if (!SecondaryTile.Exists(id))
            {
                Insights.Track(
                    "Pin To Start",
                    new Dictionary<string, string>
                    {
                        {"DisplayName", album.Name},
                        {"ProviderId", album.ProviderId},
                        {"Type", "Album"}
                    });
                created =
                    await
                        CreatePin(
                            id,
                            album.Name,
                            "albums/" + album.Id,
                            string.Format(AppConstant.ArtworkPath, album.Id));
            }
            else
            {
                var secondaryTile = new SecondaryTile(id);
                created = !await secondaryTile.RequestDeleteAsync();
            }

            return created;
        }
Example #11
0
        private async void DeleteMenuFlyout_Click(object sender, RoutedEventArgs e)
        {
            EventManage selectedEventManage = ((MenuFlyoutItem)sender).DataContext as EventManage;
            string EventFileTitle = selectedEventManage.EventFileTitle;
            StorageFile file = await applicationFolder.GetFileAsync(EventFileTitle);
            await file.DeleteAsync();
            refreshList();

            if (SecondaryTile.Exists(EventFileTitle))
            {
                SecondaryTile secondaryTile = new SecondaryTile(EventFileTitle);
                await secondaryTile.RequestDeleteAsync();
            }
        }
Example #12
0
 public async void RemoveSecondaryTile(string name)
 {
     if (TileExists(name))
     {
         var tile = new SecondaryTile("r" + name);
         await tile.RequestDeleteAsync();
     }
 }
        /// <summary>
        /// Create/Remove Secondary Tile 
        /// </summary>
        public async Task PinUnpin()
        {
            // If SecondaryTile already exists, then remove it.
            if (SecondaryTile.Exists(appbarTileId + CurrentContact.Id))
            {
                // Unpin
                SecondaryTile secondaryTile = new SecondaryTile(appbarTileId + CurrentContact.Id);

                bool isUnpinned = await secondaryTile.RequestDeleteAsync();

                // Delete data from local folder if exists.
                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                try
                {
                    StorageFile File = await localFolder.GetFileAsync(CurrentContact.Id + ".png");
                    await File.DeleteAsync();
                }
                catch
                {
                    // If no file, do nothing
                }
            }
            else
            {
                Uri square150x150Logo;

                // If Contact has its own picture, then ues it for SecondayTile.
                if (CurrentContact.EntityImage != null)
                {
                    // Store the data to local Folder.
                    StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                    // Create file
                    StorageFile File = await localFolder.CreateFileAsync(CurrentContact.Id + ".png", CreationCollisionOption.ReplaceExisting);

                    // Write data to file
                    using (Stream stream = await File.OpenStreamForWriteAsync())
                    {
                        var fs = new BinaryWriter(stream);
                        fs.Write(CurrentContact.EntityImage);
                    }

                    // Specify the saved file as SecondaryTile Icon.
                    square150x150Logo = new Uri("ms-appdata:///local/" + CurrentContact.Id + ".png");
                }
                else
                    // If Contact doesn't have picture, then use existing icon.
                    square150x150Logo = new Uri("ms-appx:///Assets/icon-contact.png");

                // Set record Id as Activation Argument.
                string tileActivationArguments = CurrentContact.Id.ToString();
                // Set Contact FullName as display
                string displayName = CurrentContact.FullName;

                TileSize newTileDesiredSize = TileSize.Square150x150;

                // Instantiate Secondary tile by specifying above information.
                SecondaryTile secondaryTile = new SecondaryTile(appbarTileId + CurrentContact.Id,
                                                                displayName,
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                newTileDesiredSize);
                // Display FullName to the tile.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

                // Create SecondaryTile
                bool isPinned = await secondaryTile.RequestCreateAsync();
            }
        }
Example #14
0
        async private void btnUnpin_Click(object sender, RoutedEventArgs e)
        {
            int uniqueId = 1;

            SecondaryTile secondaryTile = new SecondaryTile("Pin_" + uniqueId.ToString());
            await secondaryTile.RequestDeleteAsync();

            this.btnPin.Visibility = Windows.UI.Xaml.Visibility.Visible;
            this.btnUnpin.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Example #15
0
 protected async Task Remove(SecondaryTile secondTile)
 {
     await secondTile.RequestDeleteAsync();
 }
        private async void btnPinToMain_Click(object sender, RoutedEventArgs e) {
            string SecondaryTileId = "StudentSample";
            if (SecondaryTile.Exists(SecondaryTileId)) {
                var secondaryTile = new SecondaryTile(SecondaryTileId);

                bool isUnpinned = await secondaryTile.RequestDeleteAsync();

                ToggleAppBarButton(isUnpinned);
            } else {
                // Pin
                var square150x150Logo = new Uri("ms-appx:///Assets/fish.png");
                //string tileActivationArguments = (DataContext as Book).BookId.ToString();
                string tileActivationArguments = "settings";
                string displayName = "Settings";

                var newTileDesiredSize = TileSize.Square150x150;

                var secondaryTile = new SecondaryTile(SecondaryTileId,
                                                                displayName,
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                newTileDesiredSize);

                bool isPinned = await secondaryTile.RequestCreateAsync();

                ToggleAppBarButton(isPinned);
            }
        }
 /// <summary>
 /// Deletes a tile associated to the model specified. How it determines which tile to delete is determined by the class implementing this
 /// interface. If the platform does not support tiles, then the implementation should do nothing.
 /// </summary>
 /// <param name="model">Model which contains the data necessary to find the tile to delete.</param>
 public async Task<bool> DeleteTileAsync(IModel model)
 {
     var tileID = Platform.Current.GenerateModelTileID(model);
     if (!string.IsNullOrEmpty(tileID))
     {
         SecondaryTile tile = new SecondaryTile(tileID);
         return await tile.RequestDeleteAsync();
     }
     else
         throw new ArgumentException("Tile does not exist for model!");
 }
Example #18
0
        public async Task UnPinCategoryTile(string tileId)
        {
            var secondaryTile = new SecondaryTile(tileId);

            await secondaryTile.RequestDeleteAsync();
        }
        private async void btnPinToStart_Click(object sender, RoutedEventArgs e)
        {
            // Is recipe already pinned?
            if (SecondaryTile.Exists(item.UniqueId))
            {
                var tile = new SecondaryTile(item.UniqueId);
                await tile.RequestDeleteAsync();
                btnPinToStart.Icon = new SymbolIcon(Symbol.Pin);
            }
            else
            {
                var uri = new Uri(item.TileImagePath.AbsoluteUri);

                var tile = new SecondaryTile(
                        item.UniqueId,              // Tile ID
                        item.ShortTitle,            // Tile short name
                        item.UniqueId,              // Activation argument
                        uri,                        // Tile logo URI
                        TileSize.Square150x150
                    );

                await tile.RequestCreateAsync();
                btnPinToStart.Icon = new SymbolIcon(Symbol.UnPin);
            }
        }
Example #20
0
 /// <summary>
 /// Creates or removes a secondary tile
 /// </summary>
 /// <param name="removeTile"><c>true</c> to remove tile, <c>false</c> to create tile</param>
 /// <returns>Asynchronous task</returns>
 private async Task CreateOrRemoveTileAsync(bool removeTile)
 {
     if (!removeTile)
     {
         var steps = await App.Engine.GetTotalStepCountAsync(DateTime.Now.Date);
         uint stepCount = steps.TotalCount;
         uint meter = (NUM_SMALL_METER_IMAGES - 1) * Math.Min(stepCount, TARGET_STEPS) / TARGET_STEPS;
         uint meterSmall = (NUM_LARGE_METER_IMAGES - 1) * Math.Min(stepCount, TARGET_STEPS) / TARGET_STEPS;
         try
         {
             var secondaryTile = new SecondaryTile(TILE_ID, "Steps", "/MainPage.xaml", new Uri("ms-appx:///Assets/Tiles/square" + meterSmall + ".png", UriKind.Absolute), TileSize.Square150x150);
             secondaryTile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Tiles/small_square" + meterSmall + ".png", UriKind.Absolute);
             secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
             secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = false;
             secondaryTile.VisualElements.ShowNameOnWide310x150Logo = false;
             secondaryTile.VisualElements.BackgroundColor = Color.FromArgb(255, 0, 138, 0);
             secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Tiles/wide" + meter + ".png", UriKind.Absolute);
             secondaryTile.RoamingEnabled = false;
             await secondaryTile.RequestCreateAsync();
         }
         catch (Exception)
         {
         }
     }
     else
     {
         SecondaryTile secondaryTile = new SecondaryTile(TILE_ID);
         await secondaryTile.RequestDeleteAsync();
         UpdateMenuAndAppBarIcons();
     }
 }
        private async Task PinUnpinAsync()
        {
            string tileId = QueryResult.UniqueId;
            bool isCurrentlyPinned = SecondaryTile.Exists(tileId);

            if (isCurrentlyPinned)
            {
                var secondaryTile = new SecondaryTile(tileId);
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();
            }
            else
            {
                Uri logo = new Uri(Constants.SquareTileLogo);
                Uri wideLogo = new Uri(Constants.WideTileLogo);

                string tileActivationArguments = tileId;

                var secondaryTile = new SecondaryTile(tileId,
                                                                QueryResult.Name,
                                                                QueryResult.DetailTitle,
                                                                tileActivationArguments,
                                                                TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
                                                                logo, 
                                                                wideLogo);

                secondaryTile.ForegroundText = ForegroundText.Light;

                if (QueryResult.FuelType == FuelTypeEnum.Diesel)
                {
                    secondaryTile.BackgroundColor = Colors.Black;
                }
                else
                {
                    secondaryTile.BackgroundColor = Colors.DarkGreen;
                }

                bool isPinned = await secondaryTile.RequestCreateAsync();

                if (isPinned)
                {
                    CreateResultChangedNotification().NotifyGasQueryResultChanged(QueryResult);
                }
            }

            RaisePropertyChanged(PinOrUnpinStylePropertyName);
            RaisePropertyChanged(PinOrUnpinTextPropertyName);
        }
Example #22
0
 internal async Task<bool> UnPinAsync(DetailPageViewModel detailPageViewModel)
 {
     if (!await IsPinned(detailPageViewModel))
         return true;
     try
     {
         var tileId = detailPageViewModel.ToString();
         var tile = new SecondaryTile(tileId);
         return await tile.RequestDeleteAsync();
     }
     catch (Exception)
     {
         System.Diagnostics.Debugger.Break();
         return false;
     }
 }
        public async Task DeleteSelectedItemAsync()
        {
            // First, see if there is a secondary tile for what we are trying to delete right now
            string tileId = SelectedGasQueryResult.UniqueId;
            bool isCurrentlyPinned = SecondaryTile.Exists(tileId);

            if (isCurrentlyPinned)
            {
                var secondaryTile = new SecondaryTile(tileId);
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();
            }

            // And now delete the item 
            GasQueryResults.Remove(SelectedGasQueryResult);

            bool saveOk = await CreateSprudelRepository().SaveResultsAsync(GasQueryResults.ToList());
        }