Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1682) @@ -92,6 +92,7 @@ Form + Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.Designer.vb =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.Designer.vb (.../DataGridViewUserControl.Designer.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.Designer.vb (.../DataGridViewUserControl.Designer.vb) (revision 1682) @@ -26,6 +26,9 @@ Me.GridLabel = New System.Windows.Forms.Label() Me.BatchColumn = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.DueOut = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.ProductGroup = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.DeliverToResource = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.Remark = New System.Windows.Forms.DataGridViewTextBoxColumn() CType(Me.WorkItemsDataGridView,System.ComponentModel.ISupportInitialize).BeginInit Me.SuspendLayout ' @@ -35,7 +38,7 @@ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) Me.WorkItemsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize - Me.WorkItemsDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.BatchColumn, Me.DueOut}) + Me.WorkItemsDataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.BatchColumn, Me.DueOut, Me.ProductGroup, Me.DeliverToResource, Me.Remark}) Me.WorkItemsDataGridView.Location = New System.Drawing.Point(0, 29) Me.WorkItemsDataGridView.Name = "WorkItemsDataGridView" Me.WorkItemsDataGridView.Size = New System.Drawing.Size(798, 534) @@ -62,6 +65,21 @@ Me.DueOut.HeaderText = "DueOut" Me.DueOut.Name = "DueOut" ' + 'ProductGroup + ' + Me.ProductGroup.HeaderText = "Product" + Me.ProductGroup.Name = "ProductGroup" + ' + 'DeliverToResource + ' + Me.DeliverToResource.HeaderText = "Aan" + Me.DeliverToResource.Name = "DeliverToResource" + ' + 'Remark + ' + Me.Remark.HeaderText = "Opmerking" + Me.Remark.Name = "Remark" + ' 'DataGridViewUserControl ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) @@ -80,4 +98,7 @@ Friend WithEvents GridLabel As Label Friend WithEvents BatchColumn As DataGridViewTextBoxColumn Friend WithEvents DueOut As DataGridViewTextBoxColumn + Friend WithEvents ProductGroup As DataGridViewTextBoxColumn + Friend WithEvents DeliverToResource As DataGridViewTextBoxColumn + Friend WithEvents Remark As DataGridViewTextBoxColumn End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.resx =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.resx (.../DataGridViewUserControl.resx) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.resx (.../DataGridViewUserControl.resx) (revision 1682) @@ -123,4 +123,13 @@ True + + True + + + True + + + True + \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1682) @@ -7,4 +7,5 @@ True True True + True True \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1682) @@ -1,20 +1,26 @@ -Imports System.ComponentModel -Imports ActiviteitenOpvolging.configs +Imports ActiviteitenOpvolging.configs Public Class ActiviteitenOpvolgingForm - Private ReadOnly _userControls As New List(Of IDataGridUserControl) + Implements IMainForm + + Private _userControls As List(Of IDataGridUserControl) Private _workItemManager As IWorkItemManager Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try + 'Variable initialisation, putting this in a constructor breaks 'DatagridViewControlsFlowLayoutPanel.Controls.Add' -> null reference exception. + _userControls = New List(Of IDataGridUserControl) + _workItemManager = New WorkItemManager + 'Set the color of the form. BackColor = Color.White ForeColor = Color.Black 'Update size and set center position. - Size = New System.Drawing.Size(800, 600) + Size = New System.Drawing.Size(1280, 1024) StartPosition = FormStartPosition.CenterScreen 'Set the title name of the form from the config. - Text = $"Activiteiten opvolging - {ConfigsLoader.AppName}" + Text = $"RDB - Activiteiten opvolging - {ConfigsLoader.AppName}" + GridLabel.Text = ConfigsLoader.AppName 'Load the user controls with the data grids. LoadDataGridUserControls() @@ -29,10 +35,12 @@ ''' Private Sub LoadDataGridUserControls() 'Loop for every data grid view, number of grids gotten from config. - For i = 0 To ConfigsLoader.NumberOfGrids - 1 - Dim userControl As New DataGridViewUserControl + For gridNumber = 0 To ConfigsLoader.NumberOfGrids - 1 + 'Initialise the user control and set parent form and grid number. + Dim userControl As New DataGridViewUserControl(Me, gridNumber) + 'Set other parameters. With userControl - .Size = New System.Drawing.Size(300, 250) + .Size = New System.Drawing.Size(600, 250) End With 'Add to list of user controls. @@ -41,4 +49,10 @@ DatagridViewControlsFlowLayoutPanel.Controls.Add(userControl) Next End Sub + + ''' + Public Function GetWorkItems(gridNumber As Integer) As List(Of IWorkItem)Implements IMainForm.GetWorkItems + Return _workItemManager.GiveWorkItems(gridNumber) + End Function + End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb (.../ActiviteitenOpvolgingForm.Designer.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb (.../ActiviteitenOpvolgingForm.Designer.vb) (revision 1682) @@ -23,7 +23,6 @@ _ Private Sub InitializeComponent() Me.DatagridViewControlsFlowLayoutPanel = New System.Windows.Forms.FlowLayoutPanel() - Me.Button1 = New System.Windows.Forms.Button() Me.GridLabel = New System.Windows.Forms.Label() Me.SuspendLayout ' @@ -37,16 +36,6 @@ Me.DatagridViewControlsFlowLayoutPanel.Size = New System.Drawing.Size(1240, 899) Me.DatagridViewControlsFlowLayoutPanel.TabIndex = 0 ' - 'Button1 - ' - Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) - Me.Button1.Location = New System.Drawing.Point(831, 951) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 1 - Me.Button1.Text = "Button1" - Me.Button1.UseVisualStyleBackColor = true - ' 'GridLabel ' Me.GridLabel.AutoSize = true @@ -64,7 +53,6 @@ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(1264, 986) Me.Controls.Add(Me.GridLabel) - Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.DatagridViewControlsFlowLayoutPanel) Me.Name = "ActiviteitenOpvolgingForm" Me.Text = "Activiteiten Form" @@ -74,6 +62,5 @@ End Sub Friend WithEvents DatagridViewControlsFlowLayoutPanel As FlowLayoutPanel - Friend WithEvents Button1 As Button Friend WithEvents GridLabel As Label End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb (revision 1682) @@ -0,0 +1,9 @@ +Public Interface IMainForm + + ''' + ''' Fetch the work items for a specific grid. + ''' + ''' The index of the grid, 0 based + ''' A list containing all work items + Function GetWorkItems(gridNumber As Integer) As List(Of IWorkItem) +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb =================================================================== diff -u -r1681 -r1682 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1682) @@ -1,19 +1,77 @@ -Public Class DataGridViewUserControl +Imports System.ComponentModel +Imports ActiviteitenOpvolging.configs + +Public Class DataGridViewUserControl Implements IDataGridUserControl + Private ReadOnly _parentForm As IMainForm + Private ReadOnly _gridNumber As Integer - Sub New () + Sub New() + ' This call is required by the designer. + InitializeComponent() + End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) - MessageBox.Show($"This is a test, I'm user control.") + ''' + ''' Initialises the user form. + ''' + ''' The form containing this user control + ''' The index of the grid, 0 based + Sub New(parentForm As IMainForm, gridNumber As Integer) + 'Call base constructor. + Me.New() + 'Set parameters. + + 'Parent form. + 'Value can't be Nothing. + If parentForm Is Nothing Then Throw New InternalException($"The parent form can't be 'Nothing' in a {Me.Name}.") + _parentForm = parentForm + + 'Grid number. + _gridNumber = gridNumber End Sub - Public Sub ChangeColor() - BackColor = If(BackColor = Color.White, Color.Black, Color.White) - ForeColor = If(BackColor = Color.White, Color.Black, Color.White) + Private Sub DataGridViewUserControl_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Try + 'Set back color and fore color. + BackColor = Color.White + ForeColor = Color.Black + + 'Set label. + GridLabel.Text = ConfigsLoader.GridLabelNames(_gridNumber) + + 'Load all work items. + LoadWorkItems() + Catch ex As Exception + Throw New InternalException($"Could not load {Me.Name}.{vbNewLine}{ex.Message}") + End Try End Sub - Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load - BackColor = Color.White - ForeColor = Color.Black + ''' + ''' Load and show work items. + ''' + Private Sub LoadWorkItems() + Try + Dim workItems As List(Of IWorkItem) = _parentForm.GetWorkItems(_gridNumber) + ShowWorkItems(workItems) + Catch ex As Exception + + End Try End Sub + + ''' + ''' Visualize work items in grid. + ''' + ''' + Private Sub ShowWorkItems(workItems As List(Of IWorkItem)) + '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)) + + End Sub End Class