Ejemplo n.º 1
0
        public async void updateSelected()
        {
            userDecks[userDecks.IndexOf(selectedDeck)] = selectedDeck;
            allDecks[allDecks.IndexOf(selectedDeck)]   = selectedDeck;

            if (deletedDecks.Contains(selectedDeck))
            {
                deletedDecks[deletedDecks.IndexOf(selectedDeck)] = selectedDeck;
            }

            if (!MarkedDecks.Contains(selectedDeck) && selectedDeck.Marked)
            {
                MarkedDecks.Add(selectedDeck);
            }
            if (!MasteredDecks.Contains(selectedDeck) && selectedDeck.Mastered)
            {
                MasteredDecks.Add(selectedDeck);
            }

            if (MarkedDecks.Contains(selectedDeck) && !selectedDeck.Marked)
            {
                MarkedDecks.Remove(selectedDeck);
            }
            if (MasteredDecks.Contains(selectedDeck) && !selectedDeck.Mastered)
            {
                MasteredDecks.Remove(selectedDeck);
            }

            await changeSave(selectedDeck).ConfigureAwait(true);
        }
Ejemplo n.º 2
0
 public async Task MasterDeck(Deck d)
 {
     d.Mastered    = true;
     d.MasterColor = mastercolor;
     userDecks[userDecks.IndexOf(d)] = d;
     allDecks[allDecks.IndexOf(d)]   = d;
     if (!MasteredDecks.Contains(d))
     {
         MasteredDecks.Add(d);
     }
     await changeSave(d).ConfigureAwait(true);
 }
Ejemplo n.º 3
0
        public async void addCard(Card c)
        {
            StorageFolder deckFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(selectedDeck.Id);

            string      cardName = c.Name + ".xml";
            StorageFile cardData = await deckFolder.CreateFileAsync(cardName, CreationCollisionOption.ReplaceExisting);

            XmlSerializer serializer = new XmlSerializer(typeof(Card));

            using (Stream stream = await cardData.OpenStreamForWriteAsync().ConfigureAwait(true))
            {
                serializer.Serialize(stream, c);
            }

            string name = c.Name;

            try
            {
                StorageFolder cardFolder = await deckFolder.CreateFolderAsync(name, CreationCollisionOption.FailIfExists);
            }
            catch (Exception e)
            {
                return;
            }
            cards.Add(c);
            selectedDeck.Number = selectedDeck.Number + 1;
            userDecks[userDecks.IndexOf(selectedDeck)] = selectedDeck;
            allDecks[allDecks.IndexOf(selectedDeck)]   = selectedDeck;
            if (deletedDecks.Contains(selectedDeck))
            {
                deletedDecks[deletedDecks.IndexOf(selectedDeck)] = selectedDeck;
            }
            if (!MarkedDecks.Contains(selectedDeck) && selectedDeck.Marked)
            {
                MarkedDecks.Add(selectedDeck);
            }
            if (!MasteredDecks.Contains(selectedDeck) && selectedDeck.Mastered)
            {
                MasteredDecks.Add(selectedDeck);
            }
            if (MarkedDecks.Contains(selectedDeck) && !selectedDeck.Marked)
            {
                MarkedDecks.Remove(selectedDeck);
            }
            if (MasteredDecks.Contains(selectedDeck) && !selectedDeck.Mastered)
            {
                MasteredDecks.Remove(selectedDeck);
            }
            await changeSave(selectedDeck).ConfigureAwait(true);
        }
Ejemplo n.º 4
0
        public async void addMastered(string s)
        {
            if (checkName(s))
            {
                Deck d = new Deck(s);
                d.Mastered    = true;
                d.MasterColor = mastercolor;
                userDecks.Add(d);
                allDecks.Add(d);
                MasteredDecks.Add(d);
                await changeSave(d).ConfigureAwait(false);

                createCardFolder(d);
            }
        }
Ejemplo n.º 5
0
 public void restoreAll()
 {
     foreach (Deck d in deletedDecks)
     {
         d.Deleted = false;
         userDecks[userDecks.IndexOf(d)] = d;
         changeSave(d);
         allDecks.Add(d);
         if (d.Marked)
         {
             MarkedDecks.Add(d);
         }
         if (d.Mastered)
         {
             MasteredDecks.Add(d);
         }
     }
     deletedDecks.Clear();
 }
Ejemplo n.º 6
0
 public void restore(Deck d)
 {
     d.Deleted = false;
     userDecks[userDecks.IndexOf(d)] = d;
     changeSave(d);
     allDecks.Add(d);
     if (deletedDecks.Contains(d))
     {
         deletedDecks.Remove(d);
     }
     if (d.Marked)
     {
         MarkedDecks.Add(d);
     }
     if (d.Mastered)
     {
         MasteredDecks.Add(d);
     }
 }
Ejemplo n.º 7
0
        private async void retrieveLibrary()
        {
            Deck d;
            IReadOnlyList <StorageFile> files = await ApplicationData.Current.LocalFolder.GetFilesAsync();

            if (files.Count < 1)
            {
                return;
            }
            foreach (StorageFile f in files)
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Deck));
                    using (Stream stream = await f.OpenStreamForReadAsync().ConfigureAwait(true))
                    {
                        d = serializer.Deserialize(stream) as Deck;
                        userDecks.Add(d);
                        if (!d.Deleted)
                        {
                            allDecks.Add(d);
                        }
                        if (d.Deleted)
                        {
                            deletedDecks.Add(d);
                        }
                        if (!d.Deleted && d.Mastered)
                        {
                            MasteredDecks.Add(d);
                        }
                        if (!d.Deleted && d.Marked)
                        {
                            MarkedDecks.Add(d);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 8
0
        public async Task deleteCard(Card c)
        {
            StorageFolder deckFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(selectedDeck.Id);

            string      cardName = c.Name + ".xml";
            StorageFile cardData = await deckFolder.GetFileAsync(cardName);

            StorageFolder cardFolder = await deckFolder.GetFolderAsync(c.Name);

            await cardData.DeleteAsync();

            await cardFolder.DeleteAsync();

            cards.Remove(c);
            selectedDeck.Number = selectedDeck.Number - 1;
            userDecks[userDecks.IndexOf(selectedDeck)] = selectedDeck;
            allDecks[allDecks.IndexOf(selectedDeck)]   = selectedDeck;
            if (deletedDecks.Contains(selectedDeck))
            {
                deletedDecks[deletedDecks.IndexOf(selectedDeck)] = selectedDeck;
            }
            if (!MarkedDecks.Contains(selectedDeck) && selectedDeck.Marked)
            {
                MarkedDecks.Add(selectedDeck);
            }
            if (!MasteredDecks.Contains(selectedDeck) && selectedDeck.Mastered)
            {
                MasteredDecks.Add(selectedDeck);
            }
            if (MarkedDecks.Contains(selectedDeck) && !selectedDeck.Marked)
            {
                MarkedDecks.Remove(selectedDeck);
            }
            if (MasteredDecks.Contains(selectedDeck) && !selectedDeck.Mastered)
            {
                MasteredDecks.Remove(selectedDeck);
            }
            await changeSave(selectedDeck).ConfigureAwait(true);
        }