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; }
public ChecklistMenuPage(ChecklistModel checklist) { this.checklist = checklist; Title = "Checklist Options"; TableView view = new TableView(); TableRoot root = new TableRoot(); TableSection section = new TableSection(); view.Intent = TableIntent.Menu; //New Inspection ViewCell newInspectionCell = new ViewCell(); StackLayout newInspectionLayout = new StackLayout { Padding = new Thickness(20, 0, 0, 0) }; CreateInspectionButton newInspectionButton = new CreateInspectionButton(checklist); newInspectionButton.HorizontalOptions = LayoutOptions.StartAndExpand; newInspectionButton.Clicked += InspectionHelper.CreateInspectionButtonClicked; newInspectionButton.Text = "Begin a New Inspection"; newInspectionLayout.Children.Add(newInspectionButton); newInspectionCell.View = newInspectionLayout; //Existing Inspection ViewCell existingInspectionCell = new ViewCell(); StackLayout existingInspectionLayout = new StackLayout { Padding = new Thickness(20, 0, 0, 0) }; ChecklistButton existingInspectionButton = new ChecklistButton(); existingInspectionButton.HorizontalOptions = LayoutOptions.StartAndExpand; existingInspectionButton.checklist = checklist; existingInspectionButton.Text = "Continue an Existing Inspection"; existingInspectionButton.Clicked += ChecklistHelper.InspectionListButtonClicked; existingInspectionLayout.Children.Add(existingInspectionButton); existingInspectionCell.View = existingInspectionLayout; //View References ViewCell viewReferencesCell = new ViewCell(); StackLayout viewReferencesLayout = new StackLayout { Padding = new Thickness(20, 0, 0, 0) }; ChecklistButton viewReferencesButton = new ChecklistButton(); viewReferencesButton.HorizontalOptions = LayoutOptions.StartAndExpand; viewReferencesButton.checklist = checklist; viewReferencesButton.Text = "View References"; viewReferencesButton.Clicked += ChecklistHelper.ReferenceListButtonClicked; viewReferencesLayout.Children.Add(viewReferencesButton); viewReferencesCell.View = viewReferencesLayout; //Full Reference List /*ViewCell referenceListCell = new ViewCell(); * Label referenceListLabel = new Label(); * referenceListLabel.Text = "View Full Reference List"; * referenceListCell.View = referenceListLabel;*/ section.Add(newInspectionCell); section.Add(existingInspectionCell); section.Add(viewReferencesCell); //section.Add(referenceListCell); root.Add(section); view.Root = root; Content = view; }
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; }