/// <summary> /// Constructor /// </summary> public MainViewModel() { _dataBaseInputOutput = new DataBaseInputOutput(_flipcardDatabase); _deckStatus = new DeckStatus(Language.Dutch, Language.German); // If no decks loaded, create a new one. if (_flipcardDatabase.FlipcardDecks.Count <= 0) { _flipcardDatabase.AddDeck(new FlipcardDeck(_flipcardDatabase, _deckStatus) { Name = "newdeck" }); } // Register for events on the deck _flipcardDeckShown = _flipcardDatabase.FlipcardDecks.First().Value; _flipcardDeckShown.Flipcards.CollectionChanged += Flipcards_CollectionChanged; // Show the available decks foreach (var deck in _flipcardDatabase.FlipcardDecks.Values) { DecksAvailable.Add(deck.Name); } DeckSelected = DecksAvailable.First(); }
/// <summary> /// Create a new deck /// </summary> private void NewDeck() { NewDeck newDeckView = new NewDeck(); if (newDeckView.ShowDialog() == true) { var name = newDeckView.DeckName; // Create and select first deck var flipcardDeck = new FlipcardDeck(_flipcardDatabase, _deckStatus) { Name = name }; _flipcardDatabase.AddDeck(flipcardDeck); _flipcardDeckShown = flipcardDeck; DecksAvailable.Add(name); DeckSelected = DecksAvailable.Last(); } }