コード例 #1
0
        private async void Delete_Item(int i)
        {
            var res = await DisplayAlert(Lang.Resource.titleMessage, Lang.Resource.DetailsDeleting, Lang.Resource.btnOkMessage, Lang.Resource.btnCancelMessage);

            if (res && CheckNetwork.Check_Connectivity())
            {
                stackQuestions.Children.RemoveAt(i + 1);
                survey.Questions_Property.RemoveAt(i);

                folder = FileSystem.Current.LocalStorage;

                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);
                foreach (Survey S in ListSurveys)
                {
                    if (S.Id == survey.Id)
                    {
                        S.Questions_Property = survey.Questions_Property;

                        SurveysServices S_S = new SurveysServices();
                        S_S.Set_UrlApi("EditSurveys/" + username);
                        await S_S.PutSurveysAsync(survey);

                        DrowItems(S);
                    }
                }
                content = Serializable_Survey.serialize(ListSurveys.ToList());
                await file.WriteAllTextAsync(content);
            }
        }
コード例 #2
0
        private async void Save(object sender, EventArgs e)
        {
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }

            stackQuestions.Opacity      = 0.5;
            ActivityIndicator.IsRunning = true;

            folder = FileSystem.Current.LocalStorage;
            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);
            foreach (Survey S in ListSurveys)
            {
                if (S.Id == survey.Id)
                {
                    S.Title_Property       = Title.Text;
                    S.Description_Property = Description.Text;

                    survey = S;
                    SurveysServices S_S = new SurveysServices();
                    S_S.Set_UrlApi("EditSurveys/" + username);
                    await S_S.PutSurveysAsync(survey);

                    break;
                }
            }
            title.Text       = Title.Text;
            description.Text = Description.Text;
            content          = Serializable_Survey.serialize(ListSurveys.ToList());
            await file.WriteAllTextAsync(content);

            Cancel(sender, e);

            await Task.Delay(500);

            ActivityIndicator.IsRunning = false;
            stackQuestions.Opacity      = 1;
        }
コード例 #3
0
        private async void SaveData_Activated(object sender, EventArgs e)
        {
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }
            string inputs = questionEntry.Text + minvalue.Text + maxvalue.Text;

            if (String.IsNullOrWhiteSpace(inputs) || inputs.Contains("~"))
            {
                checkinputs.Text = Lang.Resource.check_inputsSignin3;
                return;
            }
            Slider_Question question = new Slider_Question(TypeQuestion.Slider, questionEntry.Text);

            question.Create_question(Int32.Parse(minvalue.Text), Int32.Parse(maxvalue.Text), switchRequireAnswer.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)
                    {
                        Slider_Question slider = new Slider_Question(TypeQuestion.Slider, questionEntry.Text);

                        slider.title      = questionEntry.Text;
                        slider.requireAns = switchRequireAnswer.IsToggled;
                        slider.min_value  = Int32.Parse(minvalue.Text);
                        slider.max_value  = Int32.Parse(maxvalue.Text);
                        (S.Questions_Property.ElementAt(_index) as Slider_Question).Edit_question(slider);
                        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 async void SaveData_Activated(object sender, EventArgs e)
        {
            int count = stackAnswerChoice.Children.Count;

            for (int i = 0; i < count; i++)
            {
                Grid  G = stackAnswerChoice.Children.ElementAt(i) as Grid;
                Entry E = G.Children.ElementAt(0) as Entry;
                if (String.IsNullOrWhiteSpace(E.Text))
                {
                    E.IsVisible = false;
                    continue;
                }
                if (E.IsVisible && E.Text.Contains("~"))
                {
                    checkinputs.Text = Lang.Resource.check_inputsSignin3;
                    return;
                }
                if (!String.IsNullOrWhiteSpace(E.Text) && G.IsVisible)
                {
                    entries.Add(E);
                }
            }
            List <string> choices = new List <string>();

            for (int i = 0; i < entries.Count; i++)
            {
                if (entries[i].IsVisible)
                {
                    choices.Add(entries[i].Text);
                }
            }
            if (switchOtherAnswer.IsToggled)
            {
                choices.Add("Other");
            }
            string[] answers = new string[choices.Count];
            for (int i = 0; i < choices.Count; i++)
            {
                answers[i] = choices[i];
            }
            Multible question = new Multible(TypeQuestion.DropDown, questionEntry.Text, answers.Length);

            question.require_Ans = switchRequireAnswer.IsToggled;
            question.Create_question(questionEntry.Text, answers);

            //// 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)
                    {
                        (S.Questions_Property.ElementAt(_index) as Multible).Type        = TypeQuestion.DropDown;
                        (S.Questions_Property.ElementAt(_index) as Multible).require_Ans = switchRequireAnswer.IsToggled;
                        (S.Questions_Property.ElementAt(_index) as Multible).bound       = answers.Length;
                        (S.Questions_Property.ElementAt(_index) as Multible).Create_question(questionEntry.Text, answers);
                        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();
        }