Skip to content

Commit

Permalink
Merge pull request #31 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
fetching latest copy of master
  • Loading branch information
maxwellfundi committed Feb 24, 2016
2 parents 25ccbde + 93ce678 commit 28a7593
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 92 deletions.
9 changes: 9 additions & 0 deletions instat/clsROperator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Public Class ROperator
End If
bToBeAssigned = True
bIsAssigned = False
End Sub

Public Sub RemoveAssignTo()
strAssignTo = ""
strAssignToDataFrame = ""
strAssignToColumn = ""
strAssignToModel = ""
bToBeAssigned = False
bIsAssigned = False
End Sub

Public Function ToScript(Optional ByRef strScript As String = "") As String
Expand Down
9 changes: 9 additions & 0 deletions instat/clsRSyntax.vb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ Public Class RSyntax
End If
End Sub

Public Sub RemoveAssignTo()
If bUseBaseOperator Then
clsBaseOperator.RemoveAssignTo()
End If
If bUseBaseFunction Then
clsBaseFunction.RemoveAssignTo()
End If
End Sub

Public Sub AddParameter(strParameterName As String, Optional strParameterValue As String = "", Optional clsRFunctionParameter As RFunction = Nothing, Optional clsROperatorParameter As ROperator = Nothing)
clsBaseFunction.AddParameter(strParameterName, strParameterValue, clsRFunctionParameter, clsROperatorParameter)
End Sub
Expand Down
4 changes: 3 additions & 1 deletion instat/dlgSort.vb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Public Class dlgSort
End Sub

Private Sub ucrReceiverSort_SelectionChanged() Handles ucrReceiverSort.SelectionChanged
ucrBase.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectForSort.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34))
ucrBase.clsRsyntax.AddParameter("col_names", ucrReceiverSort.GetVariableNames())
'Test ok enabled
TestOKEnabled()
Expand Down Expand Up @@ -128,4 +127,7 @@ Public Class dlgSort
TestOKEnabled()
End Sub

Private Sub ucrSelectForSort_DataFrameChanged() Handles ucrSelectForSort.DataFrameChanged
ucrBase.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectForSort.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34))
End Sub
End Class
16 changes: 8 additions & 8 deletions instat/dlgStack.Designer.vb

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

103 changes: 76 additions & 27 deletions instat/dlgStack.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,62 @@

Imports instat.Translations
Public Class dlgStack
Private Sub stackDefaultSettings()
Public bFirstLoad As Boolean = True
Private Sub dlgStack_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ucrBase.clsRsyntax.SetFunction("melt")
ucrBase.iHelpTopicID = 57

If bFirstLoad Then
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If

'Checks if Ok can be enabled.

TestOKEnabled()
End Sub

Private Sub ReopenDialog()
End Sub

Private Sub TestOKEnabled()
If Not ucrReceiverColumnsToBeStack.IsEmpty() Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub

Private Sub SetDefaults()
'Set receiver/selector options
ucrReceiverColumnsToBeStack.Selector = ucrDataFrameAddRemove
ucrIDVariablesReceiver.Selector = ucrDataFrameAddRemove
ucrReceiverColumnsToBeStack.Selector = ucrSelectorStack
ucrIDVariablesReceiver.Selector = ucrSelectorStack
ucrReceiverColumnsToBeStack.SetMeAsReceiver()
ucrIDVariablesReceiver.Visible = False
txtStackDataInto.Text = "Value"
txtFactorInto.Text = "Variable"
SetStackIntoText("Value")
SetFactorIntoText("Variable")
autoTranslate(Me)

End Sub
Private Sub dlgStack_Load(sender As Object, e As EventArgs) Handles MyBase.Load
stackDefaultSettings()
'Set function parameters/settings
ucrBase.clsRsyntax.SetFunction("melt")
ucrBase.clsRsyntax.AddParameter("variable.name", Chr(34) & txtFactorInto.Text & Chr(34))

Private Sub SetFactorIntoText(strNewVal As String)
txtFactorInto.Text = strNewVal
If txtFactorInto.Text <> "" Then
ucrBase.clsRsyntax.AddParameter("variable.name", Chr(34) & txtFactorInto.Text & Chr(34))
Else
ucrBase.clsRsyntax.RemoveParameter("variable.name")
End If
End Sub

ucrBase.clsRsyntax.AddParameter("value.name", Chr(34) & txtStackDataInto.Text & Chr(34))
ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=ucrDataFrameAddRemove.ucrAvailableDataFrames.clsCurrDataFrame)

ucrNewDataFrameName.txtValidation.Text = ucrDataFrameAddRemove.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked"
ucrBase.clsRsyntax.SetAssignTo(ucrNewDataFrameName.txtValidation.Text, strTempDataframe:=ucrNewDataFrameName.txtValidation.Text)

Private Sub SetStackIntoText(strNewVal As String)
txtStackDataInto.Text = strNewVal
If txtStackDataInto.Text <> "" Then
ucrBase.clsRsyntax.AddParameter("value.name", Chr(34) & txtStackDataInto.Text & Chr(34))
Else
ucrBase.clsRsyntax.RemoveParameter("value.name")
End If
End Sub

Private Sub chkIDVariables_CheckedChanged(sender As Object, e As EventArgs) Handles chkIDVariables.CheckedChanged
Expand All @@ -51,40 +83,57 @@ Public Class dlgStack
End If
End Sub

Private Sub ucrReceiverColumnsToBeStack_Leave(sender As Object, e As EventArgs) Handles ucrReceiverColumnsToBeStack.Leave
Private Sub ucrReceiverColumnsToBeStack_SelectionChanged() Handles ucrReceiverColumnsToBeStack.SelectionChanged
ucrBase.clsRsyntax.AddParameter("measure.vars", ucrReceiverColumnsToBeStack.GetVariableNames())
TestOKEnabled()
End Sub
Private Sub ucrIDVariablesReceiver_Leave(sender As Object, e As EventArgs) Handles ucrIDVariablesReceiver.Leave


Private Sub ucrIDVariablesReceiver_SelectionChanged() Handles ucrIDVariablesReceiver.SelectionChanged
ucrBase.clsRsyntax.AddParameter("id.vars", ucrIDVariablesReceiver.GetVariableNames())
TestOKEnabled()
End Sub

Private Sub txtFactorInto_Leave(sender As Object, e As EventArgs) Handles txtFactorInto.Leave
ucrBase.clsRsyntax.AddParameter("variable.name", Chr(34) & txtFactorInto.Text & Chr(34))
TestOKEnabled()
End Sub

Private Sub txtStackDataInto_Leave(sender As Object, e As EventArgs) Handles txtStackDataInto.Leave
ucrBase.clsRsyntax.AddParameter("value.name", Chr(34) & txtStackDataInto.Text & Chr(34))
TestOKEnabled()
End Sub

Private Sub ucrNewDataFrameName_Leave(sender As Object, e As EventArgs) Handles ucrNewDataFrameName.Leave
ucrBase.clsRsyntax.SetAssignTo(ucrNewDataFrameName.txtValidation.Text, strTempDataframe:=ucrNewDataFrameName.txtValidation.Text)

End Sub

Private Sub ucrDataFrameAddRemove_DataFrameChanged() Handles ucrDataFrameAddRemove.DataFrameChanged
Private Sub ucrDataFrameAddRemove_DataFrameChanged() Handles ucrSelectorStack.DataFrameChanged
'Always change the data parameter when data frame changed.
ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=ucrSelectorStack.ucrAvailableDataFrames.clsCurrDataFrame)

'For Stack ucrNewDataFrameName may also be changed when data frame changed.
If Not ucrNewDataFrameName.bUserTyped Then
ucrNewDataFrameName.txtValidation.Text = ucrDataFrameAddRemove.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked"
SetNewDataFrameName(ucrSelectorStack.ucrAvailableDataFrames.cboAvailableDataFrames.Text & "_stacked")
End If

End Sub

Private Sub chkIDVariables_KeyPress(sender As Object, e As KeyPressEventArgs) Handles chkIDVariables.KeyPress
If chkIDVariables.Checked = True And e.KeyChar = vbCr Then
chkIDVariables.Checked = False
Else
chkIDVariables.Checked = True
Private Sub SetNewDataFrameName(strNewVal As String)
If ucrNewDataFrameName.ValidateRString(strNewVal) = 0 Then
ucrNewDataFrameName.txtValidation.Text = strNewVal
ucrBase.clsRsyntax.SetAssignTo(ucrNewDataFrameName.txtValidation.Text, strTempDataframe:=ucrNewDataFrameName.txtValidation.Text)
End If
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
stackDefaultSettings()
Private Sub chkIDVariables_KeyPress(sender As Object, e As KeyPressEventArgs) Handles chkIDVariables.KeyPress
If e.KeyChar = vbCr Then
If chkIDVariables.Checked Then
chkIDVariables.Checked = False
Else
chkIDVariables.Checked = True
End If
End If
End Sub
End Class
19 changes: 11 additions & 8 deletions instat/dlgUnstack.Designer.vb

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

50 changes: 25 additions & 25 deletions instat/dlgUnstack.vb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
Imports instat.Translations
Public Class dlgUnstack
Private Sub unstackDefaultSettings()
ucrIDColumnReceiver.Selector = ucrSelectorByDataFrameAddRemove
ucrFactorToUnstackReceiver.Selector = ucrSelectorByDataFrameAddRemove
ucrIDColumnReceiver.Selector = ucrSelectorForUnstack
ucrFactorToUnstackReceiver.Selector = ucrSelectorForUnstack
ucrFactorToUnstackReceiver.SetMeAsReceiver()
autoTranslate(Me)
ucrIDColumnReceiver.Visible = False
Expand Down Expand Up @@ -51,28 +51,28 @@ Public Class dlgUnstack
ucrBase.clsRsyntax.AddParameter("", ucrIDColumnReceiver.GetVariableNames())
End Sub

Private Sub ucrColumnToUnstackReceiver_Enter(sender As Object, e As EventArgs) Handles ucrColumnToUnstackReceiver.Enter
ucrColumnToUnstackReceiver.SetMeAsReceiver()
End Sub
Private Sub ucrIDColumnReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrIDColumnReceiver.KeyPress
If e.KeyChar = vbCr Then
ucrIDColumnReceiver.RemoveSelected()
End If
End Sub
'Private Sub ucrColumnToUnstackReceiver_Enter(sender As Object, e As EventArgs) Handles ucrColumnToUnstackReceiver.Enter
' ucrColumnToUnstackReceiver.SetMeAsReceiver()
'End Sub
'Private Sub ucrIDColumnReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrIDColumnReceiver.KeyPress
' If e.KeyChar = vbCr Then
' ucrIDColumnReceiver.RemoveSelected()
' End If
'End Sub

Private Sub ucrFactorToUnstackReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrFactorToUnstackReceiver.KeyPress
If e.KeyChar = vbCr Then
ucrFactorToUnstackReceiver.RemoveSelected()
End If
End Sub
Private Sub ucrColumnToUnstackReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrColumnToUnstackReceiver.KeyPress
If e.KeyChar = vbCr Then
ucrColumnToUnstackReceiver.RemoveSelected()
End If
End Sub
Private Sub ucrSelectorByDataFrameAddRemove_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrSelectorByDataFrameAddRemove.KeyPress
If e.KeyChar = vbCr Then
ucrSelectorByDataFrameAddRemove.Add()
End If
End Sub
'Private Sub ucrFactorToUnstackReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrFactorToUnstackReceiver.KeyPress
' If e.KeyChar = vbCr Then
' ucrFactorToUnstackReceiver.RemoveSelected()
' End If
'End Sub
'Private Sub ucrColumnToUnstackReceiver_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrColumnToUnstackReceiver.KeyPress
' If e.KeyChar = vbCr Then
' ucrColumnToUnstackReceiver.RemoveSelected()
' End If
'End Sub
'Private Sub ucrSelectorByDataFrameAddRemove_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ucrSelectorByDataFrameAddRemove.KeyPress
' If e.KeyChar = vbCr Then
' ucrSelectorByDataFrameAddRemove.Add()
' End If
'End Sub
End Class
7 changes: 7 additions & 0 deletions instat/instat.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,12 @@
<Content Include="static\ClimateObject\R\SourcingScript.R">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\Library\ExperimentalSurveyData.RDS">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\Library\Samaru56.RDS">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down Expand Up @@ -3009,6 +3015,7 @@
<XliffResource Include="MultilingualResources\instat.fr-FR.xlf" />
<XliffResource Include="MultilingualResources\instat.sw-KE.xlf" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets" Label="MultilingualAppToolkit" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets')" />
<Target Name="MATPrerequisite" BeforeTargets="PrepareForBuild" Condition="!Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets')" Label="MultilingualAppToolkit">
Expand Down
Binary file added instat/static/Library/ExperimentalSurveyData.RDS
Binary file not shown.
Binary file added instat/static/Library/Samaru56.RDS
Binary file not shown.
Loading

0 comments on commit 28a7593

Please sign in to comment.