Exemple #1
0
        private void ChangeSection(object sender, EventArgs e)
        {
            GenericPicker <SectionModel> picker = (GenericPicker <SectionModel>)sender;
            SectionModel section      = picker.SelectedItem;
            double       sectionScore = ScoringHelper.ScoreSection(section, inspection).Item3;

            sectionScoreLabel.Text = "Section score: " + (sectionScore * 100).ToString("0.00") + "%";
            setScoresColor(sectionScore, sectionScoreLabel);
            if (section.SectionParts.Count == 0)
            {
                partPicker.IsVisible     = false;
                partScoreLabel.IsVisible = false;
            }
            else
            {
                partPicker.SelectedIndexChanged -= ChangePart;
                partPicker.IsVisible             = true;
                partScoreLabel.IsVisible         = true;
                partPicker.ClearItems();
                foreach (SectionPart part in section.SectionParts)
                {
                    partPicker.AddItem(part);
                }
                partPicker.SelectedIndexChanged += ChangePart;
                partPicker.SelectedIndex         = 0;
            }
        }
Exemple #2
0
        private void ChangePart(object sender, EventArgs e)
        {
            GenericPicker <SectionPart> picker = (GenericPicker <SectionPart>)sender;

            if (picker.SelectedIndex >= picker.Items.Count || picker.SelectedIndex < 0)
            {
                //this is a fix for a bug where the event listener is still listening even though it's been unassigned.
                return;
            }
            SectionPart part      = picker.SelectedItem;
            double      partScore = ScoringHelper.ScorePart(part, inspection).Item3;

            partScoreLabel.Text = "Part score: " + (partScore * 100).ToString("0.00") + "%";
            setScoresColor(partScore, partScoreLabel);
        }
Exemple #3
0
        //ResizingLayout layout;

        public CommentPage(Inspection inspection, Question initialQuestion)
        {
            this.inspection = inspection;
            ChecklistModel checklist = inspection.Checklist;

            this.Title = "Add/Edit Comment";

            StackLayout layout = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            Page   frontPage = App.Navigation.NavigationStack.First();
            double width     = frontPage.Width;

            layout.WidthRequest = width * .95;

            //Choose comment type
            Label chooseCommentTypeLabel = new Label {
                Text = "Choose comment type"
            };

            commentTypePicker = new GenericPicker <CommentType>();
            commentTypePicker.AddItem(CommentType.Finding);
            commentTypePicker.AddItem(CommentType.Observation);
            commentTypePicker.AddItem(CommentType.Commendable);
            commentTypePicker.SelectedIndexChanged += SelectCommentType;

            //Choose question
            Label chooseQuestionLabel = new Label {
                Text = "Choose question"
            };

            questionPicker = new GenericPicker <Question>();
            foreach (Question question in checklist.GetAllQuestions().Where(q => !q.HasSubItems))
            {
                questionPicker.AddItem(question);
            }
            questionPicker.SelectedIndexChanged += SelectQuestion;

            //Comment description
            Label commentSubjectLabel = new Label {
                Text = "Subject"
            };

            subjectTextEditor = new Editor();
            subjectTextEditor.HeightRequest = 80;

            //Enter comment
            commentIndicatorLabel = new Label {
                Text = "Comment:"
            };
            commentText = new Editor();
            commentText.HeightRequest = 80;

            //Discussion
            Label DiscussionLabel = new Label {
                Text = "Discussion:"
            };

            discussionText = new Editor();
            discussionText.HeightRequest = 80;

            //Recommendation
            Label RecommendationLabel = new Label {
                Text = "Recommendation/Action Taken or Required:"
            };

            recommendationText = new Editor();
            recommendationText.HeightRequest = 80;

            //Choose date
            Label chooseDateLabel = new Label {
                Text = "Date:"
            };
            DatePicker date = new DatePicker();

            date.Date = DateTime.Now;

            //Save button
            Button saveButton = new Button {
                Text = "Save Comment"
            };

            saveButton.Clicked += SaveComment;

            //Delete button
            Button deleteButton = new Button {
                Text = "Delete Comment"
            };

            deleteButton.Clicked += DeleteComment;

            //TODO: choose inspector
            //TODO more fields, I guess.

            //Perform the setup actions.
            commentTypePicker.SelectedIndex = 0;
            questionPicker.SelectedIndex    = questionPicker.TItems.IndexOf(initialQuestion);

            layout.Children.Add(chooseCommentTypeLabel);
            layout.Children.Add(commentTypePicker);
            layout.Children.Add(chooseQuestionLabel);
            layout.Children.Add(questionPicker);
            layout.Children.Add(commentSubjectLabel);
            layout.Children.Add(subjectTextEditor);
            layout.Children.Add(commentIndicatorLabel);
            layout.Children.Add(commentText);
            layout.Children.Add(DiscussionLabel);
            layout.Children.Add(discussionText);
            layout.Children.Add(RecommendationLabel);
            layout.Children.Add(recommendationText);
            layout.Children.Add(chooseDateLabel);
            layout.Children.Add(date);
            layout.Children.Add(saveButton);
            layout.Children.Add(deleteButton);

            ScrollView scroll = new ScrollView();

            scroll.Content = layout;

            this.Content = scroll;
        }
Exemple #4
0
        public ScoresPage(Inspection inspection, Question initialQuestion)
        {
            this.inspection = inspection;
            ChecklistModel checklist = inspection.Checklist;

            scoresThreshold = new Threshold(checklist.ScoreThresholdCommendable, checklist.ScoreThresholdSatisfactory);
            Padding         = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

            this.Title = "Scores";
            ScoresLayout layout = new ScoresLayout
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            Label label = new Label
            {
                Text = "Choose section and part to see scores"
            };
            //add all the other stuff.
            GenericPicker <SectionModel> sectionPicker = new GenericPicker <SectionModel>();

            foreach (SectionModel section in inspection.Checklist.Sections)
            {
                sectionPicker.AddItem(section);
            }
            partPicker = new GenericPicker <SectionPart>();
            foreach (SectionPart part in initialQuestion.section.SectionParts)
            {
                partPicker.AddItem(part);
            }
            Button backButton = new Button
            {
                Text = "Back"
            };

            sectionScoreLabel = new Label
            {
                Text      = "Section label",
                TextColor = Color.White
            };
            partScoreLabel = new Label
            {
                Text      = "Part label",
                TextColor = Color.White
            };
            backButton.Clicked += BackButtonClicked;
            layout.Children.Add(label);
            layout.Children.Add(sectionPicker);
            layout.Children.Add(sectionScoreLabel);
            layout.Children.Add(partPicker);
            layout.Children.Add(partScoreLabel);
            double cumulativeScore      = ScoringHelper.ScoreInspection(inspection).Item3;
            Label  cumulativeScoreLabel = new Label
            {
                Text      = "Cumulative Score: " + (cumulativeScore * 100).ToString("0.00") + "%",
                TextColor = Color.White
            };

            setScoresColor(cumulativeScore, cumulativeScoreLabel);
            layout.Children.Add(cumulativeScoreLabel);
            layout.Children.Add(backButton);

            this.Content = layout;

            sectionPicker.SelectedIndexChanged += ChangeSection;
            sectionPicker.SelectedIndex         = sectionPicker.TItems.IndexOf(initialQuestion.section);
            partPicker.SelectedIndexChanged    += ChangePart;
            if (initialQuestion.part != null)
            {
                partPicker.SelectedIndex = partPicker.TItems.IndexOf(initialQuestion.part);
            }
        }
        public EditInspectionPage(Inspection existingInspection = null, ChecklistModel checklist = null)
        {
            Padding = new Thickness(0, 5, 0, 0);
            if (existingInspection == null)
            {
                inspection             = new Inspection();
                inspection.Checklist   = checklist;
                inspection.ChecklistId = checklist.Id;
                Title = "Create new Inspection";
                selectedInspectors = new List <Inspector>();
            }
            else
            {
                inspection         = existingInspection;
                selectedInspectors = inspection.inspectors;
                Title = "Edit Inspection";
            }
            TableView    view    = new TableView();
            TableRoot    root    = new TableRoot("Edit Inspection");
            TableSection section = new TableSection();
            StackLayout  layout  = new StackLayout();

            StackLayout nameLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label {
                        Text = "Inspection Name:"
                    }
                }
            };
            Entry nameEntry = new Entry();

            nameEntry.WidthRequest   = 300;
            nameEntry.BindingContext = inspection;
            nameEntry.SetBinding(Entry.TextProperty, "Name");
            nameLayout.Children.Add(nameEntry);
            EntryCell NameCell = new EntryCell
            {
                BindingContext = inspection,
                Label          = "Inspection Name:",
            };

            NameCell.SetBinding(EntryCell.TextProperty, "Name");

            EntryCell OrganizationCell = new EntryCell
            {
                BindingContext = inspection,
                Label          = "Organization:",
            };

            OrganizationCell.SetBinding(EntryCell.TextProperty, "Organization");
            StackLayout orgLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label {
                        Text = "Organization:"
                    }
                }
            };
            Entry orgEntry = new Entry();

            orgEntry.BindingContext = inspection;
            orgEntry.SetBinding(Entry.TextProperty, "Organization");
            orgEntry.WidthRequest = 300;
            orgLayout.Children.Add(orgEntry);

            inspectorPicker     = new GenericPicker <Inspector>();
            availableInspectors = App.database.LoadAllInspectors();
            availableInspectors.Add(Inspector.Null);
            foreach (Inspector selectedInspector in selectedInspectors)
            {
                availableInspectors.RemoveAll(i => i.Id == selectedInspector.Id);
            }
            selectedInspectors.Add(Inspector.Null);
            foreach (Inspector inspector in availableInspectors)
            {
                inspectorPicker.AddItem(inspector);
            }
            if (inspection.inspectors.Any())
            {
                try
                {
                    inspectorPicker.SelectedItem = inspection.inspectors.First();
                }
                catch (KeyNotFoundException) { }
            }
            ViewCell inspectorCell = new ViewCell {
                View = inspectorPicker
            };

            ViewCell    inspectorsCell   = new ViewCell();
            StackLayout inspectorsLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(5, 0),
            };
            StackLayout availableLayout = new StackLayout();
            Rectangle   bounds          = App.GetPageBounds();

            availableLayout.WidthRequest  = (bounds.Width / 2) - 5;
            availableLayout.HeightRequest = 400;
            StackLayout selectedLayout = new StackLayout();

            selectedLayout.WidthRequest  = (bounds.Width / 2) - 5;
            selectedLayout.HeightRequest = 400;
            Label availableLabel = new Label {
                Text = "Available Inspectors"
            };
            Label selectedLabel = new Label {
                Text = "Selected Inspectors"
            };

            availableLayout.Children.Add(availableLabel);
            selectedLayout.Children.Add(selectedLabel);
            inspectorsLayout.Children.Add(availableLayout);
            inspectorsLayout.Children.Add(selectedLayout);
            inspectorsCell.View = inspectorsLayout;

            availableListView = CreateInspectorsListView(availableInspectors);
            selectedListView  = CreateInspectorsListView(selectedInspectors);
            availableLayout.Children.Add(availableListView);
            selectedLayout.Children.Add(selectedListView);

            ViewCell SaveCell = new ViewCell();
            //ViewCell CancelCell = new ViewCell();
            Button saveButton = new Button();

            //Button cancelButton = new Button();
            saveButton.Clicked += SaveInspectionClicked;
            //cancelButton.Clicked += CancelInspectionClicked;
            saveButton.Text = "Save";
            //cancelButton.Text = "Cancel";
            SaveCell.View = saveButton;
            //CancelCell.View = cancelButton;

            section.Add(NameCell);
            layout.Children.Add(nameLayout);
            section.Add(OrganizationCell);
            layout.Children.Add(orgLayout);
            section.Add(inspectorCell);
            layout.Children.Add(inspectorsLayout);
            section.Add(inspectorsCell);
            section.Add(SaveCell);
            layout.Children.Add(saveButton);
            //section.Add(CancelCell);
            root.Add(section);
            view.Root = root;
            //view.Intent = TableIntent.Form;
            //view.HasUnevenRows = true;
            Content = layout;
            //Content = view;
        }
Exemple #6
0
        //ResizingLayout layout;

        public CommentPage(Inspection inspection, Question initialQuestion)
        {
            this.inspection = inspection;
            ChecklistModel checklist = inspection.Checklist;

            this.Title = "Add/Edit Comment";

            StackLayout layout = new StackLayout
            {
                Padding = new Thickness(20, 28)
            };
            Page   frontPage = App.Navigation.NavigationStack.First();
            double width     = frontPage.Width;

            layout.WidthRequest = width * .95;

            //Choose comment type
            Label chooseCommentTypeLabel = new Label {
                Text = "Choose Comment Type:", FontAttributes = FontAttributes.Bold
            };

            commentTypePicker = new GenericPicker <CommentType>();
            commentTypePicker.AddItem(CommentType.Finding);
            commentTypePicker.AddItem(CommentType.Observation);
            commentTypePicker.AddItem(CommentType.Commendable);
            commentTypePicker.SelectedIndexChanged += SelectCommentType;

            //Choose question
            Label chooseQuestionLabel = new Label {
                Text = "Choose Question:", FontAttributes = FontAttributes.Bold
            };

            questionPicker = new GenericPicker <Question>();
            foreach (Question question in checklist.GetAllQuestions().Where(q => !q.HasSubItems))
            {
                questionPicker.AddItem(question);
            }
            questionPicker.SelectedIndexChanged += SelectQuestion;

            //Comment description
            Label commentSubjectLabel = new Label {
                Text = "Subject:", FontAttributes = FontAttributes.Bold
            };

            subjectTextEditor = new Editor();
            subjectTextEditor.HeightRequest = 80;

            //Enter comment
            commentIndicatorLabel = new Label {
                Text = "Comment:", FontAttributes = FontAttributes.Bold
            };
            commentText = new Editor();
            commentText.HeightRequest = 80;

            //Discussion
            Label DiscussionLabel = new Label {
                Text = "Discussion:", FontAttributes = FontAttributes.Bold
            };

            discussionText = new Editor();
            discussionText.HeightRequest = 80;

            //Recommendation
            Label RecommendationLabel = new Label {
                Text = "Recommendation/Action Taken or Required:", FontAttributes = FontAttributes.Bold
            };

            recommendationText = new Editor();
            recommendationText.HeightRequest = 80;

            //Choose date
            Label chooseDateLabel = new Label {
                Text = "Date:", FontAttributes = FontAttributes.Bold
            };
            DatePicker date = new DatePicker()
            {
                Format = "MMMM dd, yyyy", HorizontalOptions = LayoutOptions.Start
            };

            date.Date = DateTime.Now;

            //Save button
            Button saveButton = new Button {
                Text = "Save Comment"
            };

            saveButton.Clicked += SaveComment;

            //Delete button
            Button deleteButton = new Button {
                Text = "Delete Comment"
            };

            deleteButton.Clicked += DeleteComment;

            //TODO: choose inspector
            //TODO more fields, I guess.

            //Perform the setup actions.
            commentTypePicker.SelectedIndex = 0;
            questionPicker.SelectedIndex    = questionPicker.TItems.IndexOf(initialQuestion);

            double spaceBetweenQuestions = 2;

            layout.Children.Add(
                new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new StackLayout {
                        WidthRequest = width * 2 / 3,
                        Children     =
                        {
                            chooseCommentTypeLabel,
                            commentTypePicker
                        }
                    },
                    LayoutHelper.GetHorizontalSpacing(10),
                    new StackLayout {
                        WidthRequest = width * 1 / 3,
                        Children     =
                        {
                            chooseDateLabel,
                            date
                        }
                    },
                }
            });

            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(chooseQuestionLabel);
            layout.Children.Add(questionPicker);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(commentSubjectLabel);
            layout.Children.Add(subjectTextEditor);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(commentIndicatorLabel);
            layout.Children.Add(commentText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(DiscussionLabel);
            layout.Children.Add(discussionText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(RecommendationLabel);
            layout.Children.Add(recommendationText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(
                new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    saveButton,
                    LayoutHelper.GetHorizontalSpacing(30),
                    deleteButton
                }
            });

            ScrollView scroll = new ScrollView();

            scroll.Content = layout;

            this.Content = scroll;
        }