コード例 #1
0
        public ChoiceItemViewModel(Dispatcher dispatcher, IChoiceItem item)
            : base(dispatcher)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            this.item = item;
            if (item is IChoice)
            {
                choice = item as IChoice;

                var child = new ChoiceItemViewModel(dispatcher, choice.Question);
                child.Parent = this;
                children.Add(child);
            }
            else if (item is IQuestion)
            {
                question = item as IQuestion;

                foreach (var answer in question.Answers)
                {
                    var child = new ChoiceItemViewModel(dispatcher, answer);
                    child.Parent = this;
                    children.Add(child);
                }
            }
            else if (item is IAnswer)
            {
                answer = item as IAnswer;

                if (answer.FollowUp != null)
                {
                    var child = new ChoiceItemViewModel(dispatcher, answer.FollowUp);
                    child.Parent = this;
                    children.Add(child);
                }

                if (answer.ItemType is IPlayerCard)
                {
                    var playerCard = answer.GetObject<IPlayerCard>();
                    card = playerCard;
                    playerCardViewModel = new PlayerCardViewModel(dispatcher, playerCard);
                    cardVisibility = Visibility.Visible;
                }
                else if (answer.ItemType is IEncounterCard)
                {
                    var encounterCard = answer.GetObject<IEncounterCard>();
                    card = encounterCard;
                    encounterCardViewModel = new EncounterCardViewModel(dispatcher, encounterCard);
                    cardVisibility = Visibility.Visible;
                }
                else if (answer.ItemType is ICardInPlay)
                {
                    var cardInPlay = answer.GetObject<ICardInPlay>();
                    card = cardInPlay.BaseCard;
                    if (cardInPlay.BaseCard is IPlayerCard)
                    {

                    }
                }
            }
        }
コード例 #2
0
        public ChoiceItemViewModel(Dispatcher dispatcher, IChoiceItem item)
            : base(dispatcher)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            this.item = item;
            if (item is IChoice)
            {
                choice = item as IChoice;

                var child = new ChoiceItemViewModel(dispatcher, choice.Question);
                child.Parent = this;
                children.Add(child);
            }
            else if (item is IQuestion)
            {
                question = item as IQuestion;

                foreach (var answer in question.Answers)
                {
                    var child = new ChoiceItemViewModel(dispatcher, answer);
                    child.Parent = this;
                    children.Add(child);
                }
            }
            else if (item is IAnswer)
            {
                answer = item as IAnswer;

                if (answer.FollowUp != null)
                {
                    var child = new ChoiceItemViewModel(dispatcher, answer.FollowUp);
                    child.Parent = this;
                    children.Add(child);
                }

                if (answer.ItemType is IPlayerCard)
                {
                    var playerCard = answer.GetObject <IPlayerCard>();
                    card = playerCard;
                    playerCardViewModel = new PlayerCardViewModel(dispatcher, playerCard);
                    cardVisibility      = Visibility.Visible;
                }
                else if (answer.ItemType is IEncounterCard)
                {
                    var encounterCard = answer.GetObject <IEncounterCard>();
                    card = encounterCard;
                    encounterCardViewModel = new EncounterCardViewModel(dispatcher, encounterCard);
                    cardVisibility         = Visibility.Visible;
                }
                else if (answer.ItemType is ICardInPlay)
                {
                    var cardInPlay = answer.GetObject <ICardInPlay>();
                    card = cardInPlay.BaseCard;
                    if (cardInPlay.BaseCard is IPlayerCard)
                    {
                    }
                }
            }
        }