Skip to content

Commit

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

updated my master
  • Loading branch information
conlooptechnologies authored Mar 4, 2022
2 parents 1a4f763 + c2aa944 commit 0fadca3
Show file tree
Hide file tree
Showing 45 changed files with 1,633 additions and 526 deletions.
2 changes: 2 additions & 0 deletions instat/Interface/IDataViewGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Public Interface IDataViewGrid

Event ReplaceValueInData(strNewValue As String, strColumnName As String, strRowText As String)

Event DeleteValuesToDataframe()

Event WorksheetChanged()

Event WorksheetRemoved(worksheet As clsWorksheetAdapter)
Expand Down
2 changes: 2 additions & 0 deletions instat/Interface/IGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Public Interface IGrid

Function GetSelectedRows() As List(Of String)

Function GetSelectedColumnIndexes() As List(Of String)

Function GetWorksheet(strName As String) As clsWorksheetAdapter

Sub RemoveOldWorksheets()
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
2 changes: 1 addition & 1 deletion instat/Model/DataFrame/clsDataFrameFilter.vb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Imports RDotNet
''' <summary>
''' Holds filter information for the dataframe
''' </summary>
Public Class clsDataFrameFilter
Public Class clsDataFrameFilterOrColumnSelection
Protected _strDataFrameName As String
Protected _RLink As RLink

Expand Down
16 changes: 16 additions & 0 deletions instat/Model/RCommand/clsPrepareFunctionsForGrids.vb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ Public Class clsPrepareFunctionsForGrids
End If
_RLink.RunScript(clsReplaceValue.ToScript(), strComment:="Replace Value In Data")
End Sub

''' <summary>
''' Get the column type for a given column
''' </summary>
Expand All @@ -321,5 +322,20 @@ Public Class clsPrepareFunctionsForGrids
Return _RLink.GetColumnType(_strDataFrame, strColumnName)
End Function

''' <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>
''' <param name="lstColumnNames"></param>
''' <param name="lstRowNames"></param>
Public Sub DeleteCells(lstRowNames As List(Of String), lstColumnNames As List(Of String))
Dim clsDeleteCells As New RFunction
clsDeleteCells.SetRCommand(_RLink.strInstatDataObject & "$replace_values_with_NA")
clsDeleteCells.AddParameter("data_name", Chr(34) & _strDataFrame & Chr(34))
clsDeleteCells.AddParameter("column_index", _RLink.GetListAsRString(lstColumnNames, bWithQuotes:=False))
clsDeleteCells.AddParameter("row_index", _RLink.GetListAsRString(lstRowNames, bWithQuotes:=False))
_RLink.RunScript(clsDeleteCells.ToScript(), strComment:="Right click menu: Delete Cell(s)")
End Sub
End Class

7 changes: 7 additions & 0 deletions instat/UserControl/ucrOutputPage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Public Class ucrOutputPage
panel.Controls.Add(checkBox)
_checkBoxes.Add(checkBox)
AddHandler checkBox.Click, AddressOf checkButton_Click
AddHandler checkBox.MouseLeave, AddressOf panelContents_MouseLeave
End Sub

Private Sub AddNewScript(outputElement As clsOutputElement)
Expand All @@ -195,6 +196,7 @@ Public Class ucrOutputPage
panel.Controls.SetChildIndex(richTextBox, 0)
SetRichTextBoxHeight(richTextBox)
AddHandler richTextBox.KeyUp, AddressOf richTextBox_CopySelectedText
AddHandler richTextBox.MouseLeave, AddressOf panelContents_MouseLeave
End Sub

Private Function CopyOneImageOnly() As Boolean
Expand Down Expand Up @@ -256,6 +258,7 @@ Public Class ucrOutputPage
panel.Controls.SetChildIndex(richTextBox, 0)
SetRichTextBoxHeight(richTextBox)
AddHandler richTextBox.KeyUp, AddressOf richTextBox_CopySelectedText
AddHandler richTextBox.MouseLeave, AddressOf panelContents_MouseLeave
End Sub

Private Sub AddNewImageOutput(outputElement As clsOutputElement)
Expand Down Expand Up @@ -294,6 +297,10 @@ Public Class ucrOutputPage
End If
End Sub

Private Sub panelContents_MouseLeave(sender As Object, e As EventArgs)
pnlMain.Focus()
End Sub

Private Sub CopySelectedTextToClipBoard(richText As RichTextBox, richTextFormat As String)
Dim strClip As String = String.Empty
Dim dto As New DataObject()
Expand Down
8 changes: 6 additions & 2 deletions instat/UserControls/DataGrid/Linux/ucrDataViewLinuxGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Public Class ucrDataViewLinuxGrid

Public Event PasteValuesToDataframe() Implements IDataViewGrid.PasteValuesToDataframe

Public Event DeleteValueToDataframe() Implements IDataViewGrid.DeleteValuesToDataframe

Public Event WorksheetChanged() Implements IDataViewGrid.WorksheetChanged

Public Event WorksheetRemoved(worksheet As clsWorksheetAdapter) Implements IDataViewGrid.WorksheetRemoved
Expand All @@ -46,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 Expand Up @@ -112,6 +114,9 @@ Public Class ucrDataViewLinuxGrid
If ctrlV Or shiftIns Then
RaiseEvent PasteValuesToDataframe()
End If
If e.KeyCode = Keys.Delete OrElse e.KeyCode = Keys.Back Then
RaiseEvent DeleteValueToDataframe()
End If
End Sub

Private Function GetCurrentDataFrameFocus() As clsDataFrame
Expand Down Expand Up @@ -141,5 +146,4 @@ Public Class ucrDataViewLinuxGrid
Private Sub tcTabs_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tcTabs.SelectedIndexChanged
RaiseEvent WorksheetChanged()
End Sub

End Class
22 changes: 20 additions & 2 deletions instat/UserControls/DataGrid/Linux/ucrLinuxGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,30 @@ Public MustInherit Class ucrLinuxGrid
Public Function GetSelectedRows() As List(Of String) Implements IGrid.GetSelectedRows
Dim lstSelectedRows As New List(Of String)
Dim dataGrid = GetGrid(tcTabs.SelectedTab)
For Each row As DataGridViewRow In dataGrid.SelectedRows
lstSelectedRows.Add(row.HeaderCell.Value)
'For Each row As DataGridViewRow In dataGrid.SelectedRows
' lstSelectedRows.Add(row.HeaderCell.Value)
'Next
For i As Integer = 0 To dataGrid.GetCellCount(DataGridViewElementStates.Selected) - 1
lstSelectedRows.Add(dataGrid.SelectedCells(i).RowIndex.ToString + 1)
Next
lstSelectedRows = lstSelectedRows.Distinct.ToList
Return lstSelectedRows
End Function


Public Function GetSelectedColumnIndexes() As List(Of String) Implements IGrid.GetSelectedColumnIndexes
Dim lstSelectedColumnIndexes As New List(Of String)
Dim dataGrid = GetGrid(tcTabs.SelectedTab)
'For Each column As DataGridViewColumn In dataGrid.SelectedColumns
' lstSelectedColumnIndexes.Add(column.HeaderCell.Value)
'Next
For i As Integer = 0 To dataGrid.GetCellCount(DataGridViewElementStates.Selected) - 1
lstSelectedColumnIndexes.Add(dataGrid.SelectedCells(i).ColumnIndex.ToString + 1)
Next
lstSelectedColumnIndexes = lstSelectedColumnIndexes.Distinct.ToList
Return lstSelectedColumnIndexes
End Function

Public Function GetWorksheet(name As String) As clsWorksheetAdapter Implements IGrid.GetWorksheet
For Each tabPage As TabPage In tcTabs.TabPages
If tabPage.Text = name Then
Expand Down
25 changes: 22 additions & 3 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,27 @@ Public Class ucrDataViewReoGrid

Public Event ReplaceValueInData(strNewValue As String, strColumnName As String, strRowText As String) Implements IDataViewGrid.ReplaceValueInData

Public Event DeleteValueToDataframe() Implements IDataViewGrid.DeleteValuesToDataframe

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 @@ -51,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 Expand Up @@ -84,7 +95,7 @@ Public Class ucrDataViewReoGrid
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_BeforeCellsKeyDown
AddHandler worksheet.CellDataChanged, AddressOf Worksheet_CellDataChanged
End Sub

Expand Down Expand Up @@ -149,4 +160,12 @@ Public Class ucrDataViewReoGrid
Private Sub Worksheet_CellDataChanged(sender As Object, e As CellEventArgs)
RaiseEvent CellDataChanged()
End Sub

Private Sub Worksheet_BeforeCellsKeyDown(sender As Object, e As BeforeCellKeyDownEventArgs)
e.IsCancelled = True
If e.KeyCode = unvell.ReoGrid.Interaction.KeyCode.Delete OrElse e.KeyCode = unvell.ReoGrid.Interaction.KeyCode.Back Then
RaiseEvent DeleteValueToDataframe()
End If
End Sub

End Class
9 changes: 9 additions & 0 deletions instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ Public MustInherit Class ucrReoGrid
Return lstSelectedRows
End Function

Public Function GetSelectedColumnIndexes() As List(Of String) Implements IGrid.GetSelectedColumnIndexes
Dim lstSelectedColumnIndexes As New List(Of String)
Dim clsRange As RangePosition = grdData.CurrentWorksheet.SelectionRange
For i As Integer = clsRange.Col To clsRange.Col + clsRange.Cols - 1
lstSelectedColumnIndexes.Add(grdData.CurrentWorksheet.ColumnHeaders.Item(i).Index + 1)
Next
Return lstSelectedColumnIndexes
End Function

Public Function GetWorksheet(name As String) As clsWorksheetAdapter Implements IGrid.GetWorksheet
Dim worksheet = grdData.Worksheets.Where(Function(x) x.Name = name).FirstOrDefault
If worksheet IsNot Nothing Then
Expand Down
44 changes: 22 additions & 22 deletions instat/dlgDeleteObjects.Designer.vb

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

2 changes: 1 addition & 1 deletion instat/dlgDeleteObjects.vb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ Public Class dlgDeleteObjects
ucrInputComboType.SetParameter(New RParameter("object_type", 2))
dctTypes.Add("Objects", Chr(34) & "object" & Chr(34))
dctTypes.Add("Filters", Chr(34) & "filter" & Chr(34))
dctTypes.Add("Column selections", Chr(34) & "column_selection" & Chr(34))
dctTypes.Add("Calculations", Chr(34) & "calculation" & Chr(34))
dctTypes.Add("Tables", Chr(34) & "table" & Chr(34))
dctTypes.Add("Graphs", Chr(34) & "graph" & Chr(34))
dctTypes.Add("Models", Chr(34) & "model" & Chr(34))
ucrInputComboType.SetItems(dctTypes)
ucrInputComboType.SetDropDownStyleAsNonEditable()

End Sub

Private Sub SetDefaults()
Expand Down
Loading

0 comments on commit 0fadca3

Please sign in to comment.