Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb =================================================================== diff -u -r1687 -r1690 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1687) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1690) @@ -51,6 +51,12 @@ 'Show the work items. ShowWorkItems(workItems) + + 'Color the work items. + ColorWorkItems(workItems) + + 'Update enable status of cells and columns. + UpdateEnableStatus(workItems) Catch ex As Exception MessageBox.Show($"Could not load {Me.Name}.{vbNewLine}{ex.Message}", "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try @@ -61,7 +67,7 @@ ''' Private Sub UpdateStaticColumns() Dim names = ConfigsLoader.GridColumnHeaderNames().Item(_gridNumber) - For i = 0 To names.Count() -1 + For i = 0 To names.Count() - 1 'Fetch name. Dim headerText = names(i) 'Check if it's not hidden. @@ -137,15 +143,47 @@ Catch ex As Exception Throw New Exception($"Could not show work items.{vbNewLine}{ex.Message}") End Try - 'Color the work items. - ColorWorkItems(workItems) End Sub ''' ''' Set all the right colors for the work items. ''' ''' Private Sub ColorWorkItems(workItems As List(Of IWorkItem)) + 'Loop for every work item (need access to index because of row index in data grid) + For i = 0 To workItems.Count - 1 + 'Get the work item. + Dim workItem = workItems.Item(i) + 'Update due out color. + UpdateDueOutCellColor(workItem, i) + Next + End Sub + ''' + ''' Update the color of a cell in the due out column. + ''' + ''' + ''' + Private Sub UpdateDueOutCellColor(workItem As IWorkItem, index As Integer) + 'Fetch the right cell. + Dim cell = WorkItemsDataGridView.Rows.Item(index).Cells(DueOut.Index) + + 'If all activities of a batch have status "F" (excluding ReadOnly Activities) => AgColorDueOutDefault + If workItem.Activities.All(Function(activity) activity.Status = ActivityStateEnum.Finished And activity.IsReadOnly = False) Then + cell.Style.BackColor = ConfigsLoader.ColorsDueOut(DueOutStateEnum.Defaulted) + Return + End If + + 'If the StartBefore, StartAlmost and Start timestamps are not present in any of the activities, no colors are used. + if workItem.Activities.All() + End Sub + + ''' + ''' Update the enable status of columns and cells. + ''' + ''' + Private Sub UpdateEnableStatus(workItems As List(Of IWorkItem)) + 'todo Update the enable status of columns and cells. + End Sub End Class