Skip to content

Commit

Permalink
Merge pull request #92 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
fetching latest copy
  • Loading branch information
maxwellfundi authored Aug 9, 2016
2 parents d2dab7f + a8324f6 commit 98f99ac
Show file tree
Hide file tree
Showing 40 changed files with 2,502 additions and 757 deletions.
2 changes: 1 addition & 1 deletion instat/clsROperator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Public Class ROperator
If Not strAssignToDataFrame = "" AndAlso (Not strAssignToColumn = "" OrElse bAssignToColumnWithoutNames) Then
clsAddColumns.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data")
clsAddColumns.AddParameter("data_name", Chr(34) & strAssignToDataFrame & Chr(34))
If bAssignToColumnWithoutNames Then
If Not bAssignToColumnWithoutNames Then
clsAddColumns.AddParameter("col_name", Chr(34) & strAssignToColumn & Chr(34))
End If
clsAddColumns.AddParameter("col_data", strAssignTo)
Expand Down
4 changes: 3 additions & 1 deletion instat/clsRecentFiles.vb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ Public Class clsRecentFiles
Public Sub saveOnClose()
'saves the list of opened files on form close
' save MRU - delete existing files first
If File.Exists(MRUPath) Then File.Delete(MRUPath)
If File.Exists(MRUPath) Then
File.WriteAllText(MRUPath, "")
End If
' write each item to the file...
For Each sPath As String In strListMRU
File.AppendAllText(MRUPath, sPath & vbCrLf)
Expand Down
1 change: 1 addition & 0 deletions instat/dlgBarAndPieChart.vb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Public Class dlgBarAndPieChart
End Sub

Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.SetDataFrame(strNewDataFrame:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
sdgPlots.ShowDialog()
End Sub

Expand Down
1 change: 1 addition & 0 deletions instat/dlgBoxPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Public Class dlgBoxplot
End Sub

Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.SetDataFrame(strNewDataFrame:=ucrSelectorBoxPlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
sdgPlots.ShowDialog()
End Sub

Expand Down
877 changes: 661 additions & 216 deletions instat/dlgCalculator.designer.vb

Large diffs are not rendered by default.

246 changes: 176 additions & 70 deletions instat/dlgCalculator.vb
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
Imports RDotNet

' 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.Translations
Imports RDotNet
Public Class dlgCalculator
Dim dataset As DataFrame
Dim clsAttach As New RFunction
Dim clsDetach As New RFunction
Dim clsDetach As New RFunction
Public bFirstLoad As Boolean = True
Private Sub dlgCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
autoTranslate(Me)
ucrBase.iHelpTopicID = 14
If bFirstLoad Then
InitialiseDialog()
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If
TestOKEnabled()
End Sub

Private Sub dlgCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ucrBase.OKEnabled(False)
cmdBackSpace.Enabled = True
'txtCalcLine.Select()
ucrBase.iHelpTopicID = 14
InitialiseDialog()
Private Sub TestOKEnabled()
If Not ucrReceiverForCalculation.IsEmpty Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub

Private Sub SetDefaults()
ucrSaveResultInto.SetPrefix("Cal")
ucrSaveResultInto.Reset()
ucrInputCalOptions.Reset()
Me.Size = New System.Drawing.Size(436, 402)
ucrInputCalOptions.cboInput.Text = "Basic"
End Sub

Private Sub ReopenDialog()

End Sub

Private Sub InitialiseDialog()
Expand All @@ -19,7 +61,18 @@ Public Class dlgCalculator
clsDetach.SetRCommand("detach")
clsDetach.AddParameter("unload", "TRUE")
ucrBase.clsRsyntax.SetCommandString("")
End Sub
ucrSaveResultInto.SetItemsTypeAsColumns()
ucrSaveResultInto.SetDefaultTypeAsColumn()
ucrSaveResultInto.SetDataFrameSelector(ucrSelectorForCalculations.ucrAvailableDataFrames)
ucrSelectorForCalculations.Reset()
ucrInputCalOptions.cboInput.Items.Add("Basic")
ucrInputCalOptions.cboInput.Items.Add("Maths")
ucrInputCalOptions.cboInput.Items.Add("Logical")
End Sub

'Private Sub ucrSaveResultIntoInto_NameChanged() Handles ucrSaveResultInto.NameChanged
' ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrSaveResultInto.GetText, strTempDataframe:=ucrSelectorForCalculations.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrSaveResultInto.GetText, bAssignToIsPrefix:=True)
'End Sub

Private Sub AddText(strVar As String, Optional intStepsBack As Integer = 0, Optional bolInsertSelected As Boolean = False)
Dim intCurrCursorPosition As Integer
Expand All @@ -37,69 +90,79 @@ Public Class dlgCalculator
'txtCalcLine.Select()
End Sub

Private Sub cmd0_Click(sender As Object, e As EventArgs) Handles cmd0.Click
Private Sub cmd0_Click(sender As Object, e As EventArgs) Handles cmd0.Click
AddText("0")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("0")
End Sub

Private Sub cmd1_Click(sender As Object, e As EventArgs) Handles cmd1.Click
Private Sub cmd1_Click(sender As Object, e As EventArgs) Handles cmd1.Click
AddText("1")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("1")
End Sub

Private Sub cmd2_Click(sender As Object, e As EventArgs) Handles cmd2.Click
Private Sub cmd2_Click(sender As Object, e As EventArgs) Handles cmd2.Click
AddText("2")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("2")
End Sub

Private Sub cmd3_Click(sender As Object, e As EventArgs) Handles cmd3.Click
Private Sub cmd3_Click(sender As Object, e As EventArgs) Handles cmd3.Click
AddText("3")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("3")
End Sub

Private Sub cmd4_Click(sender As Object, e As EventArgs) Handles cmd4.Click
Private Sub cmd4_Click(sender As Object, e As EventArgs) Handles cmd4.Click
AddText("4")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("4")
End Sub

Private Sub cmd5_Click(sender As Object, e As EventArgs) Handles cmd5.Click
Private Sub cmd5_Click(sender As Object, e As EventArgs) Handles cmd5.Click
AddText("5")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("5")
End Sub

Private Sub cmd6_Click(sender As Object, e As EventArgs) Handles cmd6.Click
Private Sub cmd6_Click(sender As Object, e As EventArgs) Handles cmd6.Click
AddText("6")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("6")
End Sub

Private Sub cmd7_Click(sender As Object, e As EventArgs) Handles cmd7.Click
Private Sub cmd7_Click(sender As Object, e As EventArgs) Handles cmd7.Click
AddText("7")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("7")
End Sub

Private Sub cmd8_Click(sender As Object, e As EventArgs) Handles cmd8.Click
Private Sub cmd8_Click(sender As Object, e As EventArgs) Handles cmd8.Click
AddText("8")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("8")
End Sub

Private Sub cmd9_Click(sender As Object, e As EventArgs) Handles cmd9.Click
Private Sub cmd9_Click(sender As Object, e As EventArgs) Handles cmd9.Click
AddText("9")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("9")
End Sub

Private Sub cmdDot_Click(sender As Object, e As EventArgs) Handles cmdDot.Click
Private Sub cmdDot_Click(sender As Object, e As EventArgs) Handles cmdDot.Click
AddText(".")
End Sub

Private Sub cmdPi_Click(sender As Object, e As EventArgs)
AddText("pi")
End Sub

Private Sub cmdPlus_Click(sender As Object, e As EventArgs) Handles cmdPlus.Click
ucrReceiverForCalculation.AddToReceiverAtCursorPosition(".")
End Sub

Private Sub cmdPlus_Click(sender As Object, e As EventArgs) Handles cmdPlus.Click
AddText("+")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("+")
End Sub

Private Sub cmdMinus_Click(sender As Object, e As EventArgs) Handles cmdMinus.Click
Private Sub cmdMinus_Click(sender As Object, e As EventArgs) Handles cmdMinus.Click
AddText("-")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("-")
End Sub

Private Sub cmdMultiply_Click(sender As Object, e As EventArgs) Handles cmdMultiply.Click
Private Sub cmdMultiply_Click(sender As Object, e As EventArgs) Handles cmdMultiply.Click
AddText("*")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("*")
End Sub

Private Sub cmdDivide_Click(sender As Object, e As EventArgs) Handles cmdDivide.Click
Private Sub cmdDivide_Click(sender As Object, e As EventArgs) Handles cmdDivide.Click
AddText("/")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("/")
End Sub

Private Sub lstAvailableVariable_DoubleClick(sender As Object, e As EventArgs)
Expand All @@ -108,49 +171,50 @@ Public Class dlgCalculator
'End If
End Sub

Private Sub cmdPower_Click(sender As Object, e As EventArgs) Handles cmdPower.Click
Private Sub cmdPower_Click(sender As Object, e As EventArgs) Handles cmdPower.Click
AddText("^")
End Sub

'Private Sub cmdOpenBracket_Click(sender As Object, e As EventArgs) Handles cmdDelete.Click
' AddText("(")
'End Sub

ucrReceiverForCalculation.AddToReceiverAtCursorPosition("^")
End Sub

'Private Sub cmdOpenBracket_Click(sender As Object, e As EventArgs) Handles cmdDelete.Click
' AddText("(")
'End Sub

'Private Sub cmdCloseBracket_Click(sender As Object, e As EventArgs)
' Dim intCursorPosition As Integer

' intCursorPosition = txtCalcLine.SelectionStart
' txtCalcLine.Text = txtCalcLine.Text.Insert(txtCalcLine.SelectionStart, ")")
' txtCalcLine.SelectionStart = intCursorPosition + 1
' txtCalcLine.Focus()
'End Sub

Private Sub cmdRowNumbers_Click(sender As Object, e As EventArgs)
AddText("(1:nrow(data))")
End Sub

'Private Sub ucrBase_clickOK(sender As Object, e As EventArgs) Handles ucrBase.ClickOk
' Dim strScript As String
' strScript = ("data[[" & Chr(34) & txtNewColumnName.Text & Chr(34) & "]]" & " <- " & txtCalcLine.Text).ToString
' frmMain.clsRLink.RunScript(strScript)
' 'dataset = frmMain.clsRLink.GetData("data")
' 'frmEditor.UpdateSheet(dataset)
'End Sub

'Private Sub cmdBackSpace_Click(sender As Object, e As EventArgs) Handles cmdBackSpace.Click
' If txtCalcLine.Text.Length > 0 Then
' txtCalcLine.Text = txtCalcLine.Text.Remove(txtCalcLine.Text.Length - 1)
' End If
'End Sub

' Dim intCursorPosition As Integer

' intCursorPosition = txtCalcLine.SelectionStart
' txtCalcLine.Text = txtCalcLine.Text.Insert(txtCalcLine.SelectionStart, ")")
' txtCalcLine.SelectionStart = intCursorPosition + 1
' txtCalcLine.Focus()
'End Sub

'Private Sub cmdRowNumbers_Click(sender As Object, e As EventArgs)
' AddText("(1:nrow(data))")
'End Sub

'Private Sub ucrBase_clickOK(sender As Object, e As EventArgs) Handles ucrBase.ClickOk
' Dim strScript As String
' strScript = ("data[[" & Chr(34) & txtNewColumnName.Text & Chr(34) & "]]" & " <- " & txtCalcLine.Text).ToString
' frmMain.clsRLink.RunScript(strScript)
' 'dataset = frmMain.clsRLink.GetData("data")
' 'frmEditor.UpdateSheet(dataset)
'End Sub

'Private Sub cmdBackSpace_Click(sender As Object, e As EventArgs) Handles cmdBackSpace.Click
' If txtCalcLine.Text.Length > 0 Then
' txtCalcLine.Text = txtCalcLine.Text.Remove(txtCalcLine.Text.Length - 1)
' End If
'End Sub

'Private Sub txtCalcLine_TextChanged(sender As Object, e As EventArgs)
' If txtCalcLine.Text.Length = 0 Then
' cmdBackSpace.Enabled = False
' Else
' cmdBackSpace.Enabled = True
' End If
'End Sub

' If txtCalcLine.Text.Length = 0 Then
' cmdBackSpace.Enabled = False
' Else
' cmdBackSpace.Enabled = True
' End If
'End Sub

Private Sub cmdSqrt_Click(sender As Object, e As EventArgs)
AddText("sqrt()", 1, True)
End Sub
Expand Down Expand Up @@ -187,4 +251,46 @@ Public Class dlgCalculator
ucrBase.clsRsyntax.SetCommandString(ucrReceiverForCalculation.GetVariableNames(False))
ucrBase.OKEnabled(True)
End Sub

Private Sub cmdGreaterThan_Click(sender As Object, e As EventArgs) Handles cmdGreaterThan.Click
AddText(">")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition(">")
End Sub

Private Sub cmdLessThan_Click(sender As Object, e As EventArgs) Handles cmdLessThan.Click
AddText("<")
ucrReceiverForCalculation.AddToReceiverAtCursorPosition("<")
End Sub

Private Sub cmdDelete_Click(sender As Object, e As EventArgs) Handles cmdDelete.Click

End Sub


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

Private Sub ucrInputCalOptions_NameChanged() Handles ucrInputCalOptions.NameChanged
Select Case ucrInputCalOptions.GetText
Case "Maths"
grpMaths.Visible = True
grpLogical.Visible = False
grpBasic.Visible = True
Me.Size = New System.Drawing.Size(601, 402)
Case "Logical"
grpLogical.Visible = True
grpMaths.Visible = False
grpBasic.Visible = True
Me.Size = New System.Drawing.Size(500, 402)
Case Else
Me.Size = New System.Drawing.Size(436, 402)
grpBasic.Visible = True
grpLogical.Visible = False
grpMaths.Visible = False
End Select
End Sub


End Class
Loading

0 comments on commit 98f99ac

Please sign in to comment.