From 66bccfc7fbbafe2c485b94be3ffc61fb18e553e2 Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Mon, 29 Feb 2016 13:24:37 +0300 Subject: [PATCH 1/3] changes on the correlations dialog --- instat/dlgCorrelation.designer.vb | 25 +++++----- instat/dlgCorrelation.vb | 80 +++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 21 deletions(-) diff --git a/instat/dlgCorrelation.designer.vb b/instat/dlgCorrelation.designer.vb index 9a18f6f1328..0a6f76ab5e2 100644 --- a/instat/dlgCorrelation.designer.vb +++ b/instat/dlgCorrelation.designer.vb @@ -30,7 +30,7 @@ Partial Class dlgCorrelation Me.rdoSpearman = New System.Windows.Forms.RadioButton() Me.rdoKendall = New System.Windows.Forms.RadioButton() Me.rdoPearson = New System.Windows.Forms.RadioButton() - Me.cmdPlots = New System.Windows.Forms.Button() + Me.cmdCorrplot = New System.Windows.Forms.Button() Me.grpMissing = New System.Windows.Forms.GroupBox() Me.rdoPairwise = New System.Windows.Forms.RadioButton() Me.rdoCompleteRowsOnly = New System.Windows.Forms.RadioButton() @@ -135,15 +135,15 @@ Partial Class dlgCorrelation Me.rdoPearson.Text = "Pearson" Me.rdoPearson.UseVisualStyleBackColor = True ' - 'cmdPlots + 'cmdCorrplot ' - Me.cmdPlots.Location = New System.Drawing.Point(332, 293) - Me.cmdPlots.Name = "cmdPlots" - Me.cmdPlots.Size = New System.Drawing.Size(75, 23) - Me.cmdPlots.TabIndex = 11 - Me.cmdPlots.Tag = "Plots" - Me.cmdPlots.Text = "Plots" - Me.cmdPlots.UseVisualStyleBackColor = True + Me.cmdCorrplot.Location = New System.Drawing.Point(332, 293) + Me.cmdCorrplot.Name = "cmdCorrplot" + Me.cmdCorrplot.Size = New System.Drawing.Size(75, 23) + Me.cmdCorrplot.TabIndex = 11 + Me.cmdCorrplot.Tag = "corrplot" + Me.cmdCorrplot.Text = "corrplot" + Me.cmdCorrplot.UseVisualStyleBackColor = True ' 'grpMissing ' @@ -201,6 +201,7 @@ Partial Class dlgCorrelation ' Me.ucrReceiverSecondColumn.Location = New System.Drawing.Point(301, 181) Me.ucrReceiverSecondColumn.Name = "ucrReceiverSecondColumn" + Me.ucrReceiverSecondColumn.Selector = Nothing Me.ucrReceiverSecondColumn.Size = New System.Drawing.Size(106, 26) Me.ucrReceiverSecondColumn.TabIndex = 6 ' @@ -208,6 +209,7 @@ Partial Class dlgCorrelation ' Me.ucrReceiverFirstColumn.Location = New System.Drawing.Point(301, 129) Me.ucrReceiverFirstColumn.Name = "ucrReceiverFirstColumn" + Me.ucrReceiverFirstColumn.Selector = Nothing Me.ucrReceiverFirstColumn.Size = New System.Drawing.Size(106, 26) Me.ucrReceiverFirstColumn.TabIndex = 5 ' @@ -229,6 +231,7 @@ Partial Class dlgCorrelation ' Me.ucrReceiverMultipleColumns.Location = New System.Drawing.Point(278, 112) Me.ucrReceiverMultipleColumns.Name = "ucrReceiverMultipleColumns" + Me.ucrReceiverMultipleColumns.Selector = Nothing Me.ucrReceiverMultipleColumns.Size = New System.Drawing.Size(121, 104) Me.ucrReceiverMultipleColumns.TabIndex = 15 ' @@ -241,7 +244,7 @@ Partial Class dlgCorrelation Me.Controls.Add(Me.lblConfInterval) Me.Controls.Add(Me.txtConfidenceInterval) Me.Controls.Add(Me.grpMissing) - Me.Controls.Add(Me.cmdPlots) + Me.Controls.Add(Me.cmdCorrplot) Me.Controls.Add(Me.grpMethod) Me.Controls.Add(Me.lblSecondColumn) Me.Controls.Add(Me.lblFirstColumn) @@ -275,7 +278,7 @@ Partial Class dlgCorrelation Friend WithEvents rdoSpearman As RadioButton Friend WithEvents rdoKendall As RadioButton Friend WithEvents rdoPearson As RadioButton - Friend WithEvents cmdPlots As Button + Friend WithEvents cmdCorrplot As Button Friend WithEvents grpMissing As GroupBox Friend WithEvents rdoPairwise As RadioButton Friend WithEvents rdoCompleteRowsOnly As RadioButton diff --git a/instat/dlgCorrelation.vb b/instat/dlgCorrelation.vb index e476f41022f..0e115a154e6 100644 --- a/instat/dlgCorrelation.vb +++ b/instat/dlgCorrelation.vb @@ -14,46 +14,75 @@ ' 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 dlgCorrelation + Public bFirstLoad As Boolean = True + Private Sub dlgCorrelation_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'Set properties needed on load ucrBase.clsRsyntax.iCallType = 2 ucrReceiverFirstColumn.Selector = ucrSelectorDataFrameVarAddRemove ucrReceiverSecondColumn.Selector = ucrSelectorDataFrameVarAddRemove ucrReceiverMultipleColumns.Selector = ucrSelectorDataFrameVarAddRemove + ucrReceiverFirstColumn.SetDataType("numeric") + ucrReceiverSecondColumn.SetDataType("numeric") + ucrReceiverMultipleColumns.SetDataType("numeric") + autoTranslate(Me) - 'this default is independent of TwoColumn/MultipleColumn option so can be set here - rdoPearson.Checked = True - ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34)) + ucrBase.iHelpTopicID = 316 - 'default is the TwoColumn option + If bFirstLoad Then + SetDefaults() + bFirstLoad = False + End If + + TestOKEnabledForMultipleColumns() + TestOKEnabledforTwoColumns() + End Sub + + Private Sub SetDefaults() + ucrSelectorDataFrameVarAddRemove.Reset() + ucrSelectorDataFrameVarAddRemove.Focus() + rdoPearson.Checked = True rdoTwoColumns.Checked = True - SetTwoColumnAsFunction() + TestOKEnabledForMultipleColumns() + TestOKEnabledforTwoColumns() End Sub - Private Sub ucrReceiverFirstColumn_Leave(sender As Object, e As EventArgs) Handles ucrReceiverFirstColumn.Leave + + + Private Sub ucrReceiverFirstColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverFirstColumn.SelectionChanged ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverFirstColumn.GetVariables()) + + TestOKEnabledforTwoColumns() End Sub - Private Sub ucrReceiverSecondColumn_Leave(sender As Object, e As EventArgs) Handles ucrReceiverSecondColumn.Leave + Private Sub ucrReceiverSecondColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverSecondColumn.SelectionChanged ucrBase.clsRsyntax.AddParameter("y", clsRFunctionParameter:=ucrReceiverSecondColumn.GetVariables()) + TestOKEnabledforTwoColumns() + End Sub - Private Sub ucrReceiverMultipleColumns_Leave(sender As Object, e As EventArgs) Handles ucrReceiverMultipleColumns.Leave + Private Sub ucrReceiverMultipleColumns_SelectionChanged() Handles ucrReceiverMultipleColumns.SelectionChanged ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleColumns.GetVariables()) + TestOKEnabledForMultipleColumns() End Sub 'put all rdo button checked changed in one sub to make it shorter Private Sub rdoForMethodsCheckedChanged(sender As Object, e As EventArgs) Handles rdoPearson.CheckedChanged, rdoKendall.CheckedChanged, rdoSpearman.CheckedChanged If rdoPearson.Checked Then ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34)) + ElseIf rdoKendall.Checked Then ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "kendall" & Chr(34)) + ElseIf rdoSpearman.Checked Then ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "spearman" & Chr(34)) + Else ucrBase.clsRsyntax.RemoveParameter("method") + 'the else case should never happen but is there just in case End If End Sub @@ -65,10 +94,15 @@ Public Class dlgCorrelation Private Sub SetUseParameter() If rdoCompleteRowsOnly.Checked Then ucrBase.clsRsyntax.AddParameter("use", Chr(34) & "pairwise.complete.obs" & Chr(34)) + + ElseIf rdoPairwise.Checked Then ucrBase.clsRsyntax.AddParameter("use", Chr(34) & "complete.obs" & Chr(34)) + + Else ucrBase.clsRsyntax.RemoveParameter("use") + End If End Sub @@ -79,7 +113,7 @@ Public Class dlgCorrelation ucrBase.clsRsyntax.SetFunction("cor.test") 'Set what should be visible/invisible grpMissing.Visible = False - cmdPlots.Visible = False + cmdCorrplot.Visible = False lblConfInterval.Visible = True txtConfidenceInterval.Visible = True ucrReceiverFirstColumn.Visible = True @@ -96,6 +130,8 @@ Public Class dlgCorrelation ucrBase.clsRsyntax.AddParameter("y", clsRFunctionParameter:=ucrReceiverSecondColumn.GetVariables()) ucrBase.clsRsyntax.AddParameter("alternative", Chr(34) & "two.sided" & Chr(34)) ucrBase.clsRsyntax.AddParameter("exact", "NULL") + + End Sub Private Sub SetMultipleColumnAsFunction() @@ -104,7 +140,7 @@ Public Class dlgCorrelation ucrBase.clsRsyntax.SetFunction("cor") 'Set what should be visible/invisible grpMissing.Visible = True - cmdPlots.Visible = True + cmdCorrplot.Visible = True lblConfInterval.Visible = False txtConfidenceInterval.Visible = False ucrReceiverFirstColumn.Visible = False @@ -118,6 +154,7 @@ Public Class dlgCorrelation 'Add back in parameters they may have been removed in TwoColumn case SetUseParameter() ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleColumns.GetVariables()) + End Sub @@ -132,4 +169,27 @@ Public Class dlgCorrelation Private Sub txtConfidenceInterval_Leave(sender As Object, e As EventArgs) Handles txtConfidenceInterval.Leave ucrBase.clsRsyntax.AddParameter("conf.level", txtConfidenceInterval.Text) End Sub + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + End Sub + + Private Sub cmdPlots_Click(sender As Object, e As EventArgs) Handles cmdCorrplot.Click + sdgCorrPlot.ShowDialog() + End Sub + Private Sub TestOKEnabledforTwoColumns() + If ucrReceiverFirstColumn.IsEmpty() = False And ucrReceiverSecondColumn.IsEmpty() = False And (rdoPearson.Checked = True Or rdoKendall.Checked = True Or rdoSpearman.Checked = True) Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If + End Sub + Private Sub TestOKEnabledForMultipleColumns() + If ucrReceiverMultipleColumns.IsEmpty() = False And ucrReceiverMultipleColumns.lstSelectedVariables.Items.Count > 1 And (rdoCompleteRowsOnly.Checked = True Or rdoPairwise.Checked = True) AndAlso (rdoPearson.Checked = True Or rdoKendall.Checked = True Or rdoSpearman.Checked = True) Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If + + + End Sub End Class \ No newline at end of file From f912ce035bff7448e7ae071dff9a6f1737c7d1fd Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Mon, 29 Feb 2016 16:47:27 +0300 Subject: [PATCH 2/3] more changes on dlgCorrelation --- instat/dlgCorrelation.vb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/instat/dlgCorrelation.vb b/instat/dlgCorrelation.vb index 0e115a154e6..3eeab0cbaab 100644 --- a/instat/dlgCorrelation.vb +++ b/instat/dlgCorrelation.vb @@ -17,6 +17,7 @@ Imports instat.Translations Public Class dlgCorrelation Public bFirstLoad As Boolean = True + Public bIsTwoColumnFunction As Boolean Private Sub dlgCorrelation_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'Set properties needed on load @@ -37,8 +38,12 @@ Public Class dlgCorrelation bFirstLoad = False End If - TestOKEnabledForMultipleColumns() - TestOKEnabledforTwoColumns() + If bIsTwoColumnFunction Then + TestOKEnabledForMultipleColumns() + Else + TestOKEnabledForMultipleColumns() + End If + End Sub Private Sub SetDefaults() @@ -46,16 +51,14 @@ Public Class dlgCorrelation ucrSelectorDataFrameVarAddRemove.Focus() rdoPearson.Checked = True rdoTwoColumns.Checked = True - TestOKEnabledForMultipleColumns() - TestOKEnabledforTwoColumns() + TestOKEnabledForTwoColumns() End Sub Private Sub ucrReceiverFirstColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverFirstColumn.SelectionChanged ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverFirstColumn.GetVariables()) - - TestOKEnabledforTwoColumns() + TestOKEnabledForTwoColumns() End Sub Private Sub ucrReceiverSecondColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverSecondColumn.SelectionChanged @@ -73,7 +76,11 @@ Public Class dlgCorrelation Private Sub rdoForMethodsCheckedChanged(sender As Object, e As EventArgs) Handles rdoPearson.CheckedChanged, rdoKendall.CheckedChanged, rdoSpearman.CheckedChanged If rdoPearson.Checked Then ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34)) - + If frmMain.clsInstatOptions.bIncludeRDefaultParameters Then + ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34)) + Else + ucrBase.clsRsyntax.RemoveParameter("method") + End If ElseIf rdoKendall.Checked Then ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "kendall" & Chr(34)) @@ -130,6 +137,7 @@ Public Class dlgCorrelation ucrBase.clsRsyntax.AddParameter("y", clsRFunctionParameter:=ucrReceiverSecondColumn.GetVariables()) ucrBase.clsRsyntax.AddParameter("alternative", Chr(34) & "two.sided" & Chr(34)) ucrBase.clsRsyntax.AddParameter("exact", "NULL") + bIsTwoColumnFunction = True End Sub @@ -154,7 +162,7 @@ Public Class dlgCorrelation 'Add back in parameters they may have been removed in TwoColumn case SetUseParameter() ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleColumns.GetVariables()) - + bIsTwoColumnFunction = False End Sub @@ -176,7 +184,7 @@ Public Class dlgCorrelation Private Sub cmdPlots_Click(sender As Object, e As EventArgs) Handles cmdCorrplot.Click sdgCorrPlot.ShowDialog() End Sub - Private Sub TestOKEnabledforTwoColumns() + Private Sub TestOKEnabledForTwoColumns() If ucrReceiverFirstColumn.IsEmpty() = False And ucrReceiverSecondColumn.IsEmpty() = False And (rdoPearson.Checked = True Or rdoKendall.Checked = True Or rdoSpearman.Checked = True) Then ucrBase.OKEnabled(True) Else From cf7149e78cd5b56a953ba3b1c0bbef8038b5a572 Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Tue, 1 Mar 2016 13:11:46 +0300 Subject: [PATCH 3/3] more fixes on the dialog --- instat/dlgCorrelation.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgCorrelation.vb b/instat/dlgCorrelation.vb index 3eeab0cbaab..5ca90630f2e 100644 --- a/instat/dlgCorrelation.vb +++ b/instat/dlgCorrelation.vb @@ -39,7 +39,7 @@ Public Class dlgCorrelation End If If bIsTwoColumnFunction Then - TestOKEnabledForMultipleColumns() + TestOKEnabledForTwoColumns() Else TestOKEnabledForMultipleColumns() End If