diff --git a/instat/clsCondition.vb b/instat/clsCondition.vb new file mode 100644 index 00000000000..9d2188caff5 --- /dev/null +++ b/instat/clsCondition.vb @@ -0,0 +1,32 @@ +Public Class Condition + Private strType As String = "ParameterValue" + Private strParameterName As String = "" + Private lstValues As List(Of String) = New List(Of String) + + Public Sub SetParameterPresentName(strParamName As String) + strType = "ParameterPresent" + strParameterName = strParamName + End Sub + + Public Sub SetParameterValues(strParamName As String, lstParamValues As List(Of String)) + strType = "ParameterValue" + strParameterName = strParamName + lstValues = lstParamValues + End Sub + + Public Sub SetParameterValues(strParamName As String, strParamValues As String) + strType = "ParameterValue" + strParameterName = strParamName + lstValues = New List(Of String)({strParamValues}) + End Sub + + Public Sub SetFunctionName(strFuncName As String) + strType = "FunctionName" + lstValues = New List(Of String)({strFuncName}) + End Sub + + Public Sub SetFunctionNamesMultiple(lstFuncNames As List(Of String)) + strType = "FunctionName" + lstValues = lstFuncNames + End Sub +End Class diff --git a/instat/dlgFileNew.Designer.vb b/instat/dlgFileNew.Designer.vb index d9d4adff819..64e82ac9d39 100644 --- a/instat/dlgFileNew.Designer.vb +++ b/instat/dlgFileNew.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class dlgFileNew Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,17 +20,14 @@ Partial Class dlgFileNew 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. - _ + Private Sub InitializeComponent() Me.lblRows = New System.Windows.Forms.Label() Me.lblColumns = New System.Windows.Forms.Label() - Me.lblName = New System.Windows.Forms.Label() Me.ucrBase = New instat.ucrButtons() - Me.ucrName = New instat.ucrInputComboBox() - Me.nudRows = New System.Windows.Forms.NumericUpDown() - Me.nudColumns = New System.Windows.Forms.NumericUpDown() - CType(Me.nudRows, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudColumns, System.ComponentModel.ISupportInitialize).BeginInit() + Me.ucrNudRows = New instat.ucrNud() + Me.ucrNudCols = New instat.ucrNud() + Me.ucrNewDFName = New instat.ucrSave() Me.SuspendLayout() ' 'lblRows @@ -51,59 +48,50 @@ Partial Class dlgFileNew Me.lblColumns.TabIndex = 2 Me.lblColumns.Text = "Columns:" ' - 'lblName - ' - Me.lblName.AutoSize = True - Me.lblName.Location = New System.Drawing.Point(7, 78) - Me.lblName.Name = "lblName" - Me.lblName.Size = New System.Drawing.Size(94, 13) - Me.lblName.TabIndex = 4 - Me.lblName.Text = "New Sheet Name:" - ' 'ucrBase ' Me.ucrBase.Location = New System.Drawing.Point(10, 103) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(399, 48) - Me.ucrBase.TabIndex = 6 + Me.ucrBase.TabIndex = 5 ' - 'ucrName + 'ucrNudRows ' - Me.ucrName.IsReadOnly = False - Me.ucrName.Location = New System.Drawing.Point(107, 75) - Me.ucrName.Name = "ucrName" - Me.ucrName.Size = New System.Drawing.Size(137, 21) - Me.ucrName.TabIndex = 7 + Me.ucrNudRows.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudRows.Location = New System.Drawing.Point(73, 12) + Me.ucrNudRows.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudRows.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudRows.Name = "ucrNudRows" + Me.ucrNudRows.Size = New System.Drawing.Size(50, 20) + Me.ucrNudRows.TabIndex = 1 + Me.ucrNudRows.Value = New Decimal(New Integer() {0, 0, 0, 0}) ' - 'nudRows + 'ucrNudCols ' - Me.nudRows.Location = New System.Drawing.Point(75, 12) - Me.nudRows.Maximum = New Decimal(New Integer() {32767, 0, 0, 0}) - Me.nudRows.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) - Me.nudRows.Name = "nudRows" - Me.nudRows.Size = New System.Drawing.Size(47, 20) - Me.nudRows.TabIndex = 8 - Me.nudRows.Value = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudCols.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudCols.Location = New System.Drawing.Point(73, 40) + Me.ucrNudCols.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) + Me.ucrNudCols.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudCols.Name = "ucrNudCols" + Me.ucrNudCols.Size = New System.Drawing.Size(50, 20) + Me.ucrNudCols.TabIndex = 3 + Me.ucrNudCols.Value = New Decimal(New Integer() {0, 0, 0, 0}) ' - 'nudColumns + 'ucrNewDFName ' - Me.nudColumns.Location = New System.Drawing.Point(75, 41) - Me.nudColumns.Maximum = New Decimal(New Integer() {32767, 0, 0, 0}) - Me.nudColumns.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) - Me.nudColumns.Name = "nudColumns" - Me.nudColumns.Size = New System.Drawing.Size(47, 20) - Me.nudColumns.TabIndex = 9 - Me.nudColumns.Value = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNewDFName.Location = New System.Drawing.Point(10, 73) + Me.ucrNewDFName.Name = "ucrNewDFName" + Me.ucrNewDFName.Size = New System.Drawing.Size(300, 24) + Me.ucrNewDFName.TabIndex = 4 ' 'dlgFileNew ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(418, 162) - Me.Controls.Add(Me.nudColumns) - Me.Controls.Add(Me.nudRows) - Me.Controls.Add(Me.ucrName) - Me.Controls.Add(Me.lblName) + Me.Controls.Add(Me.ucrNewDFName) + Me.Controls.Add(Me.ucrNudCols) + Me.Controls.Add(Me.ucrNudRows) Me.Controls.Add(Me.lblColumns) Me.Controls.Add(Me.lblRows) Me.Controls.Add(Me.ucrBase) @@ -113,18 +101,15 @@ Partial Class dlgFileNew Me.Name = "dlgFileNew" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "New File" - CType(Me.nudRows, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudColumns, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents ucrBase As ucrButtons - Friend WithEvents lblName As Label Friend WithEvents lblColumns As Label Friend WithEvents lblRows As Label - Friend WithEvents ucrName As ucrInputComboBox - Friend WithEvents nudRows As NumericUpDown - Friend WithEvents nudColumns As NumericUpDown + Friend WithEvents ucrNudRows As ucrNud + Friend WithEvents ucrNudCols As ucrNud + Friend WithEvents ucrNewDFName As ucrSave End Class diff --git a/instat/dlgFileNew.vb b/instat/dlgFileNew.vb index 338b76fd265..9c103dc2164 100644 --- a/instat/dlgFileNew.vb +++ b/instat/dlgFileNew.vb @@ -1,24 +1,24 @@ -' 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 . +' 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 . +Imports instat Imports instat.Translations Imports RDotNet Public Class dlgFileNew - Public clsMatrix As New RFunction - Public strDefaultSheetPrefix As String = "Sheet" + Private clsOverallFunction, clsMatrixDefaultFunction, clsMatrixFunction As New RFunction Public bFirstLoad As Boolean = True Private Sub dlgFileNew_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -35,54 +35,63 @@ Public Class dlgFileNew TestOKEnabled() End Sub - Private Sub InitialiseDialog() - ucrBase.iHelpTopicID = 6 - clsMatrix.SetRCommand("matrix") - clsMatrix.AddParameter("data", "NA") - ucrBase.clsRsyntax.SetFunction("data.frame") - ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=clsMatrix) - nudRows.Maximum = Integer.MaxValue - nudRows.Minimum = 1 - nudColumns.Maximum = Integer.MaxValue - nudColumns.Minimum = 1 - 'ucrName.SetDefaultTypeAsDataFrame() This can be added in when the code is written - ucrName.SetValidationTypeAsRVariable() - End Sub + Private Sub InitialiseDialog() + ucrBase.iHelpTopicID = 6 + + 'nudRows + ucrNudRows.SetParameter(New RParameter("nrow")) + ucrNudRows.SetMinMax(1, Integer.MaxValue) + + 'nudCols + ucrNudCols.SetParameter(New RParameter("ncol")) + ucrNudCols.SetMinMax(1, Integer.MaxValue) + + ' ucrNewSheetName + ucrNewDFName.SetIsTextBox() + ucrNewDFName.SetSaveTypeAsDataFrame() + ucrNewDFName.SetLabelText("New Data Frame Name:") + ucrNewDFName.SetPrefix("data") + + ' Default R + clsOverallFunction.SetRCommand("data.frame") + + 'matrix(nrow = 10, ncol = 2, Data = NA) + clsMatrixDefaultFunction.SetRCommand("matrix") + clsMatrixDefaultFunction.AddParameter("data", "NA") + clsMatrixDefaultFunction.AddParameter("ncol", 2) + clsMatrixDefaultFunction.AddParameter("nrow", 10) + End Sub - Private Sub ReopenDialog() - ucrName.SetName(strName:=frmMain.clsRLink.GetDefaultDataFrameName(strDefaultSheetPrefix)) - End Sub + ' updating controls doesn't update the function + ' Sheet name is not on the dialog. - Private Sub SetDefaults() - nudRows.Value = 10 - nudColumns.Value = 2 - ucrName.SetName(strName:=frmMain.clsRLink.GetDefaultDataFrameName(strDefaultSheetPrefix)) - End Sub - - Private Sub nudColumns_TextChanged(sender As Object, e As EventArgs) Handles nudColumns.TextChanged - clsMatrix.AddParameter("ncol", nudColumns.Value.ToString()) - TestOKEnabled() + Private Sub ReopenDialog() End Sub - Private Sub nudRows_TextChanged(sender As Object, e As EventArgs) Handles nudRows.TextChanged - clsMatrix.AddParameter("nrow", nudRows.Value.ToString()) - TestOKEnabled() + Private Sub SetDefaults() + ucrBase.clsRsyntax.SetBaseRFunction(clsOverallFunction) + clsMatrixFunction = clsMatrixDefaultFunction.Clone() + clsOverallFunction.AddParameter("data", clsRFunctionParameter:=clsMatrixFunction) + ucrNudCols.SetRCode(clsMatrixFunction) + ucrNudRows.SetRCode(clsMatrixFunction) + ucrNewDFName.SetRCode(clsOverallFunction) + ucrNewDFName.Reset() + TestOKEnabled() End Sub - Private Sub TestOKEnabled() - If Not ucrName.IsEmpty AndAlso nudColumns.Text <> "" AndAlso nudRows.Text <> "" Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If + Private Sub TestOKEnabled() + If ucrNewDFName.IsComplete AndAlso ucrNudCols.GetText <> "" AndAlso ucrNudRows.GetText <> "" Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() - End Sub - - Private Sub ucrName_NameChanged() Handles ucrName.NameChanged - ucrBase.clsRsyntax.SetAssignTo(ucrName.GetText(), strTempDataframe:=ucrName.GetText()) - TestOKEnabled() - End Sub + End Sub + + Private Sub ucrInputDataFrameName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrNudRows.ControlContentsChanged, ucrNudCols.ControlContentsChanged, ucrNewDFName.ControlContentsChanged + TestOKEnabled() + End Sub End Class \ No newline at end of file diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 44f21ff083a..cecb793a427 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -147,6 +147,7 @@ + dlgAddComment.vb diff --git a/instat/ucrSave.vb b/instat/ucrSave.vb index c989302c9ee..5e0738bc527 100644 --- a/instat/ucrSave.vb +++ b/instat/ucrSave.vb @@ -225,7 +225,7 @@ Public Class ucrSave Case "column" clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, strTempColumn:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix, bAssignToColumnWithoutNames:=bAssignToColumnWithoutNames, bInsertColumnBefore:=bInsertColumnBefore) Case "dataframe" - clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, bAssignToIsPrefix:=bAssignToIsPrefix) + clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix) Case "graph" clsRCode.SetAssignTo(strTemp:=strSaveName, strTempDataframe:=strDataName, strTempGraph:=strSaveName, bAssignToIsPrefix:=bAssignToIsPrefix) Case "model"