Ejemplo n.º 1
0
        public void AddControl(Controls control, int?sectionID)
        {
            Bindings binding = XForm.GetBindingForControl(control);

            try
            {
                View controlView = new View(this);
                switch ((ControlType)control.type)
                {
                case ControlType.input:
                    //the user puts something in
                    controlView = WidgetHelper.CreateInput(control, binding, inflater, this);

                    break;

                case ControlType.output:
                    Console.WriteLine("not yet");
                    controlView = new LinearLayout(this);
                    controlView.SetBackgroundColor(Color.Red);
                    controlView.SetMinimumHeight(25);


                    break;

                case ControlType.select:
                    controlView = WidgetHelper.CreateSelect(control, binding, inflater, this);

                    break;

                case ControlType.select1:
                    controlView = WidgetHelper.CreateSelectOne(control, binding, inflater, this);

                    break;

                case ControlType.upload:
                    controlView = WidgetHelper.CreateUpload(control, binding, inflater, this);
                    break;
                }

                MainFormLayout.LayoutTransition.EnableTransitionType(Android.Animation.LayoutTransitionType.ChangeAppearing | Android.Animation.LayoutTransitionType.ChangeDisappearing);

                //root
                if (sectionID == null || sectionID == -1)
                {
                    RunOnUiThread(() => { MainFormLayout.AddView(controlView); });
                }

                //add to the group based on the ui
                else
                {
                    RunOnUiThread(() => {
                        LinearLayout groupParent = (LinearLayout)MainFormLayout.FindViewWithTag(sectionID.Value);
                        LinearLayout groupLayout = groupParent.FindViewById <LinearLayout>(Resource.Id.mainGroupLayout);

                        groupLayout.LayoutTransition.EnableTransitionType(Android.Animation.LayoutTransitionType.ChangeAppearing | Android.Animation.LayoutTransitionType.ChangeDisappearing);


                        Console.WriteLine($"Group tag: {groupParent.Tag}");

                        groupLayout.AddView(controlView);
                    });
                }
                //Console.WriteLine(binding.nodeset);
                ControlViews.Add(controlView);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }