Beispiel #1
0
        public void deleteInspector(object sender, EventArgs e)
        {
            BoundMenuItem <Inspector> item = (BoundMenuItem <Inspector>)sender;
            Inspector inspector            = item.BoundObject;

            Inspector.DeleteInspector(inspector);
            ResetInspectors();
        }
Beispiel #2
0
        public async void openEditInspectorPage(object sender, EventArgs e)
        {
            BoundMenuItem <Inspector> item = (BoundMenuItem <Inspector>)sender;
            Inspector         inspector    = item.BoundObject;
            EditInspectorPage page         = new EditInspectorPage(inspector);

            page.CallingPage = this;
            await App.Navigation.PushModalAsync(page);
        }
Beispiel #3
0
        public async void openEditPage(object sender, EventArgs e)
        {
            BoundMenuItem <Inspection> button = (BoundMenuItem <Inspection>)sender;
            Inspection         inspection     = button.BoundObject;
            EditInspectionPage page           = new EditInspectionPage(inspection);

            page.CallingPage = this;
            await App.Navigation.PushAsync(page);
        }
Beispiel #4
0
        public async void DeleteChecklist(object sender, EventArgs e)
        {
            BoundMenuItem <ChecklistModel> button = (BoundMenuItem <ChecklistModel>)sender;
            ChecklistModel checklist = button.BoundObject;
            bool           answer    = await DisplayAlert("Confirm Deletion", DependencyService.Get <IValuesHelper>().deleteChecklistWarning(checklist.Title), "Yes", "No");

            if (!answer)
            {
                return;
            }
            ChecklistModel.DeleteChecklist(checklist);
            checklists.Remove(checklist);
            ResetChecklists();
        }
Beispiel #5
0
        internal void ResetChecklists()
        {
            ActivityIndicator indicator = new ActivityIndicator()
            {
                IsEnabled = true,
                IsRunning = true,
                IsVisible = true,
                Color     = Color.Red,
            };
            TableView    checklistsView       = new TableView();
            TableRoot    root                 = new TableRoot("Select a Checklist");
            TableSection tempChecklistSection = new TableSection();

            checklistsView.Intent = TableIntent.Menu;
            //TableSection inspectorSection = new TableSection();
            List <ViewCell> cells = new List <ViewCell>();

            foreach (ChecklistModel checklist in checklists)
            {
                ChecklistButton button = new ChecklistButton();
                button.Clicked          += ChecklistHelper.ChecklistButtonClicked;
                button.Text              = checklist.Title;
                button.checklist         = checklist;
                button.HorizontalOptions = LayoutOptions.Start;

                ViewCell cell = new ViewCell
                {
                    View = button,
                };

                BoundMenuItem <ChecklistModel> Delete = new BoundMenuItem <ChecklistModel> {
                    Text = "Delete", BoundObject = checklist, IsDestructive = true
                };
                Delete.Clicked += DeleteChecklist;
                cell.ContextActions.Add(Delete);

                cells.Add(cell);
            }
            tempChecklistSection.Add(cells);
            tempChecklistSection.Add(ResetCell);
            root.Add(tempChecklistSection);
            checklistSection    = tempChecklistSection;
            checklistsView.Root = root;

            Content = checklistsView;
        }
Beispiel #6
0
        public void ResetInspections()
        {
            TableView view = new TableView();

            view.Intent = TableIntent.Menu;
            TableRoot       root    = new TableRoot("Inspections for " + Title);
            TableSection    section = new TableSection();
            List <ViewCell> cells   = new List <ViewCell>();

            foreach (Inspection inspection in checklist.Inspections)
            {
                ViewCell cell   = new ViewCell();
                Button   button = new InspectionButton(inspection);
                button.Clicked += InspectionHelper.SelectInspectionButtonClicked;
                cell.View       = button;

                BoundMenuItem <Inspection> Edit = new BoundMenuItem <Inspection> {
                    Text = "Edit", BoundObject = inspection
                };
                BoundMenuItem <Inspection> Delete = new BoundMenuItem <Inspection> {
                    Text = "Delete", BoundObject = inspection, IsDestructive = true
                };
                Edit.Clicked   += openEditPage;
                Delete.Clicked += deleteInspection;
                cell.ContextActions.Add(Edit);
                cell.ContextActions.Add(Delete);

                cells.Add(cell);
            }
            CreateInspectionButton createInspectionButton = new CreateInspectionButton(checklist);

            createInspectionButton.Text     = "Start new Inspection";
            createInspectionButton.Clicked += InspectionHelper.CreateInspectionButtonClicked;
            ViewCell createInspectionButtonView = new ViewCell();

            createInspectionButtonView.View = createInspectionButton;

            section.Add(cells);
            section.Add(createInspectionButtonView);
            root.Add(section);
            view.Root = root;

            Content = view;
        }
Beispiel #7
0
        public void ResetInspectors()
        {
            TableView inspectorsView = new TableView();

            inspectorsView.Intent = TableIntent.Menu;
            TableRoot       root    = new TableRoot();
            TableSection    section = new TableSection();
            List <ViewCell> cells   = new List <ViewCell>();

            foreach (Inspector inspector in App.database.LoadAllInspectors())
            {
                Button button = new Button();
                button.Text = inspector.Name;
                ViewCell cell = new ViewCell {
                    View = button
                };
                BoundMenuItem <Inspector> Edit = new BoundMenuItem <Inspector> {
                    Text = "Edit", BoundObject = inspector
                };
                BoundMenuItem <Inspector> Delete = new BoundMenuItem <Inspector> {
                    Text = "Delete", IsDestructive = true, BoundObject = inspector
                };
                Edit.Clicked   += openEditInspectorPage;
                Delete.Clicked += deleteInspector;
                cell.ContextActions.Add(Edit);
                cell.ContextActions.Add(Delete);
                cells.Add(cell);
            }

            Button createInspectorsButton = new Button();

            createInspectorsButton.Text     = "New Inspector";
            createInspectorsButton.Clicked += openCreateInspectorPage;
            cells.Add(new ViewCell {
                View = createInspectorsButton
            });

            section.Add(cells);
            root.Add(section);
            inspectorsView.Root = root;

            Content = inspectorsView;
        }
Beispiel #8
0
        public async void deleteInspection(object sender, EventArgs e)
        {
            //Warn that this is permanent.  Ask if they're sure.
            BoundMenuItem <Inspection> button = (BoundMenuItem <Inspection>)sender;
            Inspection inspection             = button.BoundObject;
            bool       answer = await DisplayAlert("Confirm Deletion", "Are you sure you want to delete " + inspection.Name + "?  All its data and scores will be lost.", "Yes", "No");

            if (!answer)
            {
                return;
            }
            Inspection.DeleteInspection(inspection);
            if (checklist.Inspections.Contains(inspection))
            {                   //This is supposed to be removed in the DeleteInspection method, but there appear to be multiple copies of som
                //objects in memory.
                checklist.Inspections.Remove(inspection);
            }
            ResetInspections();
        }
Beispiel #9
0
        public void ResetInspections()
        {
            TableView view = new TableView();

            view.Intent = TableIntent.Menu;
            TableRoot       root        = new TableRoot("Inspections list");
            TableSection    section     = new TableSection();
            List <ViewCell> cells       = new List <ViewCell>();
            double          columnWidth = (App.GetPageBounds().Width - 20) / 3;

            if (checklist.Inspections.Count > 0)
            {                   //Header cell
                ViewCell cell = new ViewCell();
                Grid     grid = new Grid();
                grid.Padding         = new Thickness(20, 0, 0, 0);
                grid.VerticalOptions = LayoutOptions.Center;
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth * 2, GridUnitType.Absolute)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth / 2, GridUnitType.Absolute)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth / 2, GridUnitType.Absolute)
                });

                grid.Children.Add(new Label
                {
                    Text = "Description",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    VerticalOptions   = LayoutOptions.Center
                }, 0, 0);
                grid.Children.Add(new Label
                {
                    Text = "Unit",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    VerticalOptions   = LayoutOptions.Center
                }, 1, 0);
                grid.Children.Add(new Label
                {
                    Text = "Date Started",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    VerticalOptions   = LayoutOptions.Center
                }, 2, 0);
                cell.View = grid;
                cells.Add(cell);
            }

            foreach (Inspection inspection in checklist.Inspections)
            {
                ViewCell cell = new ViewCell();
                BoundMenuItem <Inspection> Edit = new BoundMenuItem <Inspection> {
                    Text = "Edit", BoundObject = inspection
                };
                BoundMenuItem <Inspection> Delete = new BoundMenuItem <Inspection> {
                    Text = "Delete", BoundObject = inspection, IsDestructive = true
                };
                Edit.Clicked   += openEditPage;
                Delete.Clicked += deleteInspection;
                cell.ContextActions.Add(Edit);
                cell.ContextActions.Add(Delete);

                //Button button = new InspectionButton(inspection);
                //button.Clicked += InspectionHelper.SelectInspectionButtonClicked;
                //cell.View = button;

                InspectionGrid       grid       = new InspectionGrid(inspection);
                TapGestureRecognizer recognizer = new TapGestureRecognizer();
                recognizer.Tapped += InspectionHelper.SelectInspectionButtonClicked;
                grid.GestureRecognizers.Add(recognizer);
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth * 2, GridUnitType.Absolute)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth / 2, GridUnitType.Absolute)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(columnWidth / 2, GridUnitType.Absolute)
                });

                InspectionButton nameButton = new InspectionButton(inspection);
                nameButton.Text = inspection.Name;
                nameButton.HorizontalOptions = LayoutOptions.StartAndExpand;
                nameButton.Clicked          += InspectionHelper.SelectInspectionButtonClicked;
                InspectionButton orgButton = new InspectionButton(inspection);
                orgButton.Text = inspection.Organization;
                orgButton.HorizontalOptions = LayoutOptions.StartAndExpand;
                orgButton.Clicked          += InspectionHelper.SelectInspectionButtonClicked;
                InspectionButton dateButton = new InspectionButton(inspection);
                dateButton.HorizontalOptions = LayoutOptions.StartAndExpand;
                dateButton.Clicked          += InspectionHelper.SelectInspectionButtonClicked;
                if (inspection.Date == null)
                {
                    dateButton.Text = string.Empty;
                }
                else
                {
                    dateButton.Text = ((DateTime)inspection.Date).ToString("MM/dd/yyyy");
                }

                grid.Children.Add(
                    nameButton,
                    0, 0);
                grid.Children.Add(
                    orgButton,
                    1, 0);
                grid.Children.Add(
                    dateButton,
                    2, 0);
                grid.Padding = new Thickness(20, 0, 0, 0);

                cell.View = grid;
                cells.Add(cell);
            }
            CreateInspectionButton createInspectionButton = new CreateInspectionButton(checklist);

            createInspectionButton.Text     = "Begin a New Inspection";
            createInspectionButton.Clicked += InspectionHelper.CreateInspectionButtonClicked;
            ViewCell createInspectionButtonView = new ViewCell();

            createInspectionButtonView.View = createInspectionButton;

            section.Add(cells);
            section.Add(createInspectionButtonView);
            root.Add(section);
            view.Root = root;

            Content = view;
        }