diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 79a8d998290..5fbe10433da 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -63,23 +63,26 @@ Public Class RLink Dim i As Integer If bInstatObjectExists Then - lstCurrColumns = clsEngine.Evaluate(strInstatDataObject & "$get_column_names(" & Chr(34) & strDataFrame & Chr(34) & ")").AsList - If cboColumns IsNot Nothing Then - cboColumns.Items.Clear() - For i = 0 To lstCurrColumns.Length - 1 - cboColumns.Items.Add(lstCurrColumns.AsCharacter(i)) - Next - ElseIf lstColumns IsNot Nothing Then - lstColumns.Items.Clear() - If lstColumns.Columns.Count = 0 Then - lstColumns.Columns.Add("Available Data") + If clsEngine IsNot Nothing Then + lstCurrColumns = clsEngine.Evaluate(strInstatDataObject & "$get_column_names(" & Chr(34) & strDataFrame & Chr(34) & ")").AsList + If cboColumns IsNot Nothing Then + cboColumns.Items.Clear() + For i = 0 To lstCurrColumns.Length - 1 + cboColumns.Items.Add(lstCurrColumns.AsCharacter(i)) + Next + ElseIf lstColumns IsNot Nothing Then + lstColumns.Items.Clear() + If lstColumns.Columns.Count = 0 Then + lstColumns.Columns.Add("Available Data") + End If + For i = 0 To lstCurrColumns.Length - 1 + lstColumns.Items.Add(lstCurrColumns.AsCharacter(i)) + Next + lstColumns.Columns(0).Width = -2 End If - For i = 0 To lstCurrColumns.Length - 1 - lstColumns.Items.Add(lstCurrColumns.AsCharacter(i)) - Next - lstColumns.Columns(0).Width = -2 End If End If + End Sub Public Function GetDefaultColumnNames(strPrefix As String) @@ -216,4 +219,11 @@ Public Class RLink End If End Sub + Public Function GetDataFrameLength(strDataFrameName As String) As Integer + Dim intLength As Integer + If clsEngine IsNot Nothing Then + intLength = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$length_of_data(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsInteger(0) + End If + Return intLength + End Function End Class diff --git a/instat/clsRSyntax.vb b/instat/clsRSyntax.vb index d43c4e59f7e..47d98f8beef 100644 --- a/instat/clsRSyntax.vb +++ b/instat/clsRSyntax.vb @@ -43,7 +43,7 @@ Public Class RSyntax clsRFunction = clsBaseFunction End If clsParam.SetArgumentName(strParameterName) - If Not strParameterName = "" Then + If Not strParameterValue = "" Then clsParam.SetArgumentValue(strParameterValue) End If If Not clsRFunctionParameter Is Nothing Then diff --git a/instat/dlgRandomSample.vb b/instat/dlgRandomSample.vb index 661de8aed28..b2ceb85f71f 100644 --- a/instat/dlgRandomSample.vb +++ b/instat/dlgRandomSample.vb @@ -24,7 +24,7 @@ Public Class dlgRandomSample ' Setting distribution type and base function as distribution function ucrDistWithParameters.SetRDistributions() ucrBase.clsRsyntax.clsBaseFunction = ucrDistWithParameters.clsCurrRFunction - ucrDistWithParameters.AddParameter("n", ucrDataFrameSelector.strDataFrameLength) + ucrDistWithParameters.AddParameter("n", ucrDataFrameSelector.iDataFrameLength) ' Setting link between DataFrameSelector and NewColumnNameSelector ' TODO tidy these links up @@ -38,7 +38,7 @@ Public Class dlgRandomSample End Sub Private Sub ucrDataFrameSelector_Leave(sender As Object, e As EventArgs) Handles ucrDataFrameSelector.Leave - ucrDistWithParameters.AddParameter("n", ucrDataFrameSelector.strDataFrameLength) + ucrDistWithParameters.AddParameter("n", ucrDataFrameSelector.iDataFrameLength) End Sub Private Sub ucrNewColumnNameSelector_Leave(sender As Object, e As EventArgs) Handles ucrNewColumnNameSelector.Leave diff --git a/instat/dlgStartofRains.Designer.vb b/instat/dlgStartofRains.Designer.vb index 90884c5c4fe..851ba2f11f6 100644 --- a/instat/dlgStartofRains.Designer.vb +++ b/instat/dlgStartofRains.Designer.vb @@ -22,239 +22,239 @@ Partial Class dlgStartofRains 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.lblDataList = New System.Windows.Forms.Label() - Me.lblEarliest = New System.Windows.Forms.Label() - Me.nudNumberofRainDays = New System.Windows.Forms.NumericUpDown() - Me.lblThreashold = New System.Windows.Forms.Label() - Me.lblNumberRainDays = New System.Windows.Forms.Label() - Me.lblTotalRain = New System.Windows.Forms.Label() - Me.nudTotalRain = New System.Windows.Forms.NumericUpDown() - Me.chkDrySpell = New System.Windows.Forms.CheckBox() - Me.nudWithin = New System.Windows.Forms.NumericUpDown() - Me.lblWithin = New System.Windows.Forms.Label() - Me.lblDryLength = New System.Windows.Forms.Label() - Me.nudDryLength = New System.Windows.Forms.NumericUpDown() - Me.lblDays = New System.Windows.Forms.Label() - Me.lblColumnName = New System.Windows.Forms.Label() - Me.txtColumnName = New System.Windows.Forms.TextBox() - Me.nudEarliest = New System.Windows.Forms.NumericUpDown() - Me.nudThreshold = New System.Windows.Forms.NumericUpDown() - Me.ucrBase = New instat.ucrButtons() - CType(Me.nudNumberofRainDays, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudTotalRain, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudWithin, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudDryLength, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudEarliest, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudThreshold, System.ComponentModel.ISupportInitialize).BeginInit() - Me.SuspendLayout() - ' - 'lblDataList - ' - Me.lblDataList.AutoSize = True - Me.lblDataList.Location = New System.Drawing.Point(36, 35) - Me.lblDataList.Name = "lblDataList" - Me.lblDataList.Size = New System.Drawing.Size(106, 13) - Me.lblDataList.TabIndex = 1 - Me.lblDataList.Tag = "Not_Yet_Implemented" - Me.lblDataList.Text = "Not Yet Implemented" - ' - 'lblEarliest - ' - Me.lblEarliest.AutoSize = True - Me.lblEarliest.Location = New System.Drawing.Point(39, 75) - Me.lblEarliest.Name = "lblEarliest" - Me.lblEarliest.Size = New System.Drawing.Size(61, 13) - Me.lblEarliest.TabIndex = 2 - Me.lblEarliest.Tag = "Earliest_day" - Me.lblEarliest.Text = "Earliest day" - ' - 'nudNumberofRainDays - ' - Me.nudNumberofRainDays.Location = New System.Drawing.Point(192, 110) - Me.nudNumberofRainDays.Name = "nudNumberofRainDays" - Me.nudNumberofRainDays.Size = New System.Drawing.Size(35, 20) - Me.nudNumberofRainDays.TabIndex = 4 - Me.nudNumberofRainDays.Value = New Decimal(New Integer() {2, 0, 0, 0}) - ' - 'lblThreashold - ' - Me.lblThreashold.AutoSize = True - Me.lblThreashold.Location = New System.Drawing.Point(39, 95) - Me.lblThreashold.Name = "lblThreashold" - Me.lblThreashold.Size = New System.Drawing.Size(39, 13) - Me.lblThreashold.TabIndex = 5 - Me.lblThreashold.Tag = "Threashold" - Me.lblThreashold.Text = "Label1" - ' - 'lblNumberRainDays - ' - Me.lblNumberRainDays.AutoSize = True - Me.lblNumberRainDays.Location = New System.Drawing.Point(39, 115) - Me.lblNumberRainDays.Name = "lblNumberRainDays" - Me.lblNumberRainDays.Size = New System.Drawing.Size(39, 13) - Me.lblNumberRainDays.TabIndex = 7 - Me.lblNumberRainDays.Tag = "Number_of_Rain_Days" - Me.lblNumberRainDays.Text = "Label1" - ' - 'lblTotalRain - ' - Me.lblTotalRain.AutoSize = True - Me.lblTotalRain.Location = New System.Drawing.Point(39, 135) - Me.lblTotalRain.Name = "lblTotalRain" - Me.lblTotalRain.Size = New System.Drawing.Size(39, 13) - Me.lblTotalRain.TabIndex = 8 - Me.lblTotalRain.Tag = "Total_Rain" - Me.lblTotalRain.Text = "Label1" - ' - 'nudTotalRain - ' - Me.nudTotalRain.Location = New System.Drawing.Point(192, 131) - Me.nudTotalRain.Maximum = New Decimal(New Integer() {200, 0, 0, 0}) - Me.nudTotalRain.Name = "nudTotalRain" - Me.nudTotalRain.Size = New System.Drawing.Size(35, 20) - Me.nudTotalRain.TabIndex = 9 - Me.nudTotalRain.Value = New Decimal(New Integer() {20, 0, 0, 0}) - ' - 'chkDrySpell - ' - Me.chkDrySpell.AutoSize = True - Me.chkDrySpell.Location = New System.Drawing.Point(12, 163) - Me.chkDrySpell.Name = "chkDrySpell" - Me.chkDrySpell.Size = New System.Drawing.Size(81, 17) - Me.chkDrySpell.TabIndex = 10 - Me.chkDrySpell.Tag = "Dry_Spell" - Me.chkDrySpell.Text = "CheckBox1" - Me.chkDrySpell.UseVisualStyleBackColor = True - ' - 'nudWithin - ' - Me.nudWithin.Location = New System.Drawing.Point(288, 189) - Me.nudWithin.Maximum = New Decimal(New Integer() {200, 0, 0, 0}) - Me.nudWithin.Name = "nudWithin" - Me.nudWithin.Size = New System.Drawing.Size(35, 20) - Me.nudWithin.TabIndex = 14 - Me.nudWithin.Value = New Decimal(New Integer() {30, 0, 0, 0}) - ' - 'lblWithin - ' - Me.lblWithin.AutoSize = True - Me.lblWithin.Location = New System.Drawing.Point(233, 193) - Me.lblWithin.Name = "lblWithin" - Me.lblWithin.Size = New System.Drawing.Size(39, 13) - Me.lblWithin.TabIndex = 13 - Me.lblWithin.Tag = "Within" - Me.lblWithin.Text = "Label1" - ' - 'lblDryLength - ' - Me.lblDryLength.AutoSize = True - Me.lblDryLength.Location = New System.Drawing.Point(39, 193) - Me.lblDryLength.Name = "lblDryLength" - Me.lblDryLength.Size = New System.Drawing.Size(39, 13) - Me.lblDryLength.TabIndex = 12 - Me.lblDryLength.Tag = "Length_of_Dry_Spell" - Me.lblDryLength.Text = "Label1" - ' - 'nudDryLength - ' - Me.nudDryLength.Location = New System.Drawing.Point(192, 189) - Me.nudDryLength.Name = "nudDryLength" - Me.nudDryLength.Size = New System.Drawing.Size(35, 20) - Me.nudDryLength.TabIndex = 11 - Me.nudDryLength.Value = New Decimal(New Integer() {10, 0, 0, 0}) - ' - 'lblDays - ' - Me.lblDays.AutoSize = True - Me.lblDays.Location = New System.Drawing.Point(329, 193) - Me.lblDays.Name = "lblDays" - Me.lblDays.Size = New System.Drawing.Size(13, 13) - Me.lblDays.TabIndex = 15 - Me.lblDays.Tag = "Days" - Me.lblDays.Text = "2" - ' - 'lblColumnName - ' - Me.lblColumnName.AutoSize = True - Me.lblColumnName.Location = New System.Drawing.Point(39, 230) - Me.lblColumnName.Name = "lblColumnName" - Me.lblColumnName.Size = New System.Drawing.Size(39, 13) - Me.lblColumnName.TabIndex = 16 - Me.lblColumnName.Tag = "Column_Name" - Me.lblColumnName.Text = "Label1" - ' - 'txtColumnName - ' - Me.txtColumnName.Location = New System.Drawing.Point(192, 222) - Me.txtColumnName.Name = "txtColumnName" - Me.txtColumnName.Size = New System.Drawing.Size(100, 20) - Me.txtColumnName.TabIndex = 17 - Me.txtColumnName.Tag = "Start_of_Rain" - ' - 'nudEarliest - ' - Me.nudEarliest.Location = New System.Drawing.Point(192, 68) - Me.nudEarliest.Maximum = New Decimal(New Integer() {366, 0, 0, 0}) - Me.nudEarliest.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) - Me.nudEarliest.Name = "nudEarliest" - Me.nudEarliest.Size = New System.Drawing.Size(53, 20) - Me.nudEarliest.TabIndex = 18 - Me.nudEarliest.Value = New Decimal(New Integer() {92, 0, 0, 0}) - ' - 'nudThreshold - ' - Me.nudThreshold.DecimalPlaces = 2 - Me.nudThreshold.Increment = New Decimal(New Integer() {1, 0, 0, 65536}) - Me.nudThreshold.Location = New System.Drawing.Point(192, 89) - Me.nudThreshold.Name = "nudThreshold" - Me.nudThreshold.Size = New System.Drawing.Size(53, 20) - Me.nudThreshold.TabIndex = 19 - Me.nudThreshold.Value = New Decimal(New Integer() {85, 0, 0, 131072}) - ' - 'ucrBase - ' - Me.ucrBase.Location = New System.Drawing.Point(3, 263) - Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(425, 32) - Me.ucrBase.TabIndex = 0 - ' - 'dlgStartofRains - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(440, 294) - Me.Controls.Add(Me.nudThreshold) - Me.Controls.Add(Me.nudEarliest) - Me.Controls.Add(Me.txtColumnName) - Me.Controls.Add(Me.lblColumnName) - Me.Controls.Add(Me.lblDays) - Me.Controls.Add(Me.nudWithin) - Me.Controls.Add(Me.lblWithin) - Me.Controls.Add(Me.lblDryLength) - Me.Controls.Add(Me.nudDryLength) - Me.Controls.Add(Me.chkDrySpell) - Me.Controls.Add(Me.nudTotalRain) - Me.Controls.Add(Me.lblTotalRain) - Me.Controls.Add(Me.lblNumberRainDays) - Me.Controls.Add(Me.lblThreashold) - Me.Controls.Add(Me.nudNumberofRainDays) - Me.Controls.Add(Me.lblEarliest) - Me.Controls.Add(Me.lblDataList) - Me.Controls.Add(Me.ucrBase) - Me.MaximizeBox = False - Me.MinimizeBox = False - Me.Name = "dlgStartofRains" - Me.ShowIcon = False - Me.Text = "Start of Rains" - CType(Me.nudNumberofRainDays, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudTotalRain, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudWithin, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudDryLength, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudEarliest, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudThreshold, System.ComponentModel.ISupportInitialize).EndInit() - Me.ResumeLayout(False) - Me.PerformLayout() - + Me.lblDataList = New System.Windows.Forms.Label() + Me.lblEarliest = New System.Windows.Forms.Label() + Me.nudNumberofRainDays = New System.Windows.Forms.NumericUpDown() + Me.lblThreashold = New System.Windows.Forms.Label() + Me.lblNumberRainDays = New System.Windows.Forms.Label() + Me.lblTotalRain = New System.Windows.Forms.Label() + Me.nudTotalRain = New System.Windows.Forms.NumericUpDown() + Me.chkDrySpell = New System.Windows.Forms.CheckBox() + Me.nudWithin = New System.Windows.Forms.NumericUpDown() + Me.lblWithin = New System.Windows.Forms.Label() + Me.lblDryLength = New System.Windows.Forms.Label() + Me.nudDryLength = New System.Windows.Forms.NumericUpDown() + Me.lblDays = New System.Windows.Forms.Label() + Me.lblColumnName = New System.Windows.Forms.Label() + Me.txtColumnName = New System.Windows.Forms.TextBox() + Me.nudEarliest = New System.Windows.Forms.NumericUpDown() + Me.nudThreshold = New System.Windows.Forms.NumericUpDown() + Me.ucrBase = New instat.ucrButtons() + CType(Me.nudNumberofRainDays, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.nudTotalRain, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.nudWithin, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.nudDryLength, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.nudEarliest, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.nudThreshold, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'lblDataList + ' + Me.lblDataList.AutoSize = True + Me.lblDataList.Location = New System.Drawing.Point(36, 35) + Me.lblDataList.Name = "lblDataList" + Me.lblDataList.Size = New System.Drawing.Size(106, 13) + Me.lblDataList.TabIndex = 1 + Me.lblDataList.Tag = "Not_Yet_Implemented" + Me.lblDataList.Text = "Not Yet Implemented" + ' + 'lblEarliest + ' + Me.lblEarliest.AutoSize = True + Me.lblEarliest.Location = New System.Drawing.Point(39, 75) + Me.lblEarliest.Name = "lblEarliest" + Me.lblEarliest.Size = New System.Drawing.Size(61, 13) + Me.lblEarliest.TabIndex = 2 + Me.lblEarliest.Tag = "Earliest_day" + Me.lblEarliest.Text = "Earliest day" + ' + 'nudNumberofRainDays + ' + Me.nudNumberofRainDays.Location = New System.Drawing.Point(192, 110) + Me.nudNumberofRainDays.Name = "nudNumberofRainDays" + Me.nudNumberofRainDays.Size = New System.Drawing.Size(35, 20) + Me.nudNumberofRainDays.TabIndex = 4 + Me.nudNumberofRainDays.Value = New Decimal(New Integer() {2, 0, 0, 0}) + ' + 'lblThreashold + ' + Me.lblThreashold.AutoSize = True + Me.lblThreashold.Location = New System.Drawing.Point(39, 95) + Me.lblThreashold.Name = "lblThreashold" + Me.lblThreashold.Size = New System.Drawing.Size(39, 13) + Me.lblThreashold.TabIndex = 5 + Me.lblThreashold.Tag = "Threashold" + Me.lblThreashold.Text = "Label1" + ' + 'lblNumberRainDays + ' + Me.lblNumberRainDays.AutoSize = True + Me.lblNumberRainDays.Location = New System.Drawing.Point(39, 115) + Me.lblNumberRainDays.Name = "lblNumberRainDays" + Me.lblNumberRainDays.Size = New System.Drawing.Size(39, 13) + Me.lblNumberRainDays.TabIndex = 7 + Me.lblNumberRainDays.Tag = "Number_of_Rain_Days" + Me.lblNumberRainDays.Text = "Label1" + ' + 'lblTotalRain + ' + Me.lblTotalRain.AutoSize = True + Me.lblTotalRain.Location = New System.Drawing.Point(39, 135) + Me.lblTotalRain.Name = "lblTotalRain" + Me.lblTotalRain.Size = New System.Drawing.Size(39, 13) + Me.lblTotalRain.TabIndex = 8 + Me.lblTotalRain.Tag = "Total_Rain" + Me.lblTotalRain.Text = "Label1" + ' + 'nudTotalRain + ' + Me.nudTotalRain.Location = New System.Drawing.Point(192, 131) + Me.nudTotalRain.Maximum = New Decimal(New Integer() {200, 0, 0, 0}) + Me.nudTotalRain.Name = "nudTotalRain" + Me.nudTotalRain.Size = New System.Drawing.Size(35, 20) + Me.nudTotalRain.TabIndex = 9 + Me.nudTotalRain.Value = New Decimal(New Integer() {20, 0, 0, 0}) + ' + 'chkDrySpell + ' + Me.chkDrySpell.AutoSize = True + Me.chkDrySpell.Location = New System.Drawing.Point(12, 163) + Me.chkDrySpell.Name = "chkDrySpell" + Me.chkDrySpell.Size = New System.Drawing.Size(81, 17) + Me.chkDrySpell.TabIndex = 10 + Me.chkDrySpell.Tag = "Dry_Spell" + Me.chkDrySpell.Text = "CheckBox1" + Me.chkDrySpell.UseVisualStyleBackColor = True + ' + 'nudWithin + ' + Me.nudWithin.Location = New System.Drawing.Point(288, 189) + Me.nudWithin.Maximum = New Decimal(New Integer() {200, 0, 0, 0}) + Me.nudWithin.Name = "nudWithin" + Me.nudWithin.Size = New System.Drawing.Size(35, 20) + Me.nudWithin.TabIndex = 14 + Me.nudWithin.Value = New Decimal(New Integer() {30, 0, 0, 0}) + ' + 'lblWithin + ' + Me.lblWithin.AutoSize = True + Me.lblWithin.Location = New System.Drawing.Point(233, 193) + Me.lblWithin.Name = "lblWithin" + Me.lblWithin.Size = New System.Drawing.Size(39, 13) + Me.lblWithin.TabIndex = 13 + Me.lblWithin.Tag = "Within" + Me.lblWithin.Text = "Label1" + ' + 'lblDryLength + ' + Me.lblDryLength.AutoSize = True + Me.lblDryLength.Location = New System.Drawing.Point(39, 193) + Me.lblDryLength.Name = "lblDryLength" + Me.lblDryLength.Size = New System.Drawing.Size(39, 13) + Me.lblDryLength.TabIndex = 12 + Me.lblDryLength.Tag = "Length_of_Dry_Spell" + Me.lblDryLength.Text = "Label1" + ' + 'nudDryLength + ' + Me.nudDryLength.Location = New System.Drawing.Point(192, 189) + Me.nudDryLength.Name = "nudDryLength" + Me.nudDryLength.Size = New System.Drawing.Size(35, 20) + Me.nudDryLength.TabIndex = 11 + Me.nudDryLength.Value = New Decimal(New Integer() {10, 0, 0, 0}) + ' + 'lblDays + ' + Me.lblDays.AutoSize = True + Me.lblDays.Location = New System.Drawing.Point(329, 193) + Me.lblDays.Name = "lblDays" + Me.lblDays.Size = New System.Drawing.Size(13, 13) + Me.lblDays.TabIndex = 15 + Me.lblDays.Tag = "Days" + Me.lblDays.Text = "2" + ' + 'lblColumnName + ' + Me.lblColumnName.AutoSize = True + Me.lblColumnName.Location = New System.Drawing.Point(39, 230) + Me.lblColumnName.Name = "lblColumnName" + Me.lblColumnName.Size = New System.Drawing.Size(39, 13) + Me.lblColumnName.TabIndex = 16 + Me.lblColumnName.Tag = "Column_Name" + Me.lblColumnName.Text = "Label1" + ' + 'txtColumnName + ' + Me.txtColumnName.Location = New System.Drawing.Point(192, 222) + Me.txtColumnName.Name = "txtColumnName" + Me.txtColumnName.Size = New System.Drawing.Size(100, 20) + Me.txtColumnName.TabIndex = 17 + Me.txtColumnName.Tag = "Start_of_Rain" + ' + 'nudEarliest + ' + Me.nudEarliest.Location = New System.Drawing.Point(192, 68) + Me.nudEarliest.Maximum = New Decimal(New Integer() {366, 0, 0, 0}) + Me.nudEarliest.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) + Me.nudEarliest.Name = "nudEarliest" + Me.nudEarliest.Size = New System.Drawing.Size(53, 20) + Me.nudEarliest.TabIndex = 18 + Me.nudEarliest.Value = New Decimal(New Integer() {92, 0, 0, 0}) + ' + 'nudThreshold + ' + Me.nudThreshold.DecimalPlaces = 2 + Me.nudThreshold.Increment = New Decimal(New Integer() {1, 0, 0, 65536}) + Me.nudThreshold.Location = New System.Drawing.Point(192, 89) + Me.nudThreshold.Name = "nudThreshold" + Me.nudThreshold.Size = New System.Drawing.Size(53, 20) + Me.nudThreshold.TabIndex = 19 + Me.nudThreshold.Value = New Decimal(New Integer() {85, 0, 0, 131072}) + ' + 'ucrBase + ' + Me.ucrBase.Location = New System.Drawing.Point(14, 275) + Me.ucrBase.Name = "ucrBase" + Me.ucrBase.Size = New System.Drawing.Size(409, 52) + Me.ucrBase.TabIndex = 0 + ' + 'dlgStartofRains + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(449, 328) + Me.Controls.Add(Me.nudThreshold) + Me.Controls.Add(Me.nudEarliest) + Me.Controls.Add(Me.txtColumnName) + Me.Controls.Add(Me.lblColumnName) + Me.Controls.Add(Me.lblDays) + Me.Controls.Add(Me.nudWithin) + Me.Controls.Add(Me.lblWithin) + Me.Controls.Add(Me.lblDryLength) + Me.Controls.Add(Me.nudDryLength) + Me.Controls.Add(Me.chkDrySpell) + Me.Controls.Add(Me.nudTotalRain) + Me.Controls.Add(Me.lblTotalRain) + Me.Controls.Add(Me.lblNumberRainDays) + Me.Controls.Add(Me.lblThreashold) + Me.Controls.Add(Me.nudNumberofRainDays) + Me.Controls.Add(Me.lblEarliest) + Me.Controls.Add(Me.lblDataList) + Me.Controls.Add(Me.ucrBase) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "dlgStartofRains" + Me.ShowIcon = False + Me.Text = "Start of Rains" + CType(Me.nudNumberofRainDays, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.nudTotalRain, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.nudWithin, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.nudDryLength, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.nudEarliest, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.nudThreshold, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + End Sub Friend WithEvents ucrBase As ucrButtons diff --git a/instat/dlgStemAndLeaf.Designer.vb b/instat/dlgStemAndLeaf.Designer.vb index 946b71a6df7..1fd8976f91c 100644 --- a/instat/dlgStemAndLeaf.Designer.vb +++ b/instat/dlgStemAndLeaf.Designer.vb @@ -25,18 +25,19 @@ Partial Class dlgStemAndLeaf Me.UcrAddRemove = New instat.ucrSelectorAddRemove() Me.ucrReceiverStemAndLeaf = New instat.ucrReceiverSingle() Me.ucrBase = New instat.ucrButtons() + Me.lblSelectedVariable = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'UcrAddRemove ' Me.UcrAddRemove.Location = New System.Drawing.Point(2, 12) Me.UcrAddRemove.Name = "UcrAddRemove" - Me.UcrAddRemove.Size = New System.Drawing.Size(186, 129) + Me.UcrAddRemove.Size = New System.Drawing.Size(213, 129) Me.UcrAddRemove.TabIndex = 0 ' 'ucrReceiverStemAndLeaf ' - Me.ucrReceiverStemAndLeaf.Location = New System.Drawing.Point(245, 40) + Me.ucrReceiverStemAndLeaf.Location = New System.Drawing.Point(245, 49) Me.ucrReceiverStemAndLeaf.Name = "ucrReceiverStemAndLeaf" Me.ucrReceiverStemAndLeaf.Size = New System.Drawing.Size(106, 26) Me.ucrReceiverStemAndLeaf.TabIndex = 1 @@ -48,25 +49,38 @@ Partial Class dlgStemAndLeaf Me.ucrBase.Size = New System.Drawing.Size(410, 52) Me.ucrBase.TabIndex = 2 ' + 'lblSelectedVariable + ' + Me.lblSelectedVariable.AutoSize = True + Me.lblSelectedVariable.Location = New System.Drawing.Point(252, 34) + Me.lblSelectedVariable.Name = "lblSelectedVariable" + Me.lblSelectedVariable.Size = New System.Drawing.Size(90, 13) + Me.lblSelectedVariable.TabIndex = 3 + Me.lblSelectedVariable.Tag = "Selected_Variable" + Me.lblSelectedVariable.Text = "Selected Variable" + ' 'dlgStemAndLeaf ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(443, 280) + Me.Controls.Add(Me.lblSelectedVariable) Me.Controls.Add(Me.ucrBase) Me.Controls.Add(Me.ucrReceiverStemAndLeaf) Me.Controls.Add(Me.UcrAddRemove) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgStemAndLeaf" - Me.Tag = "StemandLeaf" + Me.Tag = "Stem_and_Leaf" Me.Text = "Stem and Leaf" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents UcrAddRemove As ucrSelectorAddRemove Friend WithEvents ucrReceiverStemAndLeaf As ucrReceiverSingle Friend WithEvents ucrBase As ucrButtons + Friend WithEvents lblSelectedVariable As Label End Class diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index 87f3b463259..921368a19c2 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -385,7 +385,8 @@ data_obj$methods(insert_column_in_data = function(col_data =c(), start_pos = len data <<- cbind(data[1:(start_pos -1)],data[(ncol(data)-number_cols+1):ncol(data)], data[(start_pos+number_cols):ncol(data)-number_cols]) } .self$append_to_changes(list(Inserted_col, start_pos)) - .self$data_changed = TRUE + .self$set_data_changed(TRUE) + .self$set_variables_metadata_changed(TRUE) } ) diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index 1b6b34ee226..a9ea6e3eff9 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -268,11 +268,11 @@ instat_obj$methods(get_model = function(model_name) { } ) -instat_obj$methods(replace_value_in_data = function(data_name, column_name, row_number, new_val) { +instat_obj$methods(replace_value_in_data = function(data_name, col_name, index, new_value) { if(!is.character(data_name)) stop("data_name must be of type character") if(!data_name %in% names(data_objects)) stop(paste("dataframe: ", data_name, " not found")) - data_objects[[data_name]]$replace_value_in_data(column_name, row_number, new_val) + data_objects[[data_name]]$replace_value_in_data(col_name, index, new_value) } ) diff --git a/instat/ucrDataFrame.vb b/instat/ucrDataFrame.vb index 1d695f1156f..ab5309b0919 100644 --- a/instat/ucrDataFrame.vb +++ b/instat/ucrDataFrame.vb @@ -14,12 +14,10 @@ ' You should have received a copy of the GNU General Public License k ' along with this program. If not, see . Imports instat.Translations -Imports RDotNet Public Class ucrDataFrame - Public strDataFrameLength As String - Public clsCurrDataFrame As RFunction - Public clsRSyntax As New RSyntax + Public iDataFrameLength As Integer + Public clsCurrDataFrame As New RFunction Private Sub ucrDataFrame_Load(sender As Object, e As EventArgs) Handles MyBase.Load frmMain.clsRLink.FillComboDataFrames(cboAvailableDataFrames) @@ -34,10 +32,13 @@ Public Class ucrDataFrame End Sub Public Sub SetDataFrameProperties() - strDataFrameLength = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$length_of_data(" & Chr(34) & cboAvailableDataFrames.Text & Chr(34) & ")").AsCharacter(0).ToString - clsRSyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$get_data_frame", clsFunction:=clsCurrDataFrame) - clsRSyntax.AddParameter("data_name", Chr(34) & cboAvailableDataFrames.SelectedItem & Chr(34), clsRFunction:=clsCurrDataFrame) - clsRSyntax.SetAssignTo(cboAvailableDataFrames.SelectedItem & "_temp", clsFunction:=clsCurrDataFrame) + Dim clsParam As New RParameter + iDataFrameLength = frmMain.clsRLink.GetDataFrameLength(cboAvailableDataFrames.Text) + clsCurrDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame") + clsParam.SetArgumentName("data_name") + clsParam.SetArgumentValue(Chr(34) & cboAvailableDataFrames.SelectedItem & Chr(34)) + clsCurrDataFrame.AddParameter(clsParam) + clsCurrDataFrame.SetAssignTo(cboAvailableDataFrames.SelectedItem & "_temp") End Sub End Class diff --git a/instat/ucrNewColumnName.vb b/instat/ucrNewColumnName.vb index 6800854e849..b5b105e61d4 100644 --- a/instat/ucrNewColumnName.vb +++ b/instat/ucrNewColumnName.vb @@ -23,18 +23,24 @@ Public Class ucrNewColumnName Public strPrefix As String = "Val" Public bDataFrameSelectorSet = False Public WithEvents ucrDataFrameSelector As ucrDataFrame + Public bUseDefault As Boolean = True + Public strCurrNewColumnText As String Private Sub ucrNewColumnName_Load(sender As Object, e As EventArgs) Handles MyBase.Load + bUseDefault = True GetNextDefaults() - SetDefaultName() + If ucrDataFrameSelector IsNot Nothing Then + frmMain.clsRLink.FillColumnNames(ucrDataFrameSelector.cboAvailableDataFrames.Text, cboColumns:=cboColumnName) + SetDefaultName() + End If End Sub - Public Sub SetDataFrameSelector(ucrNewSelector) - 'TODO fix issue here, not setting ucrDataFrameSelector correctly + Public Sub SetDataFrameSelector(ucrNewSelector As ucrDataFrame) ucrDataFrameSelector = ucrNewSelector bDataFrameSelectorSet = True GetNextDefaults() SetDefaultName() + frmMain.clsRLink.FillColumnNames(ucrDataFrameSelector.cboAvailableDataFrames.Text, cboColumns:=cboColumnName) End Sub Public Sub SetPrefix(strNewPrefix As String) @@ -49,17 +55,24 @@ Public Class ucrNewColumnName Public Sub SetDefaultName() Dim i As Integer - If bDataFrameSelectorSet Then - For i = 0 To lstNextDefaultNames.Length - 1 - If lstNextDefaultNames.Names(i) = ucrDataFrameSelector.cboAvailableDataFrames.Text Then - cboColumnName.Text = lstNextDefaultNames.AsCharacter(i) - End If - Next + If bUseDefault Then + If bDataFrameSelectorSet Then + For i = 0 To lstNextDefaultNames.Length - 1 + If lstNextDefaultNames.Names(i) = ucrDataFrameSelector.cboAvailableDataFrames.Text Then + cboColumnName.Text = lstNextDefaultNames.AsCharacter(i) + End If + Next + End If End If - End Sub Private Sub ucrDataFrameSelector_DataFrameChanged(sender As Object, e As EventArgs) Handles ucrDataFrameSelector.DataFrameChanged + frmMain.clsRLink.FillColumnNames(ucrDataFrameSelector.cboAvailableDataFrames.Text, cboColumns:=cboColumnName) SetDefaultName() End Sub + + 'NOTE: This could be a bug if the user edits the text without a key press e.g. paste using mouse + Private Sub cboColumnName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cboColumnName.KeyPress + bUseDefault = False + End Sub End Class \ No newline at end of file diff --git a/instat/ucrReceiverMultiple.designer.vb b/instat/ucrReceiverMultiple.designer.vb index 8bb382036c4..5ad05dcb2a1 100644 --- a/instat/ucrReceiverMultiple.designer.vb +++ b/instat/ucrReceiverMultiple.designer.vb @@ -24,11 +24,14 @@ Partial Class ucrReceiverMultiple ' 'lstSelectedVariables ' + Me.lstSelectedVariables.Activation = System.Windows.Forms.ItemActivation.TwoClick + Me.lstSelectedVariables.GridLines = True Me.lstSelectedVariables.Location = New System.Drawing.Point(3, 5) Me.lstSelectedVariables.Name = "lstSelectedVariables" Me.lstSelectedVariables.Size = New System.Drawing.Size(113, 95) Me.lstSelectedVariables.TabIndex = 1 Me.lstSelectedVariables.UseCompatibleStateImageBehavior = False + Me.lstSelectedVariables.View = System.Windows.Forms.View.Details ' 'ucrReceiverMultiple '