public RadioGroupOptionQuestionInputView(OptionQuestion question, SurveyPageAppearance appearance)
            : base(appearance)
        {
            var radioGroup = new CustomRadioGroup (appearance);
            radioGroup.HorizontalOptions = LayoutOptions.FillAndExpand;
            radioGroup.VerticalOptions = LayoutOptions.Fill;
            radioGroup.BindingContext = question;
            radioGroup.ItemsSource = question.OptionValues;
            radioGroup.SetBinding (RadioGroup.SelectedItemProperty, new Binding ("SelectedOption", BindingMode.TwoWay));

            HeightRequest = -1;
            Content = radioGroup;
        }
Ejemplo n.º 2
0
 private void populateFields()
 {
     Task.Run(async() => {
         List <FoodItem> f = await GlobalVariables.foodItemsDatabase.QueryById(mID);
         food             = f.First();
         dict             = GlobalVariables.DeserializeDictionary(food.ANSWERS);
         imageView.Source = ImageSource.FromStream(() => new MemoryStream(GlobalVariables.DeserializeStringToByteArray(food.IMGBYTES)));
         if (EntryType == GlobalVariables.EntryType.UPDATE_ENTRY)
         {
             mName.Text = food.NAME;
             foreach (var question in dict)
             {
                 CustomRadioGroup group = null;
                 if (radioGroups.TryGetValue(question.Key, out group))
                 {
                     group.SelectedIndex = question.Value;
                 }
             }
         }
         Update();
     });
 }
Ejemplo n.º 3
0
        public EditDetailsPage(int id, GlobalVariables.EntryType e)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();
            Title       = "Edit Details";
            EntryType   = e;
            mID         = id;
            radioGroups = new Dictionary <int, CustomRadioGroup>();

            Label nameLabel = new Label
            {
                Text      = "Name ",
                TextColor = Color.Black,
                FontSize  = 25
            };

            mName = new Entry
            {
                WidthRequest = 200,
                Placeholder  = " Name",
            };

            List <CustomRadioButton> list = new List <CustomRadioButton>();

            CustomRadioGroup Group         = null;
            Label            QuestionLabel = null;
            StackLayout      questionsView = new StackLayout();

            foreach (var question in GlobalVariables.Questions)
            {
                list.Clear();
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                Group = new CustomRadioGroup
                {
                    ItemsSource   = list,
                    Orientation   = StackOrientation.Horizontal,
                    SelectedIndex = -1
                };
                QuestionLabel = new Label
                {
                    Text = question.Value,
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    TextColor         = Color.Black,
                    FontSize          = 20,
                    Margin            = new Thickness(10, 20, 0, 0)
                };
                radioGroups.Add(question.Key, Group);
                questionsView.Children.Add(QuestionLabel);
                questionsView.Children.Add(Group);
            }

            view      = new RelativeLayout();
            imageView = new Image
            {
                WidthRequest  = 100,
                HeightRequest = 100,
                Aspect        = Aspect.AspectFill
            };

            view.Children.Add(imageView,
                              Constraint.RelativeToParent((parent) =>
            {
                return(parent.X + 10);
            }),
                              Constraint.RelativeToParent((parent) =>
            {
                return(parent.Y + 20);
            }),
                              Constraint.Constant(100), Constraint.Constant(100)
                              );

            view.Children.Add(nameLabel, Constraint.RelativeToView(imageView,
                                                                   (Parent, sibling) =>
            {
                return(sibling.Width + 40);
            }),
                              Constraint.RelativeToView(imageView,
                                                        (Parent, sibling) =>
            {
                return(Parent.Y + 30);
            }));

            view.Children.Add(mName, Constraint.RelativeToView(imageView,
                                                               (Parent, sibling) =>
            {
                return(sibling.Width + 30);
            }),
                              Constraint.RelativeToView(nameLabel,
                                                        (Parent, sibling) =>
            {
                return(sibling.Y + 30);
            }));

            view.Children.Add(questionsView, Constraint.RelativeToView(imageView,
                                                                       (Parent, sibling) =>
            {
                return(Parent.X);
            }),
                              Constraint.RelativeToView(imageView,
                                                        (Parent, sibling) =>
            {
                return(sibling.Height + 50);
            }));

            Button doneButton = new Button
            {
                Text = "Done"
            };

            doneButton.Clicked += OnDoneClicked;
            Button cancelButton = new Button
            {
                Text = "Cancel"
            };

            cancelButton.Clicked += OnCancelClicked;

            view.Children.Add(cancelButton, Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(Parent.X);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(Parent.Height - 40);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(Parent.Width * 0.5);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(40);
            }));
            view.Children.Add(doneButton, Constraint.RelativeToView(cancelButton,
                                                                    (Parent, sibling) =>
            {
                return(sibling.Width);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(Parent.Height - 40);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(Parent.Width * 0.5);
            }),
                              Constraint.RelativeToParent(
                                  (Parent) =>
            {
                return(40);
            }));

            populateFields();
        }
Ejemplo n.º 4
0
        private void OnStartDailyReview(object sender, EventArgs e)
        {
            selected    = (ReviewSelectionButton)sender;
            radioGroups = new Dictionary <int, CustomRadioGroup>();
            List <CustomRadioButton> list = new List <CustomRadioButton>();

            CustomRadioGroup Group         = null;
            Label            QuestionLabel = null;
            StackLayout      questionsView = new StackLayout {
                Margin = 10
            };

            foreach (var question in GlobalVariables.DailyReviewQuestions)
            {
                list.Clear();
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                list.Add(new CustomRadioButton {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                });
                Group = new CustomRadioGroup
                {
                    ItemsSource   = list,
                    Orientation   = StackOrientation.Horizontal,
                    SelectedIndex = -1
                };
                QuestionLabel = new Label
                {
                    Text = question.Value,
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    TextColor         = Color.Black,
                    FontSize          = 20,
                    Margin            = new Thickness(10, 20, 0, 0)
                };
                radioGroups.Add(question.Key, Group);
                questionsView.Children.Add(QuestionLabel);
                questionsView.Children.Add(Group);
            }

            StackLayout buttonsView = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };

            AbsoluteLayout.SetLayoutFlags(buttonsView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(buttonsView, new Rectangle(1, 1, 1, 0.1));
            Button doneButton = new Button
            {
                Text              = "Done",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            doneButton.Clicked += OnDoneClickedAsync;
            Button cancelButton = new Button
            {
                Text              = "Cancel",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            cancelButton.Clicked += OnCancelClicked;
            buttonsView.Children.Add(cancelButton);
            buttonsView.Children.Add(doneButton);

            ScrollView scrollView = new ScrollView
            {
                Orientation = ScrollOrientation.Vertical,
                Content     = questionsView
            };

            AbsoluteLayout.SetLayoutFlags(scrollView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(scrollView, new Rectangle(0, 0, 1, 0.9));

            AbsoluteLayout view = new AbsoluteLayout();

            view.Children.Add(scrollView);
            view.Children.Add(buttonsView);

            setView(view);
        }