Index: ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb
===================================================================
diff -u -r1692 -r1693
--- ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1692)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1693)
@@ -5,7 +5,7 @@
Namespace configs
Public Module ConfigsLoader
Const MaxIntervalSeconds As Integer = 3600 'Max of 6 hours
- Const GridColumnAmount As Integer = 5 'Batch, DueOut, Product, Naar, Opmerking
+ public Const GridColumnAmount As Integer = 5 'Batch, DueOut, Product, Naar, Opmerking
Sub New()
Try
@@ -72,20 +72,22 @@
#Region "Properties"
Public ReadOnly Property AppName As String
Public ReadOnly Property AppId As String
+ Public ReadOnly Property AppWidth As Integer
+ Public ReadOnly Property AppHeight As Integer
Public ReadOnly Property NumberOfGrids As Integer
Private ReadOnly _gridLabelNames As New List(Of String)
Public ReadOnly Property GridLabelNames As List(Of String)
Get
Return New List(Of String)(_gridLabelNames)
End Get
End Property
- private ReadOnly _gridWidths As New List(Of Integer)
+ Private ReadOnly _gridWidths As New List(Of Integer)
Public ReadOnly Property GridWidths As List(Of Integer)
Get
Return New List(Of Integer)(_gridWidths)
End Get
End Property
- private ReadOnly _gridHeights As New List(Of Integer)
+ Private ReadOnly _gridHeights As New List(Of Integer)
Public ReadOnly Property GridHeights As List(Of Integer)
Get
Return New List(Of Integer)(_gridHeights)
@@ -128,6 +130,14 @@
_AppName = value
ElseIf identifier.Equals("AppID") Then
_AppId = value
+ ElseIf identifier.Equals("AppDimension") Then
+ 'Split into width and height.
+ Dim values = value.Split("x")
+ 'Check if there are two values.
+ If values.Count() <> 2 Then Throw New ConfigurationException("The dimensions of the program have an invalid format.")
+ 'Save values.
+ _AppWidth = values(0) 'Width
+ _AppHeight = values(1) 'Height
ElseIf identifier.Equals("NumberOfGrids") Then
_NumberOfGrids = value
ElseIf identifier.Contains("GridLabel") Then
@@ -136,7 +146,7 @@
'Split into width and height.
Dim values = value.Split("x")
'Check if there are two values.
- if values.Count() <> 2 Then Throw new ConfigurationException("The dimensions of a grid have an invalid format.")
+ If values.Count() <> 2 Then Throw New ConfigurationException("The dimensions of a grid have an invalid format.")
'Save values.
_gridWidths.Add(values(0)) 'Width
_gridHeights.Add(values(1)) 'Height
@@ -169,6 +179,18 @@
If AppId Is Nothing OrElse AppId.Equals(String.Empty) Then
Throw New ConfigurationException("App id is not defined or invalid.")
End If
+ 'App width.
+ If AppWidth = 0 Then
+ Throw New ConfigurationException("The app width is not defined or too small.")
+ ElseIf AppWidth < 0 Then
+ Throw New ConfigurationException("The app width is too small.")
+ End If
+ 'App height.
+ If AppHeight = 0 Then
+ Throw New ConfigurationException("The app height is not defined or too small.")
+ ElseIf AppHeight < 0 Then
+ Throw New ConfigurationException("The app height is too small.")
+ End If
'Number of grids.
If _NumberOfGrids <= 0 Then
Throw New ConfigurationException("Number of grids is not defined or invalid.")
@@ -180,10 +202,14 @@
Throw New ConfigurationException("The amount of 'grid labels' is not equal to the 'number of grids'.")
End If
'Grid dimensions.
- If _gridWidths.Count = 0 or _gridHeights.Count = 0 then
+ If _gridWidths.Count = 0 Or _gridHeights.Count = 0 Then
Throw New ConfigurationException("There are no grid dimensions defined.")
- ElseIf _gridWidths.Count <> NumberOfGrids or _gridHeights.Count <> NumberOfGrids Then
+ ElseIf _gridWidths.Count <> NumberOfGrids Or _gridHeights.Count <> NumberOfGrids Then
Throw New ConfigurationException("The amount of 'grid dimensions' is not equal to the 'number of grids'.")
+ ElseIf _gridWidths.Any(Function(width) width <= 0) Then
+ Throw New ConfigurationException("One or more of the 'grid dimensions' has a width that is too small.")
+ ElseIf _gridHeights.Any(Function(height) height <= 0) Then
+ Throw New ConfigurationException("One or more of the 'grid dimensions' has a height that is too small.")
End If
'Column headers of grids.
If _gridsColumnHeaderNames.Count = 0 Then
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb
===================================================================
diff -u -r1691 -r1693
--- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1691)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1693)
@@ -35,41 +35,56 @@
BackColor = Color.White
ForeColor = Color.Black
+ 'Set properties of datagrid view.
+
+ 'Cell makeup.
+ 'Center header cells.
+ WorkItemsDataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
+ 'Make header text bigger.
+ WorkItemsDataGridView.ColumnHeadersDefaultCellStyle.Font = New Font("Microsoft Sans Serif", 10)
+ 'Center normal cells.
+ WorkItemsDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
+ 'Make text bigger of normal cells.
+ WorkItemsDataGridView.DefaultCellStyle.Font = New Font("Microsoft Sans Serif", 9.5)
+
+ 'Disable autogeneration of columns.
+ WorkItemsDataGridView.AutoGenerateColumns = False
+ 'Disable resizing of rows and columns.
+ WorkItemsDataGridView.AllowUserToResizeColumns = False
+ WorkItemsDataGridView.AllowUserToResizeRows = False
+ 'Make columns fill space -> removes horizontal scrollbar.
+ WorkItemsDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
+ 'Disable multiselect cells.
+ WorkItemsDataGridView.MultiSelect = False
+ 'Remove empty row at the bottom.
+ WorkItemsDataGridView.AllowUserToAddRows = False
+ 'Hide the selectors in front of a row.
+ WorkItemsDataGridView.RowHeadersVisible = False
+ 'Edit row height before generating new rows.
+ WorkItemsDataGridView.RowTemplate.Height = 30
+
'Set label.
GridLabel.Text = ConfigsLoader.GridLabelNames(_gridNumber)
+ 'Changes to data grid can trigger selectio changed event, ignore for now.
+ _skipSelectionChanged = True
+
'Update headers and visibility of static columns.
UpdateStaticColumns()
'Load all work items.
- Dim workItems = LoadWorkItems()
+ LoadWorkItems()
'Generate grid columns for the activities of the work items.
- GenerateActivityColumns(workItems)
+ GenerateActivityColumns(_workItems)
'Show the work items.
- ShowWorkItems(workItems)
+ ShowWorkItems(_workItems)
'Color the work items.
- ColorWorkItems(workItems)
+ ColorWorkItems(_workItems)
- 'Update enable status of cells and columns.
- UpdateEnableStatus(workItems)
-
- 'Set properties of datagrid view. Done here because extra columns get generated.
-
- WorkItemsDataGridView.AutoGenerateColumns = False
- 'Disable resizing of rows and columns.
- WorkItemsDataGridView.AllowUserToResizeColumns = False
- WorkItemsDataGridView.AllowUserToResizeRows = False
- 'Center all cells.
- WorkItemsDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
- 'Make columns fill space -> removes horizontal scrollbar.
- WorkItemsDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
- 'Remove empty row at the bottom.
- WorkItemsDataGridView.AllowUserToAddRows = False
- 'Hide the selectors in front of a row.
- WorkItemsDataGridView.RowHeadersVisible = False
+ 'Done here because extra columns got generated.
For Each column In WorkItemsDataGridView.Columns
'Disable sort mode for every header.
column.SortMode = DataGridViewColumnSortMode.NotSortable
@@ -79,6 +94,8 @@
Catch ex As Exception
MessageBox.Show($"Could not load {Me.Name}.{vbNewLine}{ex.Message}", "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error)
+ Finally
+ _skipSelectionChanged = False
End Try
End Sub
@@ -102,41 +119,50 @@
End Sub
'''
+ ''' Store work items.
+ '''
+ Private _workItems As List(Of IWorkItem)
+ '''
''' Load work items.
'''
- Private Function LoadWorkItems() As List(Of IWorkItem)
+ Private Sub LoadWorkItems()
Try
- Return _parentForm.GetWorkItems(_gridNumber)
+ _workItems = _parentForm.GetWorkItems(_gridNumber)
Catch ex As Exception
Throw New Exception($"Could not load work items.{vbNewLine}{ex.Message}")
End Try
- End Function
+ End Sub
'''
''' Generate the columns for the activities.
'''
'''
Private Sub GenerateActivityColumns(workItems As List(Of IWorkItem))
- 'No work items need no extra columns.
- If workItems.Count = 0 Then Return
+ Try
+ 'No work items need no extra columns.
+ If workItems.Count = 0 Then Return
- 'Register amount of already present columns.
- Dim presentColumns As Integer = WorkItemsDataGridView.Columns.Count
+ 'Register amount of already present columns.
+ Dim presentColumns As Integer = WorkItemsDataGridView.Columns.Count
- 'Get the first work item as this will provide all the necessary info.
- Dim workItem = workItems.Item(0)
+ 'Get the first work item as this will provide all the necessary info.
+ Dim workItem = workItems.Item(0)
- 'Loop through every activity.
- For Each activity In workItem.Activities
- 'Make a column for every activity with the necessary header text.
- Dim column As New DataGridViewTextBoxColumn With {
- .Name = $"{activity.Label}ActivityColumn",
- .HeaderText = activity.Label,
- .DisplayIndex = presentColumns - 3 'Update the display index, they're all the same now, so will be put after each other. -3 because of the other columns present.
- }
- 'Add column to data grid view.
- WorkItemsDataGridView.Columns.Add(column)
- Next
+ 'Loop through every activity.
+ For i = 0 To workItem.Activities.Count - 1
+ Dim activity = workItem.Activities(i)
+ 'Make a column for every activity with the necessary header text.
+ Dim column As New DataGridViewTextBoxColumn With {
+ .Name = $"{activity.Label}ActivityColumn",
+ .HeaderText = activity.Label,
+ .DisplayIndex = presentColumns + i - 3 'Update the display index. Up the index for every column. -3 because of the other columns present.
+ }
+ 'Add column to data grid view.
+ WorkItemsDataGridView.Columns.Add(column)
+ Next
+ Catch ex As Exception
+ Throw New Exception($"Could not generate activity columns.{vbNewLine}{ex.Message}")
+ End Try
End Sub
'''
@@ -198,11 +224,39 @@
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.
+ Private _skipSelectionChanged = False
+ Private Sub WorkItemsDataGridView_SelectionChanged(sender As Object, e As EventArgs) Handles WorkItemsDataGridView.SelectionChanged
+ Try
+ 'If new items are being added or selected index is smaller than 0, it indicates nothing valueable was selected. The function was triggered because new values were added.
+ If _skipSelectionChanged Or WorkItemsDataGridView.CurrentCell.ColumnIndex < 0 Or WorkItemsDataGridView.CurrentCell.RowIndex < 0 Then Return
+
+ 'Disable click on columns or cell that should not be clicked on.
+ 'Check columns, only activity columns should be able to be clicked on.
+ If Not WorkItemsDataGridView.Columns(WorkItemsDataGridView.CurrentCell.ColumnIndex).Name.Contains("ActivityColumn") Then
+ 'Column is not that of an activity. Remove selection.
+ WorkItemsDataGridView.ClearSelection()
+ Return
+ End If
+
+ 'Fetch the right activity
+ Dim workItem = _workItems.Item(WorkItemsDataGridView.CurrentCell.RowIndex)
+ 'Calculate index of the activity => activity columns are placed at end, so activity column index - amount of static columns = activity index.
+ Dim activityIndex = WorkItemsDataGridView.CurrentCell.ColumnIndex - ConfigsLoader.GridColumnAmount
+ Dim activity = workItem.Activities.Item(activityIndex)
+
+ 'Check if activity is finished, zero or read only.
+ If activity.Status = ActivityStateEnum.Finished Or
+ activity.Status = ActivityStateEnum.AllFinished Or
+ activity.Status = ActivityStateEnum.Zero Or
+ activity.IsReadOnly Then
+ 'If equal to one of those, remove selection.
+ WorkItemsDataGridView.ClearSelection()
+ End If
+ Catch ex As Exception
+ MessageBox.Show($"Could not select a cell in {Me.Name}.{vbNewLine}{ex.Message}", "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error)
+ 'Remove selection.
+ WorkItemsDataGridView.ClearSelection()
+ End Try
End Sub
+
End Class
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb
===================================================================
diff -u -r1692 -r1693
--- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1692)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1693)
@@ -16,7 +16,7 @@
BackColor = Color.White
ForeColor = Color.Black
'Update size and set center position.
- Size = New System.Drawing.Size(1280, 1024)
+ Size = New System.Drawing.Size(ConfigsLoader.AppWidth, ConfigsLoader.AppHeight)
StartPosition = FormStartPosition.CenterScreen
'Set the title name of the form from the config.
Text = $"RDB - Activiteiten opvolging - {ConfigsLoader.AppName}"
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/enums/ActivityStateEnum.vb
===================================================================
diff -u -r1679 -r1693
--- ActiviteitenOpvolging/ActiviteitenOpvolging/enums/ActivityStateEnum.vb (.../ActivityStateEnum.vb) (revision 1679)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/enums/ActivityStateEnum.vb (.../ActivityStateEnum.vb) (revision 1693)
@@ -9,7 +9,7 @@
Public Module ActivityStateEnumMapper
'''
- ''' Gets the corresponding enum value from the ActivityStateEnum with a string value.
+ ''' Gets the corresponding enum value from the with a string value.
'''
''' The string value
'''
@@ -33,7 +33,7 @@
End Function
'''
- ''' Gets the corresponding enum value from ActivityStateEnum with a char value.
+ ''' Gets the corresponding enum value from with a char value.
'''
'''
'''
@@ -43,9 +43,9 @@
'Check for type and return enum value.
Select Case Char.ToUpper(letter)
Case "S"C
- Return ActivityStateEnum.Pauzed
- Case "P"C
Return ActivityStateEnum.Started
+ Case "P"C
+ Return ActivityStateEnum.Pauzed
Case "F"C
Return ActivityStateEnum.Finished
Case Else
Index: ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb
===================================================================
diff -u -r1689 -r1693
--- ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1689)
+++ ActiviteitenOpvolging/ActiviteitenOpvolging/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1693)
@@ -117,7 +117,8 @@
.Id = ExtractItemFromDataReader(dr, $"ActiviteitID_{i}", String.Empty)
.QuantityToProduce = ExtractItemFromDataReader(dr, $"Aantal_{i}", 0)
.Label = ExtractItemFromDataReader(dr, $"Label_{i}", String.Empty)
- .Status = ActivityStateEnumMapper.GetActivityStateFromLetter(ExtractItemFromDataReader(Of Char)(dr, $"Status_{i}"))
+ 'If the quentity is 0, the status is automatically zero.
+ .Status = If(.QuantityToProduce = 0, ActivityStateEnum.Zero, ActivityStateEnumMapper.GetActivityStateFromLetter(ExtractItemFromDataReader(Of Char)(dr, $"Status_{i}")))
.User = ExtractItemFromDataReader(dr, $"Gebruiker_{i}", String.Empty)
.IsReadOnly = ExtractItemFromDataReader(dr, $"ReadOnly_{i}", False)
.StartTimeStamp = ExtractItemFromDataReader(dr, $"StartTijdstip_{i}", DateTime.MinValue)