コード例 #1
0
 private void AddQuestion(List <Question> listQuestions, int i)
 {
     if (listQuestions.ElementAt(i) is Text_Question)
     {
         Text_Question question = (Text_Question)listQuestions.ElementAt(i);
         stackQuestions.Children.Add(GetElements.GetTextQuestion(i + 1 + "- " + question.questionProperty + " ?", false, false));
         AddAnalyzeButton(i, TypeQuestion.Text);
     }
     else if (listQuestions.ElementAt(i) is Multible)
     {
         Multible question = (Multible)listQuestions.ElementAt(i);
         if (question.typeQuestion_properties.ToString().Contains("Multible"))
         {
             stackQuestions.Children.Add(GetElements.GetMultiChoices(false, i + 1 + "- " + question.title_property + " ?", question.answer, false, false));
         }
         else if (question.Type.Equals(TypeQuestion.MultiChoice))
         {
             stackQuestions.Children.Add(GetElements.GetMultiChoices(true, i + 1 + "- " + question.title_property + " ?", question.answer, false, false));
         }
         else if (question.Type.Equals(TypeQuestion.DropDown))
         {
             stackQuestions.Children.Add(GetElements.GetDropDownQuestion(i + 1 + "- " + question.title_properties + " ?", question.answer.ToList(), false, false));
         }
         AddAnalyzeButton(i, TypeQuestion.Multible);
     }
     else if (listQuestions.ElementAt(i) is Slider_Question)
     {
         Slider_Question question = (Slider_Question)listQuestions.ElementAt(i);
         stackQuestions.Children.Add(
             GetElements.GetSlider(question.Min_Value_Property, question.Max_Value_Property, i + 1 + "- " + question.title_property + " ?", false, false)
             );
         AddAnalyzeButton(i, TypeQuestion.Slider);
     }
 }
コード例 #2
0
 public TextQuestion(ItemTappedEventArgs itemtapped, Question questionSelected, int index)
 {
     InitializeComponent();
     survey            = itemtapped.Item as Survey;
     _questionSelected = questionSelected as Text_Question;
     BindingContext    = _questionSelected;
     _index            = index;
 }
コード例 #3
0
        private async void SaveData_Activated(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(questionEntry.Text) || questionEntry.Text.Contains("~"))
            {
                checkinputs.Text = Lang.Resource.check_inputsSignin3;
                return;
            }
            Text_Question question = new Text_Question(TypeQuestion.Text, questionEntry.Text);

            question.Initialize(TypeQuestion.Text, questionEntry.Text, switchAnswer.IsToggled, " ");

            // Store Data in File Of Survey
            folder = FileSystem.Current.LocalStorage;

            username = await controlFile.GetUserName();

            folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            string content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content);

            if (_questionSelected != null)
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        Text_Question questionText = new Text_Question(TypeQuestion.Text, questionEntry.Text);
                        questionText.Initialize(TypeQuestion.Text, questionEntry.Text, switchAnswer.IsToggled, " ");
                        (S.Questions_Property.ElementAt(_index) as Text_Question).Edit_Question(questionText);
                        survey = S;
                        break;
                    }
                }
            }
            else
            {
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        S.Questions_Property.Add(question);

                        survey = S;
                        break;
                    }
                }
            }
            if (CheckNetwork.Check_Connectivity())
            {
                SurveysServices S_S = new SurveysServices();
                S_S.Set_UrlApi("EditSurveys/" + username);
                await S_S.PutSurveysAsync(survey);
            }


            content = Serializable_Survey.serialize(ListSurveys.ToList());

            await file.WriteAllTextAsync(content);

            await Navigation.PopModalAsync();
        }
コード例 #4
0
 private void AddQuestion(List <Question> listQuestions, int i)
 {
     if (listQuestions.ElementAt(i) is Text_Question)
     {
         Text_Question question = (Text_Question)listQuestions.ElementAt(i);
         stackQuestions.Children.Add(GetElements.GetTextQuestion(i + 1 + "- " + question.questionProperty + " ?", false, true));
         (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[0] as Button).Clicked += (sender, e) => {
             question_selected = survey.Questions_Property.ElementAt(i);
             Navigation.PushModalAsync(new TextQuestion(_survey, question_selected, i));
         };
         (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[1] as Button).Clicked += (sender, e) => {
             Delete_Item(i);
         };
     }
     else if (listQuestions.ElementAt(i) is Multible)
     {
         Multible question = (Multible)listQuestions.ElementAt(i);
         if (question.Type.Equals(TypeQuestion.Multible))
         {
             stackQuestions.Children.Add(GetElements.GetMultiChoices(false, i + 1 + "- " + question.title_property + " ?", question.answer, false, true));
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[0] as Button).Clicked += (sender, e) =>
             {
                 question_selected = survey.Questions_Property.ElementAt(i);
                 Navigation.PushModalAsync(new MultiChoiceQuestion(_survey, question_selected, i));
             };
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[1] as Button).Clicked += (sender, e) => {
                 Delete_Item(i);
             };
         }
         else if (question.Type.Equals(TypeQuestion.MultiChoice))
         {
             stackQuestions.Children.Add(GetElements.GetMultiChoices(true, i + 1 + "- " + question.title_property + " ?", question.answer, false, true));
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[0] as Button).Clicked += (sender, e) =>
             {
                 question_selected = survey.Questions_Property.ElementAt(i);
                 Navigation.PushModalAsync(new MultiChoiceQuestion(_survey, question_selected, i));
             };
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[1] as Button).Clicked += (sender, e) => {
                 Delete_Item(i);
             };
         }
         else if (question.Type.Equals(TypeQuestion.DropDown))
         {
             stackQuestions.Children.Add(GetElements.GetDropDownQuestion(i + 1 + "- " + question.title_properties + " ?", question.answer.ToList(), false, true));
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[0] as Button).Clicked += (sender, e) => {
                 question_selected = survey.Questions_Property.ElementAt(i);
                 Navigation.PushModalAsync(new DropDownQuestion(_survey, question_selected, i));
             };
             (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[1] as Button).Clicked += (sender, e) => {
                 Delete_Item(i);
             };
         }
     }
     else if (listQuestions.ElementAt(i) is Slider_Question)
     {
         Slider_Question question = (Slider_Question)listQuestions.ElementAt(i);
         stackQuestions.Children.Add(
             GetElements.GetSlider(question.Min_Value_Property, question.Max_Value_Property, i + 1 + "- " + question.title_property + " ?", false, true)
             );
         (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[0] as Button).Clicked += (sender, e) => {
             question_selected = survey.Questions_Property.ElementAt(i);
             Navigation.PushModalAsync(new SliderQuestion(_survey, question_selected, i));
         };
         (((stackQuestions.Children[i + 1] as StackLayout).Children[(stackQuestions.Children[i + 1] as StackLayout).Children.Count - 1] as StackLayout).Children[1] as Button).Clicked += (sender, e) => {
             Delete_Item(i);
         };
     }
 }