Index: ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb =================================================================== diff -u -r1700 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1700) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/configs/ConfigsLoader.vb (.../ConfigsLoader.vb) (revision 1715) @@ -111,7 +111,7 @@ Return New List(Of String)(_sqlQueries) End Get End Property - Public ReadOnly Property NumberOfUsers As Integer + Public ReadOnly Property NumberOfEmployees As Integer #End Region ''' @@ -156,8 +156,8 @@ _numbersOfActivities.Add(value) ElseIf identifier.Contains("SQL") Then _sqlQueries.Add(value) - ElseIf identifier.Equals("NumberOfUsers") Then - _NumberOfUsers = value + ElseIf identifier.Equals("NumberOfEmployees") Then + _NumberOfEmployees = value Else Throw New Exception($"Unknown configuration: '{line}'.") End If @@ -232,7 +232,7 @@ Throw New ConfigurationException("The amount of 'SQL queries' is not equal to the 'number of grids'.") End If 'Number of users. - If NumberOfUsers <= 0 Then + If NumberOfEmployees <= 0 Then Throw New ConfigurationException("Number of users is not defined or invalid.") End If End Sub @@ -447,8 +447,8 @@ End If 'Colors users. - If _colorsUsers.Count < NumberOfUsers Then - Throw New ConfigurationException($"The colors for the users are not defined or are fewer than the amount of users {NumberOfUsers}.") + 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}.") End If End Sub Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj =================================================================== diff -u -r1714 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1714) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1715) @@ -97,10 +97,17 @@ Form - - - - + + + + EmployeeUserControl.vb + + + UserControl + + + + @@ -118,10 +125,10 @@ Settings.settings True - + DataGridViewUserControl.vb - + UserControl @@ -135,9 +142,12 @@ My.Resources Designer - + DataGridViewUserControl.vb + + EmployeeUserControl.vb + @@ -151,6 +161,8 @@ - + + + \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IDataGridUserControl.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IDataGridUserControl.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IDataGridUserControl.vb (revision 1715) @@ -0,0 +1,18 @@ +Public Interface IDataGridUserControl + ''' + ''' Access to the grid number. + ''' + ''' + ReadOnly Property GridNumber As Integer + + ''' + ''' Clears the selection from the datagrid. + ''' + Sub RemoveSelection() + + ''' + ''' Refresh the data of the grid. + ''' + ''' Whether or not it was successful + Function RefreshData() As Boolean +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.Designer.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.Designer.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.Designer.vb (revision 1715) @@ -0,0 +1,224 @@ + _ +Partial Class EmployeeUserControl + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel() + Me.ActivityLabel = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.ImagePictureBox = New System.Windows.Forms.PictureBox() + Me.StartButton = New System.Windows.Forms.Button() + Me.PauzeButton = New System.Windows.Forms.Button() + Me.StopButton = New System.Windows.Forms.Button() + Me.NameLabel = New System.Windows.Forms.Label() + Me.StatusLabel = New System.Windows.Forms.Label() + Me.Label1 = New System.Windows.Forms.Label() + Me.BatchLabel = New System.Windows.Forms.Label() + Me.TableLayoutPanel1.SuspendLayout + CType(Me.ImagePictureBox,System.ComponentModel.ISupportInitialize).BeginInit + Me.SuspendLayout + ' + 'TableLayoutPanel1 + ' + Me.TableLayoutPanel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) + Me.TableLayoutPanel1.ColumnCount = 3 + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33332!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334!)) + Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334!)) + Me.TableLayoutPanel1.Controls.Add(Me.ActivityLabel, 1, 5) + Me.TableLayoutPanel1.Controls.Add(Me.Label2, 0, 5) + Me.TableLayoutPanel1.Controls.Add(Me.ImagePictureBox, 2, 0) + Me.TableLayoutPanel1.Controls.Add(Me.StartButton, 1, 7) + Me.TableLayoutPanel1.Controls.Add(Me.PauzeButton, 1, 9) + Me.TableLayoutPanel1.Controls.Add(Me.StopButton, 1, 11) + Me.TableLayoutPanel1.Controls.Add(Me.NameLabel, 0, 0) + Me.TableLayoutPanel1.Controls.Add(Me.StatusLabel, 0, 3) + Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 4) + Me.TableLayoutPanel1.Controls.Add(Me.BatchLabel, 1, 4) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(0, 0) + Me.TableLayoutPanel1.Name = "TableLayoutPanel1" + Me.TableLayoutPanel1.RowCount = 13 + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196638!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 2.008405!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 2.008405!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.196639!)) + Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.016809!)) + Me.TableLayoutPanel1.Size = New System.Drawing.Size(498, 595) + Me.TableLayoutPanel1.TabIndex = 0 + ' + 'ActivityLabel + ' + Me.ActivityLabel.AutoSize = true + Me.ActivityLabel.Dock = System.Windows.Forms.DockStyle.Fill + Me.ActivityLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.ActivityLabel.Location = New System.Drawing.Point(168, 270) + Me.ActivityLabel.Name = "ActivityLabel" + Me.ActivityLabel.Size = New System.Drawing.Size(160, 54) + Me.ActivityLabel.TabIndex = 11 + Me.ActivityLabel.Text = "activity" + Me.ActivityLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'Label2 + ' + Me.Label2.AutoSize = true + Me.Label2.Dock = System.Windows.Forms.DockStyle.Right + Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.Label2.Location = New System.Drawing.Point(105, 270) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(57, 54) + Me.Label2.TabIndex = 9 + Me.Label2.Text = "Activiteit" + Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'ImagePictureBox + ' + Me.ImagePictureBox.Dock = System.Windows.Forms.DockStyle.Fill + Me.ImagePictureBox.Image = Global.ActiviteitenOpvolging.My.Resources.Resources.user + Me.ImagePictureBox.InitialImage = Nothing + Me.ImagePictureBox.Location = New System.Drawing.Point(334, 3) + Me.ImagePictureBox.Name = "ImagePictureBox" + Me.TableLayoutPanel1.SetRowSpan(Me.ImagePictureBox, 4) + Me.ImagePictureBox.Size = New System.Drawing.Size(161, 210) + Me.ImagePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.ImagePictureBox.TabIndex = 0 + Me.ImagePictureBox.TabStop = false + ' + 'StartButton + ' + Me.StartButton.Dock = System.Windows.Forms.DockStyle.Fill + Me.StartButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.StartButton.Location = New System.Drawing.Point(168, 381) + Me.StartButton.Name = "StartButton" + Me.StartButton.Size = New System.Drawing.Size(160, 48) + Me.StartButton.TabIndex = 2 + Me.StartButton.Text = "START" + Me.StartButton.UseVisualStyleBackColor = true + ' + 'PauzeButton + ' + Me.PauzeButton.Dock = System.Windows.Forms.DockStyle.Fill + Me.PauzeButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.PauzeButton.Location = New System.Drawing.Point(168, 446) + Me.PauzeButton.Name = "PauzeButton" + Me.PauzeButton.Size = New System.Drawing.Size(160, 48) + Me.PauzeButton.TabIndex = 5 + Me.PauzeButton.TabStop = false + Me.PauzeButton.Text = "| |" + Me.PauzeButton.UseVisualStyleBackColor = true + ' + 'StopButton + ' + Me.StopButton.Dock = System.Windows.Forms.DockStyle.Fill + Me.StopButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.StopButton.Location = New System.Drawing.Point(168, 511) + Me.StopButton.Name = "StopButton" + Me.StopButton.Size = New System.Drawing.Size(160, 48) + Me.StopButton.TabIndex = 4 + Me.StopButton.Text = "X" + Me.StopButton.UseVisualStyleBackColor = true + ' + 'NameLabel + ' + Me.NameLabel.AutoSize = true + Me.NameLabel.Dock = System.Windows.Forms.DockStyle.Left + Me.NameLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.NameLabel.Location = New System.Drawing.Point(3, 0) + Me.NameLabel.Name = "NameLabel" + Me.NameLabel.Size = New System.Drawing.Size(45, 54) + Me.NameLabel.TabIndex = 6 + Me.NameLabel.Text = "Name" + Me.NameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft + ' + 'StatusLabel + ' + Me.StatusLabel.AutoSize = true + Me.TableLayoutPanel1.SetColumnSpan(Me.StatusLabel, 2) + Me.StatusLabel.Dock = System.Windows.Forms.DockStyle.Left + Me.StatusLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.StatusLabel.Location = New System.Drawing.Point(3, 162) + Me.StatusLabel.Name = "StatusLabel" + Me.StatusLabel.Size = New System.Drawing.Size(45, 54) + Me.StatusLabel.TabIndex = 7 + Me.StatusLabel.Text = "Status" + Me.StatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft + ' + 'Label1 + ' + Me.Label1.AutoSize = true + Me.Label1.Dock = System.Windows.Forms.DockStyle.Right + Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.Label1.Location = New System.Drawing.Point(120, 216) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(42, 54) + Me.Label1.TabIndex = 8 + Me.Label1.Text = "Batch" + Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight + ' + 'BatchLabel + ' + Me.BatchLabel.AutoSize = true + Me.BatchLabel.Dock = System.Windows.Forms.DockStyle.Fill + Me.BatchLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.BatchLabel.Location = New System.Drawing.Point(168, 216) + Me.BatchLabel.Name = "BatchLabel" + Me.BatchLabel.Size = New System.Drawing.Size(160, 54) + Me.BatchLabel.TabIndex = 10 + Me.BatchLabel.Text = "batch" + Me.BatchLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + ' + 'EmployeeUserControl + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.Controls.Add(Me.TableLayoutPanel1) + Me.Name = "EmployeeUserControl" + Me.Size = New System.Drawing.Size(498, 594) + Me.TableLayoutPanel1.ResumeLayout(false) + Me.TableLayoutPanel1.PerformLayout + CType(Me.ImagePictureBox,System.ComponentModel.ISupportInitialize).EndInit + Me.ResumeLayout(false) + +End Sub + + Friend WithEvents TableLayoutPanel1 As TableLayoutPanel + Friend WithEvents ImagePictureBox As PictureBox + Friend WithEvents StartButton As Button + Friend WithEvents StopButton As Button + Friend WithEvents PauzeButton As Button + Friend WithEvents NameLabel As Label + Friend WithEvents StatusLabel As Label + Friend WithEvents Label1 As Label + Friend WithEvents Label2 As Label + Friend WithEvents BatchLabel As Label + Friend WithEvents ActivityLabel As Label +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/Resources/user.png =================================================================== diff -u Binary files differ Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.vb (revision 1715) @@ -0,0 +1,3 @@ +Public Class EmployeeUserControl + Implements IEmployeeUserControl +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.vb (revision 1715) @@ -0,0 +1,366 @@ +Imports ActiviteitenOpvolging.configs + +Public Class DataGridViewUserControl + Implements IDataGridUserControl + Private ReadOnly _parentForm As IMainForm + Public ReadOnly Property GridNumber As Integer Implements IDataGridUserControl.GridNumber + + + Sub New() + ' This call is required by the designer. + InitializeComponent() + End Sub + + ''' + ''' 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. + Me.GridNumber = gridNumber + End Sub + + ''' + Public Sub RemoveSelection() Implements IDataGridUserControl.RemoveSelection + _WorkItemsDataGridView.ClearSelection() + End Sub + + ''' + Public Function RefreshData() As Boolean Implements IDataGridUserControl.RefreshData + Try + 'Call helper method. + LoadGrid() + 'Refresh succesfull. + Return True + Catch ex As Exception + 'Failed to retrieve update with data. + Return False + Finally + _skipSelectionChanged = False + End Try + End Function + + 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 properties of datagrid view. + + 'Background color. + WorkItemsDataGridView.BackgroundColor = color.White + + 'Cell makeup. + 'Center header cells. + WorkItemsDataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter + 'Make header text bigger. + WorkItemsDataGridView.ColumnHeadersDefaultCellStyle.Font = New Font("Microsoft Sans Serif", 10) 'todo configureerbaar maken + 'Center normal cells. + WorkItemsDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter + 'Make text bigger of normal cells. + WorkItemsDataGridView.DefaultCellStyle.Font = New Font("Microsoft Sans Serif", 9.5) 'todo configureerbaar maken + + '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 'todo configureerbaar maken + + 'Set label. + GridLabel.Text = ConfigsLoader.GridLabelNames(GridNumber) + 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 + + Private isInitialLoad As Boolean = True + ''' + ''' Fetch the data and fill the data grid view with it. + ''' + Private Sub LoadGrid() + 'Load all work items. + LoadWorkItems() + + If isInitialLoad Then + 'Update headers and visibility of static columns. This only happens once. + UpdateStaticColumns() + + 'Generate grid columns for the activities of the work items. This only happens once. + GenerateActivityColumns(_workItems) + + isInitialLoad = False + End If + + 'Clear grid. + WorkItemsDataGridView.DataSource = Nothing + WorkItemsDataGridView.Rows.Clear() + + 'Changes to data grid can trigger selectio changed event, ignores it for now. + _skipSelectionChanged = True + + 'Show the work items. + ShowWorkItems(_workItems) + + 'Color the work items. + ColorWorkItems(_workItems) + + 'Done here because extra columns got generated. + For Each column In WorkItemsDataGridView.Columns + 'Disable sort mode for every header. + column.SortMode = DataGridViewColumnSortMode.NotSortable + 'Make every cell not editable. + column.ReadOnly = True + Next + + WorkItemsDataGridView.Refresh() + End Sub + + ''' + ''' Update the header text and visibility of the static columns. + ''' + Private Sub UpdateStaticColumns() + Dim names = ConfigsLoader.GridColumnHeaderNames().Item(GridNumber) + For i = 0 To names.Count() - 1 + 'Fetch name. + Dim headerText = names(i) + 'Check if it's not hidden. + If Not headerText = "-" Then + 'Visible, set header text. + WorkItemsDataGridView.Columns.Item(i).HeaderText = headerText + Else + 'It needs to be hidden. + WorkItemsDataGridView.Columns.Item(i).Visible = False + End If + Next + End Sub + + ''' + ''' Store work items. + ''' + Private _workItems As List(Of IWorkItem) + ''' + ''' Load work items. + ''' + Private Sub LoadWorkItems() + Try + _workItems = _parentForm.GetWorkItems(GridNumber) + Catch ex As Exception + Throw New Exception($"Could not load work items.{vbNewLine}{ex.Message}") + End Try + End Sub + + ''' + ''' Generate the columns for the activities. + ''' + ''' + Private Sub GenerateActivityColumns(workItems As List(Of IWorkItem)) + 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 + + 'Get the first work item as this will provide all the necessary info. + Dim workItem = workItems.Item(0) + + '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 { + .CellTemplate = New BorderedTextFigureCell(), + .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 + + ''' + ''' Visualize work items in grid. + ''' + ''' + Private Sub ShowWorkItems(workItems As List(Of IWorkItem)) + Try + 'Loop through each work item. + For Each workItem In workItems + 'Load normal parameters. + Dim data As New List(Of String) From { + workItem.BatchVisual, + workItem.EndTimeStamp.ToString("d MMM HH:mm"), + workItem.ProductGroup, + workItem.DeliverToResource, + workItem.Remark + } + 'Add data from activities to end of list. 0 gets replaced by empty string. + data.AddRange(workItem.Activities.Select( + Function(activity) If(activity.QuantityToProduce = 0, String.Empty, activity.QuantityToProduce.ToString()))) + 'Add as a row to the data grid view. + WorkItemsDataGridView.Rows.Add(data.ToArray()) + Next + Catch ex As Exception + Throw New Exception($"Could not show work items.{vbNewLine}{ex.Message}") + End Try + 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 Each row As DataGridViewRow In WorkItemsDataGridView.Rows + 'Get the work item. + Dim workItem = workItems.Item(row.Index) + 'Update the colors of the activities. + UpdateActivityCells(workItem, row) + Next + End Sub + + ''' + ''' Update the color of the cells for each activity. + ''' + Private Sub UpdateActivityCells(workItem As IWorkItem, row As DataGridViewRow) + 'Calculate the index of the first activity column. + Dim firstActivityCellIndex = row.Cells.Count - workItem.Activities.Count + 'Loop for every activity. + For activityIndex As Integer = 0 To workItem.Activities.Count - 1 + Dim activity = workItem.Activities.Item(activityIndex) + 'Fetch the right cell. Based on the activity, the offset is the index of the first activity. + Dim cell = row.Cells.Item(activityIndex + firstActivityCellIndex) + 'Update time related warning image. + UpdateActivityCellTimeStatusIndication(activity, cell) + 'Update background color. + UpdateActivityCellBackground(workItem, activity, cell) + 'todo Update border based on user + Next + End Sub + + ''' + ''' Update the image of the cell of an activity. + ''' + ''' + ''' + Private Sub UpdateActivityCellTimeStatusIndication(activity As IActivity, dataGridViewCell As DataGridViewCell) + '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 + + 'Remove border. + cell.BorderThickness = 0 + + 'Undefined start timestamp is ignored. + If activity.StartTimeStamp = DateTime.MinValue Then + cell.Figure = Nothing + Return + End If + + 'Set status image based on timestamps. + If activity.StartBeforeTimestamp < DateTime.Now Then + cell.Figure = ConfigsLoader.ActivityBeforeStatusImage + ElseIf activity.StartAlmostTimeStamp < DateTime.Now Then + cell.Figure = ConfigsLoader.ActivityAlmostStatusImage + ElseIf activity.StartTimeStamp < DateTime.Now Then + cell.Figure = ConfigsLoader.ActivityLateStatusImage + Else + 'Default. + cell.Figure = Nothing + End If + End Sub + + ''' + ''' + ''' + ''' + ''' + Private Sub UpdateActivityCellBackground(workItem As IWorkItem, activity As IActivity, dataGridViewCell As DataGridViewCell) + 'Check if readonly. + If activity.IsReadOnly Then + 'It's read only. + dataGridViewCell.Style.BackColor = ConfigsLoader.ColorsActivitiesReadOnly(activity.Status) + Else + 'It's not read only, check if not all activities have status finished. + If Not workItem.AreAllActivatableActivitiesFinished() Then + 'Not all activities are finished. + dataGridViewCell.Style.BackColor = ConfigsLoader.ColorsActivities(activity.Status) + Else + 'All activities are finished. + dataGridViewCell.Style.BackColor = ConfigsLoader.AllFinishedActivitiesColor + End If + End If + End Sub + + ''' + ''' Disable the selection changed event, useful for ignoring triggers by adding new rows. + ''' + Private _skipSelectionChanged = False + ''' + ''' Decide if a cell can be selected or not. + ''' + 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 or the headers were clicked. + 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 + _parentForm.ChangeSelectedActivity(Nothing, GridNumber) + 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.Zero Or + activity.IsReadOnly Then + 'If equal to one of those, the selection is not valid. + _parentForm.ChangeSelectedActivity(Nothing, GridNumber) + Else + 'Selection was valid. + _parentForm.ChangeSelectedActivity(activity, GridNumber) + 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/screens/custom controls/BorderedTextFigureCell.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/custom controls/BorderedTextFigureCell.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/custom controls/BorderedTextFigureCell.vb (revision 1715) @@ -0,0 +1,15 @@ +Public Class BorderedTextFigureCell + Inherits BorderCell + + Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts) + MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) + + If Figure IsNot Nothing Then + Dim imageSize = cellBounds.Height - BorderThickness - 3 + Dim imagePos As New Rectangle(cellBounds.Right - BorderThickness - imageSize - 2, cellBounds.Y + BorderThickness, imageSize, imageSize) + graphics.DrawImage(Figure, imagePos) + End If + End Sub + + Property Figure As Image +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.resx =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.resx (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/EmployeeUserControl.resx (revision 1715) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.Designer.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.Designer.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.Designer.vb (revision 1715) @@ -0,0 +1,106 @@ + _ +Partial Class DataGridViewUserControl + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.WorkItemsDataGridView = New System.Windows.Forms.DataGridView() + 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() + Me.GridLabel = New System.Windows.Forms.Label() + CType(Me.WorkItemsDataGridView,System.ComponentModel.ISupportInitialize).BeginInit + Me.SuspendLayout + ' + 'WorkItemsDataGridView + ' + Me.WorkItemsDataGridView.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) + Me.WorkItemsDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None + Me.WorkItemsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + 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(796, 532) + Me.WorkItemsDataGridView.TabIndex = 0 + ' + 'BatchColumn + ' + Me.BatchColumn.HeaderText = "Batch" + Me.BatchColumn.Name = "BatchColumn" + ' + 'DueOut + ' + Me.DueOut.HeaderText = "DueOut" + Me.DueOut.Name = "DueOut" + ' + 'ProductGroup + ' + Me.ProductGroup.HeaderText = "Product" + Me.ProductGroup.Name = "ProductGroup" + ' + 'DeliverToResource + ' + Me.DeliverToResource.HeaderText = "Naar" + Me.DeliverToResource.Name = "DeliverToResource" + ' + 'Remark + ' + Me.Remark.HeaderText = "Opmerking" + Me.Remark.Name = "Remark" + ' + 'GridLabel + ' + Me.GridLabel.AutoSize = true + Me.GridLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 13!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.GridLabel.ForeColor = System.Drawing.Color.Firebrick + Me.GridLabel.Location = New System.Drawing.Point(3, 4) + Me.GridLabel.Name = "GridLabel" + Me.GridLabel.Size = New System.Drawing.Size(87, 22) + Me.GridLabel.TabIndex = 1 + Me.GridLabel.Text = "Grid label" + ' + 'DataGridViewUserControl + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.Controls.Add(Me.GridLabel) + Me.Controls.Add(Me.WorkItemsDataGridView) + Me.Name = "DataGridViewUserControl" + Me.Size = New System.Drawing.Size(796, 561) + CType(Me.WorkItemsDataGridView,System.ComponentModel.ISupportInitialize).EndInit + Me.ResumeLayout(false) + Me.PerformLayout + +End Sub + + Friend WithEvents WorkItemsDataGridView As DataGridView + 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/screens/DataGridViewUserControl.resx =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.resx (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/DataGridViewUserControl.resx (revision 1715) @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/custom controls/BorderCell.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/custom controls/BorderCell.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/custom controls/BorderCell.vb (revision 1715) @@ -0,0 +1,31 @@ +Public Class BorderCell + Inherits DataGridViewTextBoxCell + + Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, cellState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts) + MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) + + 'Ignore if thickness is too small. + if _borderThickness = 0 Then Return + + 'Specify size and position of the border. + Dim borderRect = New Rectangle(cellBounds.X + 1, cellBounds.Y + 1, cellBounds.Width - 4, cellBounds.Height - 4) + 'Draw border with specified thickness. + graphics.DrawRectangle(New Pen(BorderColor, _borderThickness), borderRect) + + 'Create spacing between text and border. + Me.Style.Padding = New Padding(1) + End Sub + + Private _borderThickness As Integer = 1 + Property BorderThickness As Integer + Set(thickness As Integer) + If thickness < 0 Then Throw New Exception($"Border thickness of {Me.GetType().Name} can't be smaller than 0.") + _borderThickness = thickness + End Set + Get + Return _borderThickness + End Get + End Property + + Public Property BorderColor As Color = Drawing.Color.Black +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx =================================================================== diff -u -r1708 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx (.../Resources.resx) (revision 1708) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.resx (.../Resources.resx) (revision 1715) @@ -117,40 +117,44 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + SQL02 + The server name for the employees database + + + CACHE01 + The name of the server for the Caché database + ADMIN1 The name of the Caché database - - Cache01Admin1 - The name of the DSN for the Caché database + + WieIsWie + The name of the Employees database fixed The password for the Caché database - - CACHE01 - The name of the server for the Caché database + + Cache01Admin1 + The name of the DSN for the Caché database ICT_READONLY The username for the Caché database - - WieIsWie - The name of the Employees database - SQLr3*d The password for the employee database - - SQL02 - The server name for the employees database - VH_ReadOnly The username for the employees database + + + ..\Resources\user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb =================================================================== diff -u -r1708 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb (.../Resources.Designer.vb) (revision 1708) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/My Project/Resources.Designer.vb (.../Resources.Designer.vb) (revision 1715) @@ -140,5 +140,15 @@ Return ResourceManager.GetString("EmployeesDatabaseUsername", resourceCulture) End Get End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property user() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("user", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property End Module End Namespace Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IMainForm.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IMainForm.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IMainForm.vb (revision 1715) @@ -0,0 +1,16 @@ +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) + + ''' + ''' A different activity was selected in the grid. + ''' + ''' The activity. Nothing means no activity was selected. + ''' The number of the grid + sub ChangeSelectedActivity(activity As IActivity, gridNumber As Integer) +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IEmployeeUserControl.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IEmployeeUserControl.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/screens/IEmployeeUserControl.vb (revision 1715) @@ -0,0 +1,3 @@ +Public Interface IEmployeeUserControl + +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb =================================================================== diff -u -r1713 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1713) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1715) @@ -3,13 +3,15 @@ Public Class ActiviteitenOpvolgingForm Implements IMainForm - Private _userControls As List(Of IDataGridUserControl) + Private _datagridViewUserControls As List(Of IDataGridUserControl) + Private _employeeUserControls As List(Of IEmployeeUserControl) Private _domainController As IDomainController 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) + _datagridViewUserControls = New List(Of IDataGridUserControl) + _employeeUserControls = new List(Of IEmployeeUserControl) _domainController = DomainController.GetInstance() 'Set the color of the form. @@ -24,16 +26,22 @@ 'Load the user controls with the data grids. LoadDataGridUserControls() + + 'Load the user controls with the employees. + LoadEmployeeUserControls() Catch ex As Exception MessageBox.Show(ex.Message, "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error) Application.Exit() End Try End Sub +#Region "Data grids" + ''' ''' Loads the user controls with the data grid. ''' Private Sub LoadDataGridUserControls() + Try 'Loop for every data grid view, number of grids gotten from config. For gridNumber = 0 To ConfigsLoader.NumberOfGrids - 1 'Initialise the user control and set parent form and grid number. @@ -44,14 +52,17 @@ End With 'Add to list of user controls. - _userControls.Add(userControl) + _datagridViewUserControls.Add(userControl) 'Add to layout panel. DatagridViewControlsFlowLayoutPanel.Controls.Add(userControl) 'CLear selection on every data grid view. ChangeSelectedActivity(Nothing, 0) Next 'Refresh all user grids. RefreshUserGridsData() + Catch ex As Exception + Throw New Exception($"Could not load data grid user controls.{vbNewLine}{ex.Message}") + End Try End Sub ''' @@ -64,10 +75,10 @@ 'If the activity is Nothing, no activity was selected, meaning that everything should be cleared. If activity Is Nothing Then 'Clear selection for every grid user control. - _userControls.ForEach(Sub(userControl) userControl.RemoveSelection()) + _datagridViewUserControls.ForEach(Sub(userControl) userControl.RemoveSelection()) Else 'Clear selection of every grid except the one with the grid number. - For Each control In _userControls + For Each control In _datagridViewUserControls 'Remove selection from every other grid. If Not control.GridNumber = gridNumber Then control.RemoveSelection() Next @@ -83,7 +94,7 @@ ''' Private Sub RefreshUserGridsData() 'Refresh every user control. Register whether or not all refreshes were successful. - Dim allSuccesfulRefresh = _userControls.All(Function(userControl) userControl.RefreshData()) + Dim allSuccesfulRefresh = _datagridViewUserControls.All(Function(userControl) userControl.RefreshData()) If allSuccesfulRefresh Then 'Update latest refresh time label with current time. RefreshTimeLabel.Text = TimeOfDay.ToString() 'todo right formatting @@ -92,4 +103,31 @@ RefreshFailedLabel.Visible = True End If End Sub +#End Region + +#Region "Employees" + ''' + ''' Loads the user controls with the employee data. + ''' + Private Sub LoadEmployeeUserControls() + Try + 'Loop for every employee, number of grids gotten from config. + For employeeIndex = 0 To ConfigsLoader.NumberOfEmployees - 1 + 'Initialise the user control and set parent form and grid number. + Dim userControl As New EmployeeUserControl + 'Set other parameters. + With userControl + .Size = New System.Drawing.Size(250, 300) 'todo make configurable + End With + + 'Add to list of user controls. + _employeeUserControls.Add(userControl) + 'Add to layout panel. + EmployeesControlsFlowLayoutPanel.Controls.Add(userControl) + Next + Catch ex As Exception + throw New Exception($"Could not load the employee user controls.{vbNewLine}{ex.Message}") + End Try + End Sub +#End Region End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings =================================================================== diff -u -r1712 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1712) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1715) @@ -9,4 +9,6 @@ True True True - True \ No newline at end of file + True + True + True \ No newline at end of file Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb =================================================================== diff -u -r1702 -r1715 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb (.../ActiviteitenOpvolgingForm.Designer.vb) (revision 1702) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.Designer.vb (.../ActiviteitenOpvolgingForm.Designer.vb) (revision 1715) @@ -27,6 +27,7 @@ Me.RefreshButton = New System.Windows.Forms.Button() Me.RefreshTimeLabel = New System.Windows.Forms.Label() Me.RefreshFailedLabel = New System.Windows.Forms.Label() + Me.EmployeesControlsFlowLayoutPanel = New System.Windows.Forms.FlowLayoutPanel() Me.SuspendLayout ' 'DatagridViewControlsFlowLayoutPanel @@ -36,7 +37,7 @@ Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) Me.DatagridViewControlsFlowLayoutPanel.Location = New System.Drawing.Point(12, 46) Me.DatagridViewControlsFlowLayoutPanel.Name = "DatagridViewControlsFlowLayoutPanel" - Me.DatagridViewControlsFlowLayoutPanel.Size = New System.Drawing.Size(1240, 899) + Me.DatagridViewControlsFlowLayoutPanel.Size = New System.Drawing.Size(1240, 619) Me.DatagridViewControlsFlowLayoutPanel.TabIndex = 0 ' 'GridLabel @@ -80,11 +81,22 @@ Me.RefreshFailedLabel.Text = "Refresh failed. Latest refresh at:" Me.RefreshFailedLabel.Visible = false ' + 'EmployeesControlsFlowLayoutPanel + ' + Me.EmployeesControlsFlowLayoutPanel.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) + Me.EmployeesControlsFlowLayoutPanel.Location = New System.Drawing.Point(12, 671) + Me.EmployeesControlsFlowLayoutPanel.Name = "EmployeesControlsFlowLayoutPanel" + Me.EmployeesControlsFlowLayoutPanel.Size = New System.Drawing.Size(1240, 303) + Me.EmployeesControlsFlowLayoutPanel.TabIndex = 6 + ' 'ActiviteitenOpvolgingForm ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(1264, 986) + Me.Controls.Add(Me.EmployeesControlsFlowLayoutPanel) Me.Controls.Add(Me.RefreshFailedLabel) Me.Controls.Add(Me.RefreshTimeLabel) Me.Controls.Add(Me.RefreshButton) @@ -102,4 +114,5 @@ Friend WithEvents RefreshButton As Button Friend WithEvents RefreshTimeLabel As Label Friend WithEvents RefreshFailedLabel As Label + Friend WithEvents EmployeesControlsFlowLayoutPanel As FlowLayoutPanel End Class FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.Designer.vb'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.resx'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/custom controls/BorderCell.vb'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/custom controls/BorderedTextFigureCell.vb'. FishEye: No comparison available. Pass `N' to diff? FishEye: Tag 1715 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IDataGridUserControl.vb'. FishEye: No comparison available. Pass `N' to diff?