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); }
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); }
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); }
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); } }
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(); }
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); } }
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) { } } }
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); }