예제 #1
0
        public async static void deleteMediaAsync(AbMediaContent media)
        {
            //Asynchronously remove media from other cards
            var removeCardMediaTask = Task.Run(() => FSManager.removeMediaFromCards(media));

            //Make sure media wasn't imported.  If not delete its file
            if (media.filePath.Contains(FilePaths.rootPath))
            {
                IFile mediaFile = await FileSystem.Current.GetFileFromPathAsync(media.filePath);

                await mediaFile.DeleteAsync();
            }

            //Remove from relevant MediaManager data structures
            allMedia.Remove(media);

            DayMediaObservableCollection dayCollection;

            allMediaDict.TryGetValue(media.creationTime.Date, out dayCollection);
            if (dayCollection != null)
            {
                dayCollection.removeMedia(media);
            }

            //Remove empty days
            if (dayCollection.Count == 0)
            {
                allMediaDict.Remove(media.creationTime.Date);
                allMediaCollection.Remove(dayCollection);
            }

            //Wait for card media removal task to complete
            await removeCardMediaTask;
        }
예제 #2
0
        /// <summary>
        /// Delete card file, card from dictionary, and associated media
        /// </summary>
        /// <param name="cardName"></param>
        public async static void deleteCardAsync(string cardName)
        {
            // Don't do anything if no card
            if (!FSManager.cardExists(cardName))
            {
                return;
            }

            // Delete card file
            IFile cardFile = await FileSystem.Current.LocalStorage.GetFileAsync(Path.Combine(FilePaths.allCardsPath, cardName));

            await cardFile.DeleteAsync();

            // Remove card from allCardDict
            Card card;

            allCardsDict.TryGetValue(cardName, out card);

            // Remove card from dict
            allCardsDict.Remove(cardName);
        }