diff --git a/instat/clsPopup.vb b/instat/clsPopup.vb index 2d1b7804ad4..b831f20acec 100644 --- a/instat/clsPopup.vb +++ b/instat/clsPopup.vb @@ -1,3 +1,152 @@ -Public Class clsPopup +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . + +'''-------------------------------------------------------------------------------------------- +''' +''' An object of this class represents a popup component that's used and displayed as a control. +''' +''' +''' set contents control of the popup +''' +''' +''' set size of the popup +''' +''' +''' specify the display position of the popup relative to the owner. Default is top +''' +''' +''' attach the owner control and show the popup +''' +''' +''' +'''-------------------------------------------------------------------------------------------- +Public Class clsPopup + ''' + ''' Event raised when the contents control loses focus. + ''' This indicates that the popup is closing. + ''' + Public Event Closing() + + ''' + ''' Container used as the 'frame' of the popup component + ''' + Private ReadOnly frm As Form + + ''' + ''' specifies if the popup should hide automatically on lost focus or not + ''' + Public Property AutoHide As Boolean + + ''' + ''' specifies the position of the popup relative to the owner(control) + ''' + Public Property Position As PopupPosition + + ''' + ''' enumeration of allowable popup positions + ''' + Public Enum PopupPosition + Top + Below + End Enum + + Sub New() + 'initialise variables and set defaults + frm = New Form With { + .ShowInTaskbar = False, + .FormBorderStyle = FormBorderStyle.None, + .StartPosition = FormStartPosition.Manual + } + 'set default popup behaviours + AutoHide = True + Position = PopupPosition.Top + End Sub + + Public Sub SetSize(width As Integer, height As Integer) + SetSize(New Size(width, height)) + End Sub + + Public Sub SetSize(size As Size) + frm.Size = size + End Sub + + Public Sub SetLocation(x As Integer, y As Integer) + SetLocation(New Point(x, y)) + End Sub + + Public Sub SetLocation(point As Point) + frm.Location = point + End Sub + + ''' + ''' sets the specified control as the contents control of the popup + ''' + ''' The System.Windows.Forms.Control to set as the control contained in the popup + Public Sub SetContentControl(ctr As Control) + frm.Controls.Clear() 'remove any existing control first + frm.Controls.Add(ctr) + ctr.Dock = DockStyle.Fill 'the control will always be same size as the from + + 'attach the event handler that will determine auto closing + AddHandler ctr.LostFocus, Sub() + If AutoHide Then + Hide() + End If + End Sub + End Sub + + ''' + ''' shows the popup relative to the location of the specified control(owner) + ''' and the position specified + ''' + ''' The System.Windows.Forms.Control to set popup location based on + ''' PopupPosition to set the position of the popup + Public Sub Show(owner As Control, position As PopupPosition) + Me.Position = position + Show(owner) + End Sub + + ''' + ''' shows the popup relative to the location of the specified control(owner) + ''' and the position set + ''' + ''' The System.Windows.Forms.Control to set popup location based on + Public Sub Show(owner As Control) + 'compute and get the location of the specified control relative to screen coordinates + 'Don't use Point.Empty, it's not function so use Point(0, 0) + Dim ctrPos As Point = owner.PointToScreen(New Point(0, 0)) + + 'then set location of the popup relative to the position specified + Select Case Position + Case PopupPosition.Top + SetLocation(ctrPos.X - 2, ctrPos.Y - frm.Height - 2) + Case PopupPosition.Below + SetLocation(ctrPos.X - 2, ctrPos.Y + owner.Height - 2) + End Select + + 'then show popup + frm.Show() + End Sub + + ''' + ''' raises popup hiding event then hides the popup + ''' + Public Sub Hide() + RaiseEvent Closing() + frm.Close() + End Sub End Class diff --git a/instat/dlgClimaticCheckDataTemperature.vb b/instat/dlgClimaticCheckDataTemperature.vb index b6637a6e69a..f8be048aacb 100644 --- a/instat/dlgClimaticCheckDataTemperature.vb +++ b/instat/dlgClimaticCheckDataTemperature.vb @@ -107,11 +107,15 @@ Public Class dlgClimaticCheckDataTemperature ucrReceiverElement1.SetParameter(New RParameter("x", 0, bNewIncludeArgumentName:=False)) ucrReceiverElement1.SetParameterIsString() ucrReceiverElement1.bWithQuotes = False + ucrReceiverElement1.SetClimaticType("temp_max") + ucrReceiverElement1.bAutoFill = True ucrReceiverElement1.SetMeAsReceiver() ucrReceiverElement2.Selector = ucrSelectorTemperature ucrReceiverElement2.SetParameter(New RParameter("x", 1, bNewIncludeArgumentName:=False)) ucrReceiverElement2.SetParameterIsString() + ucrReceiverElement2.SetClimaticType("temp_min") + ucrReceiverElement2.bAutoFill = True ucrReceiverElement2.bWithQuotes = False 'Checkboxes for options diff --git a/instat/dlgClimsoftWizard.Designer.vb b/instat/dlgClimsoftWizard.Designer.vb new file mode 100644 index 00000000000..828e4c21565 --- /dev/null +++ b/instat/dlgClimsoftWizard.Designer.vb @@ -0,0 +1,41 @@ + +Partial Class dlgClimsoftWizard + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + 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.SuspendLayout() + ' + 'dlgClimsoftWizard + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(800, 450) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "dlgClimsoftWizard" + Me.ShowIcon = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Import From Climsoft" + Me.ResumeLayout(False) + + End Sub +End Class diff --git a/instat/dlgClimsoftWizard.resx b/instat/dlgClimsoftWizard.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/dlgClimsoftWizard.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/dlgClimsoftWizard.vb b/instat/dlgClimsoftWizard.vb new file mode 100644 index 00000000000..8f4f5d4b2d2 --- /dev/null +++ b/instat/dlgClimsoftWizard.vb @@ -0,0 +1,3 @@ +Public Class dlgClimsoftWizard + +End Class \ No newline at end of file diff --git a/instat/dlgCumulativeDistribution.resx b/instat/dlgCumulativeDistribution.resx index 8e112b67ba2..9db83083de6 100644 --- a/instat/dlgCumulativeDistribution.resx +++ b/instat/dlgCumulativeDistribution.resx @@ -157,13 +157,13 @@ 10, 236 - 120, 25 + 119, 23 7 - Options + Plot Options cmdPlotOptions diff --git a/instat/dlgDescribeTwoVarGraph.resx b/instat/dlgDescribeTwoVarGraph.resx index 4a887a215b1..3bd0c2d02a7 100644 --- a/instat/dlgDescribeTwoVarGraph.resx +++ b/instat/dlgDescribeTwoVarGraph.resx @@ -126,14 +126,14 @@ 10, 197 - 120, 23 + 119, 23 5 - Options + Plot Options cmdOptions @@ -804,4 +804,4 @@ 5 - \ No newline at end of file + diff --git a/instat/dlgEnter.Designer.vb b/instat/dlgEnter.Designer.vb index d01626b3e8d..f8638d9e5cf 100644 --- a/instat/dlgEnter.Designer.vb +++ b/instat/dlgEnter.Designer.vb @@ -78,6 +78,7 @@ Partial Class dlgEnter Me.ucrReceiverForEnterCalculation = New instat.ucrReceiverExpression() Me.ucrBase = New instat.ucrButtons() Me.ucrTryModelling = New instat.ucrTry() + Me.btnExample = New System.Windows.Forms.Button() Me.grpEnterKeybord1.SuspendLayout() Me.grpEnterKeyboard2.SuspendLayout() Me.SuspendLayout() @@ -351,10 +352,17 @@ Partial Class dlgEnter resources.ApplyResources(Me.ucrTryModelling, "ucrTryModelling") Me.ucrTryModelling.Name = "ucrTryModelling" ' + 'btnExample + ' + resources.ApplyResources(Me.btnExample, "btnExample") + Me.btnExample.Name = "btnExample" + Me.btnExample.UseVisualStyleBackColor = True + ' 'dlgEnter ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.btnExample) Me.Controls.Add(Me.ucrTryModelling) Me.Controls.Add(Me.grpEnterKeyboard2) Me.Controls.Add(Me.ucrSaveEnterResultInto) @@ -415,4 +423,5 @@ Partial Class dlgEnter Friend WithEvents cmdColon As Button Friend WithEvents grpEnterKeyboard2 As GroupBox Friend WithEvents ucrTryModelling As ucrTry + Friend WithEvents btnExample As Button End Class diff --git a/instat/dlgEnter.resx b/instat/dlgEnter.resx index 1e421263152..0e9f98a7ce9 100644 --- a/instat/dlgEnter.resx +++ b/instat/dlgEnter.resx @@ -123,7 +123,7 @@ - 347, 26 + 371, 18 106, 17 @@ -144,26 +144,26 @@ $this - 5 + 6 True - 11, 26 + 10, 20 2, 0, 2, 0 - 30, 13 + 33, 13 152 - Data + Data: lblData @@ -175,22 +175,22 @@ $this - 7 + 8 - 11, 280 + 11, 248 2, 3, 2, 3 - 174, 17 + 110, 17 157 - Save Result into + Save Result Into: chkSaveEnterResultInto @@ -202,7 +202,7 @@ $this - 3 + 4 4, 76 @@ -616,7 +616,7 @@ 0 - 163, 58 + 163, 48 2, 3, 2, 3 @@ -640,7 +640,7 @@ $this - 6 + 7 106, 14 @@ -1033,7 +1033,7 @@ 0 - 364, 58 + 364, 48 2, 3, 2, 3 @@ -1057,16 +1057,16 @@ $this - 1 + 2 - 195, 275 + 124, 244 2, 3, 2, 3 - 288, 22 + 266, 22 158 @@ -1081,10 +1081,10 @@ $this - 2 + 3 - 11, 65 + 11, 55 0, 0, 0, 0 @@ -1105,7 +1105,7 @@ $this - 4 + 5 True @@ -1114,10 +1114,40 @@ 6, 13 - 573, 376 + 573, 336 + + + NoControl + + + 301, 16 + + + 2, 2, 2, 2 + + + 64, 22 + + + 161 + + + Examples + + + btnExample + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 - 3, 236 + 3, 202 480, 33 @@ -1135,10 +1165,10 @@ $this - 0 + 1 - 11, 307 + 11, 278 452, 52 @@ -1156,7 +1186,7 @@ $this - 9 + 10 CenterScreen @@ -1171,7 +1201,7 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 65, 26 + 44, 16 2, 3, 2, 3 @@ -1192,6 +1222,6 @@ $this - 8 + 9 \ No newline at end of file diff --git a/instat/dlgEnter.vb b/instat/dlgEnter.vb index a3fc713cc74..05181d4d519 100644 --- a/instat/dlgEnter.vb +++ b/instat/dlgEnter.vb @@ -290,4 +290,48 @@ Public Class dlgEnter End If SaveResults() End Sub + + ''' + ''' displays a popup with example commands just above the input receiver + ''' + ''' + ''' + Private Sub btnExample_Click(sender As Object, e As EventArgs) Handles btnExample.Click + Dim objPopup As New clsPopup + Dim lstView As New ListView With { + .Scrollable = True, + .View = View.Details, + .FullRowSelect = True, + .ShowItemToolTips = True + } + + 'add a single column + lstView.Columns.Add("Commands", 450) + + 'add rows of sample commands + lstView.Items.Add(New ListViewItem({"seq(9 )"})) + lstView.Items.Item(0).ToolTipText = "seq(9 )" 'todo. sensible tooltip here. + + lstView.Items.Add(New ListViewItem({"LETTERS"})) + lstView.Items.Item(1).ToolTipText = "LETTERS" 'todo. sensible tooltip here. + + lstView.Items.Add(New ListViewItem({"month.name"})) + lstView.Items.Item(2).ToolTipText = "month.name" 'todo. sensible tooltip here. + + lstView.Items.Add(New ListViewItem({"month.abb"})) + lstView.Items.Item(3).ToolTipText = "month.abb" 'todo. sensible tooltip here. + + + AddHandler lstView.DoubleClick, Sub() + If lstView.SelectedItems.Count > 0 Then + ucrReceiverForEnterCalculation.Clear() + ucrReceiverForEnterCalculation.AddToReceiverAtCursorPosition(lstView.SelectedItems.Item(0).SubItems(0).Text) + objPopup.Hide() + End If + End Sub + + objPopup.SetContentControl(lstView) + objPopup.SetSize(ucrReceiverForEnterCalculation.Width, ucrReceiverForEnterCalculation.Height + 100) + objPopup.Show(ucrReceiverForEnterCalculation) + End Sub End Class diff --git a/instat/dlgFromLibrary.vb b/instat/dlgFromLibrary.vb index 0875e384b6e..b8eec57d14f 100644 --- a/instat/dlgFromLibrary.vb +++ b/instat/dlgFromLibrary.vb @@ -25,9 +25,13 @@ Public Class dlgFromLibrary Private bReset As Boolean = True Private clsDataFunction As New RFunction Private dctPackages As New Dictionary(Of String, String) - Private strAvailablePackages() As String + + 'a string array that holds the packages displayed in the combobox + 'todo. this property can be removed once the PR that enhances the inputCombobox control is merged + Private arrAvailablePackages() As String Private strSelectedPackage As String = "" + Private clsImportFunction As New RFunction 'the base function that call on import R-Instat function Private Sub dlgFromLibrary_Load(sender As Object, e As EventArgs) Handles Me.Load autoTranslate(Me) @@ -56,7 +60,6 @@ Public Class dlgFromLibrary Dim clsGetPackages As New RFunction Dim expPackageNames As SymbolicExpression Dim chrPackageNames As CharacterVector - Dim iDataSets As Integer = 0 ucrBase.iHelpTopicID = 156 @@ -66,16 +69,14 @@ Public Class dlgFromLibrary expPackageNames = frmMain.clsRLink.RunInternalScriptGetValue(clsGetPackages.ToScript(), bSilent:=True) If expPackageNames IsNot Nothing AndAlso expPackageNames.Type <> Internals.SymbolicExpressionType.Null Then chrPackageNames = expPackageNames.AsCharacter - strAvailablePackages = chrPackageNames.ToArray - System.Array.Sort(Of String)(strAvailablePackages) + arrAvailablePackages = chrPackageNames.ToArray + Array.Sort(arrAvailablePackages) + ucrInputPackages.SetParameter(New RParameter("package")) 'for combobox, can't set items without setting parameter first + ucrInputPackages.SetItems(arrAvailablePackages, bAddConditions:=True) End If - If strAvailablePackages IsNot Nothing Then - ucrInputPackages.SetParameter(New RParameter("package")) - ucrInputPackages.SetItems(strAvailablePackages, bAddConditions:=True) - ucrInputPackages.SetDropDownStyleAsNonEditable() - ucrInputPackages.SetLinkedDisplayControl(lblFromPackage) - End If + ucrInputPackages.SetDropDownStyleAsNonEditable() + ucrInputPackages.SetLinkedDisplayControl(lblFromPackage) ucrPnlOptions.AddRadioButton(rdoDefaultDatasets) ucrPnlOptions.AddRadioButton(rdoInstatCollection) @@ -91,22 +92,29 @@ Public Class dlgFromLibrary End Sub Private Sub SetDefaults() - 'TODO this should be the new clear method - clsDataFunction.ClearParameters() - + 'reset the functions and the custom controls + ucrNewDataFrameName.SetName("") 'called here cause its not called in the control's reset method ucrNewDataFrameName.Reset() + clsDataFunction.Clear() + clsImportFunction.Clear() + 'set up the data function clsDataFunction.SetPackageName("utils") clsDataFunction.SetRCommand("data") clsDataFunction.AddParameter("package", Chr(34) & "datasets" & Chr(34)) + + 'set up the import data function + clsImportFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_data") + + 'add the before codes (the data() R base function) and the base function(import_data() R-Instat function) ucrBase.clsRsyntax.AddToBeforeCodes(clsDataFunction) + ucrBase.clsRsyntax.SetBaseRFunction(clsImportFunction) End Sub Private Sub SetRCodeforControls(bReset As Boolean) - If strAvailablePackages IsNot Nothing Then + If arrAvailablePackages IsNot Nothing Then ucrInputPackages.SetRCode(clsDataFunction, bReset) End If - ucrNewDataFrameName.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) ucrPnlOptions.SetRSyntax(ucrBase.clsRsyntax, bReset) End Sub @@ -180,15 +188,14 @@ Public Class dlgFromLibrary End Sub Private Sub lstCollection_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCollection.SelectedIndexChanged - Dim strDataName As String If lstCollection.SelectedItems.Count > 0 Then - strDataName = CheckString(lstCollection.SelectedItems(0).SubItems(0).Text) - ucrBase.clsRsyntax.SetCommandString(strDataName) If Not ucrNewDataFrameName.bUserTyped Then - ucrNewDataFrameName.SetName(strDataName) + 'this will raise event ControValueChanged for this control, which will inturn call SetParameterValues() + ucrNewDataFrameName.SetName(CheckString(lstCollection.SelectedItems(0).SubItems(0).Text)) + Else + SetParameterValues() End If - clsDataFunction.AddParameter("X", strDataName) End If TestOkEnabled() EnableHelp() @@ -222,7 +229,76 @@ Public Class dlgFromLibrary End Sub Private Sub ucrNewDataFrameName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrNewDataFrameName.ControlContentsChanged - ucrBase.clsRsyntax.SetAssignTo(ucrNewDataFrameName.GetText, strTempDataframe:=ucrNewDataFrameName.GetText) TestOkEnabled() End Sub + + Private Sub ucrNewDataFrameName_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrNewDataFrameName.ControlValueChanged + SetParameterValues() + End Sub + + ''' + ''' sets the R parameters and functions used by the main import function + ''' in importing datasets of different R types + ''' + Private Sub SetParameterValues() + Dim strSelectedDataName As String + Dim strVecOutput As CharacterVector + Dim strRClass As String = "" + + If lstCollection.SelectedItems.Count < 1 Then + Exit Sub + End If + + strSelectedDataName = CheckString(lstCollection.SelectedItems(0).SubItems(0).Text) + clsDataFunction.AddParameter("X", strSelectedDataName) + + 'calling RunInternalScriptGetOutput() twice because currently it can't execute multiple lines + frmMain.clsRLink.RunInternalScriptGetOutput(clsDataFunction.Clone.ToScript(), bSilent:=True) + strVecOutput = frmMain.clsRLink.RunInternalScriptGetOutput("class(" + strSelectedDataName + ")", bSilent:=True) + If strVecOutput IsNot Nothing AndAlso strVecOutput.Length > 0 Then + strRClass = Mid(strVecOutput(0), 5).Replace("""", "").ToLower + End If + + If strRClass = "list" Then + clsImportFunction.AddParameter("data_tables", strParameterValue:=strSelectedDataName) + Else + Dim clsListFunction As New RFunction 'defines the list function. list(x=x) + Dim clsListParameterFunction As New RFunction 'defines the function that act as list parameters e.g list(y=fortify.zoo(x)) + clsListFunction.SetRCommand("list") + Select Case strRClass + Case "zoo" + 'this is the recommended command for converting zoo object types to data frames. + 'In R-Instat the data.frame doesn't convert this object type well. See issue #5649 + clsListParameterFunction.SetPackageName("zoo") + clsListParameterFunction.SetRCommand("fortify.zoo") + clsListParameterFunction.AddParameter("model", strParameterValue:=strSelectedDataName) + clsListFunction.AddParameter(ucrNewDataFrameName.GetText, clsRFunctionParameter:=clsListParameterFunction) + Case "spatialpolygonsdataframe" + 'for some reason, objects of this type have to be explicitly coerced to data.frame + 'before being imported by import R-Instat function + clsListParameterFunction.SetRCommand("data.frame") + clsListParameterFunction.AddParameter("x", strParameterValue:=strSelectedDataName) + clsListFunction.AddParameter(ucrNewDataFrameName.GetText, clsRFunctionParameter:=clsListParameterFunction) + Case "dgcmatrix", "dscmatrix" + 'this if block is used for dgcmatrix,dscmatrix. + 'The R summary() function returns an object of type data.frame if given a matrix. Used here to coerce it to data.frame + 'todo. this needs to be investigated further on the best(correct) command for coercing this type of data. + 'the data.frame command is unable to coerce data of this class type hence it's own block form the matrix command + clsListParameterFunction.SetRCommand("summary") + clsListParameterFunction.AddParameter("object", strParameterValue:=strSelectedDataName) + clsListFunction.AddParameter(ucrNewDataFrameName.GetText, clsRFunctionParameter:=clsListParameterFunction) + Case "matrix" + 'this if block is used for matrix type + 'this has been done in it's own block in anticipation of a correct way of coercing matrix to data frame + 'currently this command loses data(some columns) of the matrix once it's coerced. See issue #5649 + clsListParameterFunction.SetRCommand("data.frame") + clsListParameterFunction.AddParameter("x", strParameterValue:=strSelectedDataName) + clsListFunction.AddParameter(ucrNewDataFrameName.GetText, clsRFunctionParameter:=clsListParameterFunction) + Case Else + clsListFunction.AddParameter(ucrNewDataFrameName.GetText, strParameterValue:=strSelectedDataName) + End Select + clsImportFunction.AddParameter("data_tables", clsRFunctionParameter:=clsListFunction) + End If + End Sub + End Class \ No newline at end of file diff --git a/instat/dlgInfillMissingValues.Designer.vb b/instat/dlgInfillMissingValues.Designer.vb index b88538c623b..689566dfdf0 100644 --- a/instat/dlgInfillMissingValues.Designer.vb +++ b/instat/dlgInfillMissingValues.Designer.vb @@ -34,30 +34,30 @@ Partial Class dlgInfillMissingValues Me.rdoMultiple = New System.Windows.Forms.RadioButton() Me.rdoNeighbouring = New System.Windows.Forms.RadioButton() Me.grpMethods = New System.Windows.Forms.GroupBox() - Me.ucrPnlMethods = New instat.UcrPanel() Me.grpStartEnd = New System.Windows.Forms.GroupBox() Me.rdoExtendFill = New System.Windows.Forms.RadioButton() Me.rdoLeaveAsMissing = New System.Windows.Forms.RadioButton() - Me.ucrPnlStartEnd = New instat.UcrPanel() Me.lblValue = New System.Windows.Forms.Label() - Me.ucrInputConstant = New instat.ucrInputTextBox() Me.lblFunction = New System.Windows.Forms.Label() Me.lblRows = New System.Windows.Forms.Label() + Me.lblStation = New System.Windows.Forms.Label() + Me.ucrInputConstant = New instat.ucrInputTextBox() + Me.ucrReceiverByFactor = New instat.ucrReceiverMultiple() + Me.ucrReceiverStation = New instat.ucrReceiverSingle() Me.ucrChkSetSeed = New instat.ucrCheck() Me.ucrNudSetSeed = New instat.ucrNud() Me.ucrNudMaximum = New instat.ucrNud() Me.ucrChkMaxGap = New instat.ucrCheck() Me.ucrChkBy = New instat.ucrCheck() Me.ucrChkCopyFromBelow = New instat.ucrCheck() + Me.ucrPnlStartEnd = New instat.UcrPanel() Me.ucrSaveNewColumn = New instat.ucrSave() Me.ucrInputComboFunction = New instat.ucrInputComboBox() Me.ucrReceiverElement = New instat.ucrReceiverSingle() Me.ucrBase = New instat.ucrButtons() Me.ucrSelectorInfillMissing = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrPnlOptions = New instat.UcrPanel() - Me.ucrReceiverStation = New instat.ucrReceiverSingle() - Me.ucrReceiverByFactor = New instat.ucrReceiverMultiple() - Me.lblStation = New System.Windows.Forms.Label() + Me.ucrPnlMethods = New instat.UcrPanel() Me.grpMethods.SuspendLayout() Me.grpStartEnd.SuspendLayout() Me.SuspendLayout() @@ -152,11 +152,6 @@ Partial Class dlgInfillMissingValues Me.grpMethods.Name = "grpMethods" Me.grpMethods.TabStop = False ' - 'ucrPnlMethods - ' - resources.ApplyResources(Me.ucrPnlMethods, "ucrPnlMethods") - Me.ucrPnlMethods.Name = "ucrPnlMethods" - ' 'grpStartEnd ' Me.grpStartEnd.Controls.Add(Me.rdoExtendFill) @@ -180,16 +175,26 @@ Partial Class dlgInfillMissingValues Me.rdoLeaveAsMissing.TabStop = True Me.rdoLeaveAsMissing.UseVisualStyleBackColor = True ' - 'ucrPnlStartEnd - ' - resources.ApplyResources(Me.ucrPnlStartEnd, "ucrPnlStartEnd") - Me.ucrPnlStartEnd.Name = "ucrPnlStartEnd" - ' 'lblValue ' resources.ApplyResources(Me.lblValue, "lblValue") Me.lblValue.Name = "lblValue" ' + 'lblFunction + ' + resources.ApplyResources(Me.lblFunction, "lblFunction") + Me.lblFunction.Name = "lblFunction" + ' + 'lblRows + ' + resources.ApplyResources(Me.lblRows, "lblRows") + Me.lblRows.Name = "lblRows" + ' + 'lblStation + ' + resources.ApplyResources(Me.lblStation, "lblStation") + Me.lblStation.Name = "lblStation" + ' 'ucrInputConstant ' Me.ucrInputConstant.AddQuotesIfUnrecognised = True @@ -198,15 +203,23 @@ Partial Class dlgInfillMissingValues resources.ApplyResources(Me.ucrInputConstant, "ucrInputConstant") Me.ucrInputConstant.Name = "ucrInputConstant" ' - 'lblFunction + 'ucrReceiverByFactor ' - resources.ApplyResources(Me.lblFunction, "lblFunction") - Me.lblFunction.Name = "lblFunction" + Me.ucrReceiverByFactor.frmParent = Me + resources.ApplyResources(Me.ucrReceiverByFactor, "ucrReceiverByFactor") + Me.ucrReceiverByFactor.Name = "ucrReceiverByFactor" + Me.ucrReceiverByFactor.Selector = Nothing + Me.ucrReceiverByFactor.strNcFilePath = "" + Me.ucrReceiverByFactor.ucrSelector = Nothing ' - 'lblRows + 'ucrReceiverStation ' - resources.ApplyResources(Me.lblRows, "lblRows") - Me.lblRows.Name = "lblRows" + Me.ucrReceiverStation.frmParent = Me + resources.ApplyResources(Me.ucrReceiverStation, "ucrReceiverStation") + Me.ucrReceiverStation.Name = "ucrReceiverStation" + Me.ucrReceiverStation.Selector = Nothing + Me.ucrReceiverStation.strNcFilePath = "" + Me.ucrReceiverStation.ucrSelector = Nothing ' 'ucrChkSetSeed ' @@ -252,6 +265,11 @@ Partial Class dlgInfillMissingValues resources.ApplyResources(Me.ucrChkCopyFromBelow, "ucrChkCopyFromBelow") Me.ucrChkCopyFromBelow.Name = "ucrChkCopyFromBelow" ' + 'ucrPnlStartEnd + ' + resources.ApplyResources(Me.ucrPnlStartEnd, "ucrPnlStartEnd") + Me.ucrPnlStartEnd.Name = "ucrPnlStartEnd" + ' 'ucrSaveNewColumn ' resources.ApplyResources(Me.ucrSaveNewColumn, "ucrSaveNewColumn") @@ -260,6 +278,7 @@ Partial Class dlgInfillMissingValues 'ucrInputComboFunction ' Me.ucrInputComboFunction.AddQuotesIfUnrecognised = True + Me.ucrInputComboFunction.GetSetSelectedIndex = -1 Me.ucrInputComboFunction.IsReadOnly = False resources.ApplyResources(Me.ucrInputComboFunction, "ucrInputComboFunction") Me.ucrInputComboFunction.Name = "ucrInputComboFunction" @@ -291,28 +310,10 @@ Partial Class dlgInfillMissingValues resources.ApplyResources(Me.ucrPnlOptions, "ucrPnlOptions") Me.ucrPnlOptions.Name = "ucrPnlOptions" ' - 'ucrReceiverStation - ' - Me.ucrReceiverStation.frmParent = Me - resources.ApplyResources(Me.ucrReceiverStation, "ucrReceiverStation") - Me.ucrReceiverStation.Name = "ucrReceiverStation" - Me.ucrReceiverStation.Selector = Nothing - Me.ucrReceiverStation.strNcFilePath = "" - Me.ucrReceiverStation.ucrSelector = Nothing - ' - 'ucrReceiverByFactor - ' - Me.ucrReceiverByFactor.frmParent = Me - resources.ApplyResources(Me.ucrReceiverByFactor, "ucrReceiverByFactor") - Me.ucrReceiverByFactor.Name = "ucrReceiverByFactor" - Me.ucrReceiverByFactor.Selector = Nothing - Me.ucrReceiverByFactor.strNcFilePath = "" - Me.ucrReceiverByFactor.ucrSelector = Nothing - ' - 'lblStation + 'ucrPnlMethods ' - resources.ApplyResources(Me.lblStation, "lblStation") - Me.lblStation.Name = "lblStation" + resources.ApplyResources(Me.ucrPnlMethods, "ucrPnlMethods") + Me.ucrPnlMethods.Name = "ucrPnlMethods" ' 'dlgInfillMissingValues ' diff --git a/instat/dlgInfillMissingValues.resx b/instat/dlgInfillMissingValues.resx index 2fe3738127b..789284c8a41 100644 --- a/instat/dlgInfillMissingValues.resx +++ b/instat/dlgInfillMissingValues.resx @@ -438,15 +438,6 @@ 16 - - 6, 15 - - - 177, 71 - - - 17 - ucrPnlMethods @@ -483,24 +474,6 @@ 24 - - True - - - NoControl - - - 11, 39 - - - 73, 17 - - - 13 - - - Extend Fill - rdoExtendFill @@ -513,24 +486,6 @@ 0 - - True - - - NoControl - - - 11, 16 - - - 107, 17 - - - 12 - - - Leave as Missing - rdoLeaveAsMissing @@ -543,15 +498,6 @@ 1 - - 6, 15 - - - 118, 44 - - - 18 - ucrPnlStartEnd @@ -588,6 +534,66 @@ 12 + + True + + + NoControl + + + 11, 39 + + + 73, 17 + + + 13 + + + Extend Fill + + + rdoExtendFill + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + grpStartEnd + + + 0 + + + True + + + NoControl + + + 11, 16 + + + 107, 17 + + + 12 + + + Leave as Missing + + + rdoLeaveAsMissing + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + grpStartEnd + + + 1 + True @@ -618,27 +624,6 @@ 0 - - 279, 384 - - - 47, 21 - - - 19 - - - ucrInputConstant - - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 2 - True @@ -676,7 +661,7 @@ NoControl - 141, 283 + 159, 283 35, 13 @@ -699,6 +684,90 @@ 7 + + True + + + NoControl + + + 281, 82 + + + 43, 13 + + + 5 + + + Station: + + + lblStation + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 279, 384 + + + 47, 21 + + + 19 + + + ucrInputConstant + + + instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 2 + + + True + + + 6, 13 + + + 421, 540 + + + 281, 98 + + + 0, 0, 0, 0 + + + 120, 20 + + + 6 + + + ucrReceiverStation + + + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + 146, 427 @@ -742,7 +811,7 @@ 6 - 92, 279 + 110, 279 48, 20 @@ -766,7 +835,7 @@ 12, 280 - 76, 20 + 96, 20 11 @@ -870,92 +939,29 @@ 15 - - True - - - 6, 13 - - - 421, 540 - - - True - - - NoControl - - - 281, 82 - - - 43, 13 - - - 5 - - - Station: - - - lblStation - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - 281, 207 - - - 0, 0, 0, 0 - - - 120, 100 - - - 10 - - - ucrReceiverByFactor - - - instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 3 - - - 281, 98 + + 281, 149 - + 0, 0, 0, 0 - + 120, 20 - - 6 + + 8 - - ucrReceiverStation + + ucrReceiverElement - + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - - 4 + + 20 12, 483 @@ -1023,6 +1029,9 @@ 23 + + NoControl + CenterScreen @@ -1035,28 +1044,70 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 281, 149 + + 281, 207 - + 0, 0, 0, 0 - - 120, 20 + + 120, 100 - - 8 + + 10 - - ucrReceiverElement + + ucrReceiverByFactor - - instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - - 20 + + 3 + + + 6, 15 + + + 118, 44 + + + 18 + + + ucrPnlStartEnd + + + instat.UcrPanel, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + grpStartEnd + + + 2 + + + 6, 15 + + + 177, 71 + + + 17 + + + ucrPnlMethods + + + instat.UcrPanel, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + grpMethods + + + 6 \ No newline at end of file diff --git a/instat/dlgInfillMissingValues.vb b/instat/dlgInfillMissingValues.vb index 09d9110a288..6e7d737c3f4 100644 --- a/instat/dlgInfillMissingValues.vb +++ b/instat/dlgInfillMissingValues.vb @@ -92,7 +92,7 @@ Public Class dlgInfillMissingValues ucrChkBy.AddParameterPresentCondition(True, "by") ucrChkBy.AddParameterPresentCondition(False, "by", False) - ucrChkMaxGap.SetText("Max Gap:") + ucrChkMaxGap.SetText("Maximum Gap:") ucrChkMaxGap.AddParameterPresentCondition(True, "maxgap") ucrChkMaxGap.AddParameterPresentCondition(False, "maxgap", False) @@ -120,7 +120,7 @@ Public Class dlgInfillMissingValues ucrPnlMethods.AddToLinkedControls(ucrChkCopyFromBelow, {rdoNaLocf}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlMethods.AddToLinkedControls(ucrChkBy, {rdoNaAggregate}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrChkBy.AddToLinkedControls(ucrReceiverByFactor, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrChkMaxGap.AddToLinkedControls(ucrNudMaximum, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=1) + ucrChkMaxGap.AddToLinkedControls(ucrNudMaximum, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrInputComboFunction.AddToLinkedControls(ucrChkSetSeed, {"Sample"}, bNewLinkedHideIfParameterMissing:=True) ucrChkSetSeed.AddToLinkedControls(ucrNudSetSeed, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=1) ucrInputComboFunction.SetLinkedDisplayControl(lblFunction) @@ -159,6 +159,7 @@ Public Class dlgInfillMissingValues clsApproximateFunction.SetRCommand("na.approx") clsApproximateFunction.AddParameter("x", "x", iPosition:=0, bIncludeArgumentName:=False) clsApproximateFunction.AddParameter("rule", 2, iPosition:=1) + clsApproximateFunction.AddParameter("maxgap", 10, iPosition:=5) clsAggregateFunction.SetPackageName("zoo") clsAggregateFunction.SetRCommand("na.aggregate") @@ -178,9 +179,11 @@ Public Class dlgInfillMissingValues clsNaFillFunction.SetRCommand("na.fill") clsNaFillFunction.AddParameter("x", "x", iPosition:=0, bIncludeArgumentName:=False) - clsStructTSFunction.SetPackageName("zoo") - clsStructTSFunction.SetRCommand("na.StructTS") - clsStructTSFunction.AddParameter("object", clsRFunctionParameter:=clsZooRegFunction, iPosition:=1) + clsStructTSFunction.SetPackageName("imputeTS") + clsStructTSFunction.SetRCommand("na_kalman") + clsStructTSFunction.AddParameter("x", "x", iPosition:=0, bIncludeArgumentName:=False) + clsStructTSFunction.AddParameter("model", Chr(34) & "StructTS" & Chr(34), iPosition:=1) + clsStructTSFunction.AddParameter("smooth", "TRUE", iPosition:=2) clsZooRegFunction.SetPackageName("zoo") clsZooRegFunction.SetRCommand("zooreg") @@ -218,7 +221,7 @@ Public Class dlgInfillMissingValues ucrChkCopyFromBelow.SetRCode(clsNaLocfFunction, bReset) ucrChkBy.SetRCode(clsAggregateFunction, bReset) ucrNudMaximum.SetRCode(clsApproximateFunction, bReset) - ucrChkMaxGap.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrChkMaxGap.SetRCode(clsApproximateFunction, bReset) ucrNudSetSeed.SetRCode(clsSetSeedFunction, bReset) ucrChkSetSeed.SetRSyntax(ucrBase.clsRsyntax, bReset) diff --git a/instat/dlgRestrict.resx b/instat/dlgRestrict.resx index 96d79b09526..916af023224 100644 --- a/instat/dlgRestrict.resx +++ b/instat/dlgRestrict.resx @@ -225,9 +225,6 @@ 418, 388 - - False - NoControl @@ -361,7 +358,7 @@ 10, 197 - 378, 53 + 396, 53 4 @@ -382,10 +379,10 @@ 3 - 163, 284 + 129, 284 - 246, 42 + 277, 43 7 @@ -406,7 +403,7 @@ 10, 285 - 147, 13 + 118, 22 6 diff --git a/instat/dlgRestrict.vb b/instat/dlgRestrict.vb index 9f24bf75235..5d4a0914d8e 100644 --- a/instat/dlgRestrict.vb +++ b/instat/dlgRestrict.vb @@ -26,6 +26,7 @@ Public Class dlgRestrict Public strDefaultDataframe As String = "" Public strDefaultColumn As String = "" Public bAutoOpenSubDialog As Boolean = False + Private bResetSubdialog = False Public Sub New() ' This call is required by the designer. @@ -68,10 +69,10 @@ Public Class dlgRestrict 'rdoApplyAsSubset.Enabled = False ' ucrSave - ucrNewDataFrameName.SetIsTextBox() ucrNewDataFrameName.SetSaveTypeAsDataFrame() ucrNewDataFrameName.SetLabelText("New Data Frame Name:") ucrNewDataFrameName.SetDataFrameSelector(ucrSelectorFilter.ucrAvailableDataFrames) + ucrNewDataFrameName.SetIsTextBox() End Sub Private Sub SetDefaults() @@ -80,6 +81,7 @@ Public Class dlgRestrict SetDefaultNewDataFrameName() SetFilterSubsetStatus() SetDefaultDataFrame() + bResetSubdialog = True 'ucrNewDataFrameName.Visible = False 'temporarily while we have disabled the option to get a new dataframe 'lblNewDataFrameName.Visible = False 'temporarily while we have disabled the option to get a new dataframe End Sub @@ -213,6 +215,9 @@ Public Class dlgRestrict End Sub Private Sub cmdFilterFromFactors_Click(sender As Object, e As EventArgs) Handles cmdFilterFromFactors.Click - 'sdgFiltersFromFactor.ShowDialog() 'currently work in progress will soon be enabled! + sdgFiltersFromFactor.SetRcodeAndDefaultDataFrame(ucrSelectorFilter, bReset:=bResetSubdialog) + sdgFiltersFromFactor.ShowDialog() + bResetSubdialog = False + ucrSelectorFilter.LoadList() End Sub End Class \ No newline at end of file diff --git a/instat/dlgVisualizeData.Designer.vb b/instat/dlgVisualizeData.Designer.vb index 8ceab7c7554..bee99d8964d 100644 --- a/instat/dlgVisualizeData.Designer.vb +++ b/instat/dlgVisualizeData.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class dlgVisualizeData Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,33 +20,179 @@ Partial Class dlgVisualizeData '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.ucrBase = New instat.ucrButtons() + Me.ucrSelectorVisualizeData = New instat.ucrSelectorByDataFrameAddRemove() + Me.ucrSaveGraph = New instat.ucrSave() + Me.ucrPnlVisualizeData = New instat.UcrPanel() + Me.rdoVisDat = New System.Windows.Forms.RadioButton() + Me.rdoVisMiss = New System.Windows.Forms.RadioButton() + Me.rdoVisGuess = New System.Windows.Forms.RadioButton() + Me.ucrPnlSelectData = New instat.UcrPanel() + Me.rdoWholeDataFrame = New System.Windows.Forms.RadioButton() + Me.rdoSelectedColumn = New System.Windows.Forms.RadioButton() + Me.ucrReceiverVisualizeData = New instat.ucrReceiverMultiple() Me.SuspendLayout() ' 'ucrBase ' - Me.ucrBase.Location = New System.Drawing.Point(2, 210) + Me.ucrBase.Location = New System.Drawing.Point(10, 267) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(410, 52) - Me.ucrBase.TabIndex = 0 + Me.ucrBase.TabIndex = 10 + ' + 'ucrSelectorVisualizeData + ' + Me.ucrSelectorVisualizeData.bDropUnusedFilterLevels = False + Me.ucrSelectorVisualizeData.bShowHiddenColumns = False + Me.ucrSelectorVisualizeData.bUseCurrentFilter = True + Me.ucrSelectorVisualizeData.Location = New System.Drawing.Point(10, 50) + Me.ucrSelectorVisualizeData.Margin = New System.Windows.Forms.Padding(0) + Me.ucrSelectorVisualizeData.Name = "ucrSelectorVisualizeData" + Me.ucrSelectorVisualizeData.Size = New System.Drawing.Size(210, 180) + Me.ucrSelectorVisualizeData.TabIndex = 4 + ' + 'ucrSaveGraph + ' + Me.ucrSaveGraph.Location = New System.Drawing.Point(10, 238) + Me.ucrSaveGraph.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.ucrSaveGraph.Name = "ucrSaveGraph" + Me.ucrSaveGraph.Size = New System.Drawing.Size(264, 24) + Me.ucrSaveGraph.TabIndex = 9 + ' + 'ucrPnlVisualizeData + ' + Me.ucrPnlVisualizeData.Location = New System.Drawing.Point(44, 1) + Me.ucrPnlVisualizeData.Name = "ucrPnlVisualizeData" + Me.ucrPnlVisualizeData.Size = New System.Drawing.Size(324, 46) + Me.ucrPnlVisualizeData.TabIndex = 0 + ' + 'rdoVisDat + ' + Me.rdoVisDat.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoVisDat.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisDat.FlatAppearance.BorderSize = 2 + Me.rdoVisDat.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisDat.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoVisDat.Location = New System.Drawing.Point(60, 11) + Me.rdoVisDat.Name = "rdoVisDat" + Me.rdoVisDat.Size = New System.Drawing.Size(100, 28) + Me.rdoVisDat.TabIndex = 1 + Me.rdoVisDat.TabStop = True + Me.rdoVisDat.Text = "Data" + Me.rdoVisDat.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoVisDat.UseVisualStyleBackColor = True + ' + 'rdoVisMiss + ' + Me.rdoVisMiss.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoVisMiss.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisMiss.FlatAppearance.BorderSize = 2 + Me.rdoVisMiss.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisMiss.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoVisMiss.Location = New System.Drawing.Point(156, 11) + Me.rdoVisMiss.Name = "rdoVisMiss" + Me.rdoVisMiss.Size = New System.Drawing.Size(100, 28) + Me.rdoVisMiss.TabIndex = 2 + Me.rdoVisMiss.TabStop = True + Me.rdoVisMiss.Text = "Missing" + Me.rdoVisMiss.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoVisMiss.UseVisualStyleBackColor = True + ' + 'rdoVisGuess + ' + Me.rdoVisGuess.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoVisGuess.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisGuess.FlatAppearance.BorderSize = 2 + Me.rdoVisGuess.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoVisGuess.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoVisGuess.Location = New System.Drawing.Point(252, 11) + Me.rdoVisGuess.Name = "rdoVisGuess" + Me.rdoVisGuess.Size = New System.Drawing.Size(100, 28) + Me.rdoVisGuess.TabIndex = 3 + Me.rdoVisGuess.TabStop = True + Me.rdoVisGuess.Text = "Guess" + Me.rdoVisGuess.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoVisGuess.UseVisualStyleBackColor = True + ' + 'ucrPnlSelectData + ' + Me.ucrPnlSelectData.Location = New System.Drawing.Point(235, 80) + Me.ucrPnlSelectData.Name = "ucrPnlSelectData" + Me.ucrPnlSelectData.Size = New System.Drawing.Size(133, 40) + Me.ucrPnlSelectData.TabIndex = 5 + ' + 'rdoWholeDataFrame + ' + Me.rdoWholeDataFrame.AutoSize = True + Me.rdoWholeDataFrame.Location = New System.Drawing.Point(243, 80) + Me.rdoWholeDataFrame.Name = "rdoWholeDataFrame" + Me.rdoWholeDataFrame.Size = New System.Drawing.Size(80, 17) + Me.rdoWholeDataFrame.TabIndex = 6 + Me.rdoWholeDataFrame.TabStop = True + Me.rdoWholeDataFrame.Text = "Data Frame" + Me.rdoWholeDataFrame.UseVisualStyleBackColor = True + ' + 'rdoSelectedColumn + ' + Me.rdoSelectedColumn.AutoSize = True + Me.rdoSelectedColumn.Location = New System.Drawing.Point(243, 103) + Me.rdoSelectedColumn.Name = "rdoSelectedColumn" + Me.rdoSelectedColumn.Size = New System.Drawing.Size(113, 17) + Me.rdoSelectedColumn.TabIndex = 7 + Me.rdoSelectedColumn.TabStop = True + Me.rdoSelectedColumn.Text = "Selected Variables" + Me.rdoSelectedColumn.UseVisualStyleBackColor = True + ' + 'ucrReceiverVisualizeData + ' + Me.ucrReceiverVisualizeData.frmParent = Me + Me.ucrReceiverVisualizeData.Location = New System.Drawing.Point(243, 130) + Me.ucrReceiverVisualizeData.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverVisualizeData.Name = "ucrReceiverVisualizeData" + Me.ucrReceiverVisualizeData.Selector = Nothing + Me.ucrReceiverVisualizeData.Size = New System.Drawing.Size(120, 100) + Me.ucrReceiverVisualizeData.strNcFilePath = "" + Me.ucrReceiverVisualizeData.TabIndex = 8 + Me.ucrReceiverVisualizeData.ucrSelector = Nothing ' 'dlgVisualizeData ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(413, 265) + Me.ClientSize = New System.Drawing.Size(417, 324) + Me.Controls.Add(Me.ucrReceiverVisualizeData) + Me.Controls.Add(Me.rdoSelectedColumn) + Me.Controls.Add(Me.rdoWholeDataFrame) + Me.Controls.Add(Me.ucrPnlSelectData) + Me.Controls.Add(Me.rdoVisGuess) + Me.Controls.Add(Me.rdoVisMiss) + Me.Controls.Add(Me.rdoVisDat) + Me.Controls.Add(Me.ucrPnlVisualizeData) + Me.Controls.Add(Me.ucrSaveGraph) + Me.Controls.Add(Me.ucrSelectorVisualizeData) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgVisualizeData" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen - Me.Text = "Visualize Data" + Me.Text = "Visualise Data" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents ucrBase As ucrButtons -End Class + Friend WithEvents ucrSelectorVisualizeData As ucrSelectorByDataFrameAddRemove + Friend WithEvents ucrSaveGraph As ucrSave + Friend WithEvents ucrPnlVisualizeData As UcrPanel + Friend WithEvents rdoVisDat As RadioButton + Friend WithEvents rdoVisMiss As RadioButton + Friend WithEvents rdoVisGuess As RadioButton + Friend WithEvents ucrPnlSelectData As UcrPanel + Friend WithEvents rdoWholeDataFrame As RadioButton + Friend WithEvents rdoSelectedColumn As RadioButton + Friend WithEvents ucrReceiverVisualizeData As ucrReceiverMultiple +End Class \ No newline at end of file diff --git a/instat/dlgVisualizeData.vb b/instat/dlgVisualizeData.vb index 2c353102019..ca8b4a3e21b 100644 --- a/instat/dlgVisualizeData.vb +++ b/instat/dlgVisualizeData.vb @@ -1,3 +1,175 @@ -Public Class dlgVisualizeData +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . +Imports instat.Translations + +Public Class dlgVisualizeData + Private bFirstLoad As Boolean = True + Private bReset As Boolean = True + Private clsVisDatFunction As New RFunction + Private clsVisMissFunction As New RFunction + Private clsVisGuessFunction As New RFunction + Private clsCurrBaseFunction As New RFunction + + Private Sub dlgVisualizeData_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If bFirstLoad Then + InitialiseDialog() + bFirstLoad = False + End If + If bReset Then + SetDefaults() + End If + SetRCodeForControls(bReset) + bReset = False + autoTranslate(Me) + TestOkEnabled() + End Sub + + Private Sub InitialiseDialog() + ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False + ucrBase.clsRsyntax.iCallType = 3 + + ucrPnlVisualizeData.AddRadioButton(rdoVisDat) + ucrPnlVisualizeData.AddRadioButton(rdoVisMiss) + ucrPnlVisualizeData.AddRadioButton(rdoVisGuess) + + ucrPnlVisualizeData.AddFunctionNamesCondition(rdoVisDat, "vis_dat") + ucrPnlVisualizeData.AddFunctionNamesCondition(rdoVisMiss, "vis_miss") + ucrPnlVisualizeData.AddFunctionNamesCondition(rdoVisGuess, "vis_guess") + + ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame) + ucrPnlSelectData.AddRadioButton(rdoSelectedColumn) + + ucrPnlSelectData.AddParameterPresentCondition(rdoWholeDataFrame, "data") + ucrPnlSelectData.AddParameterPresentCondition(rdoSelectedColumn, "x") + + ucrReceiverVisualizeData.SetParameter(New RParameter("x", 0)) + ucrReceiverVisualizeData.SetParameterIsRFunction() + ucrReceiverVisualizeData.Selector = ucrSelectorVisualizeData + ucrReceiverVisualizeData.bForceAsDataFrame = True + ucrReceiverVisualizeData.SetMeAsReceiver() + + ucrPnlSelectData.AddToLinkedControls(ucrReceiverVisualizeData, {rdoSelectedColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + + ucrSaveGraph.SetIsComboBox() + ucrSaveGraph.SetCheckBoxText("Save Graph") + ucrSaveGraph.SetSaveTypeAsGraph() + ucrSaveGraph.SetDataFrameSelector(ucrSelectorVisualizeData.ucrAvailableDataFrames) + ucrSaveGraph.SetAssignToIfUncheckedValue("last_graph") + End Sub + + Private Sub SetDefaults() + clsVisDatFunction = New RFunction + clsVisMissFunction = New RFunction + clsVisGuessFunction = New RFunction + + ucrSelectorVisualizeData.Reset() + ucrSaveGraph.Reset() + + clsCurrBaseFunction = clsVisDatFunction + + clsVisDatFunction.SetPackageName("visdat") + clsVisDatFunction.SetRCommand("vis_dat") + clsVisDatFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorVisualizeData.ucrAvailableDataFrames.clsCurrDataFrame, bIncludeArgumentName:=False, iPosition:=0) + clsVisDatFunction.AddParameter("sort_type", "TRUE", iPosition:=1) + clsVisDatFunction.AddParameter("palette", Chr(34) & "default" & Chr(34), iPosition:=2) + clsVisDatFunction.AddParameter("warn_large_data", "TRUE", iPosition:=3) + clsVisDatFunction.AddParameter("large_data_size", 900000, iPosition:=4) + + clsVisMissFunction.SetPackageName("visdat") + clsVisMissFunction.SetRCommand("vis_miss") + clsVisMissFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorVisualizeData.ucrAvailableDataFrames.clsCurrDataFrame, bIncludeArgumentName:=False, iPosition:=0) + clsVisMissFunction.AddParameter("cluster", "FALSE", iPosition:=1) + clsVisMissFunction.AddParameter("sort_miss", "FALSE", iPosition:=2) + clsVisMissFunction.AddParameter("show_perc", "TRUE", iPosition:=3) + clsVisMissFunction.AddParameter("show_perc_col", "TRUE", iPosition:=4) + clsVisMissFunction.AddParameter("large_data_size", 900000, iPosition:=5) + clsVisMissFunction.AddParameter("warn_large_data", "TRUE", iPosition:=6) + + clsVisGuessFunction.SetPackageName("visdat") + clsVisGuessFunction.SetRCommand("vis_guess") + clsVisGuessFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorVisualizeData.ucrAvailableDataFrames.clsCurrDataFrame, bIncludeArgumentName:=False, iPosition:=0) + clsVisGuessFunction.AddParameter("palette", Chr(34) & "default" & Chr(34), iPosition:=1) + + clsCurrBaseFunction.SetAssignTo("last_graph", strTempDataframe:=ucrSelectorVisualizeData.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph") + ucrBase.clsRsyntax.SetBaseRFunction(clsCurrBaseFunction) + End Sub + + Private Sub SetRCodeForControls(bReset As Boolean) + ucrReceiverVisualizeData.AddAdditionalCodeParameterPair(clsVisMissFunction, New RParameter("x", 0), 1) + ucrReceiverVisualizeData.AddAdditionalCodeParameterPair(clsVisGuessFunction, New RParameter("x", 0), 2) + ucrSaveGraph.AddAdditionalRCode(clsVisMissFunction, iAdditionalPairNo:=1) + ucrSaveGraph.AddAdditionalRCode(clsVisGuessFunction, iAdditionalPairNo:=2) + + ucrPnlSelectData.SetRCode(clsCurrBaseFunction, bReset) + ucrPnlVisualizeData.SetRCode(clsCurrBaseFunction, bReset) + ucrReceiverVisualizeData.SetRCode(clsVisDatFunction, bReset) + ucrSaveGraph.SetRCode(clsVisDatFunction, bReset) + End Sub + + Private Sub TestOkEnabled() + If ucrSelectorVisualizeData.ucrAvailableDataFrames.cboAvailableDataFrames.Text = "" OrElse (rdoSelectedColumn.Checked AndAlso ucrReceiverVisualizeData.IsEmpty) OrElse Not ucrSaveGraph.IsComplete() Then + ucrBase.OKEnabled(False) + Else + ucrBase.OKEnabled(True) + End If + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + SetRCodeForControls(True) + TestOkEnabled() + End Sub + + Private Sub ucrCore_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverVisualizeData.ControlContentsChanged, ucrSelectorVisualizeData.ControlContentsChanged, ucrPnlSelectData.ControlContentsChanged, ucrSaveGraph.ControlContentsChanged + TestOkEnabled() + End Sub + + Private Sub ucrPnlVisualizeData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlVisualizeData.ControlValueChanged + If rdoVisDat.Checked Then + ucrSaveGraph.SetPrefix("vis_dat") + clsCurrBaseFunction = clsVisDatFunction + ElseIf rdoVisMiss.Checked Then + ucrSaveGraph.SetPrefix("vis_miss") + clsCurrBaseFunction = clsVisMissFunction + ElseIf rdoVisGuess.Checked Then + ucrSaveGraph.SetPrefix("vis_guess") + clsCurrBaseFunction = clsVisGuessFunction + End If + ucrBase.clsRsyntax.SetBaseRFunction(clsCurrBaseFunction) + AddRemoveDataHideOptionsButtons() + End Sub + + Private Sub AddRemoveDataHideOptionsButtons() + If rdoWholeDataFrame.Checked Then + clsCurrBaseFunction.RemoveParameterByName("x") + ucrSelectorVisualizeData.lstAvailableVariable.Visible = False + ucrSelectorVisualizeData.btnAdd.Visible = False + ucrSelectorVisualizeData.btnDataOptions.Visible = False + clsCurrBaseFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorVisualizeData.ucrAvailableDataFrames.clsCurrDataFrame, bIncludeArgumentName:=False, iPosition:=0) + ElseIf rdoSelectedColumn.Checked Then + clsCurrBaseFunction.RemoveParameterByName("data") + ucrSelectorVisualizeData.lstAvailableVariable.Visible = True + ucrSelectorVisualizeData.btnAdd.Visible = True + ucrSelectorVisualizeData.btnDataOptions.Visible = True + clsCurrBaseFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverVisualizeData.GetVariables(), iPosition:=0) + End If + End Sub + + Private Sub ucrControls_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlSelectData.ControlValueChanged, ucrSelectorVisualizeData.ControlValueChanged, ucrReceiverVisualizeData.ControlValueChanged + AddRemoveDataHideOptionsButtons() + End Sub End Class \ No newline at end of file diff --git a/instat/frmMain.resx b/instat/frmMain.resx index ab9c03ee769..ad3b44dcc04 100644 --- a/instat/frmMain.resx +++ b/instat/frmMain.resx @@ -1209,46 +1209,46 @@ Check Data - 180, 22 + 178, 22 Inventory... - 180, 22 + 178, 22 Fill Missing Values... - 177, 6 + 175, 6 - 180, 22 + 178, 22 Display Daily... - 180, 22 + 178, 22 Boxplot... - 180, 22 + 178, 22 QC Temperatures... - 180, 22 + 178, 22 QC Rainfall... - 180, 22 + 178, 22 Homogenization... @@ -2604,99 +2604,6 @@ Data Frame - - 245, 22 - - - Visualise Data - - - 245, 22 - - - Duplicates... - - - 245, 22 - - - Compare Columns... - - - 245, 22 - - - Non-numeric Cases... - - - 242, 6 - - - 245, 22 - - - Boxplot... - - - 245, 22 - - - One Variable Summarise... - - - 245, 22 - - - One Variable Graph... - - - 245, 22 - - - One Variable Frequencies... - - - 242, 6 - - - 245, 22 - - - Export To OpenRefine... - - - 245, 22 - - - Import From OpenRefine... - - - 242, 6 - - - False - - - 245, 22 - - - Jitter... - - - False - - - 245, 22 - - - Prepare to Share (sdc package)... - - - 245, 22 - - - Anonymise ID Column... - 180, 22 @@ -2760,6 +2667,84 @@ Keys and Links + + False + + + 196, 22 + + + Data Frame Metadata... + + + 196, 22 + + + Rename Data Frame... + + + False + + + 196, 22 + + + Reorder Data Frames... + + + 196, 22 + + + Copy Data Frame... + + + 196, 22 + + + Delete Data Frames... + + + 193, 6 + + + 210, 22 + + + Hide/Show Data Frames... + + + 196, 22 + + + Metadata... + + + False + + + 196, 22 + + + Rename Metadata... + + + False + + + 196, 22 + + + Reorder Metadata... + + + False + + + 196, 22 + + + Delete Metadata... + 180, 22 @@ -3045,6 +3030,99 @@ Colour by Property... + + 245, 22 + + + Visualise Data + + + 245, 22 + + + Duplicates... + + + 245, 22 + + + Compare Columns... + + + 245, 22 + + + Non-numeric Cases... + + + 242, 6 + + + 245, 22 + + + Boxplot... + + + 245, 22 + + + One Variable Summarise... + + + 245, 22 + + + One Variable Graph... + + + 245, 22 + + + One Variable Frequencies... + + + 242, 6 + + + 245, 22 + + + Export To OpenRefine... + + + 245, 22 + + + Import From OpenRefine... + + + 242, 6 + + + False + + + 245, 22 + + + Jitter... + + + False + + + 245, 22 + + + Prepare to Share (sdc package)... + + + 245, 22 + + + Anonymise ID Column... + 179, 22 @@ -3372,84 +3450,6 @@ Add Comment... - - False - - - 196, 22 - - - Data Frame Metadata... - - - 196, 22 - - - Rename Data Frame... - - - False - - - 196, 22 - - - Reorder Data Frames... - - - 196, 22 - - - Copy Data Frame... - - - 196, 22 - - - Delete Data Frames... - - - 193, 6 - - - 196, 22 - - - Hide Dataframes... - - - 196, 22 - - - Metadata... - - - False - - - 196, 22 - - - Rename Metadata... - - - False - - - 196, 22 - - - Reorder Metadata... - - - False - - - 196, 22 - - - Delete Metadata... - 126, 22 diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 5c5b162603e..11e81a3cc88 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -196,6 +196,12 @@ Form + + dlgClimsoftWizard.vb + + + Form + dlgCompareSummary.vb @@ -2539,6 +2545,9 @@ dlgCircular.vb + + dlgClimsoftWizard.vb + dlgCompareSummary.vb @@ -2555,6 +2564,12 @@ dlgTaylorDiagram.vb + + sdgExtremesDisplayOptions.vb + + + sdgExtremesMethod.vb + sdgFiltersFromFactor.vb diff --git a/instat/sdgExtremesDisplayOptions.Designer.vb b/instat/sdgExtremesDisplayOptions.Designer.vb index 76873d79fd2..e5ac1ea3aad 100644 --- a/instat/sdgExtremesDisplayOptions.Designer.vb +++ b/instat/sdgExtremesDisplayOptions.Designer.vb @@ -22,9 +22,20 @@ Partial Class sdgExtremesDisplayOptions 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - components = New System.ComponentModel.Container + Me.SuspendLayout() + ' + 'sdgExtremesDisplayOptions + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(800, 450) + Me.ClientSize = New System.Drawing.Size(323, 385) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgExtremesDisplayOptions" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "sdgExtremesDisplayOptions" + Me.ResumeLayout(False) + End Sub End Class diff --git a/instat/sdgExtremesDisplayOptions.resx b/instat/sdgExtremesDisplayOptions.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgExtremesDisplayOptions.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/sdgExtremesMethod.Designer.vb b/instat/sdgExtremesMethod.Designer.vb index 0edcdb888ac..a821267ee7e 100644 --- a/instat/sdgExtremesMethod.Designer.vb +++ b/instat/sdgExtremesMethod.Designer.vb @@ -22,9 +22,20 @@ Partial Class sdgExtremesMethod 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - components = New System.ComponentModel.Container + Me.SuspendLayout() + ' + 'sdgExtremesMethod + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(800, 450) + Me.ClientSize = New System.Drawing.Size(362, 450) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgExtremesMethod" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "sdgExtremesMethod" + Me.ResumeLayout(False) + End Sub End Class diff --git a/instat/sdgExtremesMethod.resx b/instat/sdgExtremesMethod.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgExtremesMethod.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/sdgFiltersFromFactor.Designer.vb b/instat/sdgFiltersFromFactor.Designer.vb index f1e91363110..957b7f5c7f0 100644 --- a/instat/sdgFiltersFromFactor.Designer.vb +++ b/instat/sdgFiltersFromFactor.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class sdgFiltersFromFactor Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,10 +20,15 @@ Partial Class sdgFiltersFromFactor '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() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(sdgFiltersFromFactor)) Me.ucrBase = New instat.ucrButtonsSubdialogue() + Me.ucrSelectorFiltersFromFactors = New instat.ucrSelectorByDataFrameAddRemove() + Me.ucrReceiverFactor = New instat.ucrReceiverSingle() + Me.lblFactors = New System.Windows.Forms.Label() + Me.ucrFactorLevels = New instat.ucrFactor() + Me.cmdSelectAll = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'ucrBase @@ -31,18 +36,66 @@ Partial Class sdgFiltersFromFactor resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' + 'ucrSelectorFiltersFromFactors + ' + Me.ucrSelectorFiltersFromFactors.bDropUnusedFilterLevels = False + Me.ucrSelectorFiltersFromFactors.bShowHiddenColumns = False + Me.ucrSelectorFiltersFromFactors.bUseCurrentFilter = True + resources.ApplyResources(Me.ucrSelectorFiltersFromFactors, "ucrSelectorFiltersFromFactors") + Me.ucrSelectorFiltersFromFactors.Name = "ucrSelectorFiltersFromFactors" + ' + 'ucrReceiverFactor + ' + Me.ucrReceiverFactor.frmParent = Me + resources.ApplyResources(Me.ucrReceiverFactor, "ucrReceiverFactor") + Me.ucrReceiverFactor.Name = "ucrReceiverFactor" + Me.ucrReceiverFactor.Selector = Nothing + Me.ucrReceiverFactor.strNcFilePath = "" + Me.ucrReceiverFactor.ucrSelector = Nothing + ' + 'lblFactors + ' + resources.ApplyResources(Me.lblFactors, "lblFactors") + Me.lblFactors.Name = "lblFactors" + ' + 'ucrFactorLevels + ' + resources.ApplyResources(Me.ucrFactorLevels, "ucrFactorLevels") + Me.ucrFactorLevels.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.ucrFactorLevels.clsReceiver = Nothing + Me.ucrFactorLevels.Name = "ucrFactorLevels" + Me.ucrFactorLevels.shtCurrSheet = Nothing + Me.ucrFactorLevels.ucrChkLevels = Nothing + ' + 'cmdSelectAll + ' + resources.ApplyResources(Me.cmdSelectAll, "cmdSelectAll") + Me.cmdSelectAll.Name = "cmdSelectAll" + Me.cmdSelectAll.UseVisualStyleBackColor = True + ' 'sdgFiltersFromFactor ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.cmdSelectAll) + Me.Controls.Add(Me.ucrFactorLevels) + Me.Controls.Add(Me.lblFactors) + Me.Controls.Add(Me.ucrReceiverFactor) + Me.Controls.Add(Me.ucrSelectorFiltersFromFactors) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "sdgFiltersFromFactor" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents ucrBase As ucrButtonsSubdialogue + Friend WithEvents ucrSelectorFiltersFromFactors As ucrSelectorByDataFrameAddRemove + Friend WithEvents ucrReceiverFactor As ucrReceiverSingle + Friend WithEvents lblFactors As Label + Friend WithEvents ucrFactorLevels As ucrFactor + Friend WithEvents cmdSelectAll As Button End Class diff --git a/instat/sdgFiltersFromFactor.resx b/instat/sdgFiltersFromFactor.resx index c6a8853c44d..6ef9b54b47f 100644 --- a/instat/sdgFiltersFromFactor.resx +++ b/instat/sdgFiltersFromFactor.resx @@ -119,7 +119,7 @@ - 103, 304 + 201, 304 142, 30 @@ -138,7 +138,32 @@ $this - 0 + 5 + + + 9, 51 + + + + 0, 0, 0, 0 + + + 210, 180 + + + 4 + + + ucrSelectorFiltersFromFactors + + + instat.ucrSelectorByDataFrameAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 True @@ -147,14 +172,85 @@ 6, 13 - 354, 337 + 545, 337 + + + 462, 265 + + + 75, 23 + + + 0 + + + Select All + + + cmdSelectAll + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 267, 57 + + + 270, 208 + + + 1 + + + ucrFactorLevels + + + instat.ucrFactor, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 1 + + + 267, 17 + + + 57, 13 + + + 2 + + + Factor: + + + lblFactors + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 - CenterScreen - Filters + Filters From Factor sdgFiltersFromFactor @@ -162,4 +258,28 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 267, 32 + + + 0, 0, 0, 0 + + + 120, 20 + + + 3 + + + ucrReceiverFactor + + + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + \ No newline at end of file diff --git a/instat/sdgFiltersFromFactor.vb b/instat/sdgFiltersFromFactor.vb index 658f7f1196c..0cf5b2bf394 100644 --- a/instat/sdgFiltersFromFactor.vb +++ b/instat/sdgFiltersFromFactor.vb @@ -14,8 +14,86 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . +Imports instat.Translations Public Class sdgFiltersFromFactor + Private bFirstLoad As Boolean + Private bReset As Boolean = True + Private clsAddFilterFromFactors As RFunction + + Public Sub New() + 'This call is required by the designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call. + bFirstLoad = True + clsAddFilterFromFactors = New RFunction + clsAddFilterFromFactors.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_filter_as_levels") + End Sub + Private Sub sdgFiltersFromFactor_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + If bFirstLoad Then + InitialiseControls() + bFirstLoad = False + End If + End Sub + + Private Sub InitialiseControls() + ucrSelectorFiltersFromFactors.SetParameterIsString() + + ucrFactorLevels.SetParameter(New RParameter("filter_levels", 1)) + ucrFactorLevels.strSelectorColumnName = "Select Level" + ucrFactorLevels.SetAsMultipleSelector() + ucrFactorLevels.SetReceiver(ucrReceiverFactor) + ucrFactorLevels.SetIncludeLevels(False) + + ucrReceiverFactor.SetParameter(New RParameter("column", 2)) + ucrReceiverFactor.Selector = ucrSelectorFiltersFromFactors + ucrReceiverFactor.SetParameterIsString() + ucrReceiverFactor.SetMeAsReceiver() + ucrReceiverFactor.SetDataType("factor", bStrict:=True) + + cmdSelectAll.Enabled = False + End Sub + + Public Sub SetRcodeAndDefaultDataFrame(ucrNewBaseSelector As ucrSelector, bReset As Boolean) + If ucrNewBaseSelector IsNot Nothing AndAlso ucrNewBaseSelector.strCurrentDataFrame <> "" Then + ucrSelectorFiltersFromFactors.SetDataframe(ucrNewBaseSelector.strCurrentDataFrame, False) + End If + ucrReceiverFactor.SetRCode(clsAddFilterFromFactors, bReset) + ucrFactorLevels.SetRCode(clsAddFilterFromFactors, bReset) + + If bReset Then + ucrSelectorFiltersFromFactors.Reset() + End If + End Sub + + Private Sub ucrBase_ClickReturn(sender As Object, e As EventArgs) Handles ucrBase.ClickReturn + 'TODO: check how to get count of selected items from reogrid, then remove bSilent:=False to avoid errors when no level is selected. + If Not ucrReceiverFactor.IsEmpty Then + frmMain.clsRLink.RunScript(clsAddFilterFromFactors.ToScript, strComment:="Filter From Factors subdialog: Created new filter", bSilent:=True) + End If + End Sub + + Private Sub cmdSelectAll_Click(sender As Object, e As EventArgs) Handles cmdSelectAll.Click + ucrFactorLevels.SetSelectionAllLevels(Not ucrFactorLevels.IsAllSelected()) + End Sub + + Private Sub ucrFactorLevels_SelectedLevelChanged() Handles ucrFactorLevels.SelectedLevelChanged + If ucrFactorLevels.IsAllSelected() Then + cmdSelectAll.Text = "Deselect All Levels" + cmdSelectAll.FlatStyle = FlatStyle.Flat + Else + cmdSelectAll.Text = "Select All Levels" + cmdSelectAll.FlatStyle = FlatStyle.Popup + End If + End Sub + + Private Sub ucrReceiverFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverFactor.ControlValueChanged + cmdSelectAll.Enabled = Not ucrReceiverFactor.IsEmpty + End Sub + Private Sub ucrSelectorFiltersFromFactors_DataFrameChanged() Handles ucrSelectorFiltersFromFactors.DataFrameChanged + clsAddFilterFromFactors.AddParameter("data_name", Chr(34) & ucrSelectorFiltersFromFactors.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0) End Sub End Class \ No newline at end of file diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index f27a55a6c9d..4f7216f4070 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1468,7 +1468,7 @@ DataSheet$set("public", "set_protected_columns", function(col_names) { } ) -DataSheet$set("public", "add_filter", function(filter, filter_name = "", replace = TRUE, set_as_current = FALSE, na.rm = TRUE, is_no_filter = FALSE) { +DataSheet$set("public", "add_filter", function(filter, filter_name = "", replace = TRUE, set_as_current = FALSE, na.rm = TRUE, is_no_filter = FALSE, and_or = "&") { if(missing(filter)) stop("filter is required") if(filter_name == "") filter_name = next_default_item("Filter", names(private$filters)) @@ -1483,7 +1483,7 @@ DataSheet$set("public", "add_filter", function(filter, filter_name = "", replace } else { if(filter_name %in% names(private$filters)) message("A filter named ", filter_name, " already exists. It will be replaced by the new filter.") - filter_calc = calculation$new(type = "filter", filter_conditions = filter, name = filter_name, parameters = list(na.rm = na.rm, is_no_filter = is_no_filter)) + filter_calc = calculation$new(type = "filter", filter_conditions = filter, name = filter_name, parameters = list(na.rm = na.rm, is_no_filter = is_no_filter, and_or = and_or)) private$filters[[filter_name]] <- filter_calc self$append_to_changes(list(Added_filter, filter_name)) if(set_as_current) { @@ -1494,6 +1494,13 @@ DataSheet$set("public", "add_filter", function(filter, filter_name = "", replace } ) +DataSheet$set("public","add_filter_as_levels", function(filter_levels, column){ + for (i in seq_along(filter_levels)) { + filter_cond <- list(C0 = list(column = column, operation = "==", value = filter_levels[i])) + self$add_filter(filter = filter_cond, filter_name = filter_levels[i]) + } +}) + DataSheet$set("public", "get_current_filter", function() { return(private$.current_filter) } @@ -1550,7 +1557,11 @@ DataSheet$set("public", "get_filter_as_logical", function(filter_name) { } i = i + 1 } - out <- apply(result, 1, all) + and_or <- curr_filter$parameters[["and_or"]] + if(is.null(and_or)) and_or <- "&" + if(and_or == "&") out <- apply(result, 1, all) + else if (and_or == "|") out <- apply(result, 1, any) + else stop(and_or, " should be & or |.") out[is.na(out)] <- !curr_filter$parameters[["na.rm"]] } return(out) @@ -1590,7 +1601,7 @@ DataSheet$set("public", "filter_string", function(filter_name) { out = "(" i = 1 for(condition in curr_filter$filter_conditions) { - if(i != 1) out = paste(out, "&") + if(i != 1) out = paste(out, curr_filter$parameters[["and_or"]]) out = paste0(out, " (", condition[["column"]], " ", condition[["operation"]]) if(condition[["operation"]] == "%in%") out = paste0(out, " c(", paste(paste0("'", condition[["value"]], "'"), collapse = ","), ")") else out = paste(out, condition[["value"]]) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index bf9f045b8ce..aa50fc516a3 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -712,12 +712,17 @@ DataBook$set("public", "get_table_names", function(data_name, include_overall = } ) -DataBook$set("public", "add_filter", function(data_name, filter, filter_name = "", replace = TRUE, set_as_current_filter = FALSE, na.rm = TRUE, is_no_filter = FALSE) { +DataBook$set("public", "add_filter", function(data_name, filter, filter_name = "", replace = TRUE, set_as_current_filter = FALSE, na.rm = TRUE, is_no_filter = FALSE, and_or = "&") { if(missing(filter)) stop("filter is required") - self$get_data_objects(data_name)$add_filter(filter, filter_name, replace, set_as_current_filter, na.rm = na.rm, is_no_filter = is_no_filter) + self$get_data_objects(data_name)$add_filter(filter, filter_name, replace, set_as_current_filter, na.rm = na.rm, is_no_filter = is_no_filter, and_or = and_or) } ) +DataBook$set("public","add_filter_as_levels", function(data_name, filter_levels, column){ + self$get_data_objects(data_name)$add_filter_as_levels(filter_levels, column) +}) + + DataBook$set("public", "current_filter", function(data_name) { return(self$get_data_objects(data_name)$current_filter) } diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index e0e5f1c8726..ca9371789e2 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -16,123 +16,283 @@ Imports instat +''' +''' The R-Instat user interface is implemented using Windows Forms. Windows Forms provides a set of +''' ‘controls’ such as labels, text boxes and buttons. These controls display data and/or accept +''' input. Controls also react to events triggered when the user interacts with the interface. +''' This class inherits from the Windows Forms ‘UserControl’ class. It is used to create the +''' R-Instat user controls. Each R-Instat user control class is prefixed with ‘ucr’ +''' (e.g. ucrButtons, ucrCalculator, ucrCheck etc.). +''' The R-Instat user controls, either directly replace a Windows Forms user control, or they +''' group other controls together into a single control (e.g. to provide a receiver, selector or +''' set of base buttons). These controls are the building blocks for the R-Instat dialog boxes. +''' +''' These controls typically corresponds to a single parameter in an R command. Composite core +''' controls may correspond to one or more R commands or parameters. +''' +''' The comments for this class use the following terminology: +''' +''' Control +''' Refers to a core control (unless specifically stated) +''' +''' Core control +''' A control that inherits from ucrCore. +''' +''' Control's value +''' The value entered/updated by the user (e.g. the text in a text box) +''' +''' Control's R code +''' The R code associated with the control. +''' This is encapsulated by the command-parameter pair(s) +''' +''' Primary pair +''' The main command and parameter that are affected by this control. +''' The first elements in the command-parameter lists. +''' The primary pair can be accessed directly using the properties ‘clsRCode’ +''' and ‘clsRParameter’ (these just reference the first element in the lists). +''' +''' Non-primary pair(s) +''' Any additional command-parameter pairs associated with this control. +''' +''' Linked control +''' A control whose value is dependent on the parent’s control value +''' (i.e. if the parent control changes then the linked control potentially +''' changes). For example, if a text box needs to be made visible when a check +''' box is checked, then the parent control is the check box and the linked +''' control is the text box. +''' +''' +''' + Public Class ucrCore - 'These lists are intended to be pairs of (RCode, RParameter) which this control may manage - 'The first item in each list can be accessed through the properties clsRCode and clsRParameter - 'There may be duplicate values in the lists. For example, one parameter being added into multiple functions. + + ''' The 'lstAllRCodes' and 'lstAllRParameters' lists contain pairs of R commands and + ''' parameters associated with the user control. + ''' The first pair is considered the primary pair and can be accessed directly using + ''' the properties 'clsRCode' and 'clsRParameter' (these just reference the first + ''' element in the lists). + ''' Protected lstAllRCodes As List(Of RCodeStructure) = New List(Of RCodeStructure)({Nothing}) + ''' The 'lstAllRCodes' and 'lstAllRParameters' lists contain pairs of R commands and + ''' parameters associated with the user control. + ''' The first pair is considered the primary pair and can be accessed directly using + ''' the properties 'clsRCode' and 'clsRParameter' (these just reference the first + ''' element in the lists). + ''' Protected lstAllRParameters As List(Of RParameter) = New List(Of RParameter)({Nothing}) - 'Control may have conditions on RSyntax as a whole i.e. value depends on a function being in the RSyntax + + + + ''' Only used within the conditions. + ''' A condition may apply to an RSyntax object rather than the primary command-parameter pair. Protected clsRSyntax As RSyntax = Nothing - 'Default value of the control - 'No specific type since it can be interpreted different by each control type - Protected objRDefault As Object = Nothing - Protected objDefaultState As Object = Nothing - 'Protected typControlType As Type = Object - ''A control it's linked to i.e. dependant on/depends on - 'Protected ucrLinkedControl As ucrCore - ''The name of a parameter linked to the control which determines if the control is visible/enabled - 'Protected strLinkedParameterName As String + ''' The R environment’s default value for the primary parameter (i.e. the value that + ''' R will assume if the primary parameter is not included in the script, aka the + ''' 'R default'). + ''' It is used in combination with 'objDefaultState' (the control’s default value for + ''' the primary parameter, aka the 'object default'). + ''' The object default is used for the R script functionality, and the R default is + ''' used for the R script’s appearance in the output window (whether the parameter + ''' is included in the command shown in the output window, even if including the + ''' parameter makes no difference to the functionality). + ''' Both defaults are needed. The object default is enough on its own to determine + ''' which default value is used in the R environment. However the R default is also + ''' needed to ensure that the R script explicitly contains the R parameters that the + ''' user expects to see (and doesn’t include long lists of parameters with default + ''' values that the user doesn’t expect to see). + ''' + Protected objRDefault As Object = Nothing - 'Sets what aspects of clsParameter this control can change - 'e.g. check box may not change parameter value, only add/remove it - ' For this bAddRemoveParameter = True and bChangeParameterValue = False - 'e.g. nud may not add/remove parameter, only change its value + ''' The control’s default value for the primary parameter, aka the 'object default'. + ''' It is used in combination with 'objRDefault'. For more details, see the comments + ''' for 'objRDefault'. + ''' + Protected objDefaultState As Object = Nothing + + ''' If true then this user control can add/remove parameters. + ''' Used in combination with 'bChangeParameterValue'. + ''' (e.g. check box may not change parameter value, only add/remove it + ''' For this bAddRemoveParameter = True and bChangeParameterValue = False) + ''' Public bAddRemoveParameter As Boolean = True + + ''' If true then this user control may change the value of parameters. + ''' Used in combination with 'bAddRemoveParameter'. + ''' (e.g. if a check box may not change a parameter value, but only add/remove it, then set + ''' bAddRemoveParameter = True and bChangeParameterValue = False) + ''' Public bChangeParameterValue As Boolean = True - 'Optional value - 'If parameter has this value then it will be removed from RCodeStructure - 'TODO check implementation of this. Does not seen to be used + ''' If parameter has this value then it will be removed from the RCodeStructure Public objValueToRemoveParameter As Object - 'ValueChanged is raised when a new value has been set in the control + ''' + ''' ValueChanged is raised when a new value has been set in the control (e.g. the user enters text in a textbox) + ''' + ''' The control that triggered this event. + Public Event ControlValueChanged(ucrChangedControl As ucrCore) - 'ContentsChanged is raised when the content of the control has changed, but possibly the value has not been set - 'e.g. text in a textbox changes, but the value is not changed until the user leaves the text box - 'For some controls these two events will be equivalent - 'When ValueChanged is raised, so is ContentsChanged - 'ContentsChanged is probably only needed for TestOK + + ''' + ''' ContentsChanged is raised when the content of the control has changed, + ''' but possibly the value has not been set (e.g. text in a textbox changes, + ''' but the value is not changed until the user leaves the text box). + ''' When ValueChanged is raised, so is ContentsChanged. + ''' ContentsChanged is probably only needed for TestOK + ''' + ''' The control that triggered this event. + Public Event ControlContentsChanged(ucrChangedControl As ucrCore) - 'ControlClicked is raised when the control is clicked. For some controls, this will be raised when their child controls is clicked + ''' ControlClicked is raised when the control is clicked. + ''' For some controls, this will be raised when one of their child controls is clicked. + ''' Public Event ControlClicked() - 'List of controls that this control links to - 'Used when this control determines aspects of other controls - 'e.g. add/remove the parameter of other controls - ' set the visible/enabled property of other controls - 'e.g. a checkbox that shows/hides set of controls + + ''' Lists all the controls linked to this control (hereafter called 'child control' + ''' and 'parent control' respectively). Used when this control determines aspects of other + ''' controls (e.g. by adding or removing the other control's parameters or setting the + ''' visible/enabled properties of other controls). For example a checkbox may shows/hide a set + ''' of controls. + ''' Protected lstValuesAndControl As New List(Of KeyValuePair(Of ucrCore, Object())) - 'If this control is in another controls lstLinkedControls - 'These values specifiy how that control can modify this control + + ''' If this control is in another control's lstLinkedControls then these booleans + ''' specify how the parent control can modify this control. Public bLinkedAddRemoveParameter As Boolean = False + + ''' If this control is in another control's lstLinkedControls then + ''' these booleans specify how the parent control can modify this control. Public bLinkedUpdateFunction As Boolean = False + + ''' If this control is in another control's lstLinkedControls then these booleans + ''' specify how the parent control can modify this control. Public bLinkedDisabledIfParameterMissing As Boolean = False + + ''' If this control is in another control's lstLinkedControls then + ''' these booleans specify how the parent control can modify this control. Public bLinkedHideIfParameterMissing As Boolean = False + + ''' If this control is in another control's lstLinkedControls then + ''' these booleans specify how the parent control can modify this control. Public bLinkedChangeToDefaultState As Boolean = False 'Suggested new option needed so that linked control gets value set correctly + + ''' If this control is in another control's lstLinkedControls then + ''' these booleans specify how the parent control can modify this control. Public bLinkedChangeParameterValue As Boolean = False + ''' Lists all the controls to display linked to this control. + ''' Sets the visible/enabled property of these controls (e.g. a checkbox that shows/hides set of controls). + ''' Protected lstCtrLinkedDisplayControls As List(Of Control) - 'We may set the R code for the control (because it's easier to set for a whole dialog) - 'but do not want the control to update from the code. Set to False in this case. + + ''' If true then the control's value can be set from the control's R code. Public bIsActiveRControl As Boolean = True + ''' If true, then update the control's associated commands and parameters whenever + ''' the control's value changes. Public bUpdateRCodeFromControl As Boolean = False + + ''' This dictionary is used to set the control’s value (i.e. the value displayed to + ''' the user in the control’s dialog box), from the control’s R code. + ''' It is part of the two-way process that allows R code to be set from the control + ''' value; and in the other direction, also allows the control value to be set from + ''' the R code. + ''' This dictionary contains a collection of key-value pairs. Each dictionary entry + ''' represents a possible valid value for this control, together with the list of + ''' conditions that define when this value must be used. + ''' If all the conditions In the list are met, then this control's value is set to + ''' the list’s key value. + ''' + + Protected dctConditions As New Dictionary(Of Object, List(Of Condition)) + ''' If true then allow the control's value to be set to a value that is not one of + ''' the pre-defined valid values in the 'dctConditions' dictionary. + ''' If false, then only pre-defined values are allowed (e.g. a check box sets a value to either + ''' true or false). Public bAllowNonConditionValues As Boolean = True + ''' If true then set visible property of this control Public bIsVisible As Boolean = True - ' Values which the parameter associated to the control may have but which shouldn't be used to set the control's value - ' Individual controls can determine what value to set when a parameter value is contained in strValuesToIgnore - ' (Currently only implemented for receivers) + + ''' Values which the parameter associated to the control may have + ''' but which shouldn't be used to set the control's value. + ''' (Currently only implemented for receivers) Protected strValuesToIgnore As String() - 'Update the control based on the code in RCodeStructure - 'bReset : should the control reset to the default value if the parameter is not present in the code + ''' Updates the control, and the linked controls, based upon the values of the + ''' parameters in the command-parameter pair list. This ensures that the control’s + ''' (and linked controls’) UI elements (text boxes, check boxes etc.) show the + ''' correct values when the control is displayed. + ''' + ''' (Optional) If true then reset the linked controls to their default + ''' state (but only if a number of other specified conditions are met, + ''' see the 'UpdateLinkedControls' function for details). + ''' (Optional) If true then clone each of the control's parameters + ''' (but only if the command does not already contain the parameter, + ''' or a cloned parameter with the same name). Public Overridable Sub UpdateControl(Optional bReset As Boolean = False, Optional bCloneIfNeeded As Boolean = False) Dim clsTempRCode As RCodeStructure Dim clsTempRParameter As RParameter Dim clsTempCloneParameter As RParameter + ' The main functionality is at the end of the subroutine in the calls to ‘SetControlValue’ + ' and ‘UpdateLinkedControls’. However, before these functions are called, this subroutine + ' first ensures that the commands reference the correct parameter objects. This is needed + ' because parameters are sometimes cloned. + + 'For each command in the control’s command-parameter pair list For i As Integer = 0 To lstAllRCodes.Count - 1 + + 'Get the paired parameter clsTempRCode = lstAllRCodes(i) clsTempRParameter = lstAllRParameters(i) + If clsTempRCode IsNot Nothing Then If clsTempRParameter IsNot Nothing Then + 'If the command does not already contain the paired parameter If Not clsTempRCode.ContainsParameter(clsTempRParameter) Then + 'If the command already has a parameter with the same name as the paired + ' parameter (i.e. a cloned parameter) If clsTempRCode.ContainsParameter(clsTempRParameter.strArgumentName) Then + 'Set the paired parameter to reference the cloned parameter SetParameter(clsTempRCode.GetParameter(clsTempRParameter.strArgumentName), i) - Else - 'This causes an issue if this parameter is contained in another control - 'because the link is broken - 'Not an issue if controls do not need to share parameters - 'This is needed so that if this parameter is contained in functions in multiple dialogs, - 'the parameter only changes the functions in the currently open dialog + Else 'if the command doesn't already contain the parameter, or a cloned parameter with the same name + 'If needed, clone the paired parameter + 'Note: Cloning is used in sub-dialogs. If a sub-dialog control + ' parameter is not cloned then all instances of the sub-dialog will + ' reference the same parameter. This could cause unexpected + ' behaviour if the sub-dialog is used by more than one dialog. If bCloneIfNeeded Then clsTempCloneParameter = GetParameter(i).Clone() Else clsTempCloneParameter = GetParameter(i) End If + 'If needed, clear all the parameter arguments If Not bUpdateRCodeFromControl AndAlso bChangeParameterValue AndAlso objDefaultState Is Nothing Then clsTempCloneParameter.ClearAllArguments() End If + SetParameter(clsTempCloneParameter, i) - 'If the control has a default state then it's linked control will set the value and we should not set to R default + 'If the control does not have an object default, + ' but does have an R default If objDefaultState Is Nothing Then If objRDefault IsNot Nothing Then + 'Set the parameter to the 'R default’ SetToRDefault() End If 'If there is no R default the value should remain nothing and SetControlValue() will set an apppropriate "empty" value @@ -142,13 +302,26 @@ Public Class ucrCore Else End If Else - clsTempRCode = New RCodeStructure + clsTempRCode = New RCodeStructure 'TODO SJL 13/08/20 this line does nothing - remove? End If Next SetControlValue() UpdateLinkedControls(bReset) End Sub + ''' Updates the control value from the control’s R code. + ''' It does this by checking all the control’s conditions: + ''' + ''' If one (and only one) condition is met + ''' then the control's value is set to the value associated with the condition. + ''' If no conditions are met and 'bAllowNonConditionValues' is true + ''' then the control’s value is set from the primary parameter. + ''' Else a developer error is thrown. + ''' + ''' It is common for simple controls (e.g. text boxes) not to have any conditions. + ''' Conditions are important for controls that have a finite number of states + ''' (e.g. radio boxes or combo boxes). + ''' Protected Overridable Sub SetControlValue() Dim bConditionsMet As Boolean = False @@ -180,6 +353,18 @@ Public Class ucrCore End If End Sub + ''' Returns the value of the primary parameter (the first parameter in the + ''' command-parameter list): + ''' + ''' If the parameter's argument is a string then returns a string object. + ''' Please note that all arguments that are not functions or operators (e.g. names, + ''' integers, reals, booleans etc.) are returned as strings + ''' + ''' If the parameter's argument is a function or operator, then returns an 'RCodeStructure' + ''' + ''' Else returns 'nothing'. + ''' + ''' Public Overridable Function GetValueToSet() As Object If clsParameter IsNot Nothing Then If clsParameter.bIsString Then @@ -194,12 +379,30 @@ Public Class ucrCore End If End Function + ''' Updates all the controls linked to this control (hereafter called ‘child’ and + ''' ‘parent’ respectively). This ensures that if the parent’s value changes then the + ''' child controls’ values stay consistent. + ''' The parent stores details of its children In 'lstValuesAndControl’. This lists + ''' every child control whose value may potentially need to change if the state of + ''' the parent changes. The list is a key-value pair. The ‘key’ is the child control + ''' and the ‘value’ lists all parent control values that will trigger a change to the + ''' child control’s value. + ''' If the parent is visible then for each child control, it compares the parent's + ''' state to the child’s trigger values. If the parent’s state matches one of the + ''' trigger values, then the child control is updated. + ''' If the parent's state is not in the child’s trigger list, then the child is not + ''' updated. The only exception is that under certain conditions the child may be + ''' reset to its default value. + ''' + ''' (Optional) If true then reset the linked controls to their default + ''' state (but only if a number of other specified conditions are met). Public Overridable Sub UpdateLinkedControls(Optional bReset As Boolean = False) Dim ucrControl As ucrCore Dim lstValues As Object() Dim bTemp As Boolean Dim objTempDefaultState As Object + 'For each key-value pair in the list of child controls For Each kvpTemp As KeyValuePair(Of ucrCore, Object()) In lstValuesAndControl lstValues = kvpTemp.Value ucrControl = kvpTemp.Key @@ -208,7 +411,9 @@ Public Class ucrCore ucrControl.SetRCode(clsRCode) End If If ucrControl.bLinkedChangeToDefaultState AndAlso bReset Then + 'If the linked control does not have any valid command-parameter pairs If ucrControl.clsRCode Is Nothing OrElse ucrControl.clsParameter Is Nothing OrElse (ucrControl.clsRCode IsNot Nothing AndAlso ucrControl.clsParameter IsNot Nothing AndAlso ucrControl.clsParameter.strArgumentName IsNot Nothing AndAlso (Not ucrControl.clsRCode.ContainsParameter(ucrControl.clsParameter.strArgumentName))) Then + 'Set the child control to its default state ucrControl.SetToDefaultState() End If End If @@ -230,11 +435,18 @@ Public Class ucrCore If ucrControl.bLinkedDisabledIfParameterMissing Then ucrControl.Enabled = bTemp End If + 'Update the child control’s own child controls (recursion) ucrControl.UpdateLinkedControls(bReset) Next End Sub - 'Update the RCode based on the contents of the control (reverse of above) + + ''' Updates the control’s R code to reflect the current state of the control’s + ''' parameters. + ''' For each command-parameter pair, add/remove the parameter directly to/from the command. + ''' + ''' (Optional) If true then reset the linked controls to their default + ''' state (but only if a number of other specified conditions are met). Public Overridable Sub UpdateRCode(Optional bReset As Boolean = False) If bAddRemoveParameter Then AddOrRemoveParameter(CanAddParameter()) @@ -242,12 +454,27 @@ Public Class ucrCore UpdateLinkedControls(bReset) End Sub + 'Private Sub RemoveParameterFromRCode() ' If Not clsRCode Is Nothing Then ' clsRCode.RemoveParameter(clsParameter) ' End If 'End Sub + ''' Sets the control's R code. It then updates + ''' the control, and the linked controls, based upon the values of the updated + ''' parameters in the command-parameter pair list. + ''' + ''' The new R code structure. + ''' (Optional) If true then reset the linked controls to + ''' their default state (but only if a number of other + ''' specified conditions are met, see the + ''' 'UpdateLinkedControls' function for details). + ''' (Optional) True to update. + ''' (Optional) If true then clone each of the control's + ''' parameters (but only if the command does not already + ''' contain the parameter, or a cloned parameter with the + ''' same name). Public Overridable Sub SetRCode(clsNewCodeStructure As RCodeStructure, Optional bReset As Boolean = False, Optional bUpdate As Boolean = True, Optional bCloneIfNeeded As Boolean = False) If clsRCode Is Nothing OrElse Not clsRCode.Equals(clsNewCodeStructure) Then ' If Not clsRCode Is Nothing Then @@ -265,6 +492,17 @@ Public Class ucrCore 'TODO in future may want to set RCode and RSyntax together if both needed for conditions ' then would need method to add both at the same time + + ''' Sets the control's R syntax and (if conditions are met) R code. It then updates + ''' the control, and the linked controls, based upon the values of the updated + ''' parameters in the command-parameter pair list. + ''' + ''' The new R syntax. + ''' (Optional) If true then reset the linked controls to their default + ''' state (but only if a number of other specified conditions are met). + ''' (Optional) If true then clone each of the control's parameters + ''' (but only if the command does not already contain the parameter, + ''' or a cloned parameter with the same name). Public Overridable Sub SetRSyntax(clsNewRSyntax As RSyntax, Optional bReset As Boolean = False, Optional bCloneIfNeeded As Boolean = False) If clsRSyntax Is Nothing OrElse Not clsRSyntax.Equals(clsNewRSyntax) Then clsRSyntax = clsNewRSyntax @@ -275,18 +513,28 @@ Public Class ucrCore UpdateControl(bReset, bCloneIfNeeded:=bCloneIfNeeded) End Sub + ''' Returns true if the control's R code can be safely updated. + ''' True if the primary parameter is defined but is not part of the control's R code. + ''' Else returns false. Protected Overridable Function CanUpdate() Return (clsParameter IsNot Nothing AndAlso (Not clsRCode.ContainsParameter(clsParameter.strArgumentName)) AndAlso clsParameter.HasValue()) End Function + ''' Set the object to be a default R object. + ''' The R object parameter Public Overridable Sub SetRDefault(objNewDefault As Object) objRDefault = objNewDefault End Sub + ''' Set a value in the object to remove a parameter. + ''' The parameter of the object. Public Overridable Sub SetValueToRemoveParameter(objNewValue As Object) objValueToRemoveParameter = objNewValue End Sub + ''' Sets the R environment’s default value for the primary parameter (i.e. the value + ''' that R will assume if the primary parameter is not included in the script, aka + ''' the 'R default'). Public Overridable Sub SetToRDefault() If clsParameter IsNot Nothing AndAlso objRDefault IsNot Nothing Then clsParameter.SetArgumentValue(objRDefault.ToString()) @@ -295,24 +543,24 @@ Public Class ucrCore 'UpdateControl() End Sub - ''Set a linked paramter name and what the control should do when the parameter is not in the R code - 'Public Sub SetLinkedParameterName(strNewLinkedParameterName As String, Optional bNewHideIfLinkedParameterMissing As Boolean = False, Optional bNewDisableIfLinkedParameterMissing As Boolean = False) - ' strLinkedParameterName = strNewLinkedParameterName - ' bHideIfParameterMissing = bNewHideIfLinkedParameterMissing - ' bDisabledIfParameterMissing = bNewDisableIfLinkedParameterMissing - 'End Sub - 'Set the Text property of the control(s) inside this control (should only be one). Implemented different by each VB control. + ''' Set the Text property of the control(s) inside this control (should only be one). + ''' Implemented different by each VB control. + ''' + ''' The parameter's String value. Public Overridable Sub SetText(strNewText As String) For Each ctrTemp In Controls ctrTemp.Text = strNewText Next End Sub + ''' OnControlContentsChanged is raised when the content of the control is changed. Public Sub OnControlContentsChanged() RaiseEvent ControlContentsChanged(Me) End Sub + ''' OnControlContentsChanged is raised when the value of the control is changed. + ''' This update all the prameters in the code, the Rcode and content of this control. Public Sub OnControlValueChanged() OnControlContentsChanged() UpdateAllParameters() @@ -320,10 +568,17 @@ Public Class ucrCore RaiseEvent ControlValueChanged(Me) End Sub + ''' OnControlClicked is raised when the user click on a control. Public Sub OnControlClicked() RaiseEvent ControlClicked() End Sub + + ''' Set the parameter in the R code. + ''' + ''' The new parameter to set. + ''' (Optional) The relative position of the parameter in this object's + ''' parameter list. Public Overridable Sub SetParameter(clsNewParameter As RParameter, Optional iIndex As Integer = 0) ''this should be removing the old parameter from the rcode before replacing it. Currently only implemented for iIndex =0 'If iIndex = 0 Then @@ -332,6 +587,9 @@ Public Class ucrCore lstAllRParameters(iIndex) = clsNewParameter End Sub + + ''' Get the parameter name. + ''' Return the name of the parameter. Public Overridable Function GetParameterName() As String If clsParameter IsNot Nothing Then Return clsParameter.strArgumentName @@ -340,14 +598,25 @@ Public Class ucrCore End If End Function + ''' Get the default object. + ''' Return the default object. Public Overridable Function GetDefault() As Object Return objRDefault End Function + + ''' Always returns false. This function may be overridden by a function that returns + ''' true if this control has one of the values listed in 'lstTemp'. + ''' The list of values to check against (only used if this function is + ''' overridden). + ''' False (unless function is overridden). Public Overridable Function ControlValueContainedIn(lstTemp As Object()) As Boolean Return False End Function + ''' Add/Remove parameter in the RCodes. + ''' + ''' True to add parameter in the RCode. Public Overridable Sub AddOrRemoveParameter(bAdd As Boolean) For i As Integer = 0 To lstAllRCodes.Count - 1 If lstAllRCodes(i) IsNot Nothing AndAlso lstAllRParameters(i) IsNot Nothing Then @@ -360,12 +629,37 @@ Public Class ucrCore Next End Sub + ''' Adds a list of linked control to the 'lstValuesAndControl' list. + ''' The linked control’s modification booleans are set to the values in the parameters. + ''' + ''' The parameter's control. + ''' The object parameter. + ''' Add/Remove parameter of the new linked control. + ''' Update the function of the new linked control. + ''' Disable the new linked control if parameter missing. + ''' Hide the new linked control if parameter missing. + ''' The New linked change to default state of the control. + ''' The new state of the boject. + ''' The New value change of the parameter linked. Public Sub AddToLinkedControls(lstLinked As ucrCore(), objValues As Object(), Optional bNewLinkedAddRemoveParameter As Boolean = False, Optional bNewLinkedUpdateFunction As Boolean = False, Optional bNewLinkedDisabledIfParameterMissing As Boolean = False, Optional bNewLinkedHideIfParameterMissing As Boolean = False, Optional bNewLinkedChangeToDefaultState As Boolean = False, Optional objNewDefaultState As Object = Nothing, Optional bNewLinkedChangeParameterValue As Boolean = False) For Each ucrLinked As ucrCore In lstLinked AddToLinkedControls(ucrLinked:=ucrLinked, objValues:=objValues, bNewLinkedAddRemoveParameter:=bNewLinkedAddRemoveParameter, bNewLinkedUpdateFunction:=bNewLinkedUpdateFunction, bNewLinkedDisabledIfParameterMissing:=bNewLinkedDisabledIfParameterMissing, bNewLinkedHideIfParameterMissing:=bNewLinkedHideIfParameterMissing, bNewLinkedChangeToDefaultState:=bNewLinkedChangeToDefaultState, objNewDefaultState:=objNewDefaultState, bNewLinkedChangeParameterValue:=bNewLinkedChangeParameterValue) Next End Sub + ''' Adds a new linked control to the 'lstValuesAndControl' list. + ''' The linked control’s modification booleans are set to the values in the parameters. + ''' If the linked control is already in the list then this function does nothing. + ''' + ''' The parameter's control. + ''' The object parameter. + ''' Add/Remove parameter of the new linked control. + ''' Update the function of the new linked control. + ''' Disable the new linked control if parameter missing. + ''' Hide the new linked control if parameter missing. + ''' The New linked change to default state of the control. + ''' The new state of the boject. + ''' The New value change of the parameter linked. Public Sub AddToLinkedControls(ucrLinked As ucrCore, objValues As Object(), Optional bNewLinkedAddRemoveParameter As Boolean = False, Optional bNewLinkedUpdateFunction As Boolean = False, Optional bNewLinkedDisabledIfParameterMissing As Boolean = False, Optional bNewLinkedHideIfParameterMissing As Boolean = False, Optional bNewLinkedChangeToDefaultState As Boolean = False, Optional objNewDefaultState As Object = Nothing, Optional bNewLinkedChangeParameterValue As Boolean = False) If Not IsLinkedTo(ucrLinked) Then ucrLinked.bLinkedAddRemoveParameter = bNewLinkedAddRemoveParameter @@ -379,6 +673,11 @@ Public Class ucrCore End If End Sub + + ''' Returns true if is linked to this control. + ''' + ''' the control to search for + ''' true if is linked to this control. Public Function IsLinkedTo(ucrControl) As Boolean Dim bTemp As Boolean = False @@ -391,14 +690,21 @@ Public Class ucrCore Return bTemp End Function + ''' Returns true if the primary parameter's value is the R default. + ''' True if the primary parameter's value is the R default. Public Overridable Function IsRDefault() As Boolean Return clsParameter IsNot Nothing AndAlso clsParameter.strArgumentValue IsNot Nothing AndAlso objRDefault IsNot Nothing AndAlso objRDefault.Equals(clsParameter.strArgumentValue) End Function + ''' Returns true if the primary parameter's value is not the R default. + ''' True if the primary parameter's value is not the R default. Public Overridable Function CanAddParameter() As Boolean Return Not IsRDefault() End Function + + ''' TODO SJL 18/08/20 This function is unused. Remove? + ''' True if this control has at least one child control with a parameter. Public Function LinkedControlsParametersPresent() As Boolean Dim bTemp As Boolean = False @@ -411,6 +717,10 @@ Public Class ucrCore Return bTemp End Function + ''' Returns the parameter with index . + ''' + ''' The parameter index. + ''' The parameter with index . Public Overridable Function GetParameter(Optional iIndex As Integer = 0) As RParameter If iIndex < lstAllRParameters.Count Then Return lstAllRParameters(iIndex) @@ -419,10 +729,14 @@ Public Class ucrCore End If End Function + ''' Returns the primary R command. + ''' The primary R command. Public Overridable Function GetRCode() As RCodeStructure Return clsRCode End Function + ''' Sets to 'Visible'. + ''' The control to be set to 'Visible' Public Sub SetLinkedDisplayControl(ctrNewControl As Control) Dim lstCtrNewControls As New List(Of Control) lstCtrNewControls.Add(ctrNewControl) @@ -431,6 +745,8 @@ Public Class ucrCore End Sub + ''' Sets each control in to 'Visible'. + ''' The list of controls to be set to 'Visible' Public Sub SetLinkedDisplayControl(lstCtrNewControls As List(Of Control)) lstCtrLinkedDisplayControls = lstCtrNewControls SetLinkedDisplayControlVisibility() @@ -440,10 +756,20 @@ Public Class ucrCore SetLinkedDisplayControlVisibility() End Sub + ''' Set each control to display linked to this control, to 'Visible'. Private Sub SetLinkedDisplayControlVisibility() SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(Visible) End Sub + + ''' + ''' For each control to display linked to this control, set the visibility to + ''' . If any of these linked controls is a group box then return + ''' true. + ''' + ''' If true then make the linked controls visible, else make them + ''' not visible. + ''' True if any control to display, linked to this control, is a group box. Private Function SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(bVisible As Boolean) As Boolean Dim ctr As Control Dim bContainsGroupBox As Boolean = False @@ -462,9 +788,16 @@ Public Class ucrCore Return bContainsGroupBox End Function + ''' Does nothing. May be overridden to set the control based + ''' on . + ''' The object used to set the control. Public Overridable Sub SetToValue(objTemp As Object) End Sub + ''' Adds condition for when to set this control to + ''' value . + ''' The value for this control + ''' The condition to add for this control value. Public Sub AddCondition(objControlState As Object, clsCond As Condition) If dctConditions.ContainsKey(objControlState) Then dctConditions(objControlState).Add(clsCond) @@ -473,6 +806,13 @@ Public Class ucrCore End If End Sub + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The parameter's name. + ''' The parameter's value. + ''' (Optional) If true then add condition to the parameter values. Public Sub AddParameterValuesCondition(objControlState As Object, strParamName As String, strParamValue As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -480,6 +820,14 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The parameter's name. + ''' The parameter's values list. + ''' (Optional) If true then add condition to the parameter values. Public Sub AddParameterValuesCondition(objControlState As Object, strParamName As String, lstParamValues As String(), Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -487,6 +835,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The parameter's name. + ''' (Optional) If true then add condition to the parameter. Public Sub AddParameterPresentCondition(objControlState As Object, strParamName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -494,6 +849,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The list of parameter names. + ''' (Optional) If true then add condition to the parameter. Public Sub AddParameterPresentCondition(objControlState As Object, lstParamName As String(), Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -501,6 +863,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The function name to use in the condition. + ''' (Optional) If true then add condition name to the function. Public Sub AddFunctionNamesCondition(objControlState As Object, strFunctionName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -508,6 +877,10 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Creates a new functionn name condition based on . + ''' Adds this condition to value . + ''' The value for this control. + ''' (Optional) If true then add condition name to the function. Public Sub AddRCodeIsRFunctionCondition(objControlState As Object, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -515,6 +888,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Creates a new function names condition based on + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The condition's function list. + ''' (Optional) If true then add condition name to the function. Public Sub AddFunctionNamesCondition(objControlState As Object, lstFunctionNames As String(), Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -522,6 +901,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Creates a new parameter type condition based on + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' The parameter's name. + ''' The relative position the object in the R syntax. Public Sub AddParameterIsStringCondition(objControlState As Object, strParameterName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -529,6 +914,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new R function type condition based on + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' Name of the parameter. + ''' (Optional) The relative position the object in the R syntax. Public Sub AddParameterIsRFunctionCondition(objControlState As Object, strParameterName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -536,6 +928,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new R operator type condition based on + ''' and . + ''' Adds this condition to value . + ''' The value for this control. + ''' Name of the parameter. + ''' (Optional) The relative position the object in the R syntax. Public Sub AddParameterIsROperatorCondition(objControlState As Object, strParameterName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -543,6 +942,15 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new R function name type condition based on + ''' , and + ''' . + ''' Adds this condition to value . + ''' The value for this control. + ''' Name of the parameter. + ''' Name of the function. + ''' (Optional) The relative position the object in the R syntax. Public Sub AddParameterValueFunctionNamesCondition(objControlState As Object, strParameterName As String, strFunctionName As String, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -550,6 +958,14 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new parameter type condition based on + ''' , and + ''' . + ''' The value for this control. + ''' Name of the parameter. + ''' List of functions. + ''' (Optional) The relative position the object in the R codes. Public Sub AddParameterValueFunctionNamesCondition(objControlState As Object, strParameterName As String, strFunctionNames As String(), Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -557,6 +973,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Creates a new RSyntax type condition based on + ''' and . + ''' The value for this control. + ''' Name of the function. + ''' The relative position the object in the R syntax. Public Sub AddRSyntaxContainsFunctionNamesCondition(objControlState As Object, strFunctionNames As String(), Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -564,6 +986,10 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Creates a new RSyntax containing code type condition based on + ''' . + ''' The value for this control. + ''' The relative position the object in the R syntax. Public Sub AddRSyntaxContainCodeCondition(objControlState As Object, Optional bNewIsPositive As Boolean = True) Dim clsTempCond As New Condition @@ -571,6 +997,16 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Set visible a control. + ''' If true then set a control visible property. + ''' + ''' For each control (display) linked to this control, set the visibility to + ''' If none of these linked controls is a group box then set + ''' 'Visible' to 'bVisible'. + ''' + ''' If true then make the linked controls visible, else make them + ''' not visible. ``` Public Sub SetVisible(bVisible As Boolean) 'TODO: check how this should behave with linked group boxes If Not SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(bVisible) Then @@ -581,16 +1017,26 @@ Public Class ucrCore End Sub + ''' Set the control’s default value for the primary parameter, aka + ''' the 'object default', to . + ''' The new default value. Public Sub SetDefaultState(objState As Object) objDefaultState = objState End Sub + + ''' Sets the control to the control’s default value for the primary parameter. + ''' The 'SetToValue' function must be overridden, else this function does nothing. + ''' Protected Overridable Sub SetToDefaultState() SetToValue(objDefaultState) End Sub - 'This should be used very cautiously, only if you want to change the parameter name and keep all other properties the same. - 'Setting a new parameter is usually a much safer option. + + ''' This should be used very cautiously, only if you want to change the parameter + ''' name and keep all other properties the same. + ''' The parameter's name. + ''' If true then clear the condition. Public Overridable Sub ChangeParameterName(strNewName As String, Optional bClearConditions As Boolean = True) If clsParameter IsNot Nothing Then clsParameter.SetArgumentName(strNewName) @@ -600,34 +1046,60 @@ Public Class ucrCore End If End Sub + ''' Clear the conditions. Public Sub ClearConditions() dctConditions.Clear() End Sub + ''' Set the value of the parameter. + ''' The parameter's String value. Public Sub SetParameterValue(strNewValue As String) If clsParameter IsNot Nothing Then clsParameter.SetArgumentValue(strNewValue) End If End Sub + ''' Set the value of the parameter. + ''' The parameter's function. Public Sub SetParameterValue(clsNewRCode As RCodeStructure) If clsParameter IsNot Nothing Then clsParameter.SetArgument(clsNewRCode) End If End Sub + + ''' Set the value to Ignore. + ''' The parameter's String value. Public Sub SetValuesToIgnore(strValues() As String) strValuesToIgnore = strValues End Sub + ''' Adds/updates a command-parameter pair to/in the control’s lists: + ''' + ''' If the specified pair number is -1 (the default) or is the index of + ''' the next available list element, then the new pair is added to the list. + ''' If the specified pair number already exists in the list, then that pair + ''' is updated with the new values. + ''' If the pair number is greater than the number of list elements, then + ''' throws a developer error + ''' + ''' + ''' The new R code. + ''' The new R parameter. + ''' (optional) The parameter's position in relation to the associated R command's other + ''' parameters. Public Overridable Sub AddAdditionalCodeParameterPair(clsNewRCode As RCodeStructure, clsNewRParameter As RParameter, Optional iAdditionalPairNo As Integer = -1) If iAdditionalPairNo = -1 Then iAdditionalPairNo = lstAllRCodes.Count End If + + 'If the specified pair number already exists in the list If iAdditionalPairNo < lstAllRCodes.Count Then + 'Update the pair with the new values lstAllRCodes(iAdditionalPairNo) = clsNewRCode lstAllRParameters(iAdditionalPairNo) = clsNewRParameter - ElseIf iAdditionalPairNo = lstAllRCodes.Count Then + ElseIf iAdditionalPairNo = lstAllRCodes.Count Then 'Else position is specified to be next available index position in list + 'Add the new pair to the list lstAllRCodes.Add(clsNewRCode) lstAllRParameters.Add(clsNewRParameter) Else @@ -635,31 +1107,45 @@ Public Class ucrCore End If End Sub - 'In general this should not be overrided. Only for controls which use parameters in very different way e.g. ucrSave + + ''' Update all the parameters in the R script. In general this should not be + ''' overridden. Only for controls which use parameters in very different ways + ''' e.g. ucrSave. + ''' Protected Overridable Sub UpdateAllParameters() For i As Integer = 0 To lstAllRParameters.Count - 1 UpdateParameter(lstAllRParameters(i)) Next End Sub + ''' Update the parameter in the R script. + ''' The temporary parameter's value. Public Overridable Sub UpdateParameter(clsTempParam As RParameter) If GetValueToSet() IsNot Nothing Then clsTempParam.SetArgumentValue(GetValueToSet().ToString()) End If End Sub + + ''' Set the parameter's name in the R script if needed. + ''' If true include name of the parameter in the R script. Public Sub SetParameterIncludeArgumentName(bInclude As Boolean) If clsParameter IsNot Nothing Then clsParameter.bIncludeArgumentName = bInclude End If End Sub + + ''' Set the postion of the parameter in the parameter set. + ''' Index parameter's position. Public Sub SetParameterPosition(iPosition As Integer) If clsParameter IsNot Nothing Then clsParameter.Position = iPosition End If End Sub + ''' The primary parameter. + ''' The primary parameter. Private Property clsParameter As RParameter Get Return lstAllRParameters(0) @@ -670,6 +1156,8 @@ Public Class ucrCore End Set End Property + ''' The primary R command. + ''' The primary R command. Private Property clsRCode As RCodeStructure Get Return lstAllRCodes(0) @@ -683,6 +1171,7 @@ Public Class ucrCore 'TODO implement in specific controls End Sub + ''' Clear code and parameters. Public Overridable Sub ClearCodeAndParameters() 'Shouldn't this be removing them properly by removing the parameters from the functions first? lstAllRCodes = New List(Of RCodeStructure) @@ -693,7 +1182,10 @@ Public Class ucrCore UpdateControl() End Sub + ''' Add/Remove parameter in the R code. + ''' + ''' If true then Add parameter otherwise Remove. Public Overridable Sub SetAddRemoveParameter(bNew As Boolean) bAddRemoveParameter = bNew End Sub -End Class \ No newline at end of file +End Class diff --git a/instat/ucrFilter.Designer.vb b/instat/ucrFilter.Designer.vb index 50f27305feb..b1e61f53932 100644 --- a/instat/ucrFilter.Designer.vb +++ b/instat/ucrFilter.Designer.vb @@ -38,6 +38,7 @@ Partial Class ucrFilter 'Do not modify it using the code editor. _ Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ucrFilter)) Me.lblSelectLevels = New System.Windows.Forms.Label() Me.cmdAddCondition = New System.Windows.Forms.Button() @@ -78,7 +79,8 @@ Partial Class ucrFilter Me.ucrFactorLevels = New instat.ucrFactor() Me.ucrFilterByReceiver = New instat.ucrReceiverSingle() Me.ucrSelectorForFitler = New instat.ucrSelectorByDataFrameAddRemove() - Me.Button1 = New System.Windows.Forms.Button() + Me.cmdCombineWithAndOr = New System.Windows.Forms.Button() + Me.ttpCombineWithAndOr = New System.Windows.Forms.ToolTip(Me.components) Me.grpNumeric.SuspendLayout() Me.SuspendLayout() ' @@ -295,6 +297,7 @@ Partial Class ucrFilter 'ucrLogicalCombobox ' Me.ucrLogicalCombobox.AddQuotesIfUnrecognised = True + Me.ucrLogicalCombobox.GetSetSelectedIndex = -1 Me.ucrLogicalCombobox.IsReadOnly = False resources.ApplyResources(Me.ucrLogicalCombobox, "ucrLogicalCombobox") Me.ucrLogicalCombobox.Name = "ucrLogicalCombobox" @@ -309,6 +312,7 @@ Partial Class ucrFilter 'ucrInputFilterName ' Me.ucrInputFilterName.AddQuotesIfUnrecognised = True + Me.ucrInputFilterName.GetSetSelectedIndex = -1 Me.ucrInputFilterName.IsReadOnly = False resources.ApplyResources(Me.ucrInputFilterName, "ucrInputFilterName") Me.ucrInputFilterName.Name = "ucrInputFilterName" @@ -324,6 +328,7 @@ Partial Class ucrFilter 'ucrFilterOperation ' Me.ucrFilterOperation.AddQuotesIfUnrecognised = True + Me.ucrFilterOperation.GetSetSelectedIndex = -1 Me.ucrFilterOperation.IsReadOnly = False resources.ApplyResources(Me.ucrFilterOperation, "ucrFilterOperation") Me.ucrFilterOperation.Name = "ucrFilterOperation" @@ -354,18 +359,18 @@ Partial Class ucrFilter resources.ApplyResources(Me.ucrSelectorForFitler, "ucrSelectorForFitler") Me.ucrSelectorForFitler.Name = "ucrSelectorForFitler" ' - 'Button1 + 'cmdCombineWithAndOr ' - resources.ApplyResources(Me.Button1, "Button1") - Me.Button1.Name = "Button1" - Me.Button1.Tag = "Clear_Conditions" - Me.Button1.UseVisualStyleBackColor = True + resources.ApplyResources(Me.cmdCombineWithAndOr, "cmdCombineWithAndOr") + Me.cmdCombineWithAndOr.Name = "cmdCombineWithAndOr" + Me.cmdCombineWithAndOr.Tag = "Clear_Conditions" + Me.cmdCombineWithAndOr.UseVisualStyleBackColor = True ' 'ucrFilter ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.cmdCombineWithAndOr) Me.Controls.Add(Me.ucrReceiverExpression) Me.Controls.Add(Me.grpNumeric) Me.Controls.Add(Me.ucrLogicalCombobox) @@ -432,5 +437,6 @@ Partial Class ucrFilter Friend WithEvents cmd0 As Button Friend WithEvents cmd1 As Button Friend WithEvents ucrReceiverExpression As ucrReceiverExpression - Friend WithEvents Button1 As Button + Friend WithEvents cmdCombineWithAndOr As Button + Friend WithEvents ttpCombineWithAndOr As ToolTip End Class diff --git a/instat/ucrFilter.resx b/instat/ucrFilter.resx index e31bb34589d..9fa0a78b0af 100644 --- a/instat/ucrFilter.resx +++ b/instat/ucrFilter.resx @@ -127,7 +127,7 @@ - 413, 42 + 413, 48 74, 13 @@ -150,6 +150,9 @@ 17 + + Microsoft Sans Serif, 8.25pt + NoControl @@ -157,7 +160,7 @@ 278, 64 - 93, 23 + 110, 29 4 @@ -205,10 +208,10 @@ 14 - 4, 195 + 5, 195 - 268, 132 + 271, 132 8 @@ -232,7 +235,7 @@ 5, 339 - 120, 13 + 91, 19 9 @@ -259,7 +262,7 @@ NoControl - 278, 27 + 281, 27 47, 13 @@ -286,10 +289,10 @@ NoControl - 272, 298 + 277, 298 - 110, 23 + 110, 29 14 @@ -316,10 +319,10 @@ NoControl - 272, 230 + 277, 230 - 110, 23 + 110, 29 15 @@ -346,10 +349,10 @@ NoControl - 272, 264 + 277, 264 - 110, 23 + 110, 29 16 @@ -376,7 +379,7 @@ 5, 366 - 120, 13 + 91, 19 17 @@ -396,264 +399,6 @@ 6 - - cmdClear - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 0 - - - cmdComma - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 1 - - - cmdBrackets - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 2 - - - cmdPower - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 3 - - - cmdDivide - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 4 - - - cmdPlus - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 5 - - - cmdMinus - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 6 - - - cmdMultiply - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 7 - - - cmdDot - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 8 - - - cmd9 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 9 - - - cmd8 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 10 - - - cmd7 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 11 - - - cmd6 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 12 - - - cmd5 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 13 - - - cmd4 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 14 - - - cmd3 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 15 - - - cmd2 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 16 - - - cmd0 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 17 - - - cmd1 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - grpNumeric - - - 18 - - - 424, 84 - - - 2, 3, 2, 3 - - - 2, 3, 2, 3 - - - 205, 134 - - - 180 - - - Numeric - - - grpNumeric - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - NoControl @@ -1245,8 +990,38 @@ 18 + + 398, 66 + + + 2, 3, 2, 3 + + + 2, 3, 2, 3 + + + 205, 134 + + + 180 + + + Numeric + + + grpNumeric + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + - 488, 40 + 456, 42 5, 5, 5, 5 @@ -1270,7 +1045,7 @@ 1 - 489, 39 + 455, 40 7, 6, 7, 6 @@ -1294,7 +1069,7 @@ 3 - 489, 40 + 456, 40 5, 5, 5, 5 @@ -1318,7 +1093,7 @@ 4 - 131, 364 + 100, 364 7, 6, 7, 6 @@ -1342,13 +1117,13 @@ 5 - 131, 337 + 100, 337 7, 6, 7, 6 - 275, 21 + 280, 21 10 @@ -1366,7 +1141,7 @@ 11 - 413, 40 + 399, 42 7, 6, 7, 6 @@ -1393,7 +1168,7 @@ True - 413, 61 + 398, 65 5, 5, 5, 5 @@ -1417,13 +1192,13 @@ 18 - 278, 42 + 278, 43 0, 0, 0, 0 - 120, 20 + 120, 21 1 @@ -1441,7 +1216,7 @@ 19 - 4, 4 + 5, 4 0, 0, 0, 0 @@ -1464,36 +1239,39 @@ 20 - - False + + Microsoft Sans Serif, 8.25pt - + NoControl - - 272, 196 + + 277, 196 - - 110, 23 + + 110, 29 - + 182 - - Combine with && + + All Combined with && - - Button1 + + cmdCombineWithAndOr - + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 0 + + 17, 17 + True @@ -1503,6 +1281,12 @@ 772, 395 + + ttpCombineWithAndOr + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ucrFilter diff --git a/instat/ucrFilter.vb b/instat/ucrFilter.vb index 97048fc0af7..8329c6017cc 100644 --- a/instat/ucrFilter.vb +++ b/instat/ucrFilter.vb @@ -77,6 +77,7 @@ Public Class ucrFilter ucrSelectorForFitler.btnDataOptions.Visible = False ucrLogicalCombobox.SetItems({"TRUE", "FALSE"}) ucrLogicalCombobox.SetDropDownStyleAsNonEditable() + ttpCombineWithAndOr.SetToolTip(cmdCombineWithAndOr, "With more than one condition, e.g. (year > 1990) & (year < 2021) they have all to be TRUE.") End Sub Private Sub SetDefaults() @@ -120,12 +121,11 @@ Public Class ucrFilter End Sub Private Sub CheckAddEnabled() - If ucrFilterByReceiver.IsEmpty() AndAlso ucrReceiverExpression.IsEmpty() Then + If (ucrFilterByReceiver.IsEmpty() AndAlso ucrReceiverExpression.bIsVisible AndAlso ucrReceiverExpression.IsEmpty()) OrElse ucrFilterByReceiver.IsEmpty() Then cmdAddCondition.Enabled = False Else If ucrFilterByReceiver.strCurrDataType.ToLower.Contains("factor") Then cmdAddCondition.Enabled = Not String.IsNullOrEmpty(ucrFactorLevels.GetSelectedLevels()) - Else Select Case ucrFilterOperation.GetText() Case "is.na", "! is.na" @@ -368,4 +368,29 @@ Public Class ucrFilter Private Sub cmdClear_Click(sender As Object, e As EventArgs) Handles cmdClear.Click ucrReceiverExpression.Clear() End Sub + + ''' Handles event triggered when cmdCombineWithAndOr Button is clicked. + ''' The purpose of this button is to change the filter operator to either AND(&) or OR(|). + ''' The user clicks the button to trigger a change in the operator. + ''' This subroutine changes the oparator, passes "and_or" parameter into clsFilterFunction, + ''' updates the button label and set the tooltip text for the button. + ''' Filter preview is also updated. + ''' Button text and the tooltip displayed on hover is changed whenever the button is clicked. + ''' + ''' Not used. + ''' Not used. + Private Sub cmdCombineWithAndOr_Click(sender As Object, e As EventArgs) Handles cmdCombineWithAndOr.Click + If cmdCombineWithAndOr.Text.Contains("All combined with |") Then + clsFilterView.strOperation = "&" + clsFilterFunction.AddParameter("and_or", Chr(34) & "&" & Chr(34), iPosition:=3) + cmdCombineWithAndOr.Text = " All combined with &&" + ttpCombineWithAndOr.SetToolTip(cmdCombineWithAndOr, "With more than one condition, e.g. (year > 1990) & (year < 2021) they have all to be TRUE.") + Else + clsFilterView.strOperation = "|" + clsFilterFunction.AddParameter("and_or", Chr(34) & "|" & Chr(34), iPosition:=3) + cmdCombineWithAndOr.Text = "All combined with |" + ttpCombineWithAndOr.SetToolTip(cmdCombineWithAndOr, "With more than one condition, e.g. (sunhrs >14) | (sunhrs <0) then just one need be TRUE.") + End If + ucrFilterPreview.SetName(clsFilterView.ToScript()) + End Sub End Class diff --git a/instat/ucrGeom.vb b/instat/ucrGeom.vb index 450b072c721..71455acf4cc 100644 --- a/instat/ucrGeom.vb +++ b/instat/ucrGeom.vb @@ -1217,20 +1217,29 @@ Public Class ucrGeom 'clsgeom_rect.AddLayerParameter("position", "list", Chr(34) & "identity" & Chr(34)) 'lstAllGeoms.Add(clsgeom_rect) - 'clsgeom_ribbon.strGeomName = "geom_ribbon" - 'clsgeom_ribbon.AddAesParameter("x", bIsMandatory:=TRUE) - 'clsgeom_ribbon.AddAesParameter("ymax", bIsMandatory:=TRUE) - 'clsgeom_ribbon.AddAesParameter("ymin", bIsMandatory:=TRUE) - ''optional - 'clsgeom_ribbon.AddAesParameter("alpha") - 'clsgeom_ribbon.AddAesParameter("colour") - 'clsgeom_ribbon.AddAesParameter("linetype") - 'clsgeom_ribbon.AddAesParameter("size") + clsgeom_ribbon.strGeomName = "geom_ribbon" + 'mandatory aes are s or y or ymax or y min + clsgeom_ribbon.AddAesParameter("x") + clsgeom_ribbon.AddAesParameter("y") + clsgeom_ribbon.AddAesParameter("ymax") + clsgeom_ribbon.AddAesParameter("ymin") + 'optional + clsgeom_ribbon.AddAesParameter("alpha") + clsgeom_ribbon.AddAesParameter("colour") + clsgeom_ribbon.AddAesParameter("group") + clsgeom_ribbon.AddAesParameter("linetype") + clsgeom_ribbon.AddAesParameter("size") ''add layer parameter - 'clsgeom_ribbon.AddLayerParameter("stat", "list", Chr(34) & "identity" & Chr(34)) - 'clsgeom_ribbon.AddLayerParameter("position", "list", Chr(34) & "identity" & Chr(34)) - 'lstAllGeoms.Add(clsgeom_ribbon) + 'not sure of all the options for this so i leave it as an editable list- once we know we can add all of them + clsgeom_ribbon.AddLayerParameter("stat", "editablelist", Chr(34) & "identity" & Chr(34), lstParameterStrings:={Chr(34) & "identity" & Chr(34)}) + clsgeom_ribbon.AddLayerParameter("position", "editablelist", Chr(34) & "identity" & Chr(34), lstParameterStrings:={Chr(34) & "identity" & Chr(34)}) + clsgeom_ribbon.AddLayerParameter("size", "numeric", "1") + clsgeom_ribbon.AddLayerParameter("colour", "colour", Chr(34) & "black" & Chr(34)) + clsgeom_ribbon.AddLayerParameter("show.legend", "list", "TRUE", lstParameterStrings:={"NA", "TRUE", "FALSE"}) + clsgeom_ribbon.AddLayerParameter("orientation", "list", "NA", lstParameterStrings:={"NA", "x", "y"}) + clsgeom_ribbon.AddLayerParameter("na.rm", "list", "FALSE", lstParameterStrings:={"TRUE", "FALSE"}) + lstAllGeoms.Add(clsgeom_ribbon) clsgeom_rug.SetGeomName("geom_rug") clsgeom_rug.AddAesParameter("x", strIncludedDataTypes:={"factor", "numeric"}) diff --git a/instat/ucrScript.Designer.vb b/instat/ucrScript.Designer.vb index 6d849d6f447..83d8e4a450b 100644 --- a/instat/ucrScript.Designer.vb +++ b/instat/ucrScript.Designer.vb @@ -45,6 +45,7 @@ Partial Class ucrScript Me.mnuCopy = New System.Windows.Forms.ToolStripMenuItem() Me.mnuPaste = New System.Windows.Forms.ToolStripMenuItem() Me.mnuUndo = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuRedo = New System.Windows.Forms.ToolStripMenuItem() Me.RToolStripMenuItem = New System.Windows.Forms.ToolStripSeparator() Me.mnuRunCurrentLine = New System.Windows.Forms.ToolStripMenuItem() Me.mnuRunSelectedText = New System.Windows.Forms.ToolStripMenuItem() @@ -71,6 +72,7 @@ Partial Class ucrScript Me.txtScript.Multiline = True Me.txtScript.Name = "txtScript" Me.txtScript.ScrollBars = System.Windows.Forms.ScrollBars.Both + Me.txtScript.ShortcutsEnabled = False Me.txtScript.Size = New System.Drawing.Size(405, 255) Me.txtScript.TabIndex = 0 Me.txtScript.WordWrap = False @@ -78,47 +80,55 @@ Partial Class ucrScript 'mnuContextScript ' Me.mnuContextScript.ImageScalingSize = New System.Drawing.Size(24, 24) - Me.mnuContextScript.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuCut, Me.mnuCopy, Me.mnuPaste, Me.mnuUndo, Me.RToolStripMenuItem, Me.mnuRunCurrentLine, Me.mnuRunSelectedText, Me.mnuRunAllText, Me.mnuOpenScriptasFile, Me.mnuLoadScriptFromFile, Me.mnuSaveScript, Me.mnuClearContents, Me.ToolStripSeparator1, Me.mnuHelp}) + Me.mnuContextScript.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuCut, Me.mnuCopy, Me.mnuPaste, Me.mnuUndo, Me.mnuRedo, Me.RToolStripMenuItem, Me.mnuRunCurrentLine, Me.mnuRunSelectedText, Me.mnuRunAllText, Me.mnuOpenScriptasFile, Me.mnuLoadScriptFromFile, Me.mnuSaveScript, Me.mnuClearContents, Me.ToolStripSeparator1, Me.mnuHelp}) Me.mnuContextScript.Name = "mnuContextLogFile" - Me.mnuContextScript.Size = New System.Drawing.Size(231, 280) + Me.mnuContextScript.Size = New System.Drawing.Size(230, 302) ' 'mnuCut ' Me.mnuCut.Name = "mnuCut" Me.mnuCut.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.X), System.Windows.Forms.Keys) - Me.mnuCut.Size = New System.Drawing.Size(230, 22) + Me.mnuCut.Size = New System.Drawing.Size(229, 22) Me.mnuCut.Text = "Cut" ' 'mnuCopy ' Me.mnuCopy.Name = "mnuCopy" Me.mnuCopy.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys) - Me.mnuCopy.Size = New System.Drawing.Size(230, 22) + Me.mnuCopy.Size = New System.Drawing.Size(229, 22) Me.mnuCopy.Text = "Copy" ' 'mnuPaste ' Me.mnuPaste.Name = "mnuPaste" Me.mnuPaste.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys) - Me.mnuPaste.Size = New System.Drawing.Size(230, 22) + Me.mnuPaste.Size = New System.Drawing.Size(229, 22) Me.mnuPaste.Text = "Paste" ' 'mnuUndo ' Me.mnuUndo.Name = "mnuUndo" Me.mnuUndo.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys) - Me.mnuUndo.Size = New System.Drawing.Size(230, 22) + Me.mnuUndo.Size = New System.Drawing.Size(229, 22) Me.mnuUndo.Text = "Undo" ' + 'mnuRedo + ' + Me.mnuRedo.Name = "mnuRedo" + Me.mnuRedo.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) _ + Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys) + Me.mnuRedo.Size = New System.Drawing.Size(229, 22) + Me.mnuRedo.Text = "Redo" + ' 'RToolStripMenuItem ' Me.RToolStripMenuItem.Name = "RToolStripMenuItem" - Me.RToolStripMenuItem.Size = New System.Drawing.Size(227, 6) + Me.RToolStripMenuItem.Size = New System.Drawing.Size(226, 6) ' 'mnuRunCurrentLine ' Me.mnuRunCurrentLine.Name = "mnuRunCurrentLine" - Me.mnuRunCurrentLine.Size = New System.Drawing.Size(230, 22) + Me.mnuRunCurrentLine.Size = New System.Drawing.Size(229, 22) Me.mnuRunCurrentLine.Text = "Run Current Line" ' 'mnuRunSelectedText @@ -126,7 +136,7 @@ Partial Class ucrScript Me.mnuRunSelectedText.Name = "mnuRunSelectedText" Me.mnuRunSelectedText.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Alt) _ Or System.Windows.Forms.Keys.T), System.Windows.Forms.Keys) - Me.mnuRunSelectedText.Size = New System.Drawing.Size(230, 22) + Me.mnuRunSelectedText.Size = New System.Drawing.Size(229, 22) Me.mnuRunSelectedText.Text = "Run Selected Text" ' 'mnuRunAllText @@ -134,43 +144,43 @@ Partial Class ucrScript Me.mnuRunAllText.Name = "mnuRunAllText" Me.mnuRunAllText.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Alt) _ Or System.Windows.Forms.Keys.R), System.Windows.Forms.Keys) - Me.mnuRunAllText.Size = New System.Drawing.Size(230, 22) + Me.mnuRunAllText.Size = New System.Drawing.Size(229, 22) Me.mnuRunAllText.Text = "Run All Text" ' 'mnuOpenScriptasFile ' Me.mnuOpenScriptasFile.Name = "mnuOpenScriptasFile" - Me.mnuOpenScriptasFile.Size = New System.Drawing.Size(230, 22) + Me.mnuOpenScriptasFile.Size = New System.Drawing.Size(229, 22) Me.mnuOpenScriptasFile.Text = "Open Script as File" ' 'mnuLoadScriptFromFile ' Me.mnuLoadScriptFromFile.Name = "mnuLoadScriptFromFile" - Me.mnuLoadScriptFromFile.Size = New System.Drawing.Size(230, 22) + Me.mnuLoadScriptFromFile.Size = New System.Drawing.Size(229, 22) Me.mnuLoadScriptFromFile.Text = "Load Script from File..." ' 'mnuSaveScript ' Me.mnuSaveScript.Name = "mnuSaveScript" - Me.mnuSaveScript.Size = New System.Drawing.Size(230, 22) + Me.mnuSaveScript.Size = New System.Drawing.Size(229, 22) Me.mnuSaveScript.Text = "Save Script..." ' 'mnuClearContents ' Me.mnuClearContents.Name = "mnuClearContents" Me.mnuClearContents.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.L), System.Windows.Forms.Keys) - Me.mnuClearContents.Size = New System.Drawing.Size(230, 22) + Me.mnuClearContents.Size = New System.Drawing.Size(229, 22) Me.mnuClearContents.Text = "Clear Script" ' 'ToolStripSeparator1 ' Me.ToolStripSeparator1.Name = "ToolStripSeparator1" - Me.ToolStripSeparator1.Size = New System.Drawing.Size(227, 6) + Me.ToolStripSeparator1.Size = New System.Drawing.Size(226, 6) ' 'mnuHelp ' Me.mnuHelp.Name = "mnuHelp" - Me.mnuHelp.Size = New System.Drawing.Size(230, 22) + Me.mnuHelp.Size = New System.Drawing.Size(229, 22) Me.mnuHelp.Text = "Help" ' 'cmdRun @@ -248,4 +258,5 @@ Partial Class ucrScript Friend WithEvents mnuRunCurrentLine As ToolStripMenuItem Friend WithEvents ToolStripSeparator1 As ToolStripSeparator Friend WithEvents mnuHelp As ToolStripMenuItem + Friend WithEvents mnuRedo As ToolStripMenuItem End Class \ No newline at end of file diff --git a/instat/ucrScript.vb b/instat/ucrScript.vb index 89b8bc77a56..8ff1d4dba4d 100644 --- a/instat/ucrScript.vb +++ b/instat/ucrScript.vb @@ -19,6 +19,7 @@ Public Class ucrScript Private strComment As String = "Code run from Script Window" Private strCurrentDirectory As String = "" Public strRInstatLogFilesFolderPath As String = Path.Combine(Path.GetFullPath(FileIO.SpecialDirectories.MyDocuments), "R-Instat_Log_files") + Private bUserTextChanged As Boolean = False Public Sub CopyText() txtScript.Copy() @@ -55,6 +56,7 @@ Public Class ucrScript If txtScript.TextLength > 0 Then If MessageBox.Show("Are you sure you want to clear the contents of the script window?" & Me.Text, "Clear " & Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then + bUserTextChanged = True 'This was preferred over txtScript.Clear() , to support undo txtScript.Focus() txtScript.SelectAll() @@ -155,12 +157,16 @@ Public Class ucrScript Private Sub mnuCut_Click(sender As Object, e As EventArgs) Handles mnuCut.Click If txtScript.SelectionLength > 0 Then + bUserTextChanged = False + mnuUndo.Enabled = True CutText() End If End Sub Private Sub mnuPaste_Click(sender As Object, e As EventArgs) Handles mnuPaste.Click If Clipboard.ContainsData(DataFormats.Text) Then + bUserTextChanged = False + mnuUndo.Enabled = True txtScript.Paste() Else MessageBox.Show("You can only paste text data on the script window", "Paste to Script Window", MessageBoxButtons.OK) @@ -171,10 +177,7 @@ Public Class ucrScript mnuRunCurrentLine.ShortcutKeys = Keys.Enter Or Keys.Control txtScript.WordWrap = False cmdRun.Enabled = (txtScript.TextLength > 0) - End Sub - - Private Sub txtScript_TextChanged(sender As Object, e As EventArgs) Handles txtScript.TextChanged - cmdRun.Enabled = (txtScript.TextLength > 0) + mnuRedo.Enabled = False 'this is only enabled when undo operation is done. End Sub Private Sub mnuContextScript_Opening(sender As Object, e As EventArgs) Handles mnuContextScript.Opening @@ -204,16 +207,49 @@ Public Class ucrScript End Sub - Private Sub Menu_Undo(sender As Object, e As EventArgs) Handles mnuUndo.Click + Private Sub mnuUndo_Click(sender As Object, e As EventArgs) Handles mnuUndo.Click 'Determine if last operation can be undone in text box. If txtScript.CanUndo Then - 'Undo the last operation. + bUserTextChanged = False + txtScript.Undo() 'Undo the last operation. + mnuUndo.Enabled = False + mnuRedo.Enabled = True + End If + End Sub + + Private Sub mnuRedo_Click(sender As Object, e As EventArgs) Handles mnuRedo.Click + + 'Determine if last operation can be undone in text box. + If txtScript.CanUndo Then + bUserTextChanged = False + 'This is an equivalent of redo in this case. + 'because calling undo twice gets the last undone text to be redone txtScript.Undo() - 'Clear the undo buffer to prevent last action from being redone. - txtScript.ClearUndo() + mnuUndo.Enabled = True + mnuRedo.Enabled = False End If End Sub + Private Sub txtScript_KeyDown(sender As Object, e As KeyEventArgs) Handles txtScript.KeyDown + 'Ignore the Ctrl, Shift commands. It could be a redo action which we want to ignore. + If Not (e.Control OrElse e.Shift OrElse e.Modifiers = (Keys.Control OrElse Keys.Shift)) Then + bUserTextChanged = True + End If + End Sub + + Private Sub txtScript_TextChanged(sender As Object, e As EventArgs) Handles txtScript.TextChanged + cmdRun.Enabled = (txtScript.TextLength > 0) + 'Only enabled undo if the text was changed directly by the user. + + If bUserTextChanged AndAlso Not mnuUndo.Enabled Then + txtScript.ClearUndo() 'Clear undo, because this is now a new text input by the user. + + mnuUndo.Enabled = True + mnuRedo.Enabled = False + End If + bUserTextChanged = False 'reset flag + End Sub + Private Sub mnuRunAllText_Click(sender As Object, e As EventArgs) Handles mnuRunAllText.Click RunAllText() End Sub @@ -221,4 +257,5 @@ Public Class ucrScript Private Sub mnuHelp_Click(sender As Object, e As EventArgs) Handles mnuHelp.Click Help.ShowHelp(Me, frmMain.strStaticPath & "\" & frmMain.strHelpFilePath, HelpNavigator.TopicId, "542") End Sub + End Class