Skip to content

Commit

Permalink
Merge pull request #113 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Merge from MC
  • Loading branch information
lilyclements authored Jan 30, 2017
2 parents 0f65ee3 + b6be02f commit 5e328bc
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 109 deletions.
32 changes: 32 additions & 0 deletions instat/clsCondition.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Public Class Condition
Private strType As String = "ParameterValue"
Private strParameterName As String = ""
Private lstValues As List(Of String) = New List(Of String)

Public Sub SetParameterPresentName(strParamName As String)
strType = "ParameterPresent"
strParameterName = strParamName
End Sub

Public Sub SetParameterValues(strParamName As String, lstParamValues As List(Of String))
strType = "ParameterValue"
strParameterName = strParamName
lstValues = lstParamValues
End Sub

Public Sub SetParameterValues(strParamName As String, strParamValues As String)
strType = "ParameterValue"
strParameterName = strParamName
lstValues = New List(Of String)({strParamValues})
End Sub

Public Sub SetFunctionName(strFuncName As String)
strType = "FunctionName"
lstValues = New List(Of String)({strFuncName})
End Sub

Public Sub SetFunctionNamesMultiple(lstFuncNames As List(Of String))
strType = "FunctionName"
lstValues = lstFuncNames
End Sub
End Class
87 changes: 36 additions & 51 deletions instat/dlgFileNew.Designer.vb

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

123 changes: 66 additions & 57 deletions instat/dlgFileNew.vb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
' Instat-R
' Copyright (C) 2015
'
' 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 k
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' Instat-R
' Copyright (C) 2015
'
' 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 k
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Imports instat
Imports instat.Translations
Imports RDotNet

Public Class dlgFileNew
Public clsMatrix As New RFunction
Public strDefaultSheetPrefix As String = "Sheet"
Private clsOverallFunction, clsMatrixDefaultFunction, clsMatrixFunction As New RFunction
Public bFirstLoad As Boolean = True

Private Sub dlgFileNew_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Expand All @@ -35,54 +35,63 @@ Public Class dlgFileNew
TestOKEnabled()
End Sub

Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 6
clsMatrix.SetRCommand("matrix")
clsMatrix.AddParameter("data", "NA")
ucrBase.clsRsyntax.SetFunction("data.frame")
ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=clsMatrix)
nudRows.Maximum = Integer.MaxValue
nudRows.Minimum = 1
nudColumns.Maximum = Integer.MaxValue
nudColumns.Minimum = 1
'ucrName.SetDefaultTypeAsDataFrame() This can be added in when the code is written
ucrName.SetValidationTypeAsRVariable()
End Sub
Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 6

'nudRows
ucrNudRows.SetParameter(New RParameter("nrow"))
ucrNudRows.SetMinMax(1, Integer.MaxValue)

'nudCols
ucrNudCols.SetParameter(New RParameter("ncol"))
ucrNudCols.SetMinMax(1, Integer.MaxValue)

' ucrNewSheetName
ucrNewDFName.SetIsTextBox()
ucrNewDFName.SetSaveTypeAsDataFrame()
ucrNewDFName.SetLabelText("New Data Frame Name:")
ucrNewDFName.SetPrefix("data")

' Default R
clsOverallFunction.SetRCommand("data.frame")

'matrix(nrow = 10, ncol = 2, Data = NA)
clsMatrixDefaultFunction.SetRCommand("matrix")
clsMatrixDefaultFunction.AddParameter("data", "NA")
clsMatrixDefaultFunction.AddParameter("ncol", 2)
clsMatrixDefaultFunction.AddParameter("nrow", 10)
End Sub

Private Sub ReopenDialog()
ucrName.SetName(strName:=frmMain.clsRLink.GetDefaultDataFrameName(strDefaultSheetPrefix))
End Sub
' updating controls doesn't update the function
' Sheet name is not on the dialog.

Private Sub SetDefaults()
nudRows.Value = 10
nudColumns.Value = 2
ucrName.SetName(strName:=frmMain.clsRLink.GetDefaultDataFrameName(strDefaultSheetPrefix))
End Sub

Private Sub nudColumns_TextChanged(sender As Object, e As EventArgs) Handles nudColumns.TextChanged
clsMatrix.AddParameter("ncol", nudColumns.Value.ToString())
TestOKEnabled()
Private Sub ReopenDialog()
End Sub

Private Sub nudRows_TextChanged(sender As Object, e As EventArgs) Handles nudRows.TextChanged
clsMatrix.AddParameter("nrow", nudRows.Value.ToString())
TestOKEnabled()
Private Sub SetDefaults()
ucrBase.clsRsyntax.SetBaseRFunction(clsOverallFunction)
clsMatrixFunction = clsMatrixDefaultFunction.Clone()
clsOverallFunction.AddParameter("data", clsRFunctionParameter:=clsMatrixFunction)
ucrNudCols.SetRCode(clsMatrixFunction)
ucrNudRows.SetRCode(clsMatrixFunction)
ucrNewDFName.SetRCode(clsOverallFunction)
ucrNewDFName.Reset()
TestOKEnabled()
End Sub

Private Sub TestOKEnabled()
If Not ucrName.IsEmpty AndAlso nudColumns.Text <> "" AndAlso nudRows.Text <> "" Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
Private Sub TestOKEnabled()
If ucrNewDFName.IsComplete AndAlso ucrNudCols.GetText <> "" AndAlso ucrNudRows.GetText <> "" Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
End Sub

Private Sub ucrName_NameChanged() Handles ucrName.NameChanged
ucrBase.clsRsyntax.SetAssignTo(ucrName.GetText(), strTempDataframe:=ucrName.GetText())
TestOKEnabled()
End Sub
End Sub

Private Sub ucrInputDataFrameName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrNudRows.ControlContentsChanged, ucrNudCols.ControlContentsChanged, ucrNewDFName.ControlContentsChanged
TestOKEnabled()
End Sub
End Class
1 change: 1 addition & 0 deletions instat/instat.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="clsBlockReader.vb" />
<Compile Include="clsCondition.vb" />
<Compile Include="clsRCodeStructure.vb" />
<Compile Include="dlgAddComment.Designer.vb">
<DependentUpon>dlgAddComment.vb</DependentUpon>
Expand Down
2 changes: 1 addition & 1 deletion instat/ucrSave.vb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Public Class ucrSave
Case "column"
clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, strTempColumn:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix, bAssignToColumnWithoutNames:=bAssignToColumnWithoutNames, bInsertColumnBefore:=bInsertColumnBefore)
Case "dataframe"
clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, bAssignToIsPrefix:=bAssignToIsPrefix)
clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix)
Case "graph"
clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, strTempGraph:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix)
Case "model"
Expand Down

0 comments on commit 5e328bc

Please sign in to comment.