Skip to content

Commit

Permalink
Merge pull request #244 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
updating branch
  • Loading branch information
maxwellfundi authored Jan 31, 2017
2 parents 8f57075 + aca2145 commit 9b66302
Show file tree
Hide file tree
Showing 15 changed files with 1,653 additions and 745 deletions.
58 changes: 58 additions & 0 deletions instat/clsCondition.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Public Class Condition
Private bIsParameterValues As Boolean = False
Private bIsParameterPresenet As Boolean = False
Private bIsFunctionNames As Boolean = False
Private strParameterName As String = ""
Private lstValues As List(Of String) = New List(Of String)

Public Sub SetParameterPresentName(strParamName As String)
strParameterName = strParamName
bIsParameterPresenet = True
bIsParameterValues = False
bIsFunctionNames = False
End Sub

Public Sub SetParameterValues(strParamName As String, lstParamValues As List(Of String))
strParameterName = strParamName
lstValues = lstParamValues
bIsParameterValues = True
bIsParameterPresenet = False
bIsFunctionNames = False
End Sub

Public Sub SetParameterValues(strParamName As String, strParamValues As String)
SetParameterValues(strParameterName, New List(Of String)({strParamValues}))
End Sub

Public Sub SetFunctionName(strFuncName As String)
SetFunctionNamesMultiple(New List(Of String)({strFuncName}))
End Sub

Public Sub SetFunctionNamesMultiple(lstFuncNames As List(Of String))
lstValues = lstFuncNames
bIsFunctionNames = True
bIsParameterValues = False
bIsParameterPresenet = False
End Sub

Public Function IsSatisfied(clsRCode As RCodeStructure) As Boolean
Dim clsTempParam As RParameter
Dim clsTempFunc As RFunction

If bIsParameterValues Then
clsTempParam = clsRCode.GetParameter(strParameterName)
Return (clsTempParam IsNot Nothing AndAlso clsTempParam.bIsString AndAlso clsTempParam.strArgumentValue IsNot Nothing AndAlso lstValues.Contains(clsRCode.GetParameter(strParameterName).strArgumentValue))
ElseIf bIsParameterPresenet Then
Return (clsRCode.ContainsParameter(strParameterName))
ElseIf bIsFunctionNames Then
If TypeOf clsRCode Is RFunction Then
clsTempFunc = CType(clsRCode, RFunction)
Return lstValues.Contains(clsTempFunc.strRCommand)
Else
Return False
End If
Else
Return True
End If
End Function
End Class
93 changes: 40 additions & 53 deletions instat/dlgAppend.Designer.vb

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

99 changes: 47 additions & 52 deletions instat/dlgAppend.vb
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,70 @@
'
' 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
Public Class dlgAppend
Public bFirstLoad As Boolean = True
Private clsBindRows, clsDefaultBindRows As New RFunction

Private Sub dlgAppend_Load(sender As Object, e As EventArgs) Handles MyBase.Load
autoTranslate(Me)

If bFirstLoad Then
InitialiseDialog()
SetDefaults()
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If
Else
ReopenDialog()
End If
TestOKEnabled()
End Sub
Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 465

' ucrReceiver
ucrReceiverAppendDataframe.SetParameter(New RParameter("x", 0))
ucrReceiverAppendDataframe.GetParameter().bIncludeArgumentName = False
ucrReceiverAppendDataframe.SetParameterIsRFunction()
ucrReceiverAppendDataframe.Selector = ucrSelectorDataframes
ucrReceiverAppendDataframe.SetMeAsReceiver()
ucrBase.clsRsyntax.SetFunction("bind_rows")
ucrReceiverAppendDataframe.SetItemType("dataframe")
ucrInputIDColName.SetValidationTypeAsRVariable()
ucrInputNewDataframeName.SetValidationTypeAsRVariable()

'clsRFunctionParameter:=ucrReceiverAppendDataframe.GetVariables, bIncludeArgumentName:=False)

' ucrSave
ucrSaveGraph.SetIsTextBox()
ucrSaveGraph.SetSaveTypeAsDataFrame()
ucrSaveGraph.SetLabelText("New Data Frame Name:")


'chkID
SetParameter({ucrChkIncludeIDColumn, ucrInputIDColName}, New RParameter(".id", 1))
ucrChkIncludeIDColumn.SetText("Include ID Column")
ucrChkIncludeIDColumn.bChangeParameterValue = False
ucrChkIncludeIDColumn.AddToLinkedControls(ucrLinked:=ucrInputIDColName, objValues:={True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrInputIDColName.bAddRemoveParameter = False
ucrInputIDColName.SetLabel(lblIDColName)


'Default Function
clsDefaultBindRows.SetRCommand("bind_rows")
clsDefaultBindRows.AddParameter(".id", Chr(34) & "id" & Chr(34))
clsDefaultBindRows.SetAssignTo(strTemp:="Append", strTempDataframe:="Append")
End Sub

Private Sub SetDefaults()
clsBindRows = clsDefaultBindRows.Clone()
ucrBase.clsRsyntax.SetBaseRFunction(clsBindRows)
ucrSelectorDataframes.Reset()
ucrSaveGraph.Reset()
SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, True)
TestOKEnabled()
End Sub

Private Sub TestOKEnabled()
If Not ucrReceiverAppendDataframe.IsEmpty AndAlso Not ucrInputNewDataframeName.IsEmpty Then
If chkIncludeIDColumn.Checked AndAlso ucrInputIDColName.IsEmpty Then
If Not ucrReceiverAppendDataframe.IsEmpty AndAlso ucrSaveGraph.IsComplete() Then
If ucrChkIncludeIDColumn.Checked AndAlso ucrInputIDColName.IsEmpty Then
ucrBase.OKEnabled(False)
Else
ucrBase.OKEnabled(True)
Expand All @@ -51,54 +86,14 @@ Public Class dlgAppend
End If
End Sub

Private Sub SetDefaults()
ucrSelectorDataframes.Reset()
ucrInputIDColName.SetName("id")
ucrInputNewDataframeName.SetName("Append")
chkIncludeIDColumn.Checked = False
TestOKEnabled()
End Sub


Private Sub ReopenDialog()
End Sub

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

Private Sub ucrReceiverAppendDataframe_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverAppendDataframe.SelectionChanged
If ucrReceiverAppendDataframe.IsEmpty = False Then
ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverAppendDataframe.GetVariables, bIncludeArgumentName:=False)
Else
ucrBase.clsRsyntax.RemoveParameter("x")
End If
TestOKEnabled()
End Sub

Private Sub chkIncludeIDColumn_CheckedChanged(sender As Object, e As EventArgs) Handles chkIncludeIDColumn.CheckedChanged
IncludeIDColumn()
End Sub

Private Sub ucrInputIDColName_NameChanged() Handles ucrInputIDColName.NameChanged
IncludeIDColumn()
End Sub

Private Sub IncludeIDColumn()
If chkIncludeIDColumn.Checked Then
ucrBase.clsRsyntax.AddParameter(".id", Chr(34) & ucrInputIDColName.GetText & Chr(34))
ucrInputIDColName.Visible = True
lblIDColNAme.Visible = True
Else
ucrBase.clsRsyntax.RemoveParameter(".id")
ucrInputIDColName.Visible = False
lblIDColNAme.Visible = False
End If
TestOKEnabled()
Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
End Sub

Private Sub ucrInputNewDataframeName_NameChanged() Handles ucrInputNewDataframeName.NameChanged
ucrBase.clsRsyntax.SetAssignTo(ucrInputNewDataframeName.GetText(), strTempDataframe:=ucrInputNewDataframeName.GetText())
Private Sub ucrReceiverAppendDataframe_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverAppendDataframe.ControlContentsChanged, ucrSaveGraph.ControlContentsChanged, ucrChkIncludeIDColumn.ControlContentsChanged, ucrInputIDColName.ControlContentsChanged
TestOKEnabled()
End Sub

Expand Down
Loading

0 comments on commit 9b66302

Please sign in to comment.