public void Initialize()
        {
            var settingsDB   = PlayerSettingsDB.Get();
            var modelProxyDB = ModelProxyDB.Get();

            favDecks.SuspendNotifies();

            foreach (var favDeckOb in settingsDB.favDecks)
            {
                var deck = new CardCollectionViewModel()
                {
                    Name = favDeckOb.Name
                };
                foreach (var cardOb in favDeckOb.knownCards)
                {
                    var cardVM = new CardViewModel()
                    {
                        CardModel = modelProxyDB.GetCardProxy(cardOb)
                    };
                    deck.Cards.Add(cardVM);
                }

                var favDeck = new SolvableDeckViewModel()
                {
                    Deck = deck
                };
                favDecks.Add(favDeck);

                favDeck.RefreshSolver(gameModel, favDeckOb);
            }

            favDecks.ResumeNotifies();
        }
        private void CommandFavEditFunc(SolvableDeckViewModel favDeck)
        {
            var deckVM = new DeckViewModel()
            {
                Name = favDeck.Deck.Name
            };

            foreach (var card in favDeck.Deck.Cards)
            {
                deckVM.Cards.Add(new CardViewModel()
                {
                    CardModel = card.CardModel
                });
            }

            var editVM = new FavDeckEditViewModel()
            {
                FavDeck = deckVM
            };
            var result = ViewModelServices.DialogWindow.ShowDialog(editVM);

            if (result ?? false)
            {
                favDeck.Deck.Name = deckVM.Name;
                AssignFavDeckFrom(favDeck, deckVM);
            }
        }
        private void AssignFavDeckFrom(SolvableDeckViewModel favDeck, DeckViewModel sourceDeck)
        {
            if (sourceDeck.Cards.Count == favDeck.Deck.Cards.Count)
            {
                favDeck.Deck.Cards.SuspendNotifies();
                var cards = new List <TriadCard>();

                for (int idx = 0; idx < sourceDeck.Cards.Count; idx++)
                {
                    var cardProxy = sourceDeck.Cards[idx].CardModel;
                    favDeck.Deck.Cards[idx].CardModel = cardProxy;
                    cards.Add(cardProxy.cardOb);
                }

                favDeck.Deck.Cards.ResumeNotifies();

                int slotIdx   = favDecks.IndexOf(favDeck);
                var namedDeck = new TriadDeckNamed(new TriadDeck(cards))
                {
                    Name = favDeck.Deck.Name
                };
                PlayerSettingsDB.Get().UpdateFavDeck(slotIdx, namedDeck);

                favDeck.RefreshSolver(gameModel, namedDeck);
            }
        }
        private void CommandFavUseFunc(SolvableDeckViewModel favDeck)
        {
            if (activeDeck.Cards.Count == favDeck.Deck.Cards.Count)
            {
                activeDeck.Cards.SuspendNotifies();
                for (int idx = 0; idx < activeDeck.Cards.Count; idx++)
                {
                    activeDeck.Cards[idx].CardModel     = favDeck.Deck.Cards[idx].CardModel;
                    activeDeck.Cards[idx].IsShowingLock = false;
                }

                activeDeck.Cards.ResumeNotifies();
                activeDeck.ForceCardsUpdate();
            }
        }
        private void CommandFavRemoveFunc(SolvableDeckViewModel favDeck)
        {
            int slotIdx = favDecks.IndexOf(favDeck);

            if (slotIdx >= 0)
            {
                var result = MessageBox.Show(loc.strings.FavDeckForm_Dynamic_RemoveMsg, loc.strings.App_Title, MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (result == MessageBoxResult.Yes)
                {
                    PlayerSettingsDB.Get().UpdateFavDeck(slotIdx, null);

                    favDecks.RemoveAt(slotIdx);
                }
            }
        }
        private void CommandFavCreateFunc(object dummyParam)
        {
            var deck = new CardCollectionViewModel();

            for (int idx = 1; idx < 10000; idx++)
            {
                deck.Name = string.Format(loc.strings.FavDeckForm_Dynamic_AutoName, idx);

                bool foundMatch = false;
                foreach (var testFav in favDecks)
                {
                    foundMatch = testFav.Deck.Name == deck.Name;
                    if (foundMatch)
                    {
                        break;
                    }
                }

                if (!foundMatch)
                {
                    break;
                }
            }

            for (int idx = 0; idx < activeDeck.Cards.Count; idx++)
            {
                deck.Cards.Add(new CardViewModel());
            }

            var favDeck = new SolvableDeckViewModel()
            {
                Deck = deck
            };

            favDecks.Add(favDeck);

            AssignFavDeckFrom(favDeck, activeDeck);
        }