Esempio n. 1
0
        public ReportFormPage(string reportFormPath)
        {
            Services.Form form = new Services.Form(reportFormPath);

            Button save = new Button {
                Text = "Save"
            };

            save.Clicked += (sender, args) => form.SaveForm();

            StackLayout stack = new StackLayout();

            foreach (Services.Section item in form.Sections)
            {
                stack.Children.Add(new BoxView()
                {
                    Opacity = 0.5f, Color = Color.Gray, WidthRequest = 100, HeightRequest = 2
                });
                stack.Children.Add(getSectionView(item));
            }

            stack.Children.Add(new BoxView()
            {
                Opacity = 0.5f, Color = Color.Gray, WidthRequest = 100, HeightRequest = 2
            });

            ScrollView scrollView = new ScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        save,
                        stack
                    }
                }
            };

            Content = scrollView;
        }
Esempio n. 2
0
        private StackLayout getSectionView(Services.Section item, Services.Form form, BoxView seper)
        {
            StackLayout secStack = new StackLayout()
            {
                Margin  = new Thickness(20),
                Spacing = 10
            };

            Button deleteS = new Button {
                Text = "Delete Section"
            };

            deleteS.Clicked += (sender, args) => {
                form.removeSection(item);
                secStack.IsVisible = false;
                seper.IsVisible    = false;
            };

            Entry renameS = new Entry {
                Text = item.Name, Placeholder = "Section Title"
            };

            renameS.TextChanged += (sender, args) => { item.Name = renameS.Text; };

            StackLayout qStack = new StackLayout();

            qStack.IsVisible = false;

            foreach (Services.Question q in item.Questions)
            {
                qStack.Children.Add(GetQuestionView(q, item));
            }

            Button addQuestion = new Button {
                Text = "Add a Question"
            };

            addQuestion.IsVisible = false;
            addQuestion.Clicked  += (sender, args) => AddQuestion(qStack, item);

            Button hideS = new Button {
                Text = "Show"
            };

            hideS.Clicked += (sender, args) => {
                if (qStack.IsVisible)
                {
                    qStack.IsVisible      = false;
                    addQuestion.IsVisible = false;
                    hideS.Text            = "Show";
                }
                else
                {
                    qStack.IsVisible      = true;
                    addQuestion.IsVisible = true;
                    hideS.Text            = "Hide";
                }
            };

            Grid grid = new Grid();

            grid.Children.Add(deleteS, 0, 0);
            grid.Children.Add(hideS, 1, 0);

            secStack.Children.Add(grid);
            secStack.Children.Add(renameS);
            secStack.Children.Add(qStack);
            secStack.Children.Add(addQuestion);

            return(secStack);
        }
Esempio n. 3
0
        public FormEditorPage()
        {
            Title = "Form Editor";

            selectQuestionType.IsVisible = false;

            Services.DefaultReportForm defaultForm = new Services.DefaultReportForm();
            Services.Form form = new Services.Form(defaultForm.Lines);

            Button reset = new Button {
                Text = "Reset"
            };

            reset.Clicked += (sender, args) => { defaultForm.resetForm(); };

            Button save = new Button {
                Text = "Save"
            };

            save.Clicked += (sender, args) => { defaultForm.NewCustomForm(form); };

            StackLayout stack = new StackLayout();

            foreach (Services.Section item in form.Sections)
            {
                BoxView seper = new BoxView()
                {
                    Opacity = 0.5f, Color = Color.Gray, WidthRequest = 100, HeightRequest = 2
                };
                stack.Children.Add(seper);
                stack.Children.Add(getSectionView(item, form, seper));
            }


            Button addSection = new Button {
                Text = "Add Section"
            };

            addSection.Clicked += (sender, args) =>
            {
                Services.Section newSec = new Services.Section("");
                form.addSection(newSec);
                BoxView seper = new BoxView()
                {
                    Opacity = 0.5f, Color = Color.Gray, WidthRequest = 100, HeightRequest = 2
                };
                stack.Children.Add(seper);
                stack.Children.Add(getSectionView(newSec, form, seper));
            };

            Grid grid = new Grid();

            grid.Children.Add(save, 0, 0);
            grid.Children.Add(reset, 1, 0);

            ScrollView scrollView = new ScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        grid,
                        stack,
                        new BoxView()
                        {
                            Opacity = 0.5f,Color               = Color.Gray, WidthRequest = 100, HeightRequest = 2
                        },
                        addSection,
                        selectQuestionType
                    }
                }
            };

            Content = scrollView;
        }