Skip to content

Commit

Permalink
Merge pull request #90 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
MeSophie authored Aug 8, 2023
2 parents 8ae790e + a48633f commit 61d648c
Show file tree
Hide file tree
Showing 54 changed files with 4,371 additions and 2,168 deletions.
5 changes: 5 additions & 0 deletions docs/Download.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ <h3>Latest stable release 0.7.6</h3>
<p>If you know that you have a 64 bit computer, we suggest you download the 64 Bit version</p>
<hr class="light">
<h3>Other releases (beta)</h3>
<h4>0.7.16</h4>
<p>
<a href="https://downloads.r-instat.org/R-Instat_0.7.16.50_Installer_32.exe" style="color:blue;" target="_blank">32 Bit (.exe 812MB)</a> |
<a href="https://downloads.r-instat.org/R-Instat_0.7.16.50_Installer_64.exe" style="color:blue;" target="_blank">64 Bit (.exe 950MB)</a>
</p>
<h4>0.7.15</h4>
<p>
<a href="https://downloads.r-instat.org/R-Instat_0.7.15.49_Installer_32.exe" style="color:blue;" target="_blank">32 Bit (.exe 800MB)</a> |
Expand Down
13 changes: 13 additions & 0 deletions instat/Interface/IDataViewGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ Public Interface IDataViewGrid

Event WorksheetRemoved(worksheet As clsWorksheetAdapter)

Event FindRow()

Sub AddColumns(visiblePage As clsDataFramePage)

Sub AddRowData(dataFrame As clsDataFrame)

Sub SearchRowInGrid(rowNumbers As List(Of Integer), strColumn As String, Optional iRow As Integer = 0,
Optional bApplyToRows As Boolean = False)

Sub SelectColumnInGrid(strColumn As String)

Sub AdjustColumnWidthAfterWrapping(strColumn As String, Optional bApplyWrap As Boolean = False)

Function GetSelectedColumns() As List(Of clsColumnHeaderDisplay)

Function GetFirstRowHeader() As String

Function GetLastRowHeader() As String

Function GetWorksheetCount() As Integer

End Interface
2 changes: 2 additions & 0 deletions instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ Public Class clsDataFramePage
columnHeader.strTypeShortCode = "(LT)"
ElseIf strHeaderType.Contains("complex") Then
columnHeader.strTypeShortCode = "(CX)"
ElseIf strHeaderType.Contains("sfc_MULTIPOLYGON") OrElse strHeaderType.Contains("sfc") Then
columnHeader.strTypeShortCode = "(G)"
' Types of data for specific Application areas e.g. survival are coded with "(A)"
' No examples implemented yet.
'ElseIf strType.Contains() Then
Expand Down
63 changes: 37 additions & 26 deletions instat/Model/Output/clsOutputLogger.vb
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,47 @@ Public Class clsOutputLogger
Exit Sub
End If

Dim outputType As OutputType
If String.IsNullOrEmpty(strOutput) Then
outputType = OutputType.Script
ElseIf Not bAsFile Then
outputType = OutputType.TextOutput
Else
Dim strFileExtension As String = Path.GetExtension(strOutput).ToLower
Select Case strFileExtension
Case ".png"
outputType = OutputType.ImageOutput
Case ".html"
outputType = OutputType.HtmlOutput
Case ".txt"
outputType = OutputType.TextOutput
Case Else
MessageBox.Show("The file type to be added is currently not suported",
"Developer Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error)
Exit Sub
End Select
'add the R script as an output element
Dim rScriptElement As New clsOutputElement
rScriptElement.SetContent(strScript, OutputType.Script, "")
_outputElements.Add(rScriptElement)
'raise event for output pages
RaiseEvent NewOutputAdded(rScriptElement, False)


If Not String.IsNullOrEmpty(strOutput) Then
Dim outputElement As New clsOutputElement
Dim outputType As OutputType
If bAsFile Then
Dim strFileExtension As String = Path.GetExtension(strOutput).ToLower
Select Case strFileExtension
Case ".png"
outputType = OutputType.ImageOutput
Case ".html"
outputType = OutputType.HtmlOutput
Case ".txt"
outputType = OutputType.TextOutput
Case Else
MessageBox.Show("The file type to be added is currently not suported",
"Developer Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error)
Exit Sub
End Select
Else
outputType = OutputType.TextOutput
End If

'add the output with it's R script as another output element
outputElement.SetContent("", outputType, strOutput)
'_outputElements.Add(outputElement)
'raise event for output pages
RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer)

End If

Dim outputElement As New clsOutputElement
outputElement.SetContent(strScript, outputType, strOutput)

_outputElements.Add(outputElement)

'raise event for output pages
RaiseEvent NewOutputAdded(outputElement, bDisplayOutputInExternalViewer)
End Sub

''' <summary>
Expand Down
4 changes: 2 additions & 2 deletions instat/Translations.vb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Public Class Translations
strSqlUpdate &= "("
For iListPos As Integer = 0 To lstPatterns.Count - 1
strSqlUpdate &= If(iListPos > 0, " OR ", "")
strSqlUpdate &= "control_name LIKE '" & lstPatterns.Item(iListPos) & "'"
strSqlUpdate &= "control_name LIKE '" & lstPatterns.Item(iListPos) & "' ESCAPE '\'"
Next iListPos
strSqlUpdate &= ")"
End If
Expand All @@ -306,7 +306,7 @@ Public Class Translations
strSqlUpdate &= "NOT ("
For iListPos As Integer = 0 To lstPatternNegations.Count - 1
strSqlUpdate &= If(iListPos > 0, " OR ", "")
strSqlUpdate &= "control_name LIKE '" & lstPatternNegations.Item(iListPos) & "'"
strSqlUpdate &= "control_name LIKE '" & lstPatternNegations.Item(iListPos) & "' ESCAPE '\'"
Next iListPos
strSqlUpdate &= ")"
End If
Expand Down
66 changes: 42 additions & 24 deletions instat/UserControl/ucrOutputPage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ Public Class ucrOutputPage
Public Sub AddNewOutput(outputElement As clsOutputElement, Optional bDisplayOutputInExternalViewer As Boolean = False)
'add the script first. This applies to whether the output has an output or not or
'whether it's just a script output
AddNewScript(outputElement)

'todo. temporary fix. Output element should always have an R script
If outputElement.FormattedRScript IsNot Nothing Then
AddNewScript(outputElement)
End If


'then add the output of the script if there is an output
If Not String.IsNullOrEmpty(outputElement.Output) Then
Expand Down Expand Up @@ -159,43 +164,53 @@ Public Class ucrOutputPage
.BorderStyle = BorderStyle.None
}

'if settings are not available or both show commands and comments settings are enabled then just show the whole script
FillRichTextWithRScriptBasedOnSettings(richTextBox, outputElement.FormattedRScript)

'if no contents added just exit sub
If richTextBox.TextLength = 0 Then
Exit Sub
End If

Dim panel As Panel = AddElementPanel(outputElement)
panel.Controls.Add(richTextBox)
panel.Controls.SetChildIndex(richTextBox, 0)
SetRichTextBoxHeight(richTextBox)
AddHandler richTextBox.KeyUp, AddressOf richTextBox_CopySelectedText
AddHandler richTextBox.MouseLeave, AddressOf panelContents_MouseLeave
End Sub


'fills rich textbox with r script provided based on the global options provided
'if all disabled then richtext will not be filled
Private Sub FillRichTextWithRScriptBasedOnSettings(richTextBox As RichTextBox, formattedRScript As List(Of clsRScriptElement))
'if settings are not available or both show commands and comments settings are enabled then just show the whole script
If frmMain.clsInstatOptions Is Nothing OrElse (frmMain.clsInstatOptions.bIncludeCommentDefault AndAlso frmMain.clsInstatOptions.bCommandsinOutput) Then
FillRichTextBoxWithFormatedRScript(richTextBox, outputElement.FormattedRScript)
FillRichTextBoxWithFormatedRScript(richTextBox, formattedRScript)
Else

'if either show commands or comments settings is enabled show the script that corresponds to either
If frmMain.clsInstatOptions.bIncludeCommentDefault Then
'show comments only
For Each line As clsRScriptElement In outputElement.FormattedRScript
For Each line As clsRScriptElement In formattedRScript
If line.Type = clsRToken.typToken.RComment Then
AddFormatedTextToRichTextBox(richTextBox, line.Text, OutputFont.GetFontForScriptType(line.Type), OutputFont.GetColourForScriptType(line.Type))
End If
Next

ElseIf frmMain.clsInstatOptions.bCommandsinOutput Then
'show command lines that are not comments
For Each line As clsRScriptElement In outputElement.FormattedRScript
For Each line As clsRScriptElement In formattedRScript
If Not (line.Type = clsRToken.typToken.RComment) Then
AddFormatedTextToRichTextBox(richTextBox, line.Text, OutputFont.GetFontForScriptType(line.Type), OutputFont.GetColourForScriptType(line.Type))
End If
Next
End If
End If

'if no contents added just exit sub
If richTextBox.TextLength = 0 Then
Exit Sub
End If

Dim panel As Panel = AddElementPanel(outputElement)
panel.Controls.Add(richTextBox)
panel.Controls.SetChildIndex(richTextBox, 0)
SetRichTextBoxHeight(richTextBox)
AddHandler richTextBox.KeyUp, AddressOf richTextBox_CopySelectedText
AddHandler richTextBox.MouseLeave, AddressOf panelContents_MouseLeave
End Sub



Private Sub AddNewTextOutput(outputElement As clsOutputElement)
Dim panel As Panel = AddElementPanel(outputElement)

Expand Down Expand Up @@ -403,10 +418,17 @@ Public Class ucrOutputPage
Private Sub AddElementToRichTextBox(element As clsOutputElement, richText As RichTextBox)
Select Case element.OutputType
Case OutputType.Script
FillRichTextBoxWithFormatedRScript(richText, element.FormattedRScript)
FillRichTextWithRScriptBasedOnSettings(richText, element.FormattedRScript)
Case OutputType.TextOutput
'todo. check if output is file or not. if file, read the contents of the file
AddFormatedTextToRichTextBox(richText, element.Output, OutputFont.ROutputFont, OutputFont.ROutputColour)
Dim strOutput As String = ""
If element.IsFile Then
For Each strLine As String In IO.File.ReadLines(element.Output)
strOutput = strOutput & strLine & Environment.NewLine
Next strLine
Else
strOutput = element.Output
End If
AddFormatedTextToRichTextBox(richText, strOutput, OutputFont.ROutputFont, OutputFont.ROutputColour)
Case OutputType.ImageOutput
Clipboard.Clear()
'todo. instead of copy paste, add image to rtf directly from file?
Expand All @@ -418,11 +440,7 @@ Public Class ucrOutputPage
End Sub

Private Function GetBitmapFromFile(strFilename As String) As Bitmap
Dim image As Bitmap
Using fs As New IO.FileStream(strFilename, IO.FileMode.Open)
image = New Bitmap(Drawing.Image.FromStream(fs))
End Using
Return image
Return New Bitmap(strFilename)
End Function

Private Sub AddFormatedTextToRichTextBox(richTextBox As RichTextBox, text As String, font As Font, colour As Color)
Expand Down
53 changes: 32 additions & 21 deletions instat/UserControl/ucrOutputPages.Designer.vb

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

Loading

0 comments on commit 61d648c

Please sign in to comment.