From 5ca4e675078e4f93528dbb23fdf5e8d2aa3bcecb Mon Sep 17 00:00:00 2001 From: deaspo Date: Wed, 2 Mar 2016 23:57:54 +0300 Subject: [PATCH 01/21] Updated Save As to save the Script window contents, also made the File>Save Click functional --- instat/dlgSaveAs.Designer.vb | 214 ++++++++++++++++++++++------------- instat/dlgSaveAs.fr-FR.resx | 3 + instat/dlgSaveAs.resx | 3 + instat/dlgSaveAs.sw-KE.resx | 3 + instat/dlgSaveAs.vb | 175 ++++++++++++++++++---------- instat/frmMain.vb | 7 +- 6 files changed, 269 insertions(+), 136 deletions(-) diff --git a/instat/dlgSaveAs.Designer.vb b/instat/dlgSaveAs.Designer.vb index e9f1d0e26ea..23699c39f4d 100644 --- a/instat/dlgSaveAs.Designer.vb +++ b/instat/dlgSaveAs.Designer.vb @@ -22,24 +22,31 @@ Partial Class dlgSaveAs 'Do not modify it using the code editor. _ Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() Me.chkOutput = New System.Windows.Forms.CheckBox() Me.lblChoose = New System.Windows.Forms.Label() Me.grpOptions = New System.Windows.Forms.GroupBox() + Me.grpScript = New System.Windows.Forms.GroupBox() + Me.txtScriptSave = New System.Windows.Forms.TextBox() + Me.cmdScriptSave = New System.Windows.Forms.Button() + Me.chkScript = New System.Windows.Forms.CheckBox() + Me.grpOutput = New System.Windows.Forms.GroupBox() + Me.txtOutputSave = New System.Windows.Forms.TextBox() + Me.cmdOutputSave = New System.Windows.Forms.Button() Me.lblSavePath = New System.Windows.Forms.Label() + Me.grpLog = New System.Windows.Forms.GroupBox() + Me.txtLogSave = New System.Windows.Forms.TextBox() + Me.cmdLogSave = New System.Windows.Forms.Button() + Me.chkLog = New System.Windows.Forms.CheckBox() Me.ucrBase = New instat.ucrButtons() Me.txtEditorSave = New System.Windows.Forms.TextBox() Me.cmdEditorSave = New System.Windows.Forms.Button() Me.lblSaveDataGrid = New System.Windows.Forms.Label() - Me.grpLog = New System.Windows.Forms.GroupBox() - Me.chkLog = New System.Windows.Forms.CheckBox() - Me.txtLogSave = New System.Windows.Forms.TextBox() - Me.cmdLogSave = New System.Windows.Forms.Button() - Me.grpOutput = New System.Windows.Forms.GroupBox() - Me.txtOutputSave = New System.Windows.Forms.TextBox() - Me.cmdOutputSave = New System.Windows.Forms.Button() + Me.ttScript = New System.Windows.Forms.ToolTip(Me.components) Me.grpOptions.SuspendLayout() - Me.grpLog.SuspendLayout() + Me.grpScript.SuspendLayout() Me.grpOutput.SuspendLayout() + Me.grpLog.SuspendLayout() Me.SuspendLayout() ' 'chkOutput @@ -64,6 +71,8 @@ Partial Class dlgSaveAs ' 'grpOptions ' + Me.grpOptions.Controls.Add(Me.grpScript) + Me.grpOptions.Controls.Add(Me.chkScript) Me.grpOptions.Controls.Add(Me.grpOutput) Me.grpOptions.Controls.Add(Me.lblSavePath) Me.grpOptions.Controls.Add(Me.grpLog) @@ -71,11 +80,77 @@ Partial Class dlgSaveAs Me.grpOptions.Controls.Add(Me.chkLog) Me.grpOptions.Location = New System.Drawing.Point(8, 80) Me.grpOptions.Name = "grpOptions" - Me.grpOptions.Size = New System.Drawing.Size(533, 126) + Me.grpOptions.Size = New System.Drawing.Size(533, 182) Me.grpOptions.TabIndex = 14 Me.grpOptions.TabStop = False Me.grpOptions.Text = "Available Options" ' + 'grpScript + ' + Me.grpScript.Controls.Add(Me.txtScriptSave) + Me.grpScript.Controls.Add(Me.cmdScriptSave) + Me.grpScript.Location = New System.Drawing.Point(164, 123) + Me.grpScript.Name = "grpScript" + Me.grpScript.Size = New System.Drawing.Size(362, 40) + Me.grpScript.TabIndex = 21 + Me.grpScript.TabStop = False + ' + 'txtScriptSave + ' + Me.txtScriptSave.Location = New System.Drawing.Point(6, 13) + Me.txtScriptSave.Name = "txtScriptSave" + Me.txtScriptSave.ReadOnly = True + Me.txtScriptSave.Size = New System.Drawing.Size(311, 20) + Me.txtScriptSave.TabIndex = 8 + ' + 'cmdScriptSave + ' + Me.cmdScriptSave.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.cmdScriptSave.Location = New System.Drawing.Point(319, 13) + Me.cmdScriptSave.Name = "cmdScriptSave" + Me.cmdScriptSave.Size = New System.Drawing.Size(31, 20) + Me.cmdScriptSave.TabIndex = 9 + Me.cmdScriptSave.Text = "..." + Me.cmdScriptSave.UseVisualStyleBackColor = True + ' + 'chkScript + ' + Me.chkScript.AutoSize = True + Me.chkScript.Location = New System.Drawing.Point(7, 146) + Me.chkScript.Name = "chkScript" + Me.chkScript.Size = New System.Drawing.Size(141, 17) + Me.chkScript.TabIndex = 20 + Me.chkScript.Text = "Save the Script Window" + Me.chkScript.UseVisualStyleBackColor = True + ' + 'grpOutput + ' + Me.grpOutput.Controls.Add(Me.txtOutputSave) + Me.grpOutput.Controls.Add(Me.cmdOutputSave) + Me.grpOutput.Location = New System.Drawing.Point(163, 28) + Me.grpOutput.Name = "grpOutput" + Me.grpOutput.Size = New System.Drawing.Size(364, 41) + Me.grpOutput.TabIndex = 16 + Me.grpOutput.TabStop = False + ' + 'txtOutputSave + ' + Me.txtOutputSave.Location = New System.Drawing.Point(7, 14) + Me.txtOutputSave.Name = "txtOutputSave" + Me.txtOutputSave.ReadOnly = True + Me.txtOutputSave.Size = New System.Drawing.Size(311, 20) + Me.txtOutputSave.TabIndex = 9 + ' + 'cmdOutputSave + ' + Me.cmdOutputSave.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.cmdOutputSave.Location = New System.Drawing.Point(323, 14) + Me.cmdOutputSave.Name = "cmdOutputSave" + Me.cmdOutputSave.Size = New System.Drawing.Size(31, 20) + Me.cmdOutputSave.TabIndex = 10 + Me.cmdOutputSave.Text = "..." + Me.cmdOutputSave.UseVisualStyleBackColor = True + ' 'lblSavePath ' Me.lblSavePath.AutoSize = True @@ -85,10 +160,48 @@ Partial Class dlgSaveAs Me.lblSavePath.TabIndex = 15 Me.lblSavePath.Text = "Save Path" ' + 'grpLog + ' + Me.grpLog.Controls.Add(Me.txtLogSave) + Me.grpLog.Controls.Add(Me.cmdLogSave) + Me.grpLog.Location = New System.Drawing.Point(165, 76) + Me.grpLog.Name = "grpLog" + Me.grpLog.Size = New System.Drawing.Size(362, 40) + Me.grpLog.TabIndex = 19 + Me.grpLog.TabStop = False + ' + 'txtLogSave + ' + Me.txtLogSave.Location = New System.Drawing.Point(6, 13) + Me.txtLogSave.Name = "txtLogSave" + Me.txtLogSave.ReadOnly = True + Me.txtLogSave.Size = New System.Drawing.Size(311, 20) + Me.txtLogSave.TabIndex = 8 + ' + 'cmdLogSave + ' + Me.cmdLogSave.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.cmdLogSave.Location = New System.Drawing.Point(319, 13) + Me.cmdLogSave.Name = "cmdLogSave" + Me.cmdLogSave.Size = New System.Drawing.Size(31, 20) + Me.cmdLogSave.TabIndex = 9 + Me.cmdLogSave.Text = "..." + Me.cmdLogSave.UseVisualStyleBackColor = True + ' + 'chkLog + ' + Me.chkLog.AutoSize = True + Me.chkLog.Location = New System.Drawing.Point(8, 99) + Me.chkLog.Name = "chkLog" + Me.chkLog.Size = New System.Drawing.Size(132, 17) + Me.chkLog.TabIndex = 3 + Me.chkLog.Text = "Save the Log Window" + Me.chkLog.UseVisualStyleBackColor = True + ' 'ucrBase ' Me.ucrBase.Anchor = System.Windows.Forms.AnchorStyles.Bottom - Me.ucrBase.Location = New System.Drawing.Point(45, 215) + Me.ucrBase.Location = New System.Drawing.Point(45, 268) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(410, 53) Me.ucrBase.TabIndex = 0 @@ -120,77 +233,17 @@ Partial Class dlgSaveAs Me.lblSaveDataGrid.TabIndex = 18 Me.lblSaveDataGrid.Text = "Save the Data Grid" ' - 'grpLog - ' - Me.grpLog.Controls.Add(Me.txtLogSave) - Me.grpLog.Controls.Add(Me.cmdLogSave) - Me.grpLog.Location = New System.Drawing.Point(165, 76) - Me.grpLog.Name = "grpLog" - Me.grpLog.Size = New System.Drawing.Size(362, 40) - Me.grpLog.TabIndex = 19 - Me.grpLog.TabStop = False - ' - 'chkLog - ' - Me.chkLog.AutoSize = True - Me.chkLog.Location = New System.Drawing.Point(8, 99) - Me.chkLog.Name = "chkLog" - Me.chkLog.Size = New System.Drawing.Size(132, 17) - Me.chkLog.TabIndex = 3 - Me.chkLog.Text = "Save the Log Window" - Me.chkLog.UseVisualStyleBackColor = True - ' - 'txtLogSave - ' - Me.txtLogSave.Location = New System.Drawing.Point(6, 13) - Me.txtLogSave.Name = "txtLogSave" - Me.txtLogSave.ReadOnly = True - Me.txtLogSave.Size = New System.Drawing.Size(311, 20) - Me.txtLogSave.TabIndex = 8 + 'ttScript ' - 'cmdLogSave - ' - Me.cmdLogSave.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.cmdLogSave.Location = New System.Drawing.Point(319, 13) - Me.cmdLogSave.Name = "cmdLogSave" - Me.cmdLogSave.Size = New System.Drawing.Size(31, 20) - Me.cmdLogSave.TabIndex = 9 - Me.cmdLogSave.Text = "..." - Me.cmdLogSave.UseVisualStyleBackColor = True - ' - 'grpOutput - ' - Me.grpOutput.Controls.Add(Me.txtOutputSave) - Me.grpOutput.Controls.Add(Me.cmdOutputSave) - Me.grpOutput.Location = New System.Drawing.Point(163, 28) - Me.grpOutput.Name = "grpOutput" - Me.grpOutput.Size = New System.Drawing.Size(364, 41) - Me.grpOutput.TabIndex = 16 - Me.grpOutput.TabStop = False - ' - 'txtOutputSave - ' - Me.txtOutputSave.Location = New System.Drawing.Point(7, 14) - Me.txtOutputSave.Name = "txtOutputSave" - Me.txtOutputSave.ReadOnly = True - Me.txtOutputSave.Size = New System.Drawing.Size(311, 20) - Me.txtOutputSave.TabIndex = 9 - ' - 'cmdOutputSave - ' - Me.cmdOutputSave.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.cmdOutputSave.Location = New System.Drawing.Point(323, 14) - Me.cmdOutputSave.Name = "cmdOutputSave" - Me.cmdOutputSave.Size = New System.Drawing.Size(31, 20) - Me.cmdOutputSave.TabIndex = 10 - Me.cmdOutputSave.Text = "..." - Me.cmdOutputSave.UseVisualStyleBackColor = True + Me.ttScript.IsBalloon = True + Me.ttScript.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info + Me.ttScript.ToolTipTitle = "Saving the Script" ' 'dlgSaveAs ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(551, 280) + Me.ClientSize = New System.Drawing.Size(551, 333) Me.Controls.Add(Me.lblSaveDataGrid) Me.Controls.Add(Me.txtEditorSave) Me.Controls.Add(Me.cmdEditorSave) @@ -203,10 +256,12 @@ Partial Class dlgSaveAs Me.Text = "Save As" Me.grpOptions.ResumeLayout(False) Me.grpOptions.PerformLayout() - Me.grpLog.ResumeLayout(False) - Me.grpLog.PerformLayout() + Me.grpScript.ResumeLayout(False) + Me.grpScript.PerformLayout() Me.grpOutput.ResumeLayout(False) Me.grpOutput.PerformLayout() + Me.grpLog.ResumeLayout(False) + Me.grpLog.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() @@ -227,4 +282,9 @@ Partial Class dlgSaveAs Friend WithEvents txtLogSave As TextBox Friend WithEvents cmdOutputSave As Button Friend WithEvents txtOutputSave As TextBox + Friend WithEvents grpScript As GroupBox + Friend WithEvents txtScriptSave As TextBox + Friend WithEvents cmdScriptSave As Button + Friend WithEvents chkScript As CheckBox + Friend WithEvents ttScript As ToolTip End Class diff --git a/instat/dlgSaveAs.fr-FR.resx b/instat/dlgSaveAs.fr-FR.resx index 9c9f69d752c..79b271eb6e9 100644 --- a/instat/dlgSaveAs.fr-FR.resx +++ b/instat/dlgSaveAs.fr-FR.resx @@ -12,4 +12,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/instat/dlgSaveAs.resx b/instat/dlgSaveAs.resx index 29dcb1b3a35..9306750710f 100644 --- a/instat/dlgSaveAs.resx +++ b/instat/dlgSaveAs.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/instat/dlgSaveAs.sw-KE.resx b/instat/dlgSaveAs.sw-KE.resx index 9c9f69d752c..79b271eb6e9 100644 --- a/instat/dlgSaveAs.sw-KE.resx +++ b/instat/dlgSaveAs.sw-KE.resx @@ -12,4 +12,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index ba9bd9ba0f8..95882f31b62 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -1,7 +1,52 @@ Imports System.IO Imports instat.Translations Public Class dlgSaveAs - Dim dlgSave As New SaveFileDialog + Dim returnResults As KeyValuePair(Of String, String) + Public Function SaveDialog(strFilter As String) As KeyValuePair(Of String, String) + Dim dlgOpen As New SaveFileDialog + Dim strFilePath, strFileName As String + Select Case strFilter + Case ".txt" + dlgOpen.Filter = "Text file (*.txt)|*.txt" + Case ".rtf" + dlgOpen.Filter = "Rich Text file (*.rtf)|*.rtf" + Case ".dataFile" + dlgOpen.Filter = "Comma separated file (*.csv)|*.csv|RDS (*.RDS)|*.RDS" + End Select + dlgOpen.Title = "Save workbook" + If dlgOpen.ShowDialog() = DialogResult.OK Then + 'checks if the file name is not blank' + If dlgOpen.FileName <> "" Then + strFileName = Path.GetFileNameWithoutExtension(dlgOpen.FileName) + strFilePath = Replace(dlgOpen.FileName, "\", "/") + Return New KeyValuePair(Of String, String)(strFileName, strFilePath) + End If + End If + Return New KeyValuePair(Of String, String)("", "") + End Function + + Public Sub setFilePath(strFilePath As String) + ucrBase.clsRsyntax.AddParameter("file", Chr(34) & strFilePath & Chr(34)) + End Sub + + Public Sub setFileExtension(strFileExtension As String) + Select Case strFileExtension + Case ".RDS" + 'set function + setFunction("saveRDS") + ucrBase.clsRsyntax.RemoveParameter("x") + ucrBase.clsRsyntax.AddParameter("object", frmMain.clsRLink.strInstatDataObject) + Case ".csv" + 'set function + setFunction("write.csv") + ucrBase.clsRsyntax.RemoveParameter("object") + ucrBase.clsRsyntax.AddParameter("x", frmEditor.grdData.CurrentWorksheet.Name) + End Select + End Sub + + Public Sub setFunction(strRfunction As String) + ucrBase.clsRsyntax.SetFunction(strRfunction) + End Sub Private Sub chkLog_CheckedChanged(sender As Object, e As EventArgs) Handles chkLog.CheckedChanged If chkLog.Checked = True Then @@ -9,7 +54,6 @@ Public Class dlgSaveAs Else grpLog.Enabled = False End If - CheckOKEnable() End Sub Private Sub chkOutput_CheckedChanged(sender As Object, e As EventArgs) Handles chkOutput.CheckedChanged @@ -18,88 +62,103 @@ Public Class dlgSaveAs Else grpOutput.Enabled = False End If - CheckOKEnable() End Sub Private Sub dlgSaveAs_Load(sender As Object, e As EventArgs) Handles Me.Load + ttScript.SetToolTip(chkScript, "You cannot save an empty script.") autoTranslate(Me) - ucrBase.OKEnabled(False) - If chkOutput.Checked Then - grpLog.Enabled = True - Else - grpLog.Enabled = False - End If - If chkLog.Checked Then - grpOutput.Enabled = True - Else - grpOutput.Enabled = False - End If + grpLog.Enabled = False + grpOutput.Enabled = False + grpScript.Enabled = False + TestOKEnabled() End Sub Private Sub cmdLogSave_Click(sender As Object, e As EventArgs) Handles cmdLogSave.Click - dlgSave.Reset() - dlgSave.Title = "Save Log File" - dlgSave.Filter = "Text file (*.txt)|*.txt" - If dlgSave.ShowDialog() = DialogResult.OK Then - txtLogSave.Text = dlgSave.FileName.Replace("\", "/") - End If - CheckOKEnable() + returnResults = SaveDialog(".txt") + 'Save the path + txtLogSave.Text = returnResults.Value End Sub Private Sub cmdOutputSave_Click(sender As Object, e As EventArgs) Handles cmdOutputSave.Click - dlgSave.Reset() - dlgSave.Title = "Save Output File" - dlgSave.Filter = "Rich Text file (*.rtf)|*.rtf" - If dlgSave.ShowDialog() = DialogResult.OK Then - txtOutputSave.Text = dlgSave.FileName.Replace("\", "/") - End If - CheckOKEnable() + returnResults = SaveDialog(".rtf") + 'Save path + txtOutputSave.Text = returnResults.Value End Sub - Public Sub CheckOKEnable() - Dim bEnable = False - If txtEditorSave.Text <> "" Then - bEnable = True - If chkLog.Checked And txtLogSave.Text = "" Then - bEnable = False - End If - If chkOutput.Checked And txtOutputSave.Text = "" Then - bEnable = False - End If - End If - ucrBase.OKEnabled(bEnable) - End Sub Private Sub ucrBase_ClickOk(sender As Object, e As EventArgs) Handles ucrBase.ClickOk - If chkLog.Checked = True And txtLogSave.Text <> "" Then + Dim sWriter As StreamWriter + If chkLog.Checked Then Try - Dim sWriter As New StreamWriter(txtOutputSave.Text) + sWriter = File.AppendText(txtLogSave.Text) sWriter.Write(frmLog.txtLog.Text) sWriter.Flush() + sWriter.Dispose() + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + End If + + If chkScript.Checked Then + Try + sWriter = File.AppendText(txtScriptSave.Text) + sWriter.Write(frmScript.txtScript.Text) + sWriter.Flush() + sWriter.Dispose() Catch ex As Exception + MessageBox.Show(ex.Message) End Try End If - If chkOutput.Checked = True And txtOutputSave.Text <> "" Then + If chkOutput.Checked = True Then Try frmCommand.txtCommand.SaveFile(txtOutputSave.Text, RichTextBoxStreamType.RichText) Catch ex As Exception End Try End If + + frmMain.iSaveCount = frmMain.iSaveCount + 1 + End Sub + + Private Sub txtEditorSave_TextChanged(sender As Object, e As EventArgs) Handles txtEditorSave.TextChanged + TestOKEnabled() End Sub Private Sub cmdEditorSave_Click(sender As Object, e As EventArgs) Handles cmdEditorSave.Click - dlgSave.Title = "Save Data File" - dlgSave.Filter = "RDS Data file (*.RDS)|*.RDS" - If dlgSave.ShowDialog() = DialogResult.OK Then - 'Save path - txtEditorSave.Text = dlgSave.FileName.Replace("\", "/") + returnResults = SaveDialog(".dataFile") + 'Save path + txtEditorSave.Text = returnResults.Value + 'Pass the File extension + setFileExtension(Path.GetExtension(returnResults.Value)) + setFilePath(returnResults.Value) + End Sub + + Private Sub chkScript_CheckStateChanged(sender As Object, e As EventArgs) Handles chkScript.CheckStateChanged + If frmScript.txtScript.Text <> "" Then + If chkScript.Checked Then + grpScript.Enabled = True + Else + grpScript.Enabled = False + End If + Else + chkScript.Checked = False + Exit Sub + End If + End Sub + + Private Sub TestOKEnabled() + If txtEditorSave.Text <> "" Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) End If - 'Pass the function - ucrBase.clsRsyntax.SetFunction("saveRDS") - 'Pass the object - ucrBase.clsRsyntax.AddParameter("object", frmMain.clsRLink.strInstatDataObject) - 'Pass the file - ucrBase.clsRsyntax.AddParameter("file", Chr(34) & txtEditorSave.Text & Chr(34)) - - CheckOKEnable() End Sub -End Class + + Public Sub mnuFileSave_Click() + frmMain.clsRLink.RunScript(ucrBase.clsRsyntax.GetScript(), ucrBase.clsRsyntax.iCallType, strComment:=ucrBase.txtComment.Text) + End Sub + + Private Sub cmdScriptSave_Click(sender As Object, e As EventArgs) Handles cmdScriptSave.Click + returnResults = SaveDialog(".txt") + 'Save the path + txtScriptSave.Text = returnResults.Value + End Sub +End Class \ No newline at end of file diff --git a/instat/frmMain.vb b/instat/frmMain.vb index e4d3d6c05e6..dbcd4fb48f9 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -29,6 +29,7 @@ Public Class frmMain Public clsInstatOptions As InstatOptions Public strCurrentDataFrame As String Public dlgLastDialog As Form + Public iSaveCount As Integer = 0 Dim mnuItems As New List(Of Form) @@ -731,7 +732,11 @@ Public Class frmMain End Sub Private Sub mnuFileSave_Click(sender As Object, e As EventArgs) Handles mnuFileSave.Click - dlgSaveAs.ShowDialog() + If iSaveCount = 0 Then + dlgSaveAs.ShowDialog() + Else + dlgSaveAs.mnuFileSave_Click() + End If End Sub Private Sub mnuTbPrint_Click(sender As Object, e As EventArgs) Handles mnuTbPrint.Click From 7f4267a43de5e9a3999282393dd2ae3609269a05 Mon Sep 17 00:00:00 2001 From: deaspo Date: Thu, 3 Mar 2016 16:19:09 +0300 Subject: [PATCH 02/21] Updated the Save As dialog. Removed the iSaveCount --- instat/dlgSaveAs.vb | 5 ----- instat/frmMain.vb | 7 +------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index 95882f31b62..3d5b15a962c 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -115,7 +115,6 @@ Public Class dlgSaveAs End Try End If - frmMain.iSaveCount = frmMain.iSaveCount + 1 End Sub Private Sub txtEditorSave_TextChanged(sender As Object, e As EventArgs) Handles txtEditorSave.TextChanged @@ -152,10 +151,6 @@ Public Class dlgSaveAs End If End Sub - Public Sub mnuFileSave_Click() - frmMain.clsRLink.RunScript(ucrBase.clsRsyntax.GetScript(), ucrBase.clsRsyntax.iCallType, strComment:=ucrBase.txtComment.Text) - End Sub - Private Sub cmdScriptSave_Click(sender As Object, e As EventArgs) Handles cmdScriptSave.Click returnResults = SaveDialog(".txt") 'Save the path diff --git a/instat/frmMain.vb b/instat/frmMain.vb index dbcd4fb48f9..e4d3d6c05e6 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -29,7 +29,6 @@ Public Class frmMain Public clsInstatOptions As InstatOptions Public strCurrentDataFrame As String Public dlgLastDialog As Form - Public iSaveCount As Integer = 0 Dim mnuItems As New List(Of Form) @@ -732,11 +731,7 @@ Public Class frmMain End Sub Private Sub mnuFileSave_Click(sender As Object, e As EventArgs) Handles mnuFileSave.Click - If iSaveCount = 0 Then - dlgSaveAs.ShowDialog() - Else - dlgSaveAs.mnuFileSave_Click() - End If + dlgSaveAs.ShowDialog() End Sub Private Sub mnuTbPrint_Click(sender As Object, e As EventArgs) Handles mnuTbPrint.Click From 99908b18f68a03a6b26538dce1b707e5cdf7a0fe Mon Sep 17 00:00:00 2001 From: deaspo Date: Thu, 3 Mar 2016 22:06:17 +0300 Subject: [PATCH 03/21] Massive changes on the Save As dialog --- instat/dlgSaveAs.vb | 171 ++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 93 deletions(-) diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index 3d5b15a962c..254b978f821 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -1,52 +1,8 @@ Imports System.IO Imports instat.Translations Public Class dlgSaveAs - Dim returnResults As KeyValuePair(Of String, String) - Public Function SaveDialog(strFilter As String) As KeyValuePair(Of String, String) - Dim dlgOpen As New SaveFileDialog - Dim strFilePath, strFileName As String - Select Case strFilter - Case ".txt" - dlgOpen.Filter = "Text file (*.txt)|*.txt" - Case ".rtf" - dlgOpen.Filter = "Rich Text file (*.rtf)|*.rtf" - Case ".dataFile" - dlgOpen.Filter = "Comma separated file (*.csv)|*.csv|RDS (*.RDS)|*.RDS" - End Select - dlgOpen.Title = "Save workbook" - If dlgOpen.ShowDialog() = DialogResult.OK Then - 'checks if the file name is not blank' - If dlgOpen.FileName <> "" Then - strFileName = Path.GetFileNameWithoutExtension(dlgOpen.FileName) - strFilePath = Replace(dlgOpen.FileName, "\", "/") - Return New KeyValuePair(Of String, String)(strFileName, strFilePath) - End If - End If - Return New KeyValuePair(Of String, String)("", "") - End Function - - Public Sub setFilePath(strFilePath As String) - ucrBase.clsRsyntax.AddParameter("file", Chr(34) & strFilePath & Chr(34)) - End Sub - - Public Sub setFileExtension(strFileExtension As String) - Select Case strFileExtension - Case ".RDS" - 'set function - setFunction("saveRDS") - ucrBase.clsRsyntax.RemoveParameter("x") - ucrBase.clsRsyntax.AddParameter("object", frmMain.clsRLink.strInstatDataObject) - Case ".csv" - 'set function - setFunction("write.csv") - ucrBase.clsRsyntax.RemoveParameter("object") - ucrBase.clsRsyntax.AddParameter("x", frmEditor.grdData.CurrentWorksheet.Name) - End Select - End Sub - - Public Sub setFunction(strRfunction As String) - ucrBase.clsRsyntax.SetFunction(strRfunction) - End Sub + Dim dlgSave As New SaveFileDialog + Dim bFirstLoad As Boolean = True Private Sub chkLog_CheckedChanged(sender As Object, e As EventArgs) Handles chkLog.CheckedChanged If chkLog.Checked = True Then @@ -67,67 +23,75 @@ Public Class dlgSaveAs Private Sub dlgSaveAs_Load(sender As Object, e As EventArgs) Handles Me.Load ttScript.SetToolTip(chkScript, "You cannot save an empty script.") autoTranslate(Me) - grpLog.Enabled = False - grpOutput.Enabled = False - grpScript.Enabled = False + If bFirstLoad Then + setDefaults() + bFirstLoad = False + End If TestOKEnabled() End Sub Private Sub cmdLogSave_Click(sender As Object, e As EventArgs) Handles cmdLogSave.Click - returnResults = SaveDialog(".txt") - 'Save the path - txtLogSave.Text = returnResults.Value + dlgSave.Reset() + dlgSave.Title = "Save Log File" + dlgSave.Filter = "Text file (*.txt)|*.txt" + If dlgSave.ShowDialog() = DialogResult.OK Then + txtLogSave.Text = dlgSave.FileName.Replace("\", "/") + End If End Sub Private Sub cmdOutputSave_Click(sender As Object, e As EventArgs) Handles cmdOutputSave.Click - returnResults = SaveDialog(".rtf") - 'Save path - txtOutputSave.Text = returnResults.Value + dlgSave.Reset() + dlgSave.Title = "Save Output File" + dlgSave.Filter = "Rich Text file (*.rtf)|*.rtf" + If dlgSave.ShowDialog() = DialogResult.OK Then + txtOutputSave.Text = dlgSave.FileName.Replace("\", "/") + End If + End Sub + + Private Sub TestOKEnabled() + If txtEditorSave.Text <> "" Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If End Sub Private Sub ucrBase_ClickOk(sender As Object, e As EventArgs) Handles ucrBase.ClickOk - Dim sWriter As StreamWriter - If chkLog.Checked Then - Try - sWriter = File.AppendText(txtLogSave.Text) - sWriter.Write(frmLog.txtLog.Text) - sWriter.Flush() - sWriter.Dispose() - Catch ex As Exception - MessageBox.Show(ex.Message) - End Try + If chkLog.Checked And txtLogSave.Text <> "" Then + saveTextFiles(txtLogSave.Text, frmLog.txtLog.Text) End If If chkScript.Checked Then - Try - sWriter = File.AppendText(txtScriptSave.Text) - sWriter.Write(frmScript.txtScript.Text) - sWriter.Flush() - sWriter.Dispose() - Catch ex As Exception - MessageBox.Show(ex.Message) - End Try + saveTextFiles(txtScriptSave.Text, frmScript.txtScript.Text) End If - If chkOutput.Checked = True Then + + If chkOutput.Checked And txtOutputSave.Text <> "" Then Try frmCommand.txtCommand.SaveFile(txtOutputSave.Text, RichTextBoxStreamType.RichText) Catch ex As Exception End Try End If - End Sub - Private Sub txtEditorSave_TextChanged(sender As Object, e As EventArgs) Handles txtEditorSave.TextChanged + Private Sub cmdEditorSave_Click(sender As Object, e As EventArgs) Handles cmdEditorSave.Click + dlgSave.Title = "Save Data File" + dlgSave.Filter = "RDS Data file (*.RDS)|*.RDS" + If dlgSave.ShowDialog() = DialogResult.OK Then + 'Save path + txtEditorSave.Text = dlgSave.FileName.Replace("\", "/") + End If + 'Pass the function + ucrBase.clsRsyntax.SetFunction("saveRDS") + 'Pass the object + ucrBase.clsRsyntax.AddParameter("object", frmMain.clsRLink.strInstatDataObject) + 'Pass the file + ucrBase.clsRsyntax.AddParameter("file", Chr(34) & txtEditorSave.Text & Chr(34)) + TestOKEnabled() End Sub - Private Sub cmdEditorSave_Click(sender As Object, e As EventArgs) Handles cmdEditorSave.Click - returnResults = SaveDialog(".dataFile") - 'Save path - txtEditorSave.Text = returnResults.Value - 'Pass the File extension - setFileExtension(Path.GetExtension(returnResults.Value)) - setFilePath(returnResults.Value) + Private Sub txtEditorSave_TextChanged(sender As Object, e As EventArgs) Handles txtEditorSave.TextChanged + TestOKEnabled() End Sub Private Sub chkScript_CheckStateChanged(sender As Object, e As EventArgs) Handles chkScript.CheckStateChanged @@ -143,17 +107,38 @@ Public Class dlgSaveAs End If End Sub - Private Sub TestOKEnabled() - If txtEditorSave.Text <> "" Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) + Private Sub cmdScriptSave_Click(sender As Object, e As EventArgs) Handles cmdScriptSave.Click + dlgSave.Reset() + dlgSave.Title = "Save Script File" + dlgSave.Filter = "Text file (*.txt)|*.txt" + If dlgSave.ShowDialog() = DialogResult.OK Then + txtScriptSave.Text = dlgSave.FileName.Replace("\", "/") End If End Sub - Private Sub cmdScriptSave_Click(sender As Object, e As EventArgs) Handles cmdScriptSave.Click - returnResults = SaveDialog(".txt") - 'Save the path - txtScriptSave.Text = returnResults.Value + Private Sub saveTextFiles(strPath As String, strFile As String) + Dim sWrite As New StreamWriter(strPath) + Try + sWrite.Write(strFile) + sWrite.Flush() + sWrite.Dispose() + Catch ex As Exception + + End Try + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + setDefaults() + End Sub + + Private Sub setDefaults() + txtEditorSave.Text = "" + txtLogSave.Text = "" + txtOutputSave.Text = "" + txtScriptSave.Text = "" + chkLog.Checked = False + chkOutput.Checked = False + chkScript.Checked = False + End Sub -End Class \ No newline at end of file +End Class From 45b4f472e270091bfcf494f01fbc9e536bbc81fe Mon Sep 17 00:00:00 2001 From: Stephen Kogo Date: Tue, 8 Mar 2016 15:03:36 +0300 Subject: [PATCH 04/21] Extended functionality of move_columns_in_data method to move than one column --- instat/static/InstatObject/R/data_object.R | 27 +++++++++++++------- instat/static/InstatObject/R/instat_object.R | 4 +-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index 28d67dbfe23..0b5bea07830 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -452,19 +452,24 @@ data_obj$methods(insert_column_in_data = function(col_data =c(), start_pos = (le } ) -data_obj$methods(move_column_in_data = function(col_name = "", col_number) { +data_obj$methods(move_columns_in_data = function(col_names = "", col_number) { if (col_number <= 0) stop("You cannot move a column into the position less or equal to zero.") if (col_number %% 1 != 0) stop("col_number value should be an integer.") if (length(names(data)) < col_number) stop("The col_number argument exceeds the number of columns in the data.") - if(!(col_name %in% names(data))){ - stop(col_name, " is not a column in", get_metadata(data_name_label)) + for(col_name in col_names){ + if(!(col_name %in% names(data))){ + stop(col_name, " is not a column in ", get_metadata(data_name_label)) + } } - dat1 <- as.data.frame(data[,c(col_name)]) - names(dat1) <- col_name + old_names = names(data) + dat1 <- data[(col_names)] + names(dat1) <- col_names - names(data)[names(data) == col_name] <<- "to_delete" + for(name in col_names){ + names(data)[names(data) == name] <<- .self$get_next_default_column_name(prefix = "to_delete") + } if(col_number==1){ data <<- cbind(dat1, data) @@ -475,10 +480,14 @@ data_obj$methods(move_column_in_data = function(col_name = "", col_number) { else{ data <<- cbind(data[1:(col_number)], dat1, data[(col_number+1):ncol(data)]) } + new_names = names(data) - data[,"to_delete"]<<- NULL - - .self$append_to_changes(list(Move_col, col_name)) + for(name in new_names){ + if(!(name %in% old_names)){ + data[,name]<<- NULL + } + } + .self$append_to_changes(list(Move_col, col_names)) } ) diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index ec287c1726f..e1ef3b37e55 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -346,11 +346,11 @@ instat_obj$methods(insert_column_in_data = function(data_name, col_data =c(), st } ) -instat_obj$methods(move_column_in_data = function(data_name, col_name, col_number){ +instat_obj$methods(move_columns_in_data = function(data_name, col_names = "", col_number){ 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]]$move_column_in_data(col_name = col_name, col_number = col_number) + data_objects[[data_name]]$move_columns_in_data(col_names = col_names, col_number = col_number) } ) From 915d32f193bf50bc129f46be492afb9a62798880 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 8 Mar 2016 15:50:49 +0300 Subject: [PATCH 05/21] Initial boxplot tidying --- instat/dlgBoxPlot.vb | 76 +++++++++++++++++++++++------------ instat/sdgBoxPlot.Designer.vb | 43 ++++++++++++++++++++ instat/sdgBoxPlot.vb | 2 +- 3 files changed, 94 insertions(+), 27 deletions(-) diff --git a/instat/dlgBoxPlot.vb b/instat/dlgBoxPlot.vb index 755d216749d..85a19e007cb 100644 --- a/instat/dlgBoxPlot.vb +++ b/instat/dlgBoxPlot.vb @@ -18,6 +18,7 @@ Public Class dlgBoxplot Private clsRggplotFunction As New RFunction Private clsRgeom_boxplotFunction As New RFunction Private clsRaesFunction As New RFunction + Private bFirstLoad As Boolean = True Private Sub dlgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load ucrBase.clsRsyntax.SetOperation("+") clsRggplotFunction.SetRCommand("ggplot") @@ -35,10 +36,16 @@ Public Class dlgBoxplot ucrSecondFactorReceiver.SetDataType("factor") sdgPlots.SetRSyntax(ucrBase.clsRsyntax) autoTranslate(Me) - ucrBase.OKEnabled(False) + + If bFirstLoad Then + SetDefaults() + bFirstLoad = False + End If + End Sub Private Sub SetOperator() + Dim clsTempOp As New ROperator Dim clsTempRFunc As New RFunction If chkHorizontalBoxplot.Checked Then @@ -53,22 +60,53 @@ Public Class dlgBoxplot ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_boxplotFunction) End If End Sub - Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click - sdgPlots.ShowDialog() + Private Sub SetDefaults() + ucrSelectorBoxPlot.Reset() + ucrSelectorBoxPlot.Focus() + ucrYvariableReceiver.SetMeAsReceiver() + chkHorizontalBoxplot.Checked = False + chkNotchedBoxplot.Checked = False + chkVariableWidth.Checked = False End Sub - Private Sub ucrByFactorsReceiver_Enter(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.Enter - ucrByFactorsReceiver.SetMeAsReceiver() + Private Sub TestOkEnabled() + If Not ucrYvariableReceiver.IsEmpty Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If + End Sub + Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click + sdgPlots.ShowDialog() End Sub - Private Sub ucrSelectorBoxPlot_DataFrameChanged() Handles ucrSelectorBoxPlot.DataFrameChanged clsRggplotFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorBoxPlot.ucrAvailableDataFrames.clsCurrDataFrame) End Sub - Private Sub ucrByFactorsReceiver_Leave(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.Leave - clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) + Private Sub ucrYvariableReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrYvariableReceiver.SelectionChanged + If Not ucrYvariableReceiver.IsEmpty Then + clsRaesFunction.AddParameter("y", ucrYvariableReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("y") + End If + TestOkEnabled() End Sub + Private Sub ucrByFactorsReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.SelectionChanged + If Not ucrByFactorsReceiver.IsEmpty Then + clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("x") + End If + End Sub + Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged + + If Not ucrSecondFactorReceiver.IsEmpty Then + clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False)) + Else + clsRaesFunction.RemoveParameterByName("fill") + End If + End Sub Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged SetOperator() End Sub @@ -88,25 +126,11 @@ Public Class dlgBoxplot clsRgeom_boxplotFunction.RemoveParameterByName("varwidth") End If End Sub - - Private Sub ucrYvariableReceiver_Leave(sender As Object, e As EventArgs) Handles ucrYvariableReceiver.Leave - If Not (ucrYvariableReceiver.GetVariableNames = "") Then - clsRaesFunction.AddParameter("y", ucrYvariableReceiver.GetVariableNames(False)) - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If - End Sub - - Private Sub ucrSecondFactorReceiver_Leave(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.Leave - clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False)) - End Sub - - Private Sub ucrSecondFactorReceiver_Enter(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.Enter - ucrSecondFactorReceiver.SetMeAsReceiver() - End Sub - Private Sub cmdBoxPlotOptions_Click(sender As Object, e As EventArgs) Handles cmdBoxPlotOptions.Click sdgBoxPlot.ShowDialog() End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + End Sub End Class \ No newline at end of file diff --git a/instat/sdgBoxPlot.Designer.vb b/instat/sdgBoxPlot.Designer.vb index 8e8f052119a..4c711c58c05 100644 --- a/instat/sdgBoxPlot.Designer.vb +++ b/instat/sdgBoxPlot.Designer.vb @@ -23,6 +23,9 @@ Partial Class sdgBoxPlot _ Private Sub InitializeComponent() Me.ucrBaseSdgBoxplot = New instat.ucrButtonsSubdialogue() + Me.chkNotchedBoxplot = New System.Windows.Forms.CheckBox() + Me.chkHorizontalBoxplot = New System.Windows.Forms.CheckBox() + Me.chkVariableWidth = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' 'ucrBaseSdgBoxplot @@ -32,11 +35,47 @@ Partial Class sdgBoxPlot Me.ucrBaseSdgBoxplot.Size = New System.Drawing.Size(142, 30) Me.ucrBaseSdgBoxplot.TabIndex = 0 ' + 'chkNotchedBoxplot + ' + Me.chkNotchedBoxplot.AutoSize = True + Me.chkNotchedBoxplot.Location = New System.Drawing.Point(12, 72) + Me.chkNotchedBoxplot.Name = "chkNotchedBoxplot" + Me.chkNotchedBoxplot.Size = New System.Drawing.Size(104, 17) + Me.chkNotchedBoxplot.TabIndex = 20 + Me.chkNotchedBoxplot.Tag = "Notched_boxplot" + Me.chkNotchedBoxplot.Text = "Notched boxplot" + Me.chkNotchedBoxplot.UseVisualStyleBackColor = True + ' + 'chkHorizontalBoxplot + ' + Me.chkHorizontalBoxplot.AutoSize = True + Me.chkHorizontalBoxplot.Location = New System.Drawing.Point(12, 43) + Me.chkHorizontalBoxplot.Name = "chkHorizontalBoxplot" + Me.chkHorizontalBoxplot.Size = New System.Drawing.Size(110, 17) + Me.chkHorizontalBoxplot.TabIndex = 19 + Me.chkHorizontalBoxplot.Tag = "Horizontal_boxplot" + Me.chkHorizontalBoxplot.Text = "Horizontal boxplot" + Me.chkHorizontalBoxplot.UseVisualStyleBackColor = True + ' + 'chkVariableWidth + ' + Me.chkVariableWidth.AutoSize = True + Me.chkVariableWidth.Location = New System.Drawing.Point(12, 12) + Me.chkVariableWidth.Name = "chkVariableWidth" + Me.chkVariableWidth.Size = New System.Drawing.Size(92, 17) + Me.chkVariableWidth.TabIndex = 18 + Me.chkVariableWidth.Tag = "Variable_width" + Me.chkVariableWidth.Text = "Variable width" + Me.chkVariableWidth.UseVisualStyleBackColor = True + ' 'sdgBoxPlot ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(284, 261) + Me.Controls.Add(Me.chkNotchedBoxplot) + Me.Controls.Add(Me.chkHorizontalBoxplot) + Me.Controls.Add(Me.chkVariableWidth) Me.Controls.Add(Me.ucrBaseSdgBoxplot) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Name = "sdgBoxPlot" @@ -44,8 +83,12 @@ Partial Class sdgBoxPlot Me.Tag = "BoxPlot_Options" Me.Text = "BoxPlot Options" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents ucrBaseSdgBoxplot As ucrButtonsSubdialogue + Friend WithEvents chkNotchedBoxplot As CheckBox + Friend WithEvents chkHorizontalBoxplot As CheckBox + Friend WithEvents chkVariableWidth As CheckBox End Class diff --git a/instat/sdgBoxPlot.vb b/instat/sdgBoxPlot.vb index cfd3803f15d..b9997b482f6 100644 --- a/instat/sdgBoxPlot.vb +++ b/instat/sdgBoxPlot.vb @@ -17,7 +17,7 @@ Imports instat.Translations Public Class sdgBoxPlot Public clsBoxplotFunction As RFunction - Public Sub SetBarChartFunction(clsBoxPlotFunc As RFunction) + Public Sub SetBoxPlotFUnction(clsBoxPlotFunc As RFunction) clsBoxplotFunction = clsBoxPlotFunc End Sub Private Sub sdgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load From 103bcfeb41d6c3370a7925a0be68459712fa4daf Mon Sep 17 00:00:00 2001 From: max Date: Tue, 8 Mar 2016 15:54:38 +0300 Subject: [PATCH 06/21] added tabs order, start position and formborder style --- instat/dlgBoxPlot.designer.vb | 101 ++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/instat/dlgBoxPlot.designer.vb b/instat/dlgBoxPlot.designer.vb index d731330029a..6bde9b4e7d3 100644 --- a/instat/dlgBoxPlot.designer.vb +++ b/instat/dlgBoxPlot.designer.vb @@ -22,35 +22,28 @@ Partial Class dlgBoxplot 'Do not modify it using the code editor. Private Sub InitializeComponent() - Me.ucrBase = New instat.ucrButtons() Me.lblYVarToPlot = New System.Windows.Forms.Label() Me.cmdOptions = New System.Windows.Forms.Button() Me.chkVariableWidth = New System.Windows.Forms.CheckBox() Me.chkHorizontalBoxplot = New System.Windows.Forms.CheckBox() Me.chkNotchedBoxplot = New System.Windows.Forms.CheckBox() - Me.ucrByFactorsReceiver = New instat.ucrReceiverSingle() Me.lblByFactors = New System.Windows.Forms.Label() - Me.ucrSelectorBoxPlot = New instat.ucrSelectorByDataFrameAddRemove() - Me.ucrSecondFactorReceiver = New instat.ucrReceiverSingle() Me.lblBySecondFactor = New System.Windows.Forms.Label() - Me.ucrYvariableReceiver = New instat.ucrReceiverSingle() Me.cmdBoxPlotOptions = New System.Windows.Forms.Button() + Me.ucrYvariableReceiver = New instat.ucrReceiverSingle() + Me.ucrSecondFactorReceiver = New instat.ucrReceiverSingle() + Me.ucrSelectorBoxPlot = New instat.ucrSelectorByDataFrameAddRemove() + Me.ucrByFactorsReceiver = New instat.ucrReceiverSingle() + Me.ucrBase = New instat.ucrButtons() Me.SuspendLayout() ' - 'ucrBase - ' - Me.ucrBase.Location = New System.Drawing.Point(0, 312) - Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(410, 51) - Me.ucrBase.TabIndex = 4 - ' 'lblYVarToPlot ' Me.lblYVarToPlot.AutoSize = True Me.lblYVarToPlot.Location = New System.Drawing.Point(271, 58) Me.lblYVarToPlot.Name = "lblYVarToPlot" Me.lblYVarToPlot.Size = New System.Drawing.Size(91, 13) - Me.lblYVarToPlot.TabIndex = 11 + Me.lblYVarToPlot.TabIndex = 1 Me.lblYVarToPlot.Tag = "Y_variables_to_plot" Me.lblYVarToPlot.Text = "Y variables to plot" ' @@ -59,7 +52,7 @@ Partial Class dlgBoxplot Me.cmdOptions.Location = New System.Drawing.Point(276, 208) Me.cmdOptions.Name = "cmdOptions" Me.cmdOptions.Size = New System.Drawing.Size(75, 23) - Me.cmdOptions.TabIndex = 14 + Me.cmdOptions.TabIndex = 7 Me.cmdOptions.Tag = "Options" Me.cmdOptions.Text = "Options" Me.cmdOptions.UseVisualStyleBackColor = True @@ -70,7 +63,7 @@ Partial Class dlgBoxplot Me.chkVariableWidth.Location = New System.Drawing.Point(12, 228) Me.chkVariableWidth.Name = "chkVariableWidth" Me.chkVariableWidth.Size = New System.Drawing.Size(92, 17) - Me.chkVariableWidth.TabIndex = 15 + Me.chkVariableWidth.TabIndex = 9 Me.chkVariableWidth.Tag = "Variable_width" Me.chkVariableWidth.Text = "Variable width" Me.chkVariableWidth.UseVisualStyleBackColor = True @@ -81,7 +74,7 @@ Partial Class dlgBoxplot Me.chkHorizontalBoxplot.Location = New System.Drawing.Point(12, 259) Me.chkHorizontalBoxplot.Name = "chkHorizontalBoxplot" Me.chkHorizontalBoxplot.Size = New System.Drawing.Size(110, 17) - Me.chkHorizontalBoxplot.TabIndex = 16 + Me.chkHorizontalBoxplot.TabIndex = 10 Me.chkHorizontalBoxplot.Tag = "Horizontal_boxplot" Me.chkHorizontalBoxplot.Text = "Horizontal boxplot" Me.chkHorizontalBoxplot.UseVisualStyleBackColor = True @@ -92,69 +85,79 @@ Partial Class dlgBoxplot Me.chkNotchedBoxplot.Location = New System.Drawing.Point(12, 288) Me.chkNotchedBoxplot.Name = "chkNotchedBoxplot" Me.chkNotchedBoxplot.Size = New System.Drawing.Size(104, 17) - Me.chkNotchedBoxplot.TabIndex = 17 + Me.chkNotchedBoxplot.TabIndex = 11 Me.chkNotchedBoxplot.Tag = "Notched_boxplot" Me.chkNotchedBoxplot.Text = "Notched boxplot" Me.chkNotchedBoxplot.UseVisualStyleBackColor = True ' - 'ucrByFactorsReceiver - ' - Me.ucrByFactorsReceiver.Location = New System.Drawing.Point(276, 120) - Me.ucrByFactorsReceiver.Name = "ucrByFactorsReceiver" - Me.ucrByFactorsReceiver.Size = New System.Drawing.Size(126, 26) - Me.ucrByFactorsReceiver.TabIndex = 19 - ' 'lblByFactors ' Me.lblByFactors.AutoSize = True Me.lblByFactors.Location = New System.Drawing.Point(278, 104) Me.lblByFactors.Name = "lblByFactors" Me.lblByFactors.Size = New System.Drawing.Size(60, 13) - Me.lblByFactors.TabIndex = 20 + Me.lblByFactors.TabIndex = 3 Me.lblByFactors.Tag = "By_factor_s_" Me.lblByFactors.Text = "By factor(s)" ' - 'ucrSelectorBoxPlot - ' - Me.ucrSelectorBoxPlot.Location = New System.Drawing.Point(12, 9) - Me.ucrSelectorBoxPlot.Name = "ucrSelectorBoxPlot" - Me.ucrSelectorBoxPlot.Size = New System.Drawing.Size(230, 215) - Me.ucrSelectorBoxPlot.TabIndex = 21 - ' - 'ucrSecondFactorReceiver - ' - Me.ucrSecondFactorReceiver.Location = New System.Drawing.Point(276, 176) - Me.ucrSecondFactorReceiver.Name = "ucrSecondFactorReceiver" - Me.ucrSecondFactorReceiver.Size = New System.Drawing.Size(106, 26) - Me.ucrSecondFactorReceiver.TabIndex = 22 - ' 'lblBySecondFactor ' Me.lblBySecondFactor.AutoSize = True Me.lblBySecondFactor.Location = New System.Drawing.Point(278, 158) Me.lblBySecondFactor.Name = "lblBySecondFactor" Me.lblBySecondFactor.Size = New System.Drawing.Size(92, 13) - Me.lblBySecondFactor.TabIndex = 20 + Me.lblBySecondFactor.TabIndex = 5 Me.lblBySecondFactor.Tag = "By_Second_Factor" Me.lblBySecondFactor.Text = "By Second Factor" ' - 'ucrYvariableReceiver - ' - Me.ucrYvariableReceiver.Location = New System.Drawing.Point(276, 75) - Me.ucrYvariableReceiver.Name = "ucrYvariableReceiver" - Me.ucrYvariableReceiver.Size = New System.Drawing.Size(106, 26) - Me.ucrYvariableReceiver.TabIndex = 23 - ' 'cmdBoxPlotOptions ' Me.cmdBoxPlotOptions.Location = New System.Drawing.Point(276, 238) Me.cmdBoxPlotOptions.Name = "cmdBoxPlotOptions" Me.cmdBoxPlotOptions.Size = New System.Drawing.Size(104, 23) - Me.cmdBoxPlotOptions.TabIndex = 24 + Me.cmdBoxPlotOptions.TabIndex = 8 Me.cmdBoxPlotOptions.Tag = "BoxPlot_Options" Me.cmdBoxPlotOptions.Text = "BoxPlot Options" Me.cmdBoxPlotOptions.UseVisualStyleBackColor = True ' + 'ucrYvariableReceiver + ' + Me.ucrYvariableReceiver.Location = New System.Drawing.Point(276, 75) + Me.ucrYvariableReceiver.Name = "ucrYvariableReceiver" + Me.ucrYvariableReceiver.Selector = Nothing + Me.ucrYvariableReceiver.Size = New System.Drawing.Size(106, 26) + Me.ucrYvariableReceiver.TabIndex = 2 + ' + 'ucrSecondFactorReceiver + ' + Me.ucrSecondFactorReceiver.Location = New System.Drawing.Point(276, 176) + Me.ucrSecondFactorReceiver.Name = "ucrSecondFactorReceiver" + Me.ucrSecondFactorReceiver.Selector = Nothing + Me.ucrSecondFactorReceiver.Size = New System.Drawing.Size(106, 26) + Me.ucrSecondFactorReceiver.TabIndex = 6 + ' + 'ucrSelectorBoxPlot + ' + Me.ucrSelectorBoxPlot.Location = New System.Drawing.Point(12, 9) + Me.ucrSelectorBoxPlot.Name = "ucrSelectorBoxPlot" + Me.ucrSelectorBoxPlot.Size = New System.Drawing.Size(230, 215) + Me.ucrSelectorBoxPlot.TabIndex = 0 + ' + 'ucrByFactorsReceiver + ' + Me.ucrByFactorsReceiver.Location = New System.Drawing.Point(276, 120) + Me.ucrByFactorsReceiver.Name = "ucrByFactorsReceiver" + Me.ucrByFactorsReceiver.Selector = Nothing + Me.ucrByFactorsReceiver.Size = New System.Drawing.Size(126, 26) + Me.ucrByFactorsReceiver.TabIndex = 4 + ' + 'ucrBase + ' + Me.ucrBase.Location = New System.Drawing.Point(0, 312) + Me.ucrBase.Name = "ucrBase" + Me.ucrBase.Size = New System.Drawing.Size(410, 51) + Me.ucrBase.TabIndex = 12 + ' 'dlgBoxplot ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -174,10 +177,12 @@ Partial Class dlgBoxplot Me.Controls.Add(Me.lblYVarToPlot) Me.Controls.Add(Me.ucrBase) Me.Cursor = System.Windows.Forms.Cursors.Default + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgBoxplot" Me.ShowIcon = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Tag = "Boxplot" Me.Text = "Boxplot" Me.TopMost = True From 5c480a021cb809db8ad59993acb9ee70de62f310 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 8 Mar 2016 16:44:44 +0300 Subject: [PATCH 07/21] finalised boxplot --- instat/dlgBoxPlot.vb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/instat/dlgBoxPlot.vb b/instat/dlgBoxPlot.vb index 85a19e007cb..6b70ec47101 100644 --- a/instat/dlgBoxPlot.vb +++ b/instat/dlgBoxPlot.vb @@ -24,8 +24,10 @@ Public Class dlgBoxplot clsRggplotFunction.SetRCommand("ggplot") clsRgeom_boxplotFunction.SetRCommand("geom_boxplot") clsRaesFunction.SetRCommand("aes") - clsRaesFunction.AddParameter("x", "") ' Empty string is default x value in case no factor is chosen + clsRaesFunction.AddParameter("x", Chr(34) & " " & Chr(34)) ' Empty string is default x value in case no factor is chosen clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction) + ucrBase.iHelpTopicID = 102 + SetOperator() ucrBase.clsRsyntax.iCallType = 0 ucrYvariableReceiver.Selector = ucrSelectorBoxPlot @@ -67,6 +69,8 @@ Public Class dlgBoxplot chkHorizontalBoxplot.Checked = False chkNotchedBoxplot.Checked = False chkVariableWidth.Checked = False + + TestOkEnabled() End Sub Private Sub TestOkEnabled() @@ -86,6 +90,7 @@ Public Class dlgBoxplot Private Sub ucrYvariableReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrYvariableReceiver.SelectionChanged If Not ucrYvariableReceiver.IsEmpty Then clsRaesFunction.AddParameter("y", ucrYvariableReceiver.GetVariableNames(False)) + ucrByFactorsReceiver.SetMeAsReceiver() Else clsRaesFunction.RemoveParameterByName("y") End If @@ -95,14 +100,16 @@ Public Class dlgBoxplot Private Sub ucrByFactorsReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.SelectionChanged If Not ucrByFactorsReceiver.IsEmpty Then clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) + ucrSecondFactorReceiver.SetMeAsReceiver() Else - clsRaesFunction.RemoveParameterByName("x") + clsRaesFunction.AddParameter("x", Chr(34) & " " & Chr(34)) End If End Sub Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged If Not ucrSecondFactorReceiver.IsEmpty Then clsRaesFunction.AddParameter("fill", ucrSecondFactorReceiver.GetVariableNames(False)) + ucrYvariableReceiver.SetMeAsReceiver() Else clsRaesFunction.RemoveParameterByName("fill") End If From f324133b04d008189ff70f06a861709e90693f57 Mon Sep 17 00:00:00 2001 From: dannyparsons Date: Tue, 8 Mar 2016 16:03:00 +0000 Subject: [PATCH 08/21] added SaveModel control and updated clsRLink --- instat/clsRLink.vb | 80 ++++++++----- instat/dlgSimpleWithGroups.Designer.vb | 10 ++ instat/dlgSimpleWithGroups.vb | 1 + instat/instat.vbproj | 15 +++ instat/static/InstatObject/R/instat_object.R | 7 +- instat/ucrDataFrame.vb | 4 +- instat/ucrInputComboBox.vb | 1 + instat/ucrSaveModel.Designer.vb | 62 ++++++++++ instat/ucrSaveModel.fr-FR.resx | 15 +++ instat/ucrSaveModel.resx | 120 +++++++++++++++++++ instat/ucrSaveModel.sw-KE.resx | 15 +++ instat/ucrSaveModel.vb | 12 ++ 12 files changed, 308 insertions(+), 34 deletions(-) create mode 100644 instat/ucrSaveModel.Designer.vb create mode 100644 instat/ucrSaveModel.fr-FR.resx create mode 100644 instat/ucrSaveModel.resx create mode 100644 instat/ucrSaveModel.sw-KE.resx create mode 100644 instat/ucrSaveModel.vb diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 9fef06a2246..1ef407e5937 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -68,45 +68,57 @@ Public Class RLink bLog = True End Sub + Public Function GetDataFrameNames() As List(Of String) + Dim chrDataFrameNames As CharacterVector + Dim lstDataFrameNames As New List(Of String) + chrDataFrameNames = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_names()").AsCharacter + lstDataFrameNames.AddRange(chrDataFrameNames) + Return lstDataFrameNames + End Function + + Public Function GetColumnNames(strDataFrameName As String) As List(Of String) + Dim chrCurrColumns As CharacterVector + Dim lstCurrColumns As New List(Of String) + chrCurrColumns = clsEngine.Evaluate(strInstatDataObject & "$get_column_names(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsCharacter + lstCurrColumns.AddRange(chrCurrColumns) + Return lstCurrColumns + End Function + Public Sub FillComboDataFrames(ByRef cboDataFrames As ComboBox, Optional bSetDefault As Boolean = True) - Dim lstAvailableDataFrames As GenericVector - Dim i As Integer If bInstatObjectExists Then - lstAvailableDataFrames = clsEngine.Evaluate(strInstatDataObject & "$get_data_names()").AsList - cboDataFrames.Items.Clear() - For i = 0 To lstAvailableDataFrames.Length - 1 - cboDataFrames.Items.Add(lstAvailableDataFrames.AsCharacter(i)) - Next + cboDataFrames.Items.Clear() + cboDataFrames.Items.AddRange(GetDataFrameNames().ToArray) End If + If bSetDefault Then - cboDataFrames.Text = frmEditor.grdData.CurrentWorksheet.Name + cboDataFrames.SelectedIndex = cboDataFrames.Items.IndexOf(frmEditor.grdData.CurrentWorksheet.Name) End If End Sub - Public Sub FillColumnNames(strDataFrame As String, Optional ByRef cboColumns As ComboBox = Nothing, Optional ByRef lstColumns As ListView = Nothing) - Dim lstCurrColumns As GenericVector - Dim i As Integer + Public Sub FillColumnNames(strDataFrame As String, ByRef cboColumns As ComboBox) + Dim lstCurrColumns As List(Of String) - If bInstatObjectExists Then - 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 - End If + If bInstatObjectExists AndAlso clsEngine IsNot Nothing Then + lstCurrColumns = GetColumnNames(strDataFrame) + cboColumns.Items.Clear() + cboColumns.Items.AddRange(lstCurrColumns.ToArray) + End If + End Sub + + Public Sub FillColumnNames(strDataFrame As String, ByRef lstColumns As ListView) + Dim lstCurrColumns As List(Of String) + + If bInstatObjectExists AndAlso clsEngine IsNot Nothing Then + lstCurrColumns = GetColumnNames(strDataFrame) + lstColumns.Items.Clear() + If lstColumns.Columns.Count = 0 Then + lstColumns.Columns.Add("Available Data") + End If + For Each strTemp In lstCurrColumns + lstColumns.Items.Add(strTemp) + Next + lstColumns.Columns(0).Width = -2 End If End Sub @@ -310,4 +322,12 @@ Public Class RLink End If Return intLength End Function + + Public Function GetModelNames() As List(Of String) + Dim chrModelNames As CharacterVector + Dim lstModelNames As New List(Of String) + chrModelNames = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_model_names()").AsCharacter + lstModelNames.AddRange(chrModelNames) + Return lstModelNames + End Function End Class diff --git a/instat/dlgSimpleWithGroups.Designer.vb b/instat/dlgSimpleWithGroups.Designer.vb index 15484efeff7..d79426eaaff 100644 --- a/instat/dlgSimpleWithGroups.Designer.vb +++ b/instat/dlgSimpleWithGroups.Designer.vb @@ -38,6 +38,7 @@ Partial Class dlgSimpleWithGroups Me.ucrResponse = New instat.ucrReceiverSingle() Me.ucrSelectorSimpleRegGroups = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBaseRegWithGroups = New instat.ucrButtons() + Me.UcrInputComboBox1 = New instat.ucrInputComboBox() Me.grpModelstofit.SuspendLayout() Me.SuspendLayout() ' @@ -200,11 +201,19 @@ Partial Class dlgSimpleWithGroups Me.ucrBaseRegWithGroups.Size = New System.Drawing.Size(410, 55) Me.ucrBaseRegWithGroups.TabIndex = 0 ' + 'UcrInputComboBox1 + ' + Me.UcrInputComboBox1.Location = New System.Drawing.Point(149, 15) + Me.UcrInputComboBox1.Name = "UcrInputComboBox1" + Me.UcrInputComboBox1.Size = New System.Drawing.Size(137, 25) + Me.UcrInputComboBox1.TabIndex = 19 + ' 'dlgSimpleWithGroups ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(409, 329) + Me.Controls.Add(Me.UcrInputComboBox1) Me.Controls.Add(Me.grpModelstofit) Me.Controls.Add(Me.lblGroupingFactor) Me.Controls.Add(Me.ucrGroupingFactor) @@ -243,4 +252,5 @@ Partial Class dlgSimpleWithGroups Friend WithEvents chkParallelLines As CheckBox Friend WithEvents chkSingle As CheckBox Friend WithEvents chkAll As CheckBox + Friend WithEvents UcrInputComboBox1 As ucrInputComboBox End Class diff --git a/instat/dlgSimpleWithGroups.vb b/instat/dlgSimpleWithGroups.vb index 3d5fca8751c..0d41d0515d8 100644 --- a/instat/dlgSimpleWithGroups.vb +++ b/instat/dlgSimpleWithGroups.vb @@ -21,6 +21,7 @@ Public Class dlgSimpleWithGroups Dim clsModel, clsModel1, clsModel2, clsModel3 As New ROperator Private Sub dlgSimpleWithGroups_Load(sender As Object, e As EventArgs) Handles MyBase.Load + UcrInputComboBox1.SetItemsTypeAsModels() If bFirstLoad Then InitialiseDialog() diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 2f4a5b96157..cd31443f8dd 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -1416,6 +1416,12 @@ UserControl + + ucrSaveModel.vb + + + UserControl + ucrSelector.vb @@ -3289,6 +3295,15 @@ ucrReceiverSingle.vb + + ucrSaveModel.vb + + + ucrSaveModel.vb + + + ucrSaveModel.vb + ucrSelector.vb diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index ec287c1726f..595cd757198 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -268,13 +268,18 @@ instat_obj$methods(add_model = function(model, model_name = paste("model",length ) instat_obj$methods(get_model = function(model_name) { - if(missing(model_name)) stop("model_name is required") + if(missing(model_name)) stop("model_name must be given.") if(!is.character(model_name)) stop("name must be a character") if(!model_name %in% names(models)) stop(model_name, "not found in models") models[[model_name]] } ) +instat_obj$methods(get_model_names = function() { + return(names(models)) +} +) + 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")) diff --git a/instat/ucrDataFrame.vb b/instat/ucrDataFrame.vb index 3eac83693bd..9a32dc6b129 100644 --- a/instat/ucrDataFrame.vb +++ b/instat/ucrDataFrame.vb @@ -22,11 +22,9 @@ Public Class ucrDataFrame Public strCurrDataFrame As String = "" Private Sub ucrDataFrame_Load(sender As Object, e As EventArgs) Handles MyBase.Load + frmMain.clsRLink.FillComboDataFrames(cboAvailableDataFrames, bFirstLoad) If bFirstLoad Then - frmMain.clsRLink.FillComboDataFrames(cboAvailableDataFrames, True) bFirstLoad = False - Else - frmMain.clsRLink.FillComboDataFrames(cboAvailableDataFrames, False) End If SetDataFrameProperties() End Sub diff --git a/instat/ucrInputComboBox.vb b/instat/ucrInputComboBox.vb index 9f9a98fe0fb..35c1411d6d6 100644 --- a/instat/ucrInputComboBox.vb +++ b/instat/ucrInputComboBox.vb @@ -45,6 +45,7 @@ Public Class ucrInputComboBox End If Case "Data Frames" Case "Models" + cboInput.Items.Add(frmMain.clsRLink.GetModelNames().ToArray) End Select End Sub diff --git a/instat/ucrSaveModel.Designer.vb b/instat/ucrSaveModel.Designer.vb new file mode 100644 index 00000000000..753fab01a12 --- /dev/null +++ b/instat/ucrSaveModel.Designer.vb @@ -0,0 +1,62 @@ + _ +Partial Class ucrSaveModel + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + '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.ucrInputModelName = New instat.ucrInputComboBox() + Me.chkSaveModel = New System.Windows.Forms.CheckBox() + Me.SuspendLayout() + ' + 'ucrInputModelName + ' + Me.ucrInputModelName.Location = New System.Drawing.Point(86, 3) + Me.ucrInputModelName.Name = "ucrInputModelName" + Me.ucrInputModelName.Size = New System.Drawing.Size(176, 25) + Me.ucrInputModelName.TabIndex = 0 + ' + 'chkSaveModel + ' + Me.chkSaveModel.AutoSize = True + Me.chkSaveModel.Location = New System.Drawing.Point(3, 5) + Me.chkSaveModel.Name = "chkSaveModel" + Me.chkSaveModel.Size = New System.Drawing.Size(83, 17) + Me.chkSaveModel.TabIndex = 1 + Me.chkSaveModel.Tag = "Save_Model" + Me.chkSaveModel.Text = "Save Model" + Me.chkSaveModel.UseVisualStyleBackColor = True + ' + 'ucrSaveModel + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.chkSaveModel) + Me.Controls.Add(Me.ucrInputModelName) + Me.Name = "ucrSaveModel" + Me.Size = New System.Drawing.Size(265, 27) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents chkSaveModel As CheckBox + Friend WithEvents ucrInputModelName As ucrInputComboBox +End Class diff --git a/instat/ucrSaveModel.fr-FR.resx b/instat/ucrSaveModel.fr-FR.resx new file mode 100644 index 00000000000..a3df4f013d3 --- /dev/null +++ b/instat/ucrSaveModel.fr-FR.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveModel.resx b/instat/ucrSaveModel.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/ucrSaveModel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveModel.sw-KE.resx b/instat/ucrSaveModel.sw-KE.resx new file mode 100644 index 00000000000..a3df4f013d3 --- /dev/null +++ b/instat/ucrSaveModel.sw-KE.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveModel.vb b/instat/ucrSaveModel.vb new file mode 100644 index 00000000000..14fab49df15 --- /dev/null +++ b/instat/ucrSaveModel.vb @@ -0,0 +1,12 @@ +Public Class ucrSaveModel + Public Event CheckedChanged() + Private Sub chkSaveModel_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveModel.CheckedChanged + ucrInputModelName.Enabled = False + RaiseEvent CheckedChanged() + End Sub + + Private Sub ucrSaveModel_Load(sender As Object, e As EventArgs) Handles MyBase.Load + ucrInputModelName.SetDefaultTypeAsModel() + ucrInputModelName.SetItemsTypeAsModels() + End Sub +End Class From d7dbf5bd1513141574d05c798cb71bb5543dfa84 Mon Sep 17 00:00:00 2001 From: dannyparsons Date: Tue, 8 Mar 2016 17:39:33 +0000 Subject: [PATCH 09/21] added SaveGraph user control --- instat/instat.vbproj | 15 ++++ instat/ucrInput.vb | 16 +++-- instat/ucrInputComboBox.vb | 6 ++ instat/ucrSaveGraph.Designer.vb | 62 +++++++++++++++++ instat/ucrSaveGraph.fr-FR.resx | 15 ++++ instat/ucrSaveGraph.resx | 120 ++++++++++++++++++++++++++++++++ instat/ucrSaveGraph.sw-KE.resx | 15 ++++ instat/ucrSaveGraph.vb | 16 +++++ instat/ucrSaveModel.Designer.vb | 17 ++--- instat/ucrSaveModel.vb | 10 ++- 10 files changed, 276 insertions(+), 16 deletions(-) create mode 100644 instat/ucrSaveGraph.Designer.vb create mode 100644 instat/ucrSaveGraph.fr-FR.resx create mode 100644 instat/ucrSaveGraph.resx create mode 100644 instat/ucrSaveGraph.sw-KE.resx create mode 100644 instat/ucrSaveGraph.vb diff --git a/instat/instat.vbproj b/instat/instat.vbproj index cd31443f8dd..517c1c52aa1 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -1416,6 +1416,12 @@ UserControl + + ucrSaveGraph.vb + + + UserControl + ucrSaveModel.vb @@ -3295,6 +3301,15 @@ ucrReceiverSingle.vb + + ucrSaveGraph.vb + + + ucrSaveGraph.vb + + + ucrSaveGraph.vb + ucrSaveModel.vb diff --git a/instat/ucrInput.vb b/instat/ucrInput.vb index b58258c7713..af0819580af 100644 --- a/instat/ucrInput.vb +++ b/instat/ucrInput.vb @@ -54,6 +54,10 @@ Public Class ucrInput strDefaultType = "Data Frame" End Sub + Public Sub SetDefaultTypeAsGraph() + strDefaultType = "Graph" + End Sub + Public Sub SetValidationTypeAsRVariable() strValidationType = "RVariable" End Sub @@ -71,15 +75,17 @@ Public Class ucrInput End Sub Public Sub SetDefaultName() - If strDefaultType = "Column" AndAlso (ucrDataFrameSelector IsNot Nothing) Then - SetName(frmMain.clsRLink.GetDefaultColumnNames(strDefaultPrefix, ucrDataFrameSelector.cboAvailableDataFrames.Text)) - ElseIf strDefaultType = "Model" Then - ElseIf strDefaultType = "Data Frame" Then + If strDefaultPrefix <> "" Then + If strDefaultType = "Column" AndAlso (ucrDataFrameSelector IsNot Nothing) Then + SetName(frmMain.clsRLink.GetDefaultColumnNames(strDefaultPrefix, ucrDataFrameSelector.cboAvailableDataFrames.Text)) + ElseIf strDefaultType = "Model" Then + ElseIf strDefaultType = "Data Frame" Then + ElseIf strDefaultType = "Graph" Then + End If End If End Sub - Public Sub SetValidationTypeAsNumeric(Optional dcmMin As Decimal = Decimal.MinValue, Optional bIncludeMin As Boolean = True, Optional dcmMax As Decimal = Decimal.MaxValue, Optional bIncludeMax As Boolean = True) strValidationType = "Numeric" If dcmMin <> Decimal.MinValue Then diff --git a/instat/ucrInputComboBox.vb b/instat/ucrInputComboBox.vb index 35c1411d6d6..6b43f3bf365 100644 --- a/instat/ucrInputComboBox.vb +++ b/instat/ucrInputComboBox.vb @@ -37,6 +37,11 @@ Public Class ucrInputComboBox FillItemTypes() End Sub + Public Sub SetItemsTypeAsGraphs() + strItemsType = "Graphs" + FillItemTypes() + End Sub + Private Sub FillItemTypes() Select Case strItemsType Case "Columns" @@ -46,6 +51,7 @@ Public Class ucrInputComboBox Case "Data Frames" Case "Models" cboInput.Items.Add(frmMain.clsRLink.GetModelNames().ToArray) + Case "Graphs" End Select End Sub diff --git a/instat/ucrSaveGraph.Designer.vb b/instat/ucrSaveGraph.Designer.vb new file mode 100644 index 00000000000..0f0d3e87baa --- /dev/null +++ b/instat/ucrSaveGraph.Designer.vb @@ -0,0 +1,62 @@ + _ +Partial Class ucrSaveGraph + Inherits System.Windows.Forms.UserControl + + 'UserControl overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + '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.ucrInputGraphName = New instat.ucrInputComboBox() + Me.chkSaveGraph = New System.Windows.Forms.CheckBox() + Me.SuspendLayout() + ' + 'ucrInputGraphName + ' + Me.ucrInputGraphName.Location = New System.Drawing.Point(86, 3) + Me.ucrInputGraphName.Name = "ucrInputGraphName" + Me.ucrInputGraphName.Size = New System.Drawing.Size(176, 25) + Me.ucrInputGraphName.TabIndex = 0 + ' + 'chkSaveGraph + ' + Me.chkSaveGraph.AutoSize = True + Me.chkSaveGraph.Location = New System.Drawing.Point(3, 5) + Me.chkSaveGraph.Name = "chkSaveGraph" + Me.chkSaveGraph.Size = New System.Drawing.Size(83, 17) + Me.chkSaveGraph.TabIndex = 1 + Me.chkSaveGraph.Tag = "Save_Graph" + Me.chkSaveGraph.Text = "Save Graph" + Me.chkSaveGraph.UseVisualStyleBackColor = True + ' + 'ucrSaveGraph + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.chkSaveGraph) + Me.Controls.Add(Me.ucrInputGraphName) + Me.Name = "ucrSaveGraph" + Me.Size = New System.Drawing.Size(265, 27) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents ucrInputGraphName As ucrInputComboBox + Friend WithEvents chkSaveGraph As CheckBox +End Class diff --git a/instat/ucrSaveGraph.fr-FR.resx b/instat/ucrSaveGraph.fr-FR.resx new file mode 100644 index 00000000000..a3df4f013d3 --- /dev/null +++ b/instat/ucrSaveGraph.fr-FR.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveGraph.resx b/instat/ucrSaveGraph.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/ucrSaveGraph.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveGraph.sw-KE.resx b/instat/ucrSaveGraph.sw-KE.resx new file mode 100644 index 00000000000..a3df4f013d3 --- /dev/null +++ b/instat/ucrSaveGraph.sw-KE.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/ucrSaveGraph.vb b/instat/ucrSaveGraph.vb new file mode 100644 index 00000000000..4efebda40c5 --- /dev/null +++ b/instat/ucrSaveGraph.vb @@ -0,0 +1,16 @@ +Public Class ucrSaveGraph + Public Event CheckedChanged(bChecked As Boolean) + Private Sub ucrSaveGraph_Load(sender As Object, e As EventArgs) Handles MyBase.Load + ucrInputGraphName.SetDefaultTypeAsGraph() + ucrInputGraphName.SetItemsTypeAsGraphs() + End Sub + + Private Sub chkSaveGraph_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveGraph.CheckedChanged + If chkSaveGraph.Checked Then + ucrInputGraphName.Visible = True + Else + ucrInputGraphName.Visible = False + End If + RaiseEvent CheckedChanged(chkSaveGraph.Checked) + End Sub +End Class diff --git a/instat/ucrSaveModel.Designer.vb b/instat/ucrSaveModel.Designer.vb index 753fab01a12..ef7c1874d3e 100644 --- a/instat/ucrSaveModel.Designer.vb +++ b/instat/ucrSaveModel.Designer.vb @@ -22,17 +22,10 @@ Partial Class ucrSaveModel 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.ucrInputModelName = New instat.ucrInputComboBox() Me.chkSaveModel = New System.Windows.Forms.CheckBox() + Me.ucrInputModelName = New instat.ucrInputComboBox() Me.SuspendLayout() ' - 'ucrInputModelName - ' - Me.ucrInputModelName.Location = New System.Drawing.Point(86, 3) - Me.ucrInputModelName.Name = "ucrInputModelName" - Me.ucrInputModelName.Size = New System.Drawing.Size(176, 25) - Me.ucrInputModelName.TabIndex = 0 - ' 'chkSaveModel ' Me.chkSaveModel.AutoSize = True @@ -44,6 +37,14 @@ Partial Class ucrSaveModel Me.chkSaveModel.Text = "Save Model" Me.chkSaveModel.UseVisualStyleBackColor = True ' + 'ucrInputModelName + ' + Me.ucrInputModelName.Location = New System.Drawing.Point(86, 3) + Me.ucrInputModelName.Margin = New System.Windows.Forms.Padding(0) + Me.ucrInputModelName.Name = "ucrInputModelName" + Me.ucrInputModelName.Size = New System.Drawing.Size(176, 25) + Me.ucrInputModelName.TabIndex = 0 + ' 'ucrSaveModel ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) diff --git a/instat/ucrSaveModel.vb b/instat/ucrSaveModel.vb index 14fab49df15..cd35c58288f 100644 --- a/instat/ucrSaveModel.vb +++ b/instat/ucrSaveModel.vb @@ -1,8 +1,12 @@ Public Class ucrSaveModel - Public Event CheckedChanged() + Public Event CheckedChanged(bChecked As Boolean) Private Sub chkSaveModel_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveModel.CheckedChanged - ucrInputModelName.Enabled = False - RaiseEvent CheckedChanged() + If chkSaveModel.Checked Then + ucrInputModelName.Visible = True + Else + ucrInputModelName.Visible = False + End If + RaiseEvent CheckedChanged(chkSaveModel.Checked) End Sub Private Sub ucrSaveModel_Load(sender As Object, e As EventArgs) Handles MyBase.Load From 4079de2c4f0d3e796816eebf9aad4ed5b6f21375 Mon Sep 17 00:00:00 2001 From: Stephen Kogo Date: Tue, 8 Mar 2016 21:53:48 +0300 Subject: [PATCH 10/21] Implementation of order columns using numeric vector and col_names --- instat/static/InstatObject/R/data_object.R | 94 ++++++++++++++------ instat/static/InstatObject/R/instat_object.R | 22 ++++- 2 files changed, 86 insertions(+), 30 deletions(-) diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index 0b5bea07830..501d82ed074 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -452,42 +452,80 @@ data_obj$methods(insert_column_in_data = function(col_data =c(), start_pos = (le } ) -data_obj$methods(move_columns_in_data = function(col_names = "", col_number) { - if (col_number <= 0) stop("You cannot move a column into the position less or equal to zero.") - if (col_number %% 1 != 0) stop("col_number value should be an integer.") - if (length(names(data)) < col_number) stop("The col_number argument exceeds the number of columns in the data.") - - for(col_name in col_names){ - if(!(col_name %in% names(data))){ - stop(col_name, " is not a column in ", get_metadata(data_name_label)) +# data_obj$methods(move_columns_in_data = function(col_names = "", col_number) { +# if (col_number <= 0) stop("You cannot move a column into the position less or equal to zero.") +# if (col_number %% 1 != 0) stop("col_number value should be an integer.") +# if (length(names(data)) < col_number) stop("The col_number argument exceeds the number of columns in the data.") +# +# for(col_name in col_names){ +# if(!(col_name %in% names(data))){ +# stop(col_name, " is not a column in ", get_metadata(data_name_label)) +# } +# } +# +# old_names = names(data) +# dat1 <- data[(col_names)] +# names(dat1) <- col_names +# +# for(name in col_names){ +# names(data)[names(data) == name] <<- .self$get_next_default_column_name(prefix = "to_delete") +# } +# +# if(col_number==1){ +# data <<- cbind(dat1, data) +# } +# else if(col_number == ncol(data)){ +# data <<- cbind(data,dat1) +# } +# else{ +# data <<- cbind(data[1:(col_number)], dat1, data[(col_number+1):ncol(data)]) +# } +# new_names = names(data) +# +# for(name in new_names){ +# if(!(name %in% old_names)){ +# data[,name]<<- NULL +# } +# } +# .self$append_to_changes(list(Move_col, col_names)) +# } +# ) + +data_obj$methods(order_columns_in_data_by_names = function(col_names_order = "") { + if (length(names(data)) != length(col_names_order)) stop("Columns to order should be same as columns in the data.") + + old_names_order <- names(data) + + for(col_name in old_names_order){ + if(!(col_name %in% col_names_order)){ + stop(col_name, " is missing in columns order") } } - old_names = names(data) - dat1 <- data[(col_names)] - names(dat1) <- col_names + numeric_order = c() - for(name in col_names){ - names(data)[names(data) == name] <<- .self$get_next_default_column_name(prefix = "to_delete") + for(i in 1: length(col_names_order)){ + numeric_order[i] = which(old_names_order == col_names_order[i]) } - if(col_number==1){ - data <<- cbind(dat1, data) - } - else if(col_number == ncol(data)){ - data <<- cbind(data,dat1) - } - else{ - data <<- cbind(data[1:(col_number)], dat1, data[(col_number+1):ncol(data)]) - } - new_names = names(data) + data <<- data[ ,numeric_order] + .self$append_to_changes(list(Col_order, col_names_order)) +} +) + +data_obj$methods(order_columns_in_data_by_number = function(numeric_order) { + if (length(names(data)) != length(numeric_order)) stop("Columns order should be the same length as columns in the data.") + + old_order <- c(1:ncol(data)) - for(name in new_names){ - if(!(name %in% old_names)){ - data[,name]<<- NULL + for(old_col_num in old_order){ + if(!(old_col_num %in% numeric_order)){ + stop(old_col_num, " is missing in numeric order") } } - .self$append_to_changes(list(Move_col, col_names)) + + data <<- data[ ,numeric_order] + .self$append_to_changes(list(Numeric_column_order, numeric_order)) } ) @@ -635,6 +673,8 @@ Replaced_value="Replaced value" Removed_row="Removed row" Inserted_col = "Inserted column" Move_col = "Moved column" +Col_order = "Order of columns" +Numeric_column_order = "Numeric Order of columns" Inserted_row = "Inserted row" #meta data labels diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index e1ef3b37e55..8ed2fdcc602 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -346,11 +346,27 @@ instat_obj$methods(insert_column_in_data = function(data_name, col_data =c(), st } ) -instat_obj$methods(move_columns_in_data = function(data_name, col_names = "", col_number){ +# instat_obj$methods(move_columns_in_data = function(data_name, col_names = "", col_number){ +# 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]]$move_columns_in_data(col_names = col_names, col_number = col_number) +# } +# ) + +instat_obj$methods(order_columns_in_data_by_names = function(data_name, col_names_order = ""){ 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]]$move_columns_in_data(col_names = col_names, col_number = col_number) + data_objects[[data_name]]$order_columns_in_data_by_names(col_names_order = col_names_order) +} +) + +instat_obj$methods(order_columns_in_data_by_number = function(data_name, numeric_order){ + 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]]$order_columns_in_data_by_number(numeric_order = numeric_order) } ) @@ -437,4 +453,4 @@ instat_obj$methods(append_to_dataframe_metadata = function(data_name, property, data_objects[[data_name]]$append_to_metadata(property, new_val) } -) \ No newline at end of file +) From 5747ad5ce8b403f4525c3d8e18e4d7b2ae220f2b Mon Sep 17 00:00:00 2001 From: max Date: Wed, 9 Mar 2016 08:07:20 +0300 Subject: [PATCH 11/21] Removed the "" for the x variable when x receiver is empty --- instat/dlgBoxPlot.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/dlgBoxPlot.vb b/instat/dlgBoxPlot.vb index 6b70ec47101..1c955606867 100644 --- a/instat/dlgBoxPlot.vb +++ b/instat/dlgBoxPlot.vb @@ -24,7 +24,7 @@ Public Class dlgBoxplot clsRggplotFunction.SetRCommand("ggplot") clsRgeom_boxplotFunction.SetRCommand("geom_boxplot") clsRaesFunction.SetRCommand("aes") - clsRaesFunction.AddParameter("x", Chr(34) & " " & Chr(34)) ' Empty string is default x value in case no factor is chosen + clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) ' Empty string is default x value in case no factor is chosen clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction) ucrBase.iHelpTopicID = 102 @@ -102,7 +102,7 @@ Public Class dlgBoxplot clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) ucrSecondFactorReceiver.SetMeAsReceiver() Else - clsRaesFunction.AddParameter("x", Chr(34) & " " & Chr(34)) + clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) End If End Sub Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged From 2281e43c5b7da51acbf0486e6e2cbdfcb9f73c21 Mon Sep 17 00:00:00 2001 From: John Lunalo Date: Wed, 9 Mar 2016 10:18:29 +0300 Subject: [PATCH 12/21] dlgRegularSequence Adding dataframe Length functionality --- instat/dlgRegularSequence.designer.vb | 46 +++++++++++++-------------- instat/dlgRegularSequence.vb | 18 ++++++----- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/instat/dlgRegularSequence.designer.vb b/instat/dlgRegularSequence.designer.vb index b08c1ce65ea..9cd40820c20 100644 --- a/instat/dlgRegularSequence.designer.vb +++ b/instat/dlgRegularSequence.designer.vb @@ -42,17 +42,16 @@ Partial Class dlgRegularSequence Me.lblLength = New System.Windows.Forms.Label() Me.cmdRefreshPreview = New System.Windows.Forms.Button() Me.txtGetPreview = New System.Windows.Forms.RichTextBox() - Me.nudLength = New System.Windows.Forms.NumericUpDown() Me.ucrNewColumnNameSelectorRegularSequence = New instat.ucrNewColumnName() - Me.ucrSelectDataFrame = New instat.ucrDataFrame() + Me.ucrSelectDataFrameRegularSequence = New instat.ucrDataFrame() Me.ucrBase = New instat.ucrButtons() + Me.UcrDataFrameLengthForRegularSequence = New instat.ucrDataFrameLength() Me.grpSequenceType.SuspendLayout() Me.grpSequenceDefinition.SuspendLayout() CType(Me.nudTo, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.nudFrom, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.nudRepeatValues, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.nudInstepsOf, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.nudLength, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'grpSequenceType @@ -235,10 +234,10 @@ Partial Class dlgRegularSequence Me.lblPreview.AutoSize = True Me.lblPreview.Location = New System.Drawing.Point(235, 48) Me.lblPreview.Name = "lblPreview" - Me.lblPreview.Size = New System.Drawing.Size(64, 13) + Me.lblPreview.Size = New System.Drawing.Size(45, 13) Me.lblPreview.TabIndex = 7 - Me.lblPreview.Tag = "Get_preview" - Me.lblPreview.Text = "Get preview" + Me.lblPreview.Tag = "Preview" + Me.lblPreview.Text = "Preview" ' 'lblLength ' @@ -268,14 +267,6 @@ Partial Class dlgRegularSequence Me.txtGetPreview.TabIndex = 8 Me.txtGetPreview.Text = "" ' - 'nudLength - ' - Me.nudLength.Location = New System.Drawing.Point(144, 25) - Me.nudLength.Maximum = New Decimal(New Integer() {10000000, 0, 0, 0}) - Me.nudLength.Name = "nudLength" - Me.nudLength.Size = New System.Drawing.Size(57, 20) - Me.nudLength.TabIndex = 10 - ' 'ucrNewColumnNameSelectorRegularSequence ' Me.ucrNewColumnNameSelectorRegularSequence.Location = New System.Drawing.Point(12, 258) @@ -284,12 +275,12 @@ Partial Class dlgRegularSequence Me.ucrNewColumnNameSelectorRegularSequence.TabIndex = 5 Me.ucrNewColumnNameSelectorRegularSequence.ucrDataFrameSelector = Nothing ' - 'ucrSelectDataFrame + 'ucrSelectDataFrameRegularSequence ' - Me.ucrSelectDataFrame.Location = New System.Drawing.Point(12, 9) - Me.ucrSelectDataFrame.Name = "ucrSelectDataFrame" - Me.ucrSelectDataFrame.Size = New System.Drawing.Size(126, 39) - Me.ucrSelectDataFrame.TabIndex = 0 + Me.ucrSelectDataFrameRegularSequence.Location = New System.Drawing.Point(12, 9) + Me.ucrSelectDataFrameRegularSequence.Name = "ucrSelectDataFrameRegularSequence" + Me.ucrSelectDataFrameRegularSequence.Size = New System.Drawing.Size(126, 39) + Me.ucrSelectDataFrameRegularSequence.TabIndex = 0 ' 'ucrBase ' @@ -298,19 +289,27 @@ Partial Class dlgRegularSequence Me.ucrBase.Size = New System.Drawing.Size(402, 55) Me.ucrBase.TabIndex = 9 ' + 'UcrDataFrameLengthForRegularSequence + ' + Me.UcrDataFrameLengthForRegularSequence.clsDataFrameSelector = Nothing + Me.UcrDataFrameLengthForRegularSequence.Location = New System.Drawing.Point(154, 25) + Me.UcrDataFrameLengthForRegularSequence.Name = "UcrDataFrameLengthForRegularSequence" + Me.UcrDataFrameLengthForRegularSequence.Size = New System.Drawing.Size(53, 23) + Me.UcrDataFrameLengthForRegularSequence.TabIndex = 10 + ' 'dlgRegularSequence ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(421, 351) - Me.Controls.Add(Me.nudLength) + Me.Controls.Add(Me.UcrDataFrameLengthForRegularSequence) Me.Controls.Add(Me.txtGetPreview) Me.Controls.Add(Me.cmdRefreshPreview) Me.Controls.Add(Me.grpSequenceDefinition) Me.Controls.Add(Me.lblLength) Me.Controls.Add(Me.lblPreview) Me.Controls.Add(Me.ucrNewColumnNameSelectorRegularSequence) - Me.Controls.Add(Me.ucrSelectDataFrame) + Me.Controls.Add(Me.ucrSelectDataFrameRegularSequence) Me.Controls.Add(Me.ucrBase) Me.Controls.Add(Me.grpSequenceType) Me.MaximizeBox = False @@ -328,7 +327,6 @@ Partial Class dlgRegularSequence CType(Me.nudFrom, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.nudRepeatValues, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.nudInstepsOf, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.nudLength, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() @@ -342,7 +340,7 @@ Partial Class dlgRegularSequence Friend WithEvents lblTo As Label Friend WithEvents lblFrom As Label Friend WithEvents ucrBase As ucrButtons - Friend WithEvents ucrSelectDataFrame As ucrDataFrame + Friend WithEvents ucrSelectDataFrameRegularSequence As ucrDataFrame Friend WithEvents ucrNewColumnNameSelectorRegularSequence As ucrNewColumnName Friend WithEvents lblPreview As Label Friend WithEvents lblLength As Label @@ -357,5 +355,5 @@ Partial Class dlgRegularSequence Friend WithEvents nudFrom As NumericUpDown Friend WithEvents nudRepeatValues As NumericUpDown Friend WithEvents nudInstepsOf As NumericUpDown - Friend WithEvents nudLength As NumericUpDown + Friend WithEvents UcrDataFrameLengthForRegularSequence As ucrDataFrameLength End Class diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index e4ce2138b13..3681c56328a 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -23,9 +23,11 @@ Public Class dlgRegularSequence ucrBase.iHelpTopicID = 30 'frmMain.clsRLink.SetOutput(txtGetPreview) 'ucrSelectDataFrame.SetColumnList(ucrColName) - ucrNewColumnNameSelectorRegularSequence.SetDataFrameSelector(ucrSelectDataFrame) + UcrDataFrameLengthForRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) + + ucrNewColumnNameSelectorRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) ucrNewColumnNameSelectorRegularSequence.SetPrefix("Sequence") - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrame.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) + ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) If bFirstLoad Then SetDefaults() @@ -75,13 +77,13 @@ Public Class dlgRegularSequence 'Remove this sub. 'Use DataFrameChanged event instead. - Private Sub ucrSelectDataFrame_LostFocus(sender As Object, e As EventArgs) Handles ucrSelectDataFrame.LostFocus - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrame.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) + Private Sub ucrSelectDataFrame_LostFocus(sender As Object, e As EventArgs) Handles ucrSelectDataFrameRegularSequence.LostFocus + ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) End Sub 'Delete ucrNewColumnNameSelectorRegularSequence and use the new ucrInputComboBox Private Sub ucrColName_LostFocus(sender As Object, e As EventArgs) Handles ucrNewColumnNameSelectorRegularSequence.LostFocus - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrame.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) + ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) End Sub 'To be looked at further @@ -115,9 +117,9 @@ Public Class dlgRegularSequence ucrBase.clsRsyntax.AddParameter("length.out", nudRepeatValues.Value) End Sub - Private Sub nudLength_ValueChanged(sender As Object, e As EventArgs) Handles nudLength.ValueChanged - ucrBase.clsRsyntax.AddParameter("length", nudLength.Value) - End Sub + 'Private Sub nudLength_ValueChanged(sender As Object, e As EventArgs) + ' ucrBase.clsRsyntax.AddParameter("length", nudLength.Value) + 'End Sub 'Add value change event subs for dtpSelectorA and dtpSelectorB as you have for the nuds 'This will fix the error you are having From 019c3c35d96673243c811cdd1dea593fb54a7e11 Mon Sep 17 00:00:00 2001 From: John Lunalo Date: Wed, 9 Mar 2016 12:47:52 +0300 Subject: [PATCH 13/21] dlgRegularSequene checking for OKEnabled --- instat/dlgRegularSequence.designer.vb | 34 ++++++++++++++++-------- instat/dlgRegularSequence.vb | 38 +++++++++++++++++---------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/instat/dlgRegularSequence.designer.vb b/instat/dlgRegularSequence.designer.vb index 9cd40820c20..b7f81c630bf 100644 --- a/instat/dlgRegularSequence.designer.vb +++ b/instat/dlgRegularSequence.designer.vb @@ -42,10 +42,11 @@ Partial Class dlgRegularSequence Me.lblLength = New System.Windows.Forms.Label() Me.cmdRefreshPreview = New System.Windows.Forms.Button() Me.txtGetPreview = New System.Windows.Forms.RichTextBox() - Me.ucrNewColumnNameSelectorRegularSequence = New instat.ucrNewColumnName() Me.ucrSelectDataFrameRegularSequence = New instat.ucrDataFrame() Me.ucrBase = New instat.ucrButtons() Me.UcrDataFrameLengthForRegularSequence = New instat.ucrDataFrameLength() + Me.UcrInputCboRegularSequence = New instat.ucrInputComboBox() + Me.lblNewColumnName = New System.Windows.Forms.Label() Me.grpSequenceType.SuspendLayout() Me.grpSequenceDefinition.SuspendLayout() CType(Me.nudTo, System.ComponentModel.ISupportInitialize).BeginInit() @@ -267,14 +268,6 @@ Partial Class dlgRegularSequence Me.txtGetPreview.TabIndex = 8 Me.txtGetPreview.Text = "" ' - 'ucrNewColumnNameSelectorRegularSequence - ' - Me.ucrNewColumnNameSelectorRegularSequence.Location = New System.Drawing.Point(12, 258) - Me.ucrNewColumnNameSelectorRegularSequence.Name = "ucrNewColumnNameSelectorRegularSequence" - Me.ucrNewColumnNameSelectorRegularSequence.Size = New System.Drawing.Size(402, 35) - Me.ucrNewColumnNameSelectorRegularSequence.TabIndex = 5 - Me.ucrNewColumnNameSelectorRegularSequence.ucrDataFrameSelector = Nothing - ' 'ucrSelectDataFrameRegularSequence ' Me.ucrSelectDataFrameRegularSequence.Location = New System.Drawing.Point(12, 9) @@ -297,18 +290,36 @@ Partial Class dlgRegularSequence Me.UcrDataFrameLengthForRegularSequence.Size = New System.Drawing.Size(53, 23) Me.UcrDataFrameLengthForRegularSequence.TabIndex = 10 ' + 'UcrInputCboRegularSequence + ' + Me.UcrInputCboRegularSequence.Location = New System.Drawing.Point(272, 252) + Me.UcrInputCboRegularSequence.Name = "UcrInputCboRegularSequence" + Me.UcrInputCboRegularSequence.Size = New System.Drawing.Size(137, 25) + Me.UcrInputCboRegularSequence.TabIndex = 11 + ' + 'lblNewColumnName + ' + Me.lblNewColumnName.AutoSize = True + Me.lblNewColumnName.Location = New System.Drawing.Point(18, 263) + Me.lblNewColumnName.Name = "lblNewColumnName" + Me.lblNewColumnName.Size = New System.Drawing.Size(98, 13) + Me.lblNewColumnName.TabIndex = 12 + Me.lblNewColumnName.Tag = "New_Column_Name" + Me.lblNewColumnName.Text = "New Column Name" + ' 'dlgRegularSequence ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(421, 351) + Me.Controls.Add(Me.lblNewColumnName) + Me.Controls.Add(Me.UcrInputCboRegularSequence) Me.Controls.Add(Me.UcrDataFrameLengthForRegularSequence) Me.Controls.Add(Me.txtGetPreview) Me.Controls.Add(Me.cmdRefreshPreview) Me.Controls.Add(Me.grpSequenceDefinition) Me.Controls.Add(Me.lblLength) Me.Controls.Add(Me.lblPreview) - Me.Controls.Add(Me.ucrNewColumnNameSelectorRegularSequence) Me.Controls.Add(Me.ucrSelectDataFrameRegularSequence) Me.Controls.Add(Me.ucrBase) Me.Controls.Add(Me.grpSequenceType) @@ -341,7 +352,6 @@ Partial Class dlgRegularSequence Friend WithEvents lblFrom As Label Friend WithEvents ucrBase As ucrButtons Friend WithEvents ucrSelectDataFrameRegularSequence As ucrDataFrame - Friend WithEvents ucrNewColumnNameSelectorRegularSequence As ucrNewColumnName Friend WithEvents lblPreview As Label Friend WithEvents lblLength As Label Friend WithEvents cmdRefreshPreview As Button @@ -356,4 +366,6 @@ Partial Class dlgRegularSequence Friend WithEvents nudRepeatValues As NumericUpDown Friend WithEvents nudInstepsOf As NumericUpDown Friend WithEvents UcrDataFrameLengthForRegularSequence As ucrDataFrameLength + Friend WithEvents UcrInputCboRegularSequence As ucrInputComboBox + Friend WithEvents lblNewColumnName As Label End Class diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index 3681c56328a..02cf419a52a 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -21,13 +21,15 @@ Public Class dlgRegularSequence ucrBase.clsRsyntax.SetFunction("seq") autoTranslate(Me) ucrBase.iHelpTopicID = 30 + UcrDataFrameLengthForRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) + UcrInputCboRegularSequence.SetPrefix("Regular") + UcrInputCboRegularSequence.SetItemsTypeAsColumns() + UcrInputCboRegularSequence.SetDefaultTypeAsColumn() + UcrInputCboRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) 'frmMain.clsRLink.SetOutput(txtGetPreview) 'ucrSelectDataFrame.SetColumnList(ucrColName) - UcrDataFrameLengthForRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) - ucrNewColumnNameSelectorRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) - ucrNewColumnNameSelectorRegularSequence.SetPrefix("Sequence") - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) + If bFirstLoad Then SetDefaults() @@ -42,8 +44,7 @@ Public Class dlgRegularSequence 'There should be a sequence type selected as a default. 'Then these things should become invisible automatically. Private Sub SetDefaults() - dtpSelectorA.Visible = False - dtpSelectorB.Visible = False + rdoNumeric.Checked = True End Sub @@ -56,11 +57,19 @@ Public Class dlgRegularSequence 'Need If statement to check that first. 'Ask if not sure how to do this. Private Sub TestOKEnabled() - If nudFrom.Text <> "" And nudTo.Text <> "" Then + If rdoNumeric.Checked = True Then + If nudFrom.Text <> "" And nudTo.Text <> "" Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If + ElseIf rdoDates.Checked = True Then + ucrBase.OKEnabled(True) Else ucrBase.OKEnabled(False) + End If End Sub @@ -77,14 +86,12 @@ Public Class dlgRegularSequence 'Remove this sub. 'Use DataFrameChanged event instead. - Private Sub ucrSelectDataFrame_LostFocus(sender As Object, e As EventArgs) Handles ucrSelectDataFrameRegularSequence.LostFocus - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) + Private Sub ucrSelectDataFrame_DataFrameChanged() Handles ucrSelectDataFrameRegularSequence.DataFrameChanged + End Sub 'Delete ucrNewColumnNameSelectorRegularSequence and use the new ucrInputComboBox - Private Sub ucrColName_LostFocus(sender As Object, e As EventArgs) Handles ucrNewColumnNameSelectorRegularSequence.LostFocus - ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnNameSelectorRegularSequence.cboColumnName.Text) - End Sub + 'To be looked at further Private Sub cmdRefreshPreview_Click(sender As Object, e As EventArgs) Handles cmdRefreshPreview.Click @@ -96,8 +103,9 @@ Public Class dlgRegularSequence 'Put the correct visible properties in here If rdoNumeric.Checked Then - ucrBase.clsRsyntax.AddParameter("from", nudFrom.Value) - ucrBase.clsRsyntax.AddParameter("to", nudTo.Value) + nudFrom.Visible = True + nudTo.Visible = True + Else dtpSelectorA.Visible = True dtpSelectorB.Visible = True @@ -117,6 +125,8 @@ Public Class dlgRegularSequence ucrBase.clsRsyntax.AddParameter("length.out", nudRepeatValues.Value) End Sub + + 'Private Sub nudLength_ValueChanged(sender As Object, e As EventArgs) ' ucrBase.clsRsyntax.AddParameter("length", nudLength.Value) 'End Sub From 073917085d1fcb970b4f53bddeeff542a541813a Mon Sep 17 00:00:00 2001 From: John Lunalo Date: Wed, 9 Mar 2016 13:20:25 +0300 Subject: [PATCH 14/21] adding value changed event --- instat/dlgRegularSequence.vb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index 02cf419a52a..41b354ca7db 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -106,13 +106,13 @@ Public Class dlgRegularSequence nudFrom.Visible = True nudTo.Visible = True + Else dtpSelectorA.Visible = True dtpSelectorB.Visible = True nudFrom.Visible = False nudTo.Visible = False - ucrBase.clsRsyntax.AddParameter("from", "as.Date('" & Format(dtpSelectorA.Value, "yyyy/MM/dd") & "')") - ucrBase.clsRsyntax.AddParameter("to", "as.Date('" & Format(dtpSelectorB.Value, "yyyy/MM/dd") & "')") + End If TestOKEnabled() End Sub @@ -122,9 +122,26 @@ Public Class dlgRegularSequence End Sub Private Sub nudRepeatValues_ValueChanged(sender As Object, e As EventArgs) Handles nudRepeatValues.ValueChanged + ucrBase.clsRsyntax.AddParameter("length.out", nudRepeatValues.Value) End Sub + Private Sub nudFrom_ValueChanged(sender As Object, e As EventArgs) Handles nudFrom.ValueChanged + ucrBase.clsRsyntax.AddParameter("from", nudFrom.Value) + End Sub + + Private Sub nudTo_ValueChanged(sender As Object, e As EventArgs) Handles nudTo.ValueChanged + ucrBase.clsRsyntax.AddParameter("to", nudTo.Value) + End Sub + + Private Sub dtpSelectorA_ValueChanged(sender As Object, e As EventArgs) Handles dtpSelectorA.ValueChanged + ucrBase.clsRsyntax.AddParameter("from", "as.Date('" & Format(dtpSelectorA.Value, "yyyy/MM/dd") & "')") + End Sub + + Private Sub dtpSelectorB_ValueChanged(sender As Object, e As EventArgs) Handles dtpSelectorB.ValueChanged + ucrBase.clsRsyntax.AddParameter("to", "as.Date('" & Format(dtpSelectorB.Value, "yyyy/MM/dd") & "')") + End Sub + 'Private Sub nudLength_ValueChanged(sender As Object, e As EventArgs) From 9a2a50f719647c56baa3eb4d59a2a76b226c1644 Mon Sep 17 00:00:00 2001 From: John Lunalo Date: Wed, 9 Mar 2016 13:37:53 +0300 Subject: [PATCH 15/21] Tidying up --- instat/dlgRegularSequence.vb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index 41b354ca7db..97a5156249a 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -105,6 +105,9 @@ Public Class dlgRegularSequence If rdoNumeric.Checked Then nudFrom.Visible = True nudTo.Visible = True + dtpSelectorA.Visible = False + dtpSelectorB.Visible = False + nudRepeatValues.Enabled = False Else @@ -122,8 +125,12 @@ Public Class dlgRegularSequence End Sub Private Sub nudRepeatValues_ValueChanged(sender As Object, e As EventArgs) Handles nudRepeatValues.ValueChanged + If rdoDates.Checked Then + ucrBase.clsRsyntax.AddParameter("length.out", "NULL") + Else + ucrBase.clsRsyntax.AddParameter("length.out", nudRepeatValues.Value) + End If - ucrBase.clsRsyntax.AddParameter("length.out", nudRepeatValues.Value) End Sub Private Sub nudFrom_ValueChanged(sender As Object, e As EventArgs) Handles nudFrom.ValueChanged From 615f2a5344413d1aab839f3ebad995b82624813d Mon Sep 17 00:00:00 2001 From: max Date: Wed, 9 Mar 2016 13:47:29 +0300 Subject: [PATCH 16/21] Moved checkboxes from main dialog to the subdialog. this is really working well now --- instat/dlgBoxPlot.designer.vb | 50 +++-------------------------------- instat/dlgBoxPlot.vb | 50 ++++++++++++----------------------- instat/sdgBoxPlot.Designer.vb | 5 ++-- instat/sdgBoxPlot.vb | 31 +++++++++++++++++++++- 4 files changed, 54 insertions(+), 82 deletions(-) diff --git a/instat/dlgBoxPlot.designer.vb b/instat/dlgBoxPlot.designer.vb index 6bde9b4e7d3..64d6d5da2a5 100644 --- a/instat/dlgBoxPlot.designer.vb +++ b/instat/dlgBoxPlot.designer.vb @@ -24,9 +24,6 @@ Partial Class dlgBoxplot Private Sub InitializeComponent() Me.lblYVarToPlot = New System.Windows.Forms.Label() Me.cmdOptions = New System.Windows.Forms.Button() - Me.chkVariableWidth = New System.Windows.Forms.CheckBox() - Me.chkHorizontalBoxplot = New System.Windows.Forms.CheckBox() - Me.chkNotchedBoxplot = New System.Windows.Forms.CheckBox() Me.lblByFactors = New System.Windows.Forms.Label() Me.lblBySecondFactor = New System.Windows.Forms.Label() Me.cmdBoxPlotOptions = New System.Windows.Forms.Button() @@ -49,7 +46,7 @@ Partial Class dlgBoxplot ' 'cmdOptions ' - Me.cmdOptions.Location = New System.Drawing.Point(276, 208) + Me.cmdOptions.Location = New System.Drawing.Point(307, 208) Me.cmdOptions.Name = "cmdOptions" Me.cmdOptions.Size = New System.Drawing.Size(75, 23) Me.cmdOptions.TabIndex = 7 @@ -57,39 +54,6 @@ Partial Class dlgBoxplot Me.cmdOptions.Text = "Options" Me.cmdOptions.UseVisualStyleBackColor = True ' - 'chkVariableWidth - ' - Me.chkVariableWidth.AutoSize = True - Me.chkVariableWidth.Location = New System.Drawing.Point(12, 228) - Me.chkVariableWidth.Name = "chkVariableWidth" - Me.chkVariableWidth.Size = New System.Drawing.Size(92, 17) - Me.chkVariableWidth.TabIndex = 9 - Me.chkVariableWidth.Tag = "Variable_width" - Me.chkVariableWidth.Text = "Variable width" - Me.chkVariableWidth.UseVisualStyleBackColor = True - ' - 'chkHorizontalBoxplot - ' - Me.chkHorizontalBoxplot.AutoSize = True - Me.chkHorizontalBoxplot.Location = New System.Drawing.Point(12, 259) - Me.chkHorizontalBoxplot.Name = "chkHorizontalBoxplot" - Me.chkHorizontalBoxplot.Size = New System.Drawing.Size(110, 17) - Me.chkHorizontalBoxplot.TabIndex = 10 - Me.chkHorizontalBoxplot.Tag = "Horizontal_boxplot" - Me.chkHorizontalBoxplot.Text = "Horizontal boxplot" - Me.chkHorizontalBoxplot.UseVisualStyleBackColor = True - ' - 'chkNotchedBoxplot - ' - Me.chkNotchedBoxplot.AutoSize = True - Me.chkNotchedBoxplot.Location = New System.Drawing.Point(12, 288) - Me.chkNotchedBoxplot.Name = "chkNotchedBoxplot" - Me.chkNotchedBoxplot.Size = New System.Drawing.Size(104, 17) - Me.chkNotchedBoxplot.TabIndex = 11 - Me.chkNotchedBoxplot.Tag = "Notched_boxplot" - Me.chkNotchedBoxplot.Text = "Notched boxplot" - Me.chkNotchedBoxplot.UseVisualStyleBackColor = True - ' 'lblByFactors ' Me.lblByFactors.AutoSize = True @@ -112,7 +76,7 @@ Partial Class dlgBoxplot ' 'cmdBoxPlotOptions ' - Me.cmdBoxPlotOptions.Location = New System.Drawing.Point(276, 238) + Me.cmdBoxPlotOptions.Location = New System.Drawing.Point(171, 208) Me.cmdBoxPlotOptions.Name = "cmdBoxPlotOptions" Me.cmdBoxPlotOptions.Size = New System.Drawing.Size(104, 23) Me.cmdBoxPlotOptions.TabIndex = 8 @@ -153,7 +117,7 @@ Partial Class dlgBoxplot ' 'ucrBase ' - Me.ucrBase.Location = New System.Drawing.Point(0, 312) + Me.ucrBase.Location = New System.Drawing.Point(0, 236) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(410, 51) Me.ucrBase.TabIndex = 12 @@ -162,7 +126,7 @@ Partial Class dlgBoxplot ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(412, 368) + Me.ClientSize = New System.Drawing.Size(402, 291) Me.Controls.Add(Me.cmdBoxPlotOptions) Me.Controls.Add(Me.ucrYvariableReceiver) Me.Controls.Add(Me.ucrSecondFactorReceiver) @@ -170,9 +134,6 @@ Partial Class dlgBoxplot Me.Controls.Add(Me.lblBySecondFactor) Me.Controls.Add(Me.lblByFactors) Me.Controls.Add(Me.ucrByFactorsReceiver) - Me.Controls.Add(Me.chkNotchedBoxplot) - Me.Controls.Add(Me.chkHorizontalBoxplot) - Me.Controls.Add(Me.chkVariableWidth) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.lblYVarToPlot) Me.Controls.Add(Me.ucrBase) @@ -193,9 +154,6 @@ Partial Class dlgBoxplot Friend WithEvents ucrBase As ucrButtons Friend WithEvents lblYVarToPlot As Label Friend WithEvents cmdOptions As Button - Friend WithEvents chkVariableWidth As CheckBox - Friend WithEvents chkHorizontalBoxplot As CheckBox - Friend WithEvents chkNotchedBoxplot As CheckBox Friend WithEvents ucrByFactorsReceiver As ucrReceiverSingle Friend WithEvents lblByFactors As Label Friend WithEvents ucrSelectorBoxPlot As ucrSelectorByDataFrameAddRemove diff --git a/instat/dlgBoxPlot.vb b/instat/dlgBoxPlot.vb index 1c955606867..f55c4bd4c50 100644 --- a/instat/dlgBoxPlot.vb +++ b/instat/dlgBoxPlot.vb @@ -19,6 +19,7 @@ Public Class dlgBoxplot Private clsRgeom_boxplotFunction As New RFunction Private clsRaesFunction As New RFunction Private bFirstLoad As Boolean = True + Private Sub dlgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load ucrBase.clsRsyntax.SetOperation("+") clsRggplotFunction.SetRCommand("ggplot") @@ -26,51 +27,50 @@ Public Class dlgBoxplot clsRaesFunction.SetRCommand("aes") clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) ' Empty string is default x value in case no factor is chosen clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsRaesFunction) - ucrBase.iHelpTopicID = 102 + ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction) + ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_boxplotFunction) - SetOperator() + ucrBase.iHelpTopicID = 102 ucrBase.clsRsyntax.iCallType = 0 + ucrYvariableReceiver.Selector = ucrSelectorBoxPlot ucrYvariableReceiver.SetMeAsReceiver() ucrByFactorsReceiver.Selector = ucrSelectorBoxPlot ucrByFactorsReceiver.SetDataType("factor") ucrSecondFactorReceiver.Selector = ucrSelectorBoxPlot ucrSecondFactorReceiver.SetDataType("factor") + sdgPlots.SetRSyntax(ucrBase.clsRsyntax) + sdgBoxPlot.SetBoxPlotFunction(clsRgeom_boxplotFunction) autoTranslate(Me) If bFirstLoad Then SetDefaults() bFirstLoad = False + Else + ReopenDialog() End If End Sub - Private Sub SetOperator() - + Public Sub SetOperator() Dim clsTempOp As New ROperator Dim clsTempRFunc As New RFunction - If chkHorizontalBoxplot.Checked Then + If sdgBoxPlot.chkHorizontalBoxplot.Checked Then clsTempOp.SetOperation("+") clsTempOp.SetParameter(True, clsRFunc:=clsRggplotFunction) clsTempOp.SetParameter(False, clsRFunc:=clsRgeom_boxplotFunction) clsTempRFunc.SetRCommand("coord_flip") ucrBase.clsRsyntax.SetOperatorParameter(True, clsOp:=clsTempOp) ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsTempRFunc) - Else - ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction) - ucrBase.clsRsyntax.SetOperatorParameter(False, clsRFunc:=clsRgeom_boxplotFunction) End If End Sub Private Sub SetDefaults() ucrSelectorBoxPlot.Reset() ucrSelectorBoxPlot.Focus() ucrYvariableReceiver.SetMeAsReceiver() - chkHorizontalBoxplot.Checked = False - chkNotchedBoxplot.Checked = False - chkVariableWidth.Checked = False - TestOkEnabled() + End Sub Private Sub TestOkEnabled() @@ -98,12 +98,7 @@ Public Class dlgBoxplot End Sub Private Sub ucrByFactorsReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrByFactorsReceiver.SelectionChanged - If Not ucrByFactorsReceiver.IsEmpty Then - clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) - ucrSecondFactorReceiver.SetMeAsReceiver() - Else - clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) - End If + ReopenDialog() End Sub Private Sub ucrSecondFactorReceiver_SelectionChanged(sender As Object, e As EventArgs) Handles ucrSecondFactorReceiver.SelectionChanged @@ -114,25 +109,14 @@ Public Class dlgBoxplot clsRaesFunction.RemoveParameterByName("fill") End If End Sub - Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged - SetOperator() - End Sub - - Private Sub chkNotchedBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkNotchedBoxplot.CheckedChanged - If chkNotchedBoxplot.Checked Then - clsRgeom_boxplotFunction.AddParameter("notch", "TRUE") + Private Sub ReopenDialog() + If Not ucrByFactorsReceiver.IsEmpty Then + clsRaesFunction.AddParameter("x", ucrByFactorsReceiver.GetVariableNames(False)) Else - clsRgeom_boxplotFunction.RemoveParameterByName("notch") + clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) End If End Sub - Private Sub chkVariableWidth_CheckedChanged(sender As Object, e As EventArgs) Handles chkVariableWidth.CheckedChanged - If chkVariableWidth.Checked Then - clsRgeom_boxplotFunction.AddParameter("varwidth", "TRUE") - Else - clsRgeom_boxplotFunction.RemoveParameterByName("varwidth") - End If - End Sub Private Sub cmdBoxPlotOptions_Click(sender As Object, e As EventArgs) Handles cmdBoxPlotOptions.Click sdgBoxPlot.ShowDialog() End Sub diff --git a/instat/sdgBoxPlot.Designer.vb b/instat/sdgBoxPlot.Designer.vb index 4c711c58c05..6ad58ea0793 100644 --- a/instat/sdgBoxPlot.Designer.vb +++ b/instat/sdgBoxPlot.Designer.vb @@ -30,7 +30,7 @@ Partial Class sdgBoxPlot ' 'ucrBaseSdgBoxplot ' - Me.ucrBaseSdgBoxplot.Location = New System.Drawing.Point(56, 219) + Me.ucrBaseSdgBoxplot.Location = New System.Drawing.Point(12, 115) Me.ucrBaseSdgBoxplot.Name = "ucrBaseSdgBoxplot" Me.ucrBaseSdgBoxplot.Size = New System.Drawing.Size(142, 30) Me.ucrBaseSdgBoxplot.TabIndex = 0 @@ -72,7 +72,7 @@ Partial Class sdgBoxPlot ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) + Me.ClientSize = New System.Drawing.Size(186, 157) Me.Controls.Add(Me.chkNotchedBoxplot) Me.Controls.Add(Me.chkHorizontalBoxplot) Me.Controls.Add(Me.chkVariableWidth) @@ -82,6 +82,7 @@ Partial Class sdgBoxPlot Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Tag = "BoxPlot_Options" Me.Text = "BoxPlot Options" + Me.TopMost = True Me.ResumeLayout(False) Me.PerformLayout() diff --git a/instat/sdgBoxPlot.vb b/instat/sdgBoxPlot.vb index b9997b482f6..323884e580b 100644 --- a/instat/sdgBoxPlot.vb +++ b/instat/sdgBoxPlot.vb @@ -13,14 +13,43 @@ ' ' You should have received a copy of the GNU General Public License k ' along with this program. If not, see . + Imports instat.Translations + Public Class sdgBoxPlot Public clsBoxplotFunction As RFunction - Public Sub SetBoxPlotFUnction(clsBoxPlotFunc As RFunction) + Public Sub SetBoxPlotFunction(clsBoxPlotFunc As RFunction) clsBoxplotFunction = clsBoxPlotFunc End Sub Private Sub sdgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Me.BringToFront() autoTranslate(Me) + SetSubdialogDefaults() + End Sub + + Public Sub SetSubdialogDefaults() + chkHorizontalBoxplot.Checked = False + chkNotchedBoxplot.Checked = False + chkVariableWidth.Checked = False + End Sub + + Private Sub chkVariableWidth_CheckedChanged(sender As Object, e As EventArgs) Handles chkVariableWidth.CheckedChanged + If chkVariableWidth.Checked Then + clsBoxplotFunction.AddParameter("varwidth", "TRUE") + Else + clsBoxplotFunction.RemoveParameterByName("varwidth") + End If + End Sub + + Private Sub chkNotchedBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkNotchedBoxplot.CheckedChanged + If chkNotchedBoxplot.Checked Then + clsBoxplotFunction.AddParameter("notch", "TRUE") + Else + clsBoxplotFunction.RemoveParameterByName("notch") + End If + End Sub + Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged + dlgBoxplot.SetOperator() End Sub End Class \ No newline at end of file From 7e6a7a0b518fde1ec921e3f39bfd2b76660a0429 Mon Sep 17 00:00:00 2001 From: Stephen Kogo Date: Wed, 9 Mar 2016 15:25:54 +0300 Subject: [PATCH 17/21] Fixing order columns in data method --- instat/static/InstatObject/R/data_object.R | 39 ++++---------------- instat/static/InstatObject/R/instat_object.R | 12 +----- 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index 501d82ed074..3d41544deb5 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -491,44 +491,20 @@ data_obj$methods(insert_column_in_data = function(col_data =c(), start_pos = (le # } # ) -data_obj$methods(order_columns_in_data_by_names = function(col_names_order = "") { +data_obj$methods(order_columns_in_data = function(col_names_order) { if (length(names(data)) != length(col_names_order)) stop("Columns to order should be same as columns in the data.") + if(is.numeric(col_names_order) && identical(sort(col_names_order), sort(as.numeric(1:ncol(data))))){ - old_names_order <- names(data) - - for(col_name in old_names_order){ - if(!(col_name %in% col_names_order)){ - stop(col_name, " is missing in columns order") - } - } - - numeric_order = c() - - for(i in 1: length(col_names_order)){ - numeric_order[i] = which(old_names_order == col_names_order[i]) + }else if(is.character(col_names_order) && identical(sort(col_names_order), sort(as.character(names(data))))){ + + }else{ + stop("Invalid column order") } - - data <<- data[ ,numeric_order] + data <<- data[ ,col_names_order] .self$append_to_changes(list(Col_order, col_names_order)) } ) -data_obj$methods(order_columns_in_data_by_number = function(numeric_order) { - if (length(names(data)) != length(numeric_order)) stop("Columns order should be the same length as columns in the data.") - - old_order <- c(1:ncol(data)) - - for(old_col_num in old_order){ - if(!(old_col_num %in% numeric_order)){ - stop(old_col_num, " is missing in numeric order") - } - } - - data <<- data[ ,numeric_order] - .self$append_to_changes(list(Numeric_column_order, numeric_order)) -} -) - data_obj$methods(insert_row_in_data = function(start_pos = (nrow(data)+1), row_data = c(), number_rows = 1) { if (start_pos != as.integer(start_pos) || start_pos < 1 || start_pos > nrow(data) + 1 ) { @@ -674,7 +650,6 @@ Removed_row="Removed row" Inserted_col = "Inserted column" Move_col = "Moved column" Col_order = "Order of columns" -Numeric_column_order = "Numeric Order of columns" Inserted_row = "Inserted row" #meta data labels diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index 8ed2fdcc602..902d2efe494 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -354,19 +354,11 @@ instat_obj$methods(insert_column_in_data = function(data_name, col_data =c(), st # } # ) -instat_obj$methods(order_columns_in_data_by_names = function(data_name, col_names_order = ""){ +instat_obj$methods(order_columns_in_data = function(data_name, col_names_order){ 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]]$order_columns_in_data_by_names(col_names_order = col_names_order) -} -) - -instat_obj$methods(order_columns_in_data_by_number = function(data_name, numeric_order){ - 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]]$order_columns_in_data_by_number(numeric_order = numeric_order) + data_objects[[data_name]]$order_columns_in_data(col_names_order = col_names_order) } ) From 5fd3e07926a6e47783f5b8dc880cca3232ee4a51 Mon Sep 17 00:00:00 2001 From: Stephen Kogo Date: Wed, 9 Mar 2016 15:59:43 +0300 Subject: [PATCH 18/21] Edited the order columns method --- instat/static/InstatObject/R/data_object.R | 24 ++++++++++++-------- instat/static/InstatObject/R/instat_object.R | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index 3d41544deb5..eacb211935d 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -491,17 +491,23 @@ data_obj$methods(insert_column_in_data = function(col_data =c(), start_pos = (le # } # ) -data_obj$methods(order_columns_in_data = function(col_names_order) { - if (length(names(data)) != length(col_names_order)) stop("Columns to order should be same as columns in the data.") - if(is.numeric(col_names_order) && identical(sort(col_names_order), sort(as.numeric(1:ncol(data))))){ + +data_obj$methods(order_columns_in_data = function(col_order) { + if (length(names(data)) != length(col_order)) stop("Columns to order should be same as columns in the data.") - }else if(is.character(col_names_order) && identical(sort(col_names_order), sort(as.character(names(data))))){ - - }else{ - stop("Invalid column order") + if(is.numeric(col_order)) { + if(! (identical(sort(col_order), sort(as.numeric(1:ncol(data)))))) { + stop("Invalid column order") + } + }else if(is.character(col_order)) { + if(! (identical(sort(col_order), sort(as.character(names(data)))))){ + stop("Invalid column order") + } + }else{ + stop("column order must be a numeric or character vector") } - data <<- data[ ,col_names_order] - .self$append_to_changes(list(Col_order, col_names_order)) + data <<- data[ ,col_order] + .self$append_to_changes(list(Col_order, col_order)) } ) diff --git a/instat/static/InstatObject/R/instat_object.R b/instat/static/InstatObject/R/instat_object.R index 902d2efe494..5675460501b 100644 --- a/instat/static/InstatObject/R/instat_object.R +++ b/instat/static/InstatObject/R/instat_object.R @@ -354,11 +354,11 @@ instat_obj$methods(insert_column_in_data = function(data_name, col_data =c(), st # } # ) -instat_obj$methods(order_columns_in_data = function(data_name, col_names_order){ +instat_obj$methods(order_columns_in_data = function(data_name, col_order){ 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]]$order_columns_in_data(col_names_order = col_names_order) + data_objects[[data_name]]$order_columns_in_data(col_order = col_order) } ) From 17305b27e89f8c1d7f089f4ff3b6de287eb8fe6a Mon Sep 17 00:00:00 2001 From: John Lunalo Date: Wed, 9 Mar 2016 16:11:58 +0300 Subject: [PATCH 19/21] dlgRegularSequence Tidying up --- instat/dlgRegularSequence.vb | 59 +++--------------------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index 97a5156249a..4dc89fe398e 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -26,10 +26,7 @@ Public Class dlgRegularSequence UcrInputCboRegularSequence.SetItemsTypeAsColumns() UcrInputCboRegularSequence.SetDefaultTypeAsColumn() UcrInputCboRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence) - 'frmMain.clsRLink.SetOutput(txtGetPreview) - 'ucrSelectDataFrame.SetColumnList(ucrColName) - - + ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=UcrInputCboRegularSequence.GetText, strTempDataframe:=ucrSelectDataFrameRegularSequence.cboAvailableDataFrames.Text, strTempColumn:=UcrInputCboRegularSequence.GetText) If bFirstLoad Then SetDefaults() @@ -37,25 +34,17 @@ Public Class dlgRegularSequence Else ReopenDialog() End If - TestOKEnabled() End Sub - 'There should be a sequence type selected as a default. - 'Then these things should become invisible automatically. Private Sub SetDefaults() rdoNumeric.Checked = True - End Sub Private Sub ReopenDialog() End Sub - 'This is not correct. - 'It depends on which option has been chosen (numeric/dates) - 'Need If statement to check that first. - 'Ask if not sure how to do this. Private Sub TestOKEnabled() If rdoNumeric.Checked = True Then If nudFrom.Text <> "" And nudTo.Text <> "" Then @@ -68,54 +57,26 @@ Public Class dlgRegularSequence ucrBase.OKEnabled(True) Else ucrBase.OKEnabled(False) - - End If End Sub - 'This is the same event as in grpSequenceType_CheckedChanged - 'Remove this sub and copy any code needed from here into grpSequenceType_CheckedChanged - Private Sub rdoNumeric_CheckedChanged(sender As Object, e As EventArgs) Handles rdoNumeric.Click - If rdoNumeric.Checked = True Then - dtpSelectorA.Visible = False - dtpSelectorB.Visible = False - chkDefineAsFactor.Visible = True - - End If - End Sub - - 'Remove this sub. - 'Use DataFrameChanged event instead. - Private Sub ucrSelectDataFrame_DataFrameChanged() Handles ucrSelectDataFrameRegularSequence.DataFrameChanged - - End Sub - - 'Delete ucrNewColumnNameSelectorRegularSequence and use the new ucrInputComboBox - - - 'To be looked at further - Private Sub cmdRefreshPreview_Click(sender As Object, e As EventArgs) Handles cmdRefreshPreview.Click - 'frmMain.clsRLink.RunScript(ucrBase.clsRsyntax.clsBaseFunction.ToScript(), 2) - 'txtGetPreview.Refresh() - End Sub + 'Private Sub cmdRefreshPreview_Click(sender As Object, e As EventArgs) Handles cmdRefreshPreview.Click + ' frmMain.clsRLink.RunScript(ucrBase.clsRsyntax.clsBaseFunction.ToScript(), 2) + ' txtGetPreview.Refresh() + 'End Sub Private Sub grpSequenceType_CheckedChanged(sender As Object, e As EventArgs) Handles rdoDates.CheckedChanged, rdoNumeric.CheckedChanged - - 'Put the correct visible properties in here If rdoNumeric.Checked Then nudFrom.Visible = True nudTo.Visible = True dtpSelectorA.Visible = False dtpSelectorB.Visible = False nudRepeatValues.Enabled = False - - Else dtpSelectorA.Visible = True dtpSelectorB.Visible = True nudFrom.Visible = False nudTo.Visible = False - End If TestOKEnabled() End Sub @@ -148,14 +109,4 @@ Public Class dlgRegularSequence Private Sub dtpSelectorB_ValueChanged(sender As Object, e As EventArgs) Handles dtpSelectorB.ValueChanged ucrBase.clsRsyntax.AddParameter("to", "as.Date('" & Format(dtpSelectorB.Value, "yyyy/MM/dd") & "')") End Sub - - - - 'Private Sub nudLength_ValueChanged(sender As Object, e As EventArgs) - ' ucrBase.clsRsyntax.AddParameter("length", nudLength.Value) - 'End Sub - - 'Add value change event subs for dtpSelectorA and dtpSelectorB as you have for the nuds - 'This will fix the error you are having - End Class \ No newline at end of file From f4e39d0170c82ef22993e718c1cd23e7fb36c092 Mon Sep 17 00:00:00 2001 From: Stephen Kogo Date: Wed, 9 Mar 2016 21:42:14 +0300 Subject: [PATCH 20/21] Editing updates --- instat/static/InstatObject/R/data_object.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/data_object.R b/instat/static/InstatObject/R/data_object.R index eacb211935d..f000ba7196d 100644 --- a/instat/static/InstatObject/R/data_object.R +++ b/instat/static/InstatObject/R/data_object.R @@ -506,7 +506,7 @@ data_obj$methods(order_columns_in_data = function(col_order) { }else{ stop("column order must be a numeric or character vector") } - data <<- data[ ,col_order] + set_data(data[ ,col_order]) .self$append_to_changes(list(Col_order, col_order)) } ) From d993380da90667029b3642abad51968949862bff Mon Sep 17 00:00:00 2001 From: max Date: Thu, 10 Mar 2016 07:17:51 +0300 Subject: [PATCH 21/21] Changed thing as discussed on git. Moving Horizontal boxplot to the main and also changing the subdialogs SetDefaults --- instat/dlgBoxPlot.designer.vb | 14 ++++++++++++++ instat/dlgBoxPlot.vb | 7 ++++++- instat/sdgBoxPlot.Designer.vb | 16 +--------------- instat/sdgBoxPlot.vb | 5 ++--- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/instat/dlgBoxPlot.designer.vb b/instat/dlgBoxPlot.designer.vb index 64d6d5da2a5..e98e6a5a629 100644 --- a/instat/dlgBoxPlot.designer.vb +++ b/instat/dlgBoxPlot.designer.vb @@ -32,6 +32,7 @@ Partial Class dlgBoxplot Me.ucrSelectorBoxPlot = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrByFactorsReceiver = New instat.ucrReceiverSingle() Me.ucrBase = New instat.ucrButtons() + Me.chkHorizontalBoxplot = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' 'lblYVarToPlot @@ -122,11 +123,23 @@ Partial Class dlgBoxplot Me.ucrBase.Size = New System.Drawing.Size(410, 51) Me.ucrBase.TabIndex = 12 ' + 'chkHorizontalBoxplot + ' + Me.chkHorizontalBoxplot.AutoSize = True + Me.chkHorizontalBoxplot.Location = New System.Drawing.Point(12, 207) + Me.chkHorizontalBoxplot.Name = "chkHorizontalBoxplot" + Me.chkHorizontalBoxplot.Size = New System.Drawing.Size(110, 17) + Me.chkHorizontalBoxplot.TabIndex = 20 + Me.chkHorizontalBoxplot.Tag = "Horizontal_boxplot" + Me.chkHorizontalBoxplot.Text = "Horizontal boxplot" + Me.chkHorizontalBoxplot.UseVisualStyleBackColor = True + ' 'dlgBoxplot ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(402, 291) + Me.Controls.Add(Me.chkHorizontalBoxplot) Me.Controls.Add(Me.cmdBoxPlotOptions) Me.Controls.Add(Me.ucrYvariableReceiver) Me.Controls.Add(Me.ucrSecondFactorReceiver) @@ -161,4 +174,5 @@ Partial Class dlgBoxplot Friend WithEvents lblBySecondFactor As Label Friend WithEvents ucrYvariableReceiver As ucrReceiverSingle Friend WithEvents cmdBoxPlotOptions As Button + Friend WithEvents chkHorizontalBoxplot As CheckBox End Class diff --git a/instat/dlgBoxPlot.vb b/instat/dlgBoxPlot.vb index f55c4bd4c50..b27a1bb6834 100644 --- a/instat/dlgBoxPlot.vb +++ b/instat/dlgBoxPlot.vb @@ -56,7 +56,7 @@ Public Class dlgBoxplot Public Sub SetOperator() Dim clsTempOp As New ROperator Dim clsTempRFunc As New RFunction - If sdgBoxPlot.chkHorizontalBoxplot.Checked Then + If chkHorizontalBoxplot.Checked Then clsTempOp.SetOperation("+") clsTempOp.SetParameter(True, clsRFunc:=clsRggplotFunction) clsTempOp.SetParameter(False, clsRFunc:=clsRgeom_boxplotFunction) @@ -69,6 +69,7 @@ Public Class dlgBoxplot ucrSelectorBoxPlot.Reset() ucrSelectorBoxPlot.Focus() ucrYvariableReceiver.SetMeAsReceiver() + sdgBoxPlot.SetDefaults() TestOkEnabled() End Sub @@ -124,4 +125,8 @@ Public Class dlgBoxplot Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() End Sub + + Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged + SetOperator() + End Sub End Class \ No newline at end of file diff --git a/instat/sdgBoxPlot.Designer.vb b/instat/sdgBoxPlot.Designer.vb index 6ad58ea0793..b1c7bbc415d 100644 --- a/instat/sdgBoxPlot.Designer.vb +++ b/instat/sdgBoxPlot.Designer.vb @@ -24,7 +24,6 @@ Partial Class sdgBoxPlot Private Sub InitializeComponent() Me.ucrBaseSdgBoxplot = New instat.ucrButtonsSubdialogue() Me.chkNotchedBoxplot = New System.Windows.Forms.CheckBox() - Me.chkHorizontalBoxplot = New System.Windows.Forms.CheckBox() Me.chkVariableWidth = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' @@ -46,21 +45,10 @@ Partial Class sdgBoxPlot Me.chkNotchedBoxplot.Text = "Notched boxplot" Me.chkNotchedBoxplot.UseVisualStyleBackColor = True ' - 'chkHorizontalBoxplot - ' - Me.chkHorizontalBoxplot.AutoSize = True - Me.chkHorizontalBoxplot.Location = New System.Drawing.Point(12, 43) - Me.chkHorizontalBoxplot.Name = "chkHorizontalBoxplot" - Me.chkHorizontalBoxplot.Size = New System.Drawing.Size(110, 17) - Me.chkHorizontalBoxplot.TabIndex = 19 - Me.chkHorizontalBoxplot.Tag = "Horizontal_boxplot" - Me.chkHorizontalBoxplot.Text = "Horizontal boxplot" - Me.chkHorizontalBoxplot.UseVisualStyleBackColor = True - ' 'chkVariableWidth ' Me.chkVariableWidth.AutoSize = True - Me.chkVariableWidth.Location = New System.Drawing.Point(12, 12) + Me.chkVariableWidth.Location = New System.Drawing.Point(12, 25) Me.chkVariableWidth.Name = "chkVariableWidth" Me.chkVariableWidth.Size = New System.Drawing.Size(92, 17) Me.chkVariableWidth.TabIndex = 18 @@ -74,7 +62,6 @@ Partial Class sdgBoxPlot Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(186, 157) Me.Controls.Add(Me.chkNotchedBoxplot) - Me.Controls.Add(Me.chkHorizontalBoxplot) Me.Controls.Add(Me.chkVariableWidth) Me.Controls.Add(Me.ucrBaseSdgBoxplot) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow @@ -90,6 +77,5 @@ Partial Class sdgBoxPlot Friend WithEvents ucrBaseSdgBoxplot As ucrButtonsSubdialogue Friend WithEvents chkNotchedBoxplot As CheckBox - Friend WithEvents chkHorizontalBoxplot As CheckBox Friend WithEvents chkVariableWidth As CheckBox End Class diff --git a/instat/sdgBoxPlot.vb b/instat/sdgBoxPlot.vb index 323884e580b..cc08e03c47e 100644 --- a/instat/sdgBoxPlot.vb +++ b/instat/sdgBoxPlot.vb @@ -25,10 +25,9 @@ Public Class sdgBoxPlot Private Sub sdgBoxPlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.BringToFront() autoTranslate(Me) - SetSubdialogDefaults() End Sub - Public Sub SetSubdialogDefaults() + Public Sub SetDefaults() chkHorizontalBoxplot.Checked = False chkNotchedBoxplot.Checked = False chkVariableWidth.Checked = False @@ -49,7 +48,7 @@ Public Class sdgBoxPlot clsBoxplotFunction.RemoveParameterByName("notch") End If End Sub - Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) Handles chkHorizontalBoxplot.CheckedChanged + Private Sub chkHorizontalBoxplot_CheckedChanged(sender As Object, e As EventArgs) dlgBoxplot.SetOperator() End Sub End Class \ No newline at end of file