Пример #1
0
        private List <Question> PrepareQuestionsCopy(NormalCategory owner)
        {
            List <Question> newList = new List <Question>(QuestionsTemplate.Count);

            foreach (Question question in QuestionsTemplate)
            {
                newList.Add(question.Copy(owner));
            }
            return(newList);
        }
Пример #2
0
 /// <summary>
 /// Creates subcategories.
 /// </summary>
 /// <param name="from">Start index.</param>
 /// <param name="to">End index.</param>
 public void MakeSubCategories(int from, int to)
 {
     for (int i = from; i < to; ++i)
     {
         NormalCategory newCategory = new NormalCategory(Parent)
         {
             Id = string.Format("{0}_{1}", this.Id, i + 1), Name = string.Format("No. {0}", i + 1)
         };
         List <Question> copyOfQuestions = PrepareQuestionsCopy(newCategory);
         newCategory.Questions = copyOfQuestions;
         SubCategories.Add(newCategory);
         newCategory.RefreshQuestionsVisibility();
     }
     Parent.IsResultChanged = true;
 }
Пример #3
0
        private void ParseCategories(IEnumerable <XElement> categories)
        {
            Category category;

            foreach (var categoryIterator in categories)
            {
                var    questions    = categoryIterator.Descendants("question");
                string categoryId   = categoryIterator.Attribute("id").Value;
                string categoryName = categoryIterator.Attribute("name").Value;
                if (categoryIterator.Attribute("condition") != null)
                {
                    ConditionCategory condintionalCategoryInstance = new ConditionCategory(this)
                    {
                        Id = categoryId, Name = categoryName
                    };
                    condintionalCategoryInstance.ConditionQuestion = categoryIterator.Attribute("condition").Value;
                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, condintionalCategoryInstance.QuestionsTemplate, condintionalCategoryInstance);
                    }
                    category = condintionalCategoryInstance;
                }
                else
                {
                    NormalCategory normalCategoryInstance = new NormalCategory(this)
                    {
                        Id = categoryId, Name = categoryName
                    };

                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, normalCategoryInstance.Questions, normalCategoryInstance);
                    }
                    category = normalCategoryInstance;
                }
                Categories.Add(category);
            }
        }
 /// <summary>
 /// Standard WP7 method which is running always when user navigates to page.
 /// </summary>
 /// <param name="e">NavigationService argument</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (_isNewInstance)
     {
         String categoryName = String.Empty;
         if (NavigationContext.QueryString.TryGetValue("CategoryName", out categoryName))
         {
             _category = App.AppDictionary["SentCategory"] as NormalCategory;
             if (_category != null)
             {
                 if (!_category.Visited)
                     _category.Visited = true;
                 SubSategoryName.Text = _category.Name;
                 CategoryName.Text = categoryName;
                 NormalCategoryViewModel normalCategoryViewModel = new NormalCategoryViewModel(_category);
                 normalCategoryViewModel.AddQuestionsToListBox(QuestionsList);
             }
             else
             {
                 _backPreesed = true;
                 NavigationService.GoBack();
             }
         }
         _isNewInstance= false;
     }
 }
 /// <summary>
 /// Constructor which sets private _category field on input value.
 /// </summary>
 /// <param name="category">Value contains information about category which will be added to pivot.</param>
 public PreviewCategoryViewModel(NormalCategory category)
 {
     _category = category;
 }
 private List<Question> PrepareQuestionsCopy(NormalCategory owner)
 {
     List<Question> newList = new List<Question>(QuestionsTemplate.Count);
     foreach (Question question in QuestionsTemplate)
     {
         newList.Add(question.Copy(owner));
     }
     return newList;
 }
 /// <summary>
 /// Creates subcategories.
 /// </summary>
 /// <param name="from">Start index.</param>
 /// <param name="to">End index.</param>
 public void MakeSubCategories(int from, int to)
 {
     for (int i = from; i < to; ++i)
     {
         NormalCategory newCategory = new NormalCategory(Parent) { Id = string.Format("{0}_{1}", this.Id, i + 1), Name = string.Format("No. {0}", i + 1) };
         List<Question> copyOfQuestions = PrepareQuestionsCopy(newCategory);
         newCategory.Questions = copyOfQuestions;
         SubCategories.Add(newCategory);
         newCategory.RefreshQuestionsVisibility();
     }
     Parent.IsResultChanged = true;
 }
Пример #8
0
        private void ParseCategories(IEnumerable<XElement> categories)
        {
            Category category;
            foreach (var categoryIterator in categories)
            {
                var questions = categoryIterator.Descendants("question");
                string categoryId = categoryIterator.Attribute("id").Value;
                string categoryName = categoryIterator.Attribute("name").Value;
                if (categoryIterator.Attribute("condition") != null)
                {
                    ConditionCategory condintionalCategoryInstance = new ConditionCategory(this) { Id = categoryId, Name = categoryName };
                    condintionalCategoryInstance.ConditionQuestion = categoryIterator.Attribute("condition").Value;
                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, condintionalCategoryInstance.QuestionsTemplate, condintionalCategoryInstance);
                    }
                    category = condintionalCategoryInstance;
                }
                else
                {
                    NormalCategory normalCategoryInstance = new NormalCategory(this) { Id = categoryId, Name = categoryName };

                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, normalCategoryInstance.Questions, normalCategoryInstance);
                    }
                    category = normalCategoryInstance;
                }
                Categories.Add(category);
            }
        }