Skip to content

Commit

Permalink
Merge pull request #54 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
MeSophie authored Apr 19, 2023
2 parents 799cc46 + 58c89fc commit 9899f92
Show file tree
Hide file tree
Showing 122 changed files with 25,218 additions and 11,623 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,4 @@ installer/Output/
/packages/jacobslusser.ScintillaNET.*/

/packages/NLog.*/
/packages/Newtonsoft.Json.*/
10 changes: 10 additions & 0 deletions docs/Download.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ <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.10</h4>
<p>
<a href="https://downloads.r-instat.org/R-Instat_0.7.10.43_Installer_32.exe" style="color:blue;" target="_blank">32 Bit (.exe 874MB)</a> |
<a href="https://downloads.r-instat.org/R-Instat_0.7.10.43_Installer_64.exe" style="color:blue;" target="_blank">64 Bit (.exe 1015MB)</a>
</p>
<h4>0.7.9</h4>
<p>
<a href="https://downloads.r-instat.org/R-Instat_0.7.9.41_Installer_32.exe" style="color:blue;" target="_blank">32 Bit (.exe 850MB)</a> |
<a href="https://downloads.r-instat.org/R-Instat_0.7.9.41_Installer_64.exe" style="color:blue;" target="_blank">64 Bit (.exe 979MB)</a>
</p>
<h4>0.7.8</h4>
<p>
<a href="https://downloads.r-instat.org/R-Instat_0_7_8_Installer_32.exe" style="color:blue;" target="_blank">32 Bit (.exe 780MB)</a> |
Expand Down
418 changes: 209 additions & 209 deletions instat/DlgDefineClimaticData.Designer.vb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions instat/DlgDefineClimaticData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ Public Class DlgDefineClimaticData

Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 328
Dim kvpRain As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("rain", {"rain", "prec", "rr", "prcp"}.ToList())
Dim kvpRain As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("rain", {"rain", "prec", "rr", "prcp", "x5"}.ToList())
Dim kvpDate As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("date", {"date", "record"}.ToList())
Dim kvpStation As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("station", {"station", "id", "name"}.ToList())
Dim kvpCloudCover As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("cloud_cover", {"cloud"}.ToList())
Dim kvpTempMax As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("temp_max", {"tmax", "tx", "tempmax", "tmp_max"}.ToList())
Dim kvpTempMin As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("temp_min", {"tmin", "tn", "tempmin", "tmp_min"}.ToList())
Dim kvpTempMax As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("temp_max", {"tmax", "tx", "tempmax", "tmp_max", "x2", "tmpmax"}.ToList())
Dim kvpTempMin As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("temp_min", {"tmin", "tn", "tempmin", "tmp_min", "x3", "tmpmin"}.ToList())
Dim kvpRadiation As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("radiation", {"radiation", "rad"}.ToList())
Dim kvpSunshineHours As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("sunshine_hours", {"sunshine", "sunh", "sunhrs"}.ToList())
Dim kvpWindDirection As KeyValuePair(Of String, List(Of String)) = New KeyValuePair(Of String, List(Of String))("wind_direction", {"winddirection"}.ToList())
Expand Down
2 changes: 1 addition & 1 deletion instat/NLog.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
name="AllLogs"
xsi:type="File"
layout="${longdate} ${uppercase:${level}} ${message}|${exception}"
fileName="${basedir}/logs/${shortdate}.log"
fileName="${specialfolder:folder=ApplicationData}/RInstat/logs/${shortdate}.log"
maxArchiveDays="5"
archiveEvery="Day"
archiveOldFileOnStartup="true"
Expand Down
2 changes: 0 additions & 2 deletions instat/Translations.vb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Public Class Translations
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrColumnMeta.Name, frmMain.ucrColumnMeta.statusColumnMenu.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrDataFrameMeta.Name, frmMain.ucrDataFrameMeta.cellContextMenuStrip.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrDataFrameMeta.Name, frmMain.ucrDataFrameMeta.rowRightClickMenu.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrLogWindow.Name, frmMain.ucrLogWindow.mnuContextLogFile.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrScriptWindow.Name, frmMain.ucrScriptWindow.mnuContextScript.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrDataViewer.Name, frmMain.ucrDataViewer.rowContextMenu.Items, strDbPath, strLanguageCode))
HandleError(TranslateWinForm.clsTranslateWinForm.TranslateMenuItems(frmMain.ucrDataViewer.Name, frmMain.ucrDataViewer.ColumnContextMenu.Items, strDbPath, strLanguageCode))
Expand Down Expand Up @@ -202,7 +201,6 @@ Public Class Translations
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrColumnMeta, frmMain.ucrColumnMeta.statusColumnMenu.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrDataFrameMeta, frmMain.ucrDataFrameMeta.cellContextMenuStrip.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrDataFrameMeta, frmMain.ucrDataFrameMeta.rowRightClickMenu.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrLogWindow, frmMain.ucrLogWindow.mnuContextLogFile.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrScriptWindow, frmMain.ucrScriptWindow.mnuContextScript.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrDataViewer, frmMain.ucrDataViewer.RowContextMenu.Items)
strControlsAsCsv &= TranslateWinForm.clsTranslateWinForm.GetMenuItemsAsCsv(frmMain.ucrDataViewer, frmMain.ucrDataViewer.ColumnContextMenu.Items)
Expand Down
6 changes: 6 additions & 0 deletions instat/UserControls/DataGrid/Linux/ucrDataViewLinuxGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Public Class ucrDataViewLinuxGrid
RaiseEvent IDataViewGrid_ReplaceValueInData(dataGrid.CurrentCell.Value.ToString(),
GetCurrentDataFrameFocus().clsVisibleDataFramePage.lstColumns(dataGrid.CurrentCell.ColumnIndex).strName,
GetCurrentDataFrameFocus().clsVisibleDataFramePage.RowNames()(dataGrid.CurrentCell.RowIndex))
RefreshSingleCell(dataGrid.CurrentCell.ColumnIndex, dataGrid.CurrentCell.RowIndex)
End Sub

'ToDo allow editing
Expand Down Expand Up @@ -146,4 +147,9 @@ Public Class ucrDataViewLinuxGrid
Private Sub tcTabs_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tcTabs.SelectedIndexChanged
RaiseEvent WorksheetChanged()
End Sub

Private Sub RefreshSingleCell(iColumn As Integer, iRow As Integer)
Dim dataGrid = GetDataGridFromSelectedTab()
dataGrid.Rows(iRow).Cells(iColumn).Value = GetCurrentDataFrameFocus.DisplayedData(iRow, iColumn)
End Sub
End Class
7 changes: 7 additions & 0 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Public Class ucrDataViewReoGrid
End If
Next

grdData.CurrentWorksheet.ScrollToCell("A1") ' will always set the scrollbar at the top.

'todo. As of 30/05/2022, the reogrid control version used did not have this setting option
'see issue #7221 for more information.
'get pixel size equivalent of the longest row header text
Expand All @@ -94,6 +96,10 @@ Public Class ucrDataViewReoGrid
grdData.CurrentWorksheet.RowHeaderWidth = TextRenderer.MeasureText(strLongestRowHeaderText, Me.Font).Width
End Sub

Private Sub RefreshSingleCell(iColumn As Integer, iRow As Integer)
grdData.CurrentWorksheet(iRow, iColumn) = GetCurrentDataFrameFocus.DisplayedData(iRow, iColumn)
End Sub

Private Function GetInnerBracketedString(strData As String) As String
Dim intFirstRightBracket As Integer = InStr(strData, ")")
Dim intLastLeftBracket As Integer = InStrRev(strData, "(")
Expand Down Expand Up @@ -168,6 +174,7 @@ Public Class ucrDataViewReoGrid
GetCurrentDataFrameFocus().clsVisibleDataFramePage.lstColumns(e.Cell.Column).strName,
GetCurrentDataFrameFocus().clsVisibleDataFramePage.RowNames()(e.Cell.Row))
e.EndReason = unvell.ReoGrid.EndEditReason.Cancel
RefreshSingleCell(e.Cell.Column, e.Cell.Row)
End Sub


Expand Down
5 changes: 4 additions & 1 deletion instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ Public MustInherit Class ucrReoGrid
End Sub

Public Sub CopyRange() Implements IGrid.CopyRange
grdData.CurrentWorksheet.Copy()
If Not IsNothing(grdData) _
AndAlso Not IsNothing(grdData.CurrentWorksheet) Then
grdData.CurrentWorksheet.Copy()
End If
End Sub

Public Function GetSelectedRows() As List(Of String) Implements IGrid.GetSelectedRows
Expand Down
8 changes: 5 additions & 3 deletions instat/UserControls/Webview/Windows/ucrWebViewer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Public Class ucrWebViewer
Me.Controls.Add(_browser)
End Sub

Public Sub LoadHtmlFile(strFileName As String)
Public Sub LoadHtmlFile(strFileName As String, Optional bReplace As Boolean = True)
If _browser Is Nothing Then
Return
End If
Expand All @@ -45,8 +45,10 @@ Public Class ucrWebViewer
'it's not yet clear how we can implement a custom schema at this point,
'not unless we specify R-Instat temp output folder in the R commands.
'that should be the first step

Dim strUrl As String = "file:///" + strFileName.Replace("\", "/")
Dim strUrl As String = strFileName
If bReplace Then
strUrl = "file:///" + strFileName.Replace("\", "/")
End If
_browser.LoadUrl(strUrl)
_browser.Dock = DockStyle.Fill
End Sub
Expand Down
4 changes: 2 additions & 2 deletions instat/UserControls/frmMaximiseOutput.vb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Public Class frmMaximiseOutput
'todo. to be used by the output page to remember paths selected by user when saving outputs
Public _strFileDestinationDirectory As String = ""

Public Overloads Sub Show(strFileName As String)
Public Overloads Sub Show(strFileName As String, Optional bReplace As Boolean = True)
Me._strDisplayedFileName = strFileName
Dim strFileExtension As String = Path.GetExtension(_strDisplayedFileName).ToLower
Me.panelControl.Controls.Clear()
Expand All @@ -51,7 +51,7 @@ Public Class frmMaximiseOutput
If RuntimeInformation.IsOSPlatform(OSPlatform.Windows) AndAlso CefRuntimeWrapper.IsCefInitilised Then
_strFileFilter = "html (*.html)|*.html"
Dim ucrWebView As New ucrWebViewer
ucrWebView.LoadHtmlFile(_strDisplayedFileName)
ucrWebView.LoadHtmlFile(strFileName:=_strDisplayedFileName, bReplace:=bReplace)
Me.panelControl.Controls.Add(ucrWebView)
ucrWebView.Dock = DockStyle.Fill
Else
Expand Down
63 changes: 63 additions & 0 deletions instat/clsFileUrlUtilities.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
' R- Instat
' Copyright (C) 2015-2017
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports System.IO
Imports RDotNet
Public Class clsFileUrlUtilities

''' <summary>
''' Returns the URL of the package HTML file.
''' </summary>
''' <param name="strPackageName"> The package name. </param>
''' <param name="strTopic"> The package topic. </param>
''' <param name="bVignette"> Check if we need to return the URL of the package vignette file. </param>
''' <returns></returns>
Public Shared Function GetHelpFileURL(strPackageName As String, Optional strTopic As String = "", Optional bVignette As Boolean = False) As String
Dim clsGetPortFunction As New RFunction

clsGetPortFunction.SetPackageName("tools")
clsGetPortFunction.SetRCommand("startDynamicHelp")
clsGetPortFunction.AddParameter("start", "NA", iPosition:=0)

Dim expPortTemp As SymbolicExpression
expPortTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsGetPortFunction.ToScript(), bSeparateThread:=False)
Dim strPort As String = ""
If expPortTemp IsNot Nothing AndAlso expPortTemp.Type <> Internals.SymbolicExpressionType.Null Then
strPort = expPortTemp.AsInteger(0)
End If

Dim strFilePath As String = Path.Combine("library", strPackageName, "html", "00Index.html")
If strTopic <> "" Then
strFilePath = Path.Combine("library", strPackageName, "html", String.Concat(strTopic, ".html"))
End If

Dim strLocalHost As String = "127.0.0.1:"
Dim strURL As String = Path.Combine(String.Concat("http://", strLocalHost), strPort, strFilePath)

If bVignette Then
Dim clsGetVignetteFunction As New RFunction

clsGetVignetteFunction.SetRCommand("get_vignette")
clsGetVignetteFunction.AddParameter("package", Chr(34) & strPackageName & Chr(34), iPosition:=0)
strURL = frmMain.clsRLink.RunInternalScriptGetValue(clsGetVignetteFunction.ToScript(), bSeparateThread:=False).AsCharacter(0)
End If

If strURL <> "" Then
strURL = strURL.Replace("\", "/")
End If
Return strURL
End Function
End Class
34 changes: 6 additions & 28 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ Public Class RLink
''' <summary> True if the link to the R environment is initialised. </summary>
Public bREngineInitialised As Boolean = False

''' The log window.
Public txtLog As New TextBox

''' <summary>
''' Is set to True when the log window is defined.
''' If set to False, R scripts will not be logged.
''' </summary>
Public bLogRScripts As Boolean = False

''' <summary> True to climate object exists. </summary>
Public bClimateObjectExists As Boolean = False 'TODO SJL 23/04/20 Not used. Delete?

Expand Down Expand Up @@ -134,7 +125,6 @@ Public Class RLink
''' The time in seconds to wait before showing the waiting dialog
Private iWaitDelay As Integer = 2


''' <summary> The R version major required. </summary>
Private strRVersionMajorRequired As String = "4"

Expand All @@ -149,6 +139,8 @@ Public Class RLink

Private clsOutputLogger As clsOutputLogger

Private Shared ReadOnly Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()

''' <summary>
''' Create method for clsRLink
''' Must pass in the output logger so the R link knows where to post outputs to
Expand Down Expand Up @@ -229,12 +221,12 @@ Public Class RLink
cpuArchitectureFolder = "x64"
End If
Dim rPath = Path.Combine(rHome, "bin", cpuArchitectureFolder)
Console.WriteLine("R Home: " & rHome)
Console.WriteLine("R Path: " & rPath)
Logger.Info("R Home: " & rHome)
Logger.Info("R Path: " & rPath)

' Use bundled R if included
If Directory.Exists(rHome) And Directory.Exists(rPath) Then
Console.WriteLine("Using bundled R")
Logger.Info("Using bundled R")
REngine.SetEnvironmentVariables(rPath, rHome)
Else
' Use normal process for finding local R if bundled version not included
Expand Down Expand Up @@ -472,16 +464,6 @@ Public Class RLink
End Sub


'''--------------------------------------------------------------------------------------------
''' <summary> Sets the log window. </summary>
'''
''' <param name="tempLog"> The log window. </param>
'''--------------------------------------------------------------------------------------------
Public Sub SetLog(tempLog As TextBox)
txtLog = tempLog
bLogRScripts = True
End Sub

'''--------------------------------------------------------------------------------------------
''' <summary> Gets a list of data frame names. </summary>
'''
Expand Down Expand Up @@ -799,11 +781,7 @@ Public Class RLink
'Prefix comment to script, e.g. "# Code generated by the dialog, Import Dataset" & vbCrLf & "new_RDS <- readRDS(file=""C:/Users/myName ...
Dim strScriptWithComment As String = If(String.IsNullOrEmpty(strComment), strScript, GetFormattedComment(strComment) & Environment.NewLine & strScript)

If bLogRScripts Then
'todo. adding a lot of text to the text control can raise an out of memory exception.
'change this to only display the text when the audit log is visible.
txtLog.Text = txtLog.Text & strScriptWithComment & Environment.NewLine
End If
frmMain.ucrScriptWindow.LogText(strScriptWithComment & Environment.NewLine)

'TODO SJL 20/04/20 - is the commented out check below needed?
'If strScript.Length > 2000 Then
Expand Down
Loading

0 comments on commit 9899f92

Please sign in to comment.