Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb =================================================================== diff -u -r1727 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1727) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1735) @@ -181,13 +181,17 @@ _domainController.SelectEmployee(employeeIndex, employee) 'Send message that the selected employee changed to all user controls. _employeeUserControls.ForEach(Sub(employeeUserControl) employeeUserControl.SelectedEmployeeChanged()) + 'Refresh the grids, so one can recolor. + RefreshUserGridsData() End Sub ''' Public Sub DeselectEmployee(employeeIndex As Integer) Implements IEmployeesMainForm.DeselectEmployee _domainController.DeselectEmployee(employeeIndex) 'Send message that the selected employee changed to all user controls. _employeeUserControls.ForEach(Sub(employeeUserControl) employeeUserControl.SelectedEmployeeChanged()) + 'Refresh the grids, so one can recolor. + RefreshUserGridsData() End Sub ''' Index: ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb =================================================================== diff -u -r1715 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1715) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1735) @@ -266,10 +266,10 @@ End Get End Property Public ReadOnly Property AllFinishedActivitiesColor As color - Private ReadOnly _colorsUsers As New List(Of Color) - Public ReadOnly Property ColorsUsers As List(Of Color) + Private ReadOnly _colorsEmployees As New List(Of Color) + Public ReadOnly Property ColorsEmployees As List(Of Color) Get - Return New List(Of Color)(_colorsUsers) + Return New List(Of Color)(_colorsEmployees) End Get End Property #End Region @@ -322,8 +322,8 @@ AddColorActivity(identifier, value, False) ElseIf identifier.Equals("ColorActivityAllFinished") Then _AllFinishedActivitiesColor = GetColorFromHexStringValue(value) - ElseIf identifier.Contains("ColorUser") Then - _colorsUsers.Add(GetColorFromHexStringValue(value)) + ElseIf identifier.Contains("ColorEmployee") Then + _colorsEmployees.Add(GetColorFromHexStringValue(value)) Else Throw New Exception($"Unknown configuration: '{line}'.") End If @@ -447,8 +447,8 @@ End If 'Colors users. - If _colorsUsers.Count < NumberOfEmployees Then - Throw New ConfigurationException($"The colors for the users are not defined or are fewer than the amount of users {NumberOfEmployees}.") + If _colorsEmployees.Count < NumberOfEmployees Then + Throw New ConfigurationException($"The colors for the employees are not defined or are fewer than the amount of users {NumberOfEmployees}.") End If End Sub Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStoppedState.vb =================================================================== diff -u -r1734 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStoppedState.vb (.../ActivityStoppedState.vb) (revision 1734) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStoppedState.vb (.../ActivityStoppedState.vb) (revision 1735) @@ -1,18 +1,16 @@ Public Class ActivityStoppedState inherits ActivityState - Private ReadOnly _employee As IEmployee - 'Not from other state. Public Sub New(activity As IActivity, employee As IEmployee) Me.Activity = activity - _employee = employee + CurrentEmployee = employee End Sub 'From other state. Public Sub New(state As ActivityState) Activity = state.Activity - _employee = state.GetEmployee() + CurrentEmployee = state.GetEmployee() End Sub ''' @@ -22,7 +20,7 @@ ''' Public Overrides Function GetEmployee() As IEmployee - Return _employee + Return CurrentEmployee End Function ''' Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb =================================================================== diff -u -r1723 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb (.../EmployeeManager.vb) (revision 1723) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb (.../EmployeeManager.vb) (revision 1735) @@ -68,6 +68,9 @@ Throw New Exception($"An employee was already chosen for number (index): {employeeNumber}.") End If + 'Update the employeeNumber in the employee. + employee.Number = employeeNumber + 'Add employee to dictionary of selected employees -> set the value according to an employee number. _selectedEmployeesDictionary.Item(employeeNumber) = employee End Sub @@ -80,6 +83,10 @@ 'The employee was not selected, thus can't be deselected. Throw New Exception("Cannot remove the selection of a non-selected employee.") End If + + 'Update the employee number of the employee. + _selectedEmployeesDictionary.Item(employeeNumber).Number = -1 + 'Remove the employee -> set the value back to 'Nothing'. _selectedEmployeesDictionary.Item(employeeNumber) = Nothing End Sub Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/employee/EmployeeUserControl.vb =================================================================== diff -u -r1727 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/employee/EmployeeUserControl.vb (.../EmployeeUserControl.vb) (revision 1727) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/employee/EmployeeUserControl.vb (.../EmployeeUserControl.vb) (revision 1735) @@ -52,7 +52,7 @@ ''' Private Sub EmployeeUserControl_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint 'Border color. - Dim borderColor = ConfigsLoader.ColorsUsers(EmployeeIndex) + Dim borderColor = ConfigsLoader.ColorsEmployees(EmployeeIndex) 'Border thickness. Const borderThickness As Integer = 5I 'Border rectangle. @@ -71,11 +71,8 @@ _currentUserControl = userControl 'Remove the current user control from the screen. UserControlPanel.Controls.Clear() - 'Set the properties of the user control. - With userControl - 'Make it exactly as big as the panel it will go into. - .Size = UserControlPanel.Size - End With + 'Make it exactly as big as the panel it will go into. + userControl.Size = UserControlPanel.Size 'Add it onto the panel. UserControlPanel.Controls.Add(userControl) End Sub Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb =================================================================== diff -u -r1734 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb (.../ActivityStartedState.vb) (revision 1734) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb (.../ActivityStartedState.vb) (revision 1735) @@ -1,18 +1,16 @@ Public Class ActivityStartedState Inherits ActivityState - Private ReadOnly _employee As IEmployee - 'Not from other state. Public Sub New(activity As IActivity, employee As IEmployee) Me.Activity = activity - _employee = employee + Me.CurrentEmployee = employee End Sub 'From other state. Public Sub New(state As ActivityState, employee As IEmployee) Activity = state.Activity - _employee = employee + Me.CurrentEmployee = employee End Sub ''' @@ -22,12 +20,12 @@ ''' Public Overrides Function GetEmployee() As IEmployee - Return _employee + Return CurrentEmployee End Function ''' Public Overrides Sub StopActivity(employee As IEmployee) - If Not _employee.Equals(employee) Then + If Not CurrentEmployee.Equals(employee) Then 'Different employee. Throw New Exception($"A different employee can't stop a started activity. Current activity belongs to {employee.ToString()}") End If @@ -36,7 +34,7 @@ ''' Public Overrides Sub FinishActivity(employee As IEmployee) - If Not _employee.Equals(employee) Then + If Not CurrentEmployee.Equals(employee) Then 'Different employee. Throw New Exception($"A different employee can't finish a started activity. Current activity belongs to {employee.ToString()}") End If Index: ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb =================================================================== diff -u -r1733 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1733) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1735) @@ -172,7 +172,6 @@ .Id = ExtractItemFromDataReader(dr, $"ActiviteitID_{i}", String.Empty) .QuantityToProduce = ExtractItemFromDataReader(dr, $"Aantal_{i}", 0) .Label = ExtractItemFromDataReader(dr, $"Label_{i}", String.Empty) - .EmployeeInitials = ExtractItemFromDataReader(dr, $"Gebruiker_{i}", String.Empty) .IsReadOnly = ExtractItemFromDataReader(dr, $"ReadOnly_{i}", False) .StartTimeStamp = ExtractItemFromDataReader(dr, $"StartTijdstip_{i}", DateTime.MinValue) 'Subtract time when date was specified. Time is gotten from config. @@ -182,7 +181,8 @@ .WorkItem = workItem 'Fetch the employee if defined. - Dim employee As IEmployee = employees.FirstOrDefault(Function(employeeToCheck) employeeToCheck.Initials.Equals(.EmployeeInitials)) + Dim employeeInitials = ExtractItemFromDataReader(dr, $"Gebruiker_{i}", String.Empty) + Dim employee As IEmployee = If(employeeInitials.Equals(string.Empty), Nothing,employees.FirstOrDefault(Function(employeeToCheck) employeeToCheck.Initials.Equals(employeeInitials))) 'Set the current state based on the enum value. If the quantity is 0, the status is automatically zero. .State = ConvertEnumValueToActivityState(If(.QuantityToProduce = 0, ActivityStateEnum.Zero, ActivityStateEnumMapper.GetActivityStateFromLetter(ExtractItemFromDataReader(Of Char)(dr, $"Status_{i}"))), activity, employee) End With Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb =================================================================== diff -u -r1723 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1723) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1735) @@ -61,7 +61,7 @@ 'Set properties of datagrid view. 'Background color. - WorkItemsDataGridView.BackgroundColor = color.White + WorkItemsDataGridView.BackgroundColor = Color.White 'Cell makeup. 'Center header cells. @@ -265,7 +265,8 @@ UpdateActivityCellTimeStatusIndication(activity, cell) 'Update background color. UpdateActivityCellBackground(workItem, activity, cell) - 'todo Update border based on user + 'Update border based on employee. + UpdateActivityCellBorder(workItem, activity, cell) Next End Sub @@ -304,7 +305,7 @@ End Sub ''' - ''' + ''' Update the background of the cell based on the activity status. ''' ''' ''' @@ -326,6 +327,26 @@ End Sub ''' + ''' Update the border of the cell. Depends on the state and the employee. + ''' + ''' + ''' + ''' + Private Sub UpdateActivityCellBorder(workItem As IWorkItem, activity As IActivity, dataGridViewCell As DataGridViewCell) + If activity.Status = ActivityStateEnum.Started AndAlso activity.CurrentEmployee.Number <> -1 Then + 'The employee is selected for this activity in the started state. + 'Only this type of cell is supported. + If Not TypeOf dataGridViewCell Is BorderedTextFigureCell Then Throw New InternalException($"Only cells of type {TypeName(New BorderedTextFigureCell)} are supported when updating the cell for an activity.") + + 'Cast cell as right type. + Dim cell As BorderedTextFigureCell = dataGridViewCell + + cell.BorderColor = ConfigsLoader.ColorsEmployees(activity.CurrentEmployee.Number) + cell.BorderThickness = 3 'todo Configureerbaar maken + End If + End Sub + + ''' ''' Disable the selection changed event, useful for ignoring triggers by adding new rows. ''' Private _skipSelectionChanged = False Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityFinishedState.vb =================================================================== diff -u -r1730 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityFinishedState.vb (.../ActivityFinishedState.vb) (revision 1730) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityFinishedState.vb (.../ActivityFinishedState.vb) (revision 1735) @@ -3,22 +3,25 @@ Public Class ActivityFinishedState Inherits ActivityState - Private ReadOnly _employee As IEmployee - 'Not from other state. Public Sub New(activity As IActivity, employee As IEmployee) Me.Activity = activity - _employee = employee + CurrentEmployee = employee End Sub 'From other state. Public Sub New(state As ActivityState) Activity = state.Activity - _employee = state.GetEmployee() + CurrentEmployee = state.GetEmployee() End Sub ''' Public Overrides Function ActivityStateEnum() As ActivityStateEnum Return ActiviteitenOpvolging.ActivityStateEnum.Finished End Function + + ''' + Public Overrides Function GetEmployee() As IEmployee + Return CurrentEmployee + End Function End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IEmployee.vb =================================================================== diff -u -r1730 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IEmployee.vb (.../IEmployee.vb) (revision 1730) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IEmployee.vb (.../IEmployee.vb) (revision 1735) @@ -7,6 +7,12 @@ Property CurrentActivity As IActivity + ''' + ''' If an employee gets selected, it receives a number. + ''' + ''' + Property Number As Integer + Function Equals(obj As Object) As Boolean Function ToString() As String End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb =================================================================== diff -u -r1729 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb (.../ActivityState.vb) (revision 1729) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb (.../ActivityState.vb) (revision 1735) @@ -3,6 +3,17 @@ Public Activity As IActivity + Dim _employee As IEmployee + Protected Property CurrentEmployee As IEmployee + Set(value As IEmployee) + _employee = value + _employee.CurrentActivity = Activity + End Set + Get + Return _employee + End Get + End Property + ''' ''' The for the current state. ''' Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Employee.vb =================================================================== diff -u -r1730 -r1735 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Employee.vb (.../Employee.vb) (revision 1730) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Employee.vb (.../Employee.vb) (revision 1735) @@ -9,6 +9,9 @@ Public Property Initials As String Implements IEmployee.Initials Public Property CurrentActivity As IActivity Implements IEmployee.CurrentActivity + ''' + Public Property Number As Integer = -1 Implements IEmployee.Number + Public Overrides Function Equals(obj As Object) As Boolean Implements IEmployee.Equals If Not TypeOf obj Is IEmployee Then 'Not the right type. @@ -20,7 +23,7 @@ Return employee.Initials.Equals(Initials, StringComparison.CurrentCultureIgnoreCase) End Function - Public overrides Function ToString() As String Implements IEmployee.ToString + Public Overrides Function ToString() As String Implements IEmployee.ToString Return $"Employee: {FirstName} {LastName} ({Initials})" End Function End Class