コード例 #1
0
        /// <summary>
        /// Gets the radio button result.
        /// </summary>
        /// <returns>The radio button result.</returns>
        /// <param name="title">Title.</param>
        /// <param name="source">Source.</param>
        /// <param name="selectedItem">Selected item.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public static Task <T> GetRadioButtonResult <T>(string title, IEnumerable <T> source, T selectedItem = default(T)) /*where T: new()*/
        {
            TaskCompletionSource <T> tcs = new TaskCompletionSource <T>();
            RadioButtonGroupView     rgv = new RadioButtonGroupView {
                Margin = new Thickness(30, 5),
            };
            Button btn = new Button {
                Text = "UYGULA", Margin = new Thickness(20, 0), CornerRadius = 20, BackgroundColor = Color.Accent, TextColor = Color.White,
            };

            foreach (var item in source)
            {
                rgv.Children.Add(new RadioButton(item, null, item.Equals(selectedItem))
                {
                    Color = Color.Accent
                });
            }

            btn.Clicked += (s, e) =>
            {
                tcs.TrySetResult((T)rgv.SelectedItem);
                PopupNavigation.PopAsync();
            };

            Frame frame = new Frame
            {
                BorderColor     = Color.Transparent,
                BackgroundColor = Color.WhiteSmoke,
                Margin          = 25,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Content         = new StackLayout
                {
                    Padding  = new Thickness(5),
                    Children =
                    {
                        new Label      {
                            Text = title, FontSize = 18, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold
                        },
                        new ScrollView {
                            Content = rgv
                        },
                        btn
                    }
                }
            };

            var popupPage = new PopupPage {
                Content = frame, CloseWhenBackgroundIsClicked = false
            };

            PopupNavigation.PushAsync(popupPage);
            popupPage.Disappearing += (s, e) => tcs.TrySetResult((T)rgv.SelectedItem);


            return(tcs.Task);
        }
コード例 #2
0
 public void SetterRB(RadioButtonGroupView ItemsRB, string FieldValue)
 {
     foreach (var Item in ItemsRB.Children)
     {
         if (Item is Plugin.InputKit.Shared.Controls.RadioButton ItemRB && ItemRB.Text.Equals(FieldValue))
         {
             ItemRB.IsChecked = true;
         }
     }
 }
コード例 #3
0
        public string GetterRB(RadioButtonGroupView ItemsRB)
        {
            string FieldValue = "";

            foreach (var Item in ItemsRB.Children)
            {
                if (Item is Plugin.InputKit.Shared.Controls.RadioButton ItemRB && ItemRB.IsChecked)
                {
                    FieldValue = ItemRB.Text;
                }
            }
            return(FieldValue);
        }
コード例 #4
0
        public StackLayout BasicQuestion()
        {
            ////Création du stack layout englobant tout.
            StackLayout stackLayoutGlobal = new StackLayout();

            stackLayoutGlobal.HorizontalOptions = LayoutOptions.Center;
            stackLayoutGlobal.Margin            = new Thickness(10, 0, 10, 10);
            Grid.SetRow(stackLayoutGlobal, 1);
            Grid.SetColumn(stackLayoutGlobal, 1);



            ////Création du label avec la question
            Label labelQuestion = new Label();

            labelQuestion.HorizontalTextAlignment = TextAlignment.Center;
            labelQuestion.TextColor = Color.White;
            labelQuestion.Text      = "Combien de Climats sont inscrits sur la Liste du patrimoine mondial?";
            stackLayoutGlobal.Children.Add(labelQuestion);

            RadioButtonGroupView RadioButtonGroupeQuestion = new RadioButtonGroupView();

            //RadioButtonGroupeQuestion.SetBinding(RadioButtonGroupView.SelectedIndexProperty, nameof(trial.Answers));
            stackLayoutGlobal.Children.Add(RadioButtonGroupeQuestion);



            // foreach(Answer answer in trial.Answers)
            // {
            StackLayout stackLayoutResponse1 = new StackLayout();

            stackLayoutResponse1.BackgroundColor = Color.White;
            stackLayoutResponse1.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse1 = new RadioButton();

            radioButtonResponse1.TextColor = Color.Black;
            radioButtonResponse1.Text      = "3 046";
            stackLayoutResponse1.Children.Add(radioButtonResponse1);



            StackLayout stackLayoutResponse2 = new StackLayout();

            stackLayoutResponse2.BackgroundColor = Color.White;
            stackLayoutResponse2.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2 = new RadioButton();

            radioButtonResponse2.TextColor = Color.Black;
            radioButtonResponse2.Text      = "2 500";
            stackLayoutResponse2.Children.Add(radioButtonResponse2);



            StackLayout stackLayoutResponse3 = new StackLayout();

            stackLayoutResponse3.BackgroundColor = Color.White;
            stackLayoutResponse3.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse3 = new RadioButton();

            radioButtonResponse3.TextColor = Color.Black;
            radioButtonResponse3.Text      = " 1 247";
            stackLayoutResponse3.Children.Add(radioButtonResponse3);


            RadioButtonGroupeQuestion.Children.Add(stackLayoutResponse1);
            RadioButtonGroupeQuestion.Children.Add(stackLayoutResponse2);
            RadioButtonGroupeQuestion.Children.Add(stackLayoutResponse3);



            stackLayoutGlobal.Children.Add(RadioButtonGroupeQuestion);



            Label labelQuestion2 = new Label();

            labelQuestion2.HorizontalTextAlignment = TextAlignment.Center;
            labelQuestion2.TextColor = Color.White;
            labelQuestion2.Text      = "Quelle est la définition pour le  métier de Tonnelier ?";
            stackLayoutGlobal.Children.Add(labelQuestion2);



            RadioButtonGroupView RadioButtonGroupeQuestion2 = new RadioButtonGroupView();

            //RadioButtonGroupeQuestion.SetBinding(RadioButtonGroupView.SelectedIndexProperty, nameof(trial.Answers));
            stackLayoutGlobal.Children.Add(RadioButtonGroupeQuestion);



            // foreach(Answer answer in trial.Answers)
            // {
            StackLayout stackLayoutResponse2_1 = new StackLayout();

            stackLayoutResponse2_1.BackgroundColor = Color.White;
            stackLayoutResponse2_1.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2_1 = new RadioButton();

            radioButtonResponse2_1.TextColor = Color.Black;
            radioButtonResponse2_1.Text      = "Je récolte les raisins mûrs destinés à la production de vin.";
            stackLayoutResponse2_1.Children.Add(radioButtonResponse2_1);



            StackLayout stackLayoutResponse2_2 = new StackLayout();

            stackLayoutResponse2_2.BackgroundColor = Color.White;
            stackLayoutResponse2_2.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2_2 = new RadioButton();

            radioButtonResponse2_2.TextColor = Color.Black;
            radioButtonResponse2_2.Text      = "J’achète des raisins, je les transforme en vin et le vends.";
            stackLayoutResponse2_2.Children.Add(radioButtonResponse2_2);



            StackLayout stackLayoutResponse2_3 = new StackLayout();

            stackLayoutResponse2_3.BackgroundColor = Color.White;
            stackLayoutResponse2_3.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2_3 = new RadioButton();

            radioButtonResponse2_3.TextColor = Color.Black;
            radioButtonResponse2_3.Text      = "Je cultive la vigne, produis du vin et le vends.";
            stackLayoutResponse2_3.Children.Add(radioButtonResponse2_3);



            StackLayout stackLayoutResponse2_4 = new StackLayout();

            stackLayoutResponse2_4.BackgroundColor = Color.White;
            stackLayoutResponse2_4.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2_4 = new RadioButton();

            radioButtonResponse2_4.TextColor = Color.Black;
            radioButtonResponse2_4.Text      = "Artisan spécialiste du bois, je fabrique et répare les tonneaux";
            stackLayoutResponse2_4.Children.Add(radioButtonResponse2_4);



            StackLayout stackLayoutResponse2_5 = new StackLayout();

            stackLayoutResponse2_5.BackgroundColor = Color.White;
            stackLayoutResponse2_5.Padding         = new Thickness(5, 0);



            RadioButton radioButtonResponse2_5 = new RadioButton();

            radioButtonResponse2_5.TextColor = Color.Black;
            radioButtonResponse2_5.Text      = "Technicien  et chimiste, je dirige la production du vin de la vigne à la bouteille.";
            stackLayoutResponse2_5.Children.Add(radioButtonResponse2_5);



            RadioButtonGroupeQuestion2.Children.Add(stackLayoutResponse2_1);
            RadioButtonGroupeQuestion2.Children.Add(stackLayoutResponse2_2);
            RadioButtonGroupeQuestion2.Children.Add(stackLayoutResponse2_3);
            RadioButtonGroupeQuestion2.Children.Add(stackLayoutResponse2_4);
            RadioButtonGroupeQuestion2.Children.Add(stackLayoutResponse2_5);



            stackLayoutGlobal.Children.Add(RadioButtonGroupeQuestion2);



            //  radioButtonResponse.SetBinding(RadioButton.TextProperty, nameof(trial.Libelle));
            //}



            GridQuizzPage.Children.Add(stackLayoutGlobal);



            return(stackLayoutGlobal);
        }
コード例 #5
0
        public ResponderQuestionario(long id)
        {
            InitializeComponent();

            _alternativas            = new Dictionary <int, RadioButtonGroupView>();
            _opcoes                  = new Dictionary <int, RadioButtonGroupView>();
            _IdtRespostaQuestionario = id;

            AcessoBanco banco = new AcessoBanco();

            RespostaQuestionario questionario = banco.PegarQuestionario(id);

            _form = JsonConvert.DeserializeObject <RespostaQuestionarioForm>(questionario.Objeto);

            List <Municipio> municipios = banco.ListarMunicipios();

            List <AlternativaICQ> alternativas = banco.ListarAlternativas();

            List <OpcaoTipoResposta> opcoes = banco.ListarOpcoes();

            NomeRelatorio.Text  = _form.NomeRelatorio;
            TextoCabecalho.Text = _form.TextoCabecalho;

            foreach (var item in municipios)
            {
                Municipio.Items.Add(item.NomMunicipio);
            }

            foreach (var item in _form.RespostasPerfil)
            {
                StackLayoutPrincipal.Children.Add(new Label()
                {
                    Text = item.DescPergunta
                });

                var rbgAlternativa = new RadioButtonGroupView();

                foreach (var alternativa in alternativas.Where(a => a.IdtItemCabecalhoQuestionario == item.IdtItemCabecalhoQuestionario).ToList())
                {
                    rbgAlternativa.Children.Add(new RadioButton()
                    {
                        Value        = alternativa.IdtAlternativaICQ,
                        Text         = alternativa.DescAlternativa,
                        TextFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
                    });
                }

                StackLayoutPrincipal.Children.Add(rbgAlternativa);
                _alternativas.Add(item.IdtItemCabecalhoQuestionario, rbgAlternativa);
            }

            foreach (var item in _form.Competencias)
            {
                StackLayoutPrincipal.Children.Add(new Label()
                {
                    Text     = item.DescCompetencia,
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                });
                AdicionarLinha();

                foreach (var resposta in item.Respostas)
                {
                    StackLayoutPrincipal.Children.Add(new Label()
                    {
                        Text = resposta.DescPergunta
                    });

                    var rbgOpcao = new RadioButtonGroupView();

                    foreach (var opcao in opcoes.Where(o => o.IdtTipoResposta == resposta.IdtTipoResposta).ToList())
                    {
                        rbgOpcao.Children.Add(new RadioButton()
                        {
                            Value        = opcao.IdtOpcaoTipoResposta,
                            Text         = opcao.DescOpcao,
                            TextFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
                        });
                    }
                    StackLayoutPrincipal.Children.Add(rbgOpcao);
                    _opcoes.Add(resposta.IdtQuestionarioPergunta, rbgOpcao);
                }
            }


            Button btnConfirmar = new Button()
            {
                Text = "Salvar",
                HorizontalOptions = LayoutOptions.Center,
                Margin            = 20
            };

            btnConfirmar.Clicked += Salvar;

            StackLayoutPrincipal.Children.Add(btnConfirmar);
        }