Skip to content

Commit

Permalink
Merge pull request IDEMSInternational#264 from africanmathsinitiative…
Browse files Browse the repository at this point in the history
…/master

Updating master
  • Loading branch information
Ivanluv authored Mar 29, 2022
2 parents b441a3b + b412756 commit 6d2e6b8
Show file tree
Hide file tree
Showing 86 changed files with 3,011 additions and 1,415 deletions.
2 changes: 2 additions & 0 deletions instat/Interface/IColumnMetaDataGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Public Interface IColumnMetaDataGrid

Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object)

Event DeleteLabels(strColumnName As String)

Sub AddColumns(columnMetaData As clsColumnMetaData)

Sub AddRowData(columnMetaData As clsColumnMetaData)
Expand Down
2 changes: 2 additions & 0 deletions instat/Interface/IDataframeMetaDataGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Public Interface IDataframeMetaDataGrid

Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object)

Event DeleteLabels(strColumnName As String)

Sub AddColumns()

Sub AddRowData()
Expand Down
18 changes: 9 additions & 9 deletions instat/Model/DataFrame/clsDataFrame.vb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ Public Class clsDataFrame
Private _clsPrepareFunctions As clsPrepareFunctionsForGrids
Private _clsVisiblePage As clsDataFramePage
Private _clsColumnMetaData As clsColumnMetaData
Private _clsFilter As clsDataFrameFilter
Private _clsFilterOrColumnSelection As clsDataFrameFilterOrColumnSelection
Private _strName As String
Private _RLink As RLink
Private _iTotalRowCount As Integer
Private _iTotalColumnCount As Integer

''' <summary>
''' Filter information
''' Filter or column selection information
''' </summary>
''' <returns></returns>
Public ReadOnly Property clsFilter() As clsDataFrameFilter
Public ReadOnly Property clsFilterOrColumnSelection() As clsDataFrameFilterOrColumnSelection
Get
Return _clsFilter
Return _clsFilterOrColumnSelection
End Get
End Property

Expand All @@ -51,7 +51,7 @@ Public Class clsDataFrame
End Property

''' <summary>
''' Column meta data for the dataframe
''' Column metadata for the dataframe
''' </summary>
''' <returns></returns>
Public ReadOnly Property clsColumnMetaData As clsColumnMetaData
Expand Down Expand Up @@ -142,7 +142,7 @@ Public Class clsDataFrame
_strName = strName
_clsPrepareFunctions = New clsPrepareFunctionsForGrids(rLink, strName)
_clsVisiblePage = New clsDataFramePage(rLink, strName)
_clsFilter = New clsDataFrameFilter(rLink, strName)
_clsFilterOrColumnSelection = New clsDataFrameFilterOrColumnSelection(rLink, strName)
_clsColumnMetaData = New clsColumnMetaData(rLink, strName)
End Sub

Expand All @@ -168,9 +168,9 @@ Public Class clsDataFrame
If _clsVisiblePage.RefreshData() Then
_iTotalRowCount = _RLink.GetDataFrameLength(_strName, False)
_iTotalColumnCount = _RLink.GetDataFrameColumnCount(_strName)
_clsFilter.RefreshData()
If _clsFilter.bFilterApplied Then
_clsVisiblePage.SetTotalRowAndColumnCounts(_iTotalColumnCount, _clsFilter.iFilteredRowCount)
_clsFilterOrColumnSelection.RefreshData()
If _clsFilterOrColumnSelection.bFilterApplied Then
_clsVisiblePage.SetTotalRowAndColumnCounts(_iTotalColumnCount, _clsFilterOrColumnSelection.iFilteredRowCount)
Else
_clsVisiblePage.SetTotalRowAndColumnCounts(_iTotalColumnCount, _iTotalRowCount)
End If
Expand Down
25 changes: 24 additions & 1 deletion instat/Model/DataFrame/clsDataFrameFilter.vb
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,41 @@ Imports RDotNet
''' <summary>
''' Holds filter information for the dataframe
''' </summary>
Public Class clsDataFrameFilter
Public Class clsDataFrameFilterOrColumnSelection
Protected _strDataFrameName As String
Protected _RLink As RLink

Protected _bFilterApplied As Boolean
Protected _bColumnSelectionApplied As Boolean
Protected _iFilteredRowCount As Integer
Protected _iSelectedColumnCount As Integer
Protected _strFilterName As String
Protected _strSelectionName As String

Public ReadOnly Property iFilteredRowCount As Integer
Get
Return _iFilteredRowCount
End Get
End Property

Public ReadOnly Property iSelectedColumnCount As Integer
Get
Return _iSelectedColumnCount
End Get
End Property

Public ReadOnly Property strName As String
Get
Return _strFilterName
End Get
End Property

Public ReadOnly Property strSelectionName As String
Get
Return _strSelectionName
End Get
End Property

Public ReadOnly Property bFilterApplied() As Boolean
Get
Return _bFilterApplied
Expand All @@ -64,6 +78,13 @@ Public Class clsDataFrameFilter
Return _RLink.RunInternalScriptGetValue(clsGetCurrentFilterName.ToScript(), bSilent:=True).AsCharacter(0)
End Function

Private Function GetSelectionNameFromRCommand() As String
Dim clsGetCurrentFilterName As New RFunction
clsGetCurrentFilterName.SetRCommand(_RLink.strInstatDataObject & "$get_current_column_selection")
clsGetCurrentFilterName.AddParameter("data_name", Chr(34) & _strDataFrameName & Chr(34), iPosition:=0)
Return _RLink.RunInternalScriptGetValue(clsGetCurrentFilterName.ToScript(), bSilent:=True).AsCharacter(0)
End Function

Private Function GetFilterAppliedFromRCommand() As Boolean
Dim clsFilterApplied As New RFunction
clsFilterApplied.SetRCommand(_RLink.strInstatDataObject & "$filter_applied")
Expand All @@ -80,9 +101,11 @@ Public Class clsDataFrameFilter

Public Sub RefreshData()
_iFilteredRowCount = _RLink.GetDataFrameLength(_strDataFrameName, True)
_iSelectedColumnCount = _RLink.GetDataFrameColumnCount(_strDataFrameName)
_bFilterApplied = GetFilterAppliedFromRCommand()
_bColumnSelectionApplied = GetColumnSelectionAppliedFromRCommand()
_strFilterName = GetFilterNameFromRCommand()
_strSelectionName = GetSelectionNameFromRCommand()
End Sub

End Class
24 changes: 22 additions & 2 deletions instat/Model/RCommand/clsPrepareFunctionsForGrids.vb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ Public Class clsPrepareFunctionsForGrids
End If
_RLink.RunScript(clsConvertToNumeric.ToScript(), strComment:="Right click menu: Convert Column(s) To Numeric")
End Sub

''' <summary>
''' Check if the column factor contains labels.
''' </summary>
Public Function CheckHasLabels(strColumnName As String) As Boolean
Dim clsColmnLabelsRFunction = New RFunction
Dim clsGetColumnsFromData As New RFunction

clsGetColumnsFromData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_columns_from_data")
clsGetColumnsFromData.AddParameter("data_name", Chr(34) & _strDataFrame & Chr(34), iPosition:=0)
clsGetColumnsFromData.AddParameter("col_names", Chr(34) & strColumnName & Chr(34), iPosition:=1)
clsGetColumnsFromData.AddParameter("use_current_filter", "FALSE", iPosition:=2)

clsColmnLabelsRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$has_labels")
clsColmnLabelsRFunction.AddParameter("data_name", Chr(34) & _strDataFrame & Chr(34), iPosition:=0)
clsColmnLabelsRFunction.AddParameter("col_names", clsRFunctionParameter:=clsGetColumnsFromData, iPosition:=1)

Return frmMain.clsRLink.RunInternalScriptGetValue(clsColmnLabelsRFunction.ToScript(), bSilent:=True).AsLogical(0)
End Function

''' <summary>
''' View dataframe the whole dataframe within a pop up
''' </summary>
Expand Down Expand Up @@ -322,11 +342,11 @@ Public Class clsPrepareFunctionsForGrids
Return _RLink.GetColumnType(_strDataFrame, strColumnName)
End Function

'' <summary>
''' <summary>
''' Description: To Delete one or many cells
''' the delete cell function is to be used to Replace selected values with NA
''' in the dataframe.
''' </summary>
'''</summary>
''' <param name="lstColumnNames"></param>
''' <param name="lstRowNames"></param>
Public Sub DeleteCells(lstRowNames As List(Of String), lstColumnNames As List(Of String))
Expand Down
Binary file added instat/Resources/upward-arrow1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 1 addition & 13 deletions instat/UcrGeomListWithAes.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Public Class ucrColumnMetadataLinuxGrid

Private _lstNonEditableColumns As New List(Of String)

Event DeleteLabels(strColumnName As String) Implements IColumnMetaDataGrid.DeleteLabels

Public Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object) Implements IColumnMetaDataGrid.EditValue

Public Sub AddColumns(columnMetaData As clsColumnMetaData) Implements IColumnMetaDataGrid.AddColumns
Expand Down
2 changes: 1 addition & 1 deletion instat/UserControls/DataGrid/Linux/ucrDataViewLinuxGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Public Class ucrDataViewLinuxGrid
Public Sub AddRowData(dataFrame As clsDataFrame) Implements IDataViewGrid.AddRowData
Dim dataGrid = GetDataGridFromSelectedTab()

If dataFrame.clsFilter.bFilterApplied Then
If dataFrame.clsFilterOrColumnSelection.bFilterApplied Then
dataGrid.RowHeadersDefaultCellStyle.ForeColor = Color.Red
Else
dataGrid.RowHeadersDefaultCellStyle.ForeColor = Color.DarkBlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Public Class ucrDataframeMetadataLinuxGrid
Implements IDataframeMetaDataGrid

Event DeleteLabels(strColumnName As String) Implements IDataframeMetaDataGrid.DeleteLabels

Public Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object) Implements IDataframeMetaDataGrid.EditValue

Public Sub AddColumns() Implements IDataframeMetaDataGrid.AddColumns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Public Class ucrColumnMetadataReoGrid
Private _lstNonEditableColumns As New List(Of String)
Private strPreviousCellText As String

Public Event DeleteLabels(strColumnName As String) Implements IColumnMetaDataGrid.DeleteLabels
Public Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object) Implements IColumnMetaDataGrid.EditValue

Public Sub AddColumns(columnMetaData As clsColumnMetaData) Implements IColumnMetaDataGrid.AddColumns
Expand Down Expand Up @@ -66,7 +67,7 @@ Public Class ucrColumnMetadataReoGrid
AddHandler worksheet.BeforeCut, AddressOf Worksheet_BeforeCut
AddHandler worksheet.BeforePaste, AddressOf Worksheet_BeforePaste
AddHandler worksheet.BeforeRangeMove, AddressOf Worksheet_BeforeRangeMove
AddHandler worksheet.BeforeCellKeyDown, AddressOf Worksheet_BeforeCellKeyDown
AddHandler worksheet.BeforeCellKeyDown, AddressOf Worksheet_BeforeCellKeyDownColumnMetadata
End Sub

Private Sub Worksheet_AfterCellEdit(sender As Object, e As CellAfterEditEventArgs)
Expand All @@ -91,4 +92,11 @@ Public Class ucrColumnMetadataReoGrid
e.IsCancelled = True
End Sub

Protected Sub Worksheet_BeforeCellKeyDownColumnMetadata(sender As Object, e As BeforeCellKeyDownEventArgs)
If e.KeyCode = unvell.ReoGrid.Interaction.KeyCode.Delete OrElse e.KeyCode = unvell.ReoGrid.Interaction.KeyCode.Back Then
RaiseEvent DeleteLabels(grdData.CurrentWorksheet.ColumnHeaders(e.Cell.Column).Text)
e.IsCancelled = True
End If
End Sub

End Class
13 changes: 11 additions & 2 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ Public Class ucrDataViewReoGrid
Public Event WorksheetChanged() Implements IDataViewGrid.WorksheetChanged

Public Event WorksheetRemoved(worksheet As clsWorksheetAdapter) Implements IDataViewGrid.WorksheetRemoved

Public Sub AddColumns(visiblePage As clsDataFramePage) Implements IDataViewGrid.AddColumns
Dim workSheetColumnHeader As ColumnHeader
Dim variableTextColour As Color

grdData.CurrentWorksheet.Columns = visiblePage.lstColumns.Count

If GetCurrentDataFrameFocus.clsFilterOrColumnSelection.bColumnSelectionApplied Then
variableTextColour = Color.Red
Else
variableTextColour = Color.DarkBlue
End If
For i = 0 To visiblePage.lstColumns.Count - 1
workSheetColumnHeader = grdData.CurrentWorksheet.ColumnHeaders(i)
workSheetColumnHeader.Text = visiblePage.lstColumns(i).strDisplayName
workSheetColumnHeader.TextColor = visiblePage.lstColumns(i).clsColour
workSheetColumnHeader.TextColor = variableTextColour
workSheetColumnHeader.Style.BackColor = visiblePage.lstColumns(i).clsBackGroundColour
Next
End Sub
Expand All @@ -53,7 +62,7 @@ Public Class ucrDataViewReoGrid
grdData.CurrentWorksheet.Rows = dataFrame.iDisplayedRowCount
UpdateWorksheetSettings(grdData.CurrentWorksheet)

If dataFrame.clsFilter.bFilterApplied Then
If dataFrame.clsFilterOrColumnSelection.bFilterApplied Then
textColour = Color.Red
Else
textColour = Color.DarkBlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Public Class ucrDataframeMetadataReoGrid
Private lstNonEditableColumns As New List(Of String)
Private strPreviousCellText As String

Event DeleteLabels(strColumnName As String) Implements IDataframeMetaDataGrid.DeleteLabels
Public Event EditValue(iRow As Integer, strColumnName As String, strPreviousValue As String, newValue As Object) Implements IDataframeMetaDataGrid.EditValue

Public Sub AddColumns() Implements IDataframeMetaDataGrid.AddColumns
Expand Down
Loading

0 comments on commit 6d2e6b8

Please sign in to comment.