示例#1
0
        private void WriteAggregateDecks()
        {
            string aggregateDeckName;

            if (TryBuildAggregateDeckName(out aggregateDeckName))
            {
                EnablePermanentExtraOptionsFromUI(mAggregateEnabledOptions);

                const int totalSteps = 5;
                ResetProgressBar(totalSteps);

                // 1 : Aggregate all specified decks into a list
                List <Deck> sourceDecks = new List <Deck>();
                for (int i = mTrackBarMin.Value; i <= mTrackBarMax.Value; ++i)
                {
                    BookAndChapterNum selectedChapter = mBookAndChapterNumbers[i];
                    mDeckSerializer.AddAllDecksOfQualifyingBookAndChapter(selectedChapter, ref sourceDecks);
                }
                IncrementBar();

                // 2 : Combine the decks into a mega-deck
                Deck combinedDeck = new Deck(mDeckSerializer);
                combinedDeck.InitializeFromDeckList(sourceDecks, aggregateDeckName);
                IncrementBar();

                // 3 : Filter mega-deck down to selected card type
                CardType filterDownTo = CardType.kInvalid;
                switch (mAggregateFilterDownTo)
                {
                case "Verbs":
                    filterDownTo = CardType.kVerb;
                    break;

                case "Adjectives":
                    filterDownTo = CardType.kAdjective;
                    break;

                case "Phrases":
                    filterDownTo = CardType.kPhrase;
                    break;
                }

                if (filterDownTo != CardType.kInvalid)
                {
                    combinedDeck.FilterCardsDownTo(filterDownTo);
                }
                IncrementBar();

                // 4 : Randomize deck
                if (mDeckSerializer.HasExtraOptionEnabled(StudyOptions.Option.kRandomize))
                {
                    combinedDeck.RandomizeDeck();
                }
                IncrementBar();

                // 5 : Write Deck
                mDeckSerializer.SetPermanentExtraOption(StudyOptions.Option.kIncludeChapterSourceInResult);
                mDeckSerializer.WriteSingleDeck(combinedDeck);
                IncrementBar();

                mDeckSerializer.ClearPermanentExtraOptions();
            }
        }