Skip to content

Commit

Permalink
Merge pull request #70 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Updating Master
  • Loading branch information
Wycklife authored May 9, 2019
2 parents fb3c7a4 + 3bc745a commit f8f1f1a
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 24 deletions.
20 changes: 20 additions & 0 deletions instat/dlgNewDataFrame.Designer.vb

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

97 changes: 77 additions & 20 deletions instat/dlgNewDataFrame.resx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblRows.ZOrder" xml:space="preserve">
<value>14</value>
<value>16</value>
</data>
<data name="lblColumns.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
Expand All @@ -172,7 +172,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblColumns.ZOrder" xml:space="preserve">
<value>13</value>
<value>15</value>
</data>
<data name="rdoCommand.Appearance" type="System.Windows.Forms.Appearance, System.Windows.Forms">
<value>Button</value>
Expand Down Expand Up @@ -208,7 +208,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;rdoCommand.ZOrder" xml:space="preserve">
<value>5</value>
<value>7</value>
</data>
<data name="rdoRandom.Appearance" type="System.Windows.Forms.Appearance, System.Windows.Forms">
<value>Button</value>
Expand Down Expand Up @@ -244,7 +244,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;rdoRandom.ZOrder" xml:space="preserve">
<value>6</value>
<value>8</value>
</data>
<data name="rdoEmpty.Appearance" type="System.Windows.Forms.Appearance, System.Windows.Forms">
<value>Button</value>
Expand Down Expand Up @@ -280,7 +280,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;rdoEmpty.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="rdoConstruct.Appearance" type="System.Windows.Forms.Appearance, System.Windows.Forms">
<value>Button</value>
Expand Down Expand Up @@ -316,7 +316,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;rdoConstruct.ZOrder" xml:space="preserve">
<value>8</value>
<value>10</value>
</data>
<metadata name="colRowNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -343,7 +343,7 @@
<value>Expression</value>
</data>
<data name="dataGridView.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 76</value>
<value>10, 83</value>
</data>
<data name="dataGridView.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
Expand All @@ -364,7 +364,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;dataGridView.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<metadata name="mnuStripCommand.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
Expand Down Expand Up @@ -451,13 +451,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblCommand.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="btnExample.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnExample.Location" type="System.Drawing.Point, System.Drawing">
<value>68, 57</value>
<value>69, 55</value>
</data>
<data name="btnExample.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
Expand All @@ -481,10 +481,64 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnExample.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="btnTry.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnTry.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 248</value>
</data>
<data name="btnTry.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 3, 2, 3</value>
</data>
<data name="btnTry.Size" type="System.Drawing.Size, System.Drawing">
<value>74, 23</value>
</data>
<data name="btnTry.TabIndex" type="System.Int32, mscorlib">
<value>176</value>
</data>
<data name="btnTry.Text" xml:space="preserve">
<value>Try</value>
</data>
<data name="&gt;&gt;btnTry.Name" xml:space="preserve">
<value>btnTry</value>
</data>
<data name="&gt;&gt;btnTry.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnTry.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnTry.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="ucrInputTryMessage.Location" type="System.Drawing.Point, System.Drawing">
<value>92, 248</value>
</data>
<data name="ucrInputTryMessage.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 3, 2, 3</value>
</data>
<data name="ucrInputTryMessage.Size" type="System.Drawing.Size, System.Drawing">
<value>293, 22</value>
</data>
<data name="ucrInputTryMessage.TabIndex" type="System.Int32, mscorlib">
<value>177</value>
</data>
<data name="&gt;&gt;ucrInputTryMessage.Name" xml:space="preserve">
<value>ucrInputTryMessage</value>
</data>
<data name="&gt;&gt;ucrInputTryMessage.Type" xml:space="preserve">
<value>instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;ucrInputTryMessage.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;ucrInputTryMessage.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="ucrInputCommand.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 97</value>
<value>10, 83</value>
</data>
<data name="ucrInputCommand.Size" type="System.Drawing.Size, System.Drawing">
<value>417, 159</value>
Expand All @@ -502,7 +556,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrInputCommand.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="ucrPnlDataFrame.Location" type="System.Drawing.Point, System.Drawing">
<value>17, 10</value>
Expand All @@ -526,10 +580,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrPnlDataFrame.ZOrder" xml:space="preserve">
<value>9</value>
<value>11</value>
</data>
<data name="ucrNewDFName.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 255</value>
<value>10, 284</value>
</data>
<data name="ucrNewDFName.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
Expand All @@ -550,7 +604,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrNewDFName.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</value>
</data>
<data name="ucrNudCols.Location" type="System.Drawing.Point, System.Drawing">
<value>121, 140</value>
Expand All @@ -574,7 +628,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrNudCols.ZOrder" xml:space="preserve">
<value>11</value>
<value>13</value>
</data>
<data name="ucrNudRows.Location" type="System.Drawing.Point, System.Drawing">
<value>124, 97</value>
Expand All @@ -598,10 +652,10 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrNudRows.ZOrder" xml:space="preserve">
<value>12</value>
<value>14</value>
</data>
<data name="ucrBase.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 290</value>
<value>10, 318</value>
</data>
<data name="ucrBase.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 5, 4, 5</value>
Expand All @@ -622,7 +676,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ucrBase.ZOrder" xml:space="preserve">
<value>15</value>
<value>17</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -634,7 +688,10 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>439, 343</value>
<value>439, 378</value>
</data>
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
Expand Down
57 changes: 53 additions & 4 deletions instat/dlgNewDataFrame.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports instat.Translations
Imports RDotNet

Public Class dlgNewDataFrame
Private clsEmptyOverallFunction, clsEmptyMatrixFunction As New RFunction
Expand Down Expand Up @@ -186,8 +187,8 @@ Public Class dlgNewDataFrame
ucrNudCols.SetRCode(clsEmptyMatrixFunction, bReset)
ucrNudRows.SetRCode(clsEmptyMatrixFunction, bReset)

ucrNewDFName.AddAdditionalRCode(clsConstructFunction, iAdditionalPairNo:=1)
ucrNewDFName.SetRCode(clsEmptyOverallFunction, bReset)
ucrNewDFName.AddAdditionalRCode(clsEmptyOverallFunction, iAdditionalPairNo:=1)
ucrNewDFName.SetRCode(clsConstructFunction, bReset)

If bReset Then
ucrPnlDataFrame.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
Expand All @@ -207,14 +208,24 @@ Public Class dlgNewDataFrame
Private Sub ucrPnlDataFrame_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlDataFrame.ControlValueChanged
If rdoConstruct.Checked Then
dataGridView.Visible = True
btnTry.Visible = True
ucrInputTryMessage.Visible = True
ucrInputTryMessage.SetText("")
ucrInputTryMessage.txtInput.BackColor = Color.White
ucrBase.clsRsyntax.SetBaseRFunction(clsConstructFunction)
ElseIf rdoCommand.Checked Then
dataGridView.Visible = False
btnTry.Visible = True
ucrInputTryMessage.Visible = True
ucrInputTryMessage.SetText("")
ucrInputTryMessage.txtInput.BackColor = Color.White
ucrBase.clsRsyntax.SetCommandString(ucrInputCommand.GetText())
ucrBase.clsRsyntax.SetAssignTo(ucrNewDFName.GetText(), strTempDataframe:=ucrNewDFName.GetText())
ElseIf rdoRandom.Checked Then
'TODO
ElseIf rdoEmpty.Checked Then
btnTry.Visible = False
ucrInputTryMessage.Visible = False
dataGridView.Visible = False
ucrBase.clsRsyntax.SetBaseRFunction(clsEmptyOverallFunction)
End If
Expand All @@ -227,11 +238,14 @@ Public Class dlgNewDataFrame
End Sub

Private Sub ucrInputCommand_ContentsChanged() Handles ucrInputCommand.ContentsChanged
ucrInputTryMessage.SetText("")
ucrBase.clsRsyntax.SetCommandString(ucrInputCommand.GetText())
TestOKEnabled()
End Sub

Private Sub dataGridView_ValueChanged(sender As Object, e As EventArgs) Handles dataGridView.CellValueChanged
ucrInputTryMessage.SetText("")
ucrInputTryMessage.txtInput.BackColor = Color.White
TestOKEnabled()
End Sub

Expand Down Expand Up @@ -277,8 +291,8 @@ Public Class dlgNewDataFrame
lstView.Items.Add(New ListViewItem({"data.frame(data = matrix(data = NA, nrow = 10, ncol = 2))", "10 rows and 2 columns filled with missing values"}))
lstView.Items.Add(New ListViewItem({"data.frame(x = 1:30, y = rnorm(30, mean = 100, sd = 15), z = runif(30, min = 10, max = 30))", " "}))
lstView.Items.Add(New ListViewItem({"data.frame(block = gl(4, 3), treat = c(""C"", ""A"", ""B"", ""B"", ""C"", ""A"", ""A"", ""B"", ""C"", ""A"", ""C"", ""B""), yield = c(74, 68, 50, 62, 68, 57, 70, 56, 83, 67, 67, 59))", " "}))
'lstView.Items.Add(New ListViewItem({"wakefield::r_data_theme(n = 100, data_theme = ""the_works"")", " "}))
'lstView.Items.Add(New ListViewItem({"wakefield::r_data_frame(n = 30, id, race, age, sex, hour, iq, height, died, Scoring = rnorm, Smoker = valid)", " "}))
lstView.Items.Add(New ListViewItem({"wakefield::r_data_theme(n = 100, data_theme = ""the_works"")", " "}))
lstView.Items.Add(New ListViewItem({"wakefield::r_data_frame(n = 30, id, race, age, sex, hour, iq, height, died, Scoring = rnorm, Smoker = valid)", " "}))

'set respective handlers
AddHandler lstView.LostFocus, Sub()
Expand All @@ -296,4 +310,39 @@ Public Class dlgNewDataFrame
frm.Location = New Point(ctlpos.X - 2, ctlpos.Y - frm.Height - 2) 'set location to show the form just above the examples button
frm.Show()
End Sub

Private Sub cmdTry_Click(sender As Object, e As EventArgs) Handles btnTry.Click
Dim vecOutput As CharacterVector
Dim strScript As String = ""
Try

If rdoConstruct.Checked Then
strScript = clsConstructFunction.ToScript
ElseIf rdoCommand.Checked Then
If ucrInputCommand.IsEmpty Then
ucrInputTryMessage.SetText("")
ucrInputTryMessage.txtInput.BackColor = Color.White
Return
End If
strScript = ucrInputCommand.GetText
End If

vecOutput = frmMain.clsRLink.RunInternalScriptGetOutput(strScript, bSilent:=True)
If vecOutput IsNot Nothing Then
'If strVecOutput.Length > 0 Then
'End If
ucrInputTryMessage.SetText("Command Ok.")
ucrInputTryMessage.txtInput.BackColor = Color.White
Else
ucrInputTryMessage.SetText("Command produced an error or no output to display.")
ucrInputTryMessage.txtInput.BackColor = Color.Red
End If


Catch ex As Exception
ucrInputTryMessage.SetText("Command produced an error.")
ucrInputTryMessage.txtInput.BackColor = Color.Red
End Try
End Sub

End Class
Loading

0 comments on commit f8f1f1a

Please sign in to comment.