From 134063f37db5709f9676ded17747e812354acabb Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 10 Aug 2020 14:35:18 +0200 Subject: [PATCH 01/44] integrate the ucrCoreNotes in the ucrClass.vb --- instat/ucrCore.vb | 389 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 357 insertions(+), 32 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index e0e5f1c8726..25b81894680 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -16,18 +16,51 @@ Imports instat +''' The ucrCore class inherits from the 'System.Windows.Forms.UserControl' class. +''' It is an empty control that is used as the foundation class for the other R-Instat controls. +''' Each R-Instat user control class is prefixed with 'ucr' (e.g. ucrButtons, ucrCalculator, ucrCheck etc.). +''' Any class that inherits from ucrCore is called a core control. +''' There are also some non-core controls such as the selector (which does not correspond to any R command or parameter). +''' The comments for this class use the following terminology: +''' Control +''' Core control +''' Control's value +''' Control’s R code +''' Primary pair +''' Non-primary pair(s) +''' Linked control +''' Parent control +''' +''' + 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. + + ''' These lists contain pairs of (R commands and parameters) associated with the user control. + ''' The first pair considered primary pair 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}) + ''' These lists contain pairs of (R commands and parameters) associated with the user control. + ''' The first pair considered primary pair 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 + + + + ''' The object default is the control'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). Protected objRDefault As Object = Nothing + ''' The object default is the control'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). Protected objDefaultState As Object = Nothing 'Protected typControlType As Type = Object @@ -41,65 +74,109 @@ Public Class ucrCore '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 + + ''' If true then this user control can add/remove parameters. + ''' (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. + ''' (e.g. check box may not change parameter value, only add/remove it + ''' For this 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 the 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 set a text in a textbox) + ''' + ''' Refer to the control changed 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 + ''' + ''' Refer to the control changed 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 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. 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) + ''' 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 + ''' List all the controls to display linked to this control, + ''' set 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 (if false, then it cannot be set). 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. 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. + ''' (Optional) Should the control reset to the default value if the parameter is not present in the code + ''' (Optional) Should the control control if needed when the parameter is present in the code Public Overridable Sub UpdateControl(Optional bReset As Boolean = False, Optional bCloneIfNeeded As Boolean = False) Dim clsTempRCode As RCodeStructure Dim clsTempRParameter As RParameter @@ -149,6 +226,15 @@ Public Class ucrCore 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. + ''' + ''' + ''' Protected Overridable Sub SetControlValue() Dim bConditionsMet As Boolean = False @@ -180,6 +266,14 @@ 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,6 +288,8 @@ Public Class ucrCore End If End Function + ''' Updates all the controls linked to this control (hereafter called 'child' and 'parent' respectively) + ''' (Optional) The control should reset to the default value. Public Overridable Sub UpdateLinkedControls(Optional bReset As Boolean = False) Dim ucrControl As ucrCore Dim lstValues As Object() @@ -234,7 +330,9 @@ Public Class ucrCore Next End Sub - 'Update the RCode based on the contents of the control (reverse of above) + + ''' Update the R code by adding/removing parameter. + ''' (Optional) The control should reset to the default value. Public Overridable Sub UpdateRCode(Optional bReset As Boolean = False) If bAddRemoveParameter Then AddOrRemoveParameter(CanAddParameter()) @@ -265,6 +363,11 @@ 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 + + ''' Set the R syntax to the control. + ''' The new R syntax. + ''' If true reset to default + ''' (Optional) The control should reset to the default value. 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 +378,26 @@ Public Class ucrCore UpdateControl(bReset, bCloneIfNeeded:=bCloneIfNeeded) End Sub + ''' Can update the parameter into the R codes. + ''' The parameter updated. 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 + + ''' Set an object to R default. Public Overridable Sub SetToRDefault() If clsParameter IsNot Nothing AndAlso objRDefault IsNot Nothing Then clsParameter.SetArgumentValue(objRDefault.ToString()) @@ -303,16 +414,24 @@ Public Class ucrCore '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 +439,16 @@ 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 +457,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 +468,23 @@ 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 + + ''' Control the value contained in the control. + ''' The parameter of the control. + ''' Return False. 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 +497,32 @@ Public Class ucrCore Next End Sub + ''' Adds a new linked control to the 'lstValuesAndControl' list. + ''' 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 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 +536,11 @@ Public Class ucrCore End If End Sub + + ''' Check if the control is linked to another control. + ''' + ''' parameter refering to the control + ''' Temporary control value. Public Function IsLinkedTo(ucrControl) As Boolean Dim bTemp As Boolean = False @@ -391,14 +553,21 @@ Public Class ucrCore Return bTemp End Function + ''' If the parameter is a default R code. + ''' Parameter. 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 + ''' Can add parameter in the R code. + ''' True if it's not a default R code. False otherwise. Public Overridable Function CanAddParameter() As Boolean Return Not IsRDefault() End Function + + ''' True if the is a present linked controls parameters otherwise False. + ''' Temporary control value Public Function LinkedControlsParametersPresent() As Boolean Dim bTemp As Boolean = False @@ -411,6 +580,10 @@ Public Class ucrCore Return bTemp End Function + ''' Get the list of all the R parameters. + ''' + ''' The position that needs to count the list of R parameters + ''' A list of All the R parameters or Nothing. Public Overridable Function GetParameter(Optional iIndex As Integer = 0) As RParameter If iIndex < lstAllRParameters.Count Then Return lstAllRParameters(iIndex) @@ -419,10 +592,16 @@ Public Class ucrCore End If End Function + ''' Get the R codes. + ''' R codes. Public Overridable Function GetRCode() As RCodeStructure Return clsRCode End Function + ''' + ''' Set the link of the new control with other controls linked to display. + ''' + ''' The new control to be linked to other Public Sub SetLinkedDisplayControl(ctrNewControl As Control) Dim lstCtrNewControls As New List(Of Control) lstCtrNewControls.Add(ctrNewControl) @@ -431,6 +610,10 @@ Public Class ucrCore End Sub + ''' + ''' Set the link of the new control with other controls linked to display to be visible. + ''' + ''' The list of new controls to be linked to other Public Sub SetLinkedDisplayControl(lstCtrNewControls As List(Of Control)) lstCtrLinkedDisplayControls = lstCtrNewControls SetLinkedDisplayControlVisibility() @@ -439,11 +622,19 @@ Public Class ucrCore Private Sub ucrCore_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged SetLinkedDisplayControlVisibility() End Sub - + ''' + ''' Set the linked control to display to be visible property and return the contains groupbox. + ''' Private Sub SetLinkedDisplayControlVisibility() SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(Visible) End Sub + + ''' + ''' Set the linked control to display to be visible property and return the contains groupbox. + ''' + ''' True then visible property of the controls. + ''' True is if the type of control is a groupbox. Private Function SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(bVisible As Boolean) As Boolean Dim ctr As Control Dim bContainsGroupBox As Boolean = False @@ -462,9 +653,14 @@ Public Class ucrCore Return bContainsGroupBox End Function + ''' Set the value to the object. + ''' The parameter's object value. Public Overridable Sub SetToValue(objTemp As Object) End Sub + ''' Add a condition to the object. + ''' The parameter that control the state of the object + ''' The parameter of the condition to add Public Sub AddCondition(objControlState As Object, clsCond As Condition) If dctConditions.ContainsKey(objControlState) Then dctConditions(objControlState).Add(clsCond) @@ -473,6 +669,11 @@ Public Class ucrCore End If End Sub + ''' Add the condition to the valus of the parameter + ''' The parameter that control the state of the object. + ''' The parameter's name. + ''' The parameter's name. + ''' (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 +681,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add the condition to the valus of the parameter + ''' The parameter that control the state of the object. + ''' 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 +694,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add condition to the current parameter. + ''' + ''' The parameter that control the state of the object. + ''' 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 +707,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add condition to the current parameter. + ''' + ''' The parameter that control the state of the object. + ''' The parameter's list. + ''' (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 +720,12 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add condition name to the function. + ''' + ''' The parameter that control the state of the object. + ''' The parameter's function. + ''' (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 +733,10 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Add condition to the R function is a R codes. + ''' + ''' The parameter that control the state of the object. + ''' (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 +744,11 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Add condition name to the function. + ''' + ''' The parameter that control the state of the object. + ''' The parameter'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 +756,11 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' dd condition to the parameter is string. + ''' Set the parameter's name to . + ''' The parameter control the object in the R syntax. + ''' 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 +768,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add a condition to the parameter is the R function. + ''' Sets parameter's name to . + ''' + ''' The parameter control the object in the R codes. + ''' 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 +782,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add a condition to the parameter is the R opertor. + ''' Sets parameter's name to . + ''' + ''' The parameter control the object in the R codes. + ''' 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 +796,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add the condition to the parameter value and function names. + ''' Sets parameter's name to and function'name to . + ''' The parameter control the object in the R codes. + ''' 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 +810,14 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add a condition to the parameter value and function name of the R codes. + ''' Sets parameter's name to and function's name to . + ''' + ''' The parameter control the object in the R codes. + ''' Name of the parameter. + ''' Name of the function. + ''' (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 +825,13 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Add a conditon to the R syntax contains the function name. + ''' Set the function's name to . + ''' + ''' The parameter control the object in the R syntax. + ''' 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 +839,9 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + ''' Add a condition to the code contain the R syntax. + ''' The parameter control the R state. + ''' 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 +849,9 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub + + ''' Set visible a control. + ''' If true then set a control visible property. Public Sub SetVisible(bVisible As Boolean) 'TODO: check how this should behave with linked group boxes If Not SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(bVisible) Then @@ -581,16 +862,22 @@ Public Class ucrCore End Sub + ''' Set to default state an object. + ''' The object to set default. Public Sub SetDefaultState(objState As Object) objDefaultState = objState End Sub + + ''' Set to default state an object. 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,26 +887,45 @@ 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 @@ -635,31 +941,44 @@ 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 overrided. Only for controls which use parameters in very different way 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 + ''' List of all the Parameters. + ''' List all Parameters. Private Property clsParameter As RParameter Get Return lstAllRParameters(0) @@ -670,6 +989,8 @@ Public Class ucrCore End Set End Property + ''' List of all the R codes. + ''' List all R codes Private Property clsRCode As RCodeStructure Get Return lstAllRCodes(0) @@ -683,6 +1004,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,6 +1015,9 @@ 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 From a56815f9239f999f60de056dff2a3d2a156b3e79 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 10 Aug 2020 14:39:15 +0200 Subject: [PATCH 02/44] integrate comment from ucrCoreNote to ucrCore.vb --- instat/ucrCore.vb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 25b81894680..02292e20399 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -406,14 +406,6 @@ 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. @@ -622,6 +614,7 @@ Public Class ucrCore Private Sub ucrCore_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged SetLinkedDisplayControlVisibility() End Sub + ''' ''' Set the linked control to display to be visible property and return the contains groupbox. ''' From 2543b06e389813d5fe240e6f3cf3489149eea53e Mon Sep 17 00:00:00 2001 From: N-thony Date: Sun, 16 Aug 2020 12:50:57 +0200 Subject: [PATCH 03/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 02292e20399..751ed33089d 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -38,12 +38,18 @@ Public Class ucrCore '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. - ''' These lists contain pairs of (R commands and parameters) associated with the user control. - ''' The first pair considered primary pair can be accessed directly using the properties 'clsRCode' and 'clsRParameter' (these just reference the first element in the lists). + ''' 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}) - ''' These lists contain pairs of (R commands and parameters) associated with the user control. - ''' The first pair considered primary pair can be accessed directly using the properties 'clsRCode' and 'clsRParameter' (these just reference the first element in the lists). + ''' 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}) @@ -1014,4 +1020,4 @@ Public Class ucrCore Public Overridable Sub SetAddRemoveParameter(bNew As Boolean) bAddRemoveParameter = bNew End Sub -End Class \ No newline at end of file +End Class From 85ca1c803f9512d6918ecebd3f554ca5fbc20f38 Mon Sep 17 00:00:00 2001 From: N-thony Date: Sun, 16 Aug 2020 12:58:56 +0200 Subject: [PATCH 04/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 751ed33089d..57ce211d994 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -82,13 +82,15 @@ Public Class ucrCore 'e.g. nud may not add/remove parameter, only change its value ''' 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. - ''' (e.g. check box may not change parameter value, only add/remove it + ''' Used in combination with 'bAddRemoveParameter'. + ''' (e.g. check box may not change parameter value, only add/remove it ''' For this bAddRemoveParameter = True and bChangeParameterValue = False) ''' Public bChangeParameterValue As Boolean = True From 2c85526da422619333d0bbd197a3270d93f1fc87 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:08:57 +0200 Subject: [PATCH 05/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 57ce211d994..614bdf16891 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -61,12 +61,27 @@ Public Class ucrCore - ''' The object default is the control'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). + ''' 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 - ''' The object default is the control'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). + ''' 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 'Protected typControlType As Type = Object From 30b8ee1baed3295818087c9100ba8571c0d6bbfe Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:10:04 +0200 Subject: [PATCH 06/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 614bdf16891..8faf032c66f 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -114,7 +114,8 @@ Public Class ucrCore Public objValueToRemoveParameter As Object ''' - ''' ValueChanged is raised when a new value has been set in the control (e.g. the user set a text in a textbox) + ''' ValueChanged is raised when a new value has been set in the control (e.g. the user enters text in a textbox) + ''' ''' Refer to the control changed Public Event ControlValueChanged(ucrChangedControl As ucrCore) From c4e11f8032399348fef5868fef526967608713a4 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:10:51 +0200 Subject: [PATCH 07/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 8faf032c66f..8542df8dcdb 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -117,7 +117,8 @@ Public Class ucrCore ''' ValueChanged is raised when a new value has been set in the control (e.g. the user enters text in a textbox) ''' - ''' Refer to the control changed + ''' The control that triggered this event. + Public Event ControlValueChanged(ucrChangedControl As ucrCore) From 16d9610d27c409719b2ded9764f6d47655957b74 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:11:29 +0200 Subject: [PATCH 08/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 8542df8dcdb..9c591decc53 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -125,8 +125,9 @@ Public Class 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) - ''' When ValueChanged is raised, so is ContentsChanged + ''' 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 ''' ''' Refer to the control changed From 47634d03aa74ca424ca0332b7d4234aec71fc5cb Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:11:47 +0200 Subject: [PATCH 09/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 9c591decc53..2d1b4759c6a 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -404,8 +404,9 @@ Public Class ucrCore UpdateControl(bReset, bCloneIfNeeded:=bCloneIfNeeded) End Sub - ''' Can update the parameter into the R codes. - ''' The parameter updated. + ''' 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 From 5fe72956b5893befd2f207353e0353b63da3a24c Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:12:12 +0200 Subject: [PATCH 10/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 2d1b4759c6a..fd7856d84f3 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -423,8 +423,9 @@ Public Class ucrCore objValueToRemoveParameter = objNewValue End Sub - - ''' Set an object to R default. + ''' 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()) From 40bcc0f62ceffca054b92123d84bc5ffec012c6d Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:12:29 +0200 Subject: [PATCH 11/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index fd7856d84f3..b9bc0a4dea9 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -517,7 +517,9 @@ Public Class ucrCore Next End Sub - ''' Adds a new linked control to the 'lstValuesAndControl' list. + ''' 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. From ab83ca54b67f1020922c8d3e6cdb420a5a89fd02 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:13:03 +0200 Subject: [PATCH 12/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index b9bc0a4dea9..8e0b4ba78c8 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -535,7 +535,10 @@ Public Class ucrCore Next End Sub - ''' Adds a new linked control to the 'lstValuesAndControl' list. + ''' 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. From ab374fce530ab6ff9be13c825f1bbdae37fcafb2 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:13:48 +0200 Subject: [PATCH 13/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 8e0b4ba78c8..99bf997c7bb 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -130,7 +130,8 @@ Public Class ucrCore ''' ContentsChanged is probably only needed for TestOK ''' - ''' Refer to the control changed + ''' The control that triggered this event. + Public Event ControlContentsChanged(ucrChangedControl As ucrCore) ''' ControlClicked is raised when the control is clicked. From ce60d37450d5ef41fb13334180bd1d4cb1fa3597 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:14:36 +0200 Subject: [PATCH 14/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 99bf997c7bb..24b91f1e121 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -135,7 +135,8 @@ Public Class ucrCore 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. + ''' For some controls, this will be raised when one of their child controls is clicked. + ''' Public Event ControlClicked() From f70e07b1a4987b7ed4b82445d209d3cf4b54a296 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:15:17 +0200 Subject: [PATCH 15/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 24b91f1e121..6e54e498364 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -172,8 +172,9 @@ Public Class ucrCore ''' these booleans specify how the parent control can modify this control. Public bLinkedChangeParameterValue As Boolean = False - ''' List all the controls to display linked to this control, - ''' set the visible/enabled property of these controls (e.g. a checkbox that shows/hides set of controls) + ''' 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) From 9ec6d53d18c9123b30803f9530c13289693f02d7 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:15:49 +0200 Subject: [PATCH 16/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 6e54e498364..e3ec1872a55 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -186,7 +186,19 @@ Public Class ucrCore 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. + ''' 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. From ed9fe2e50d5665ce469c761298a92fe173ff10bc Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:16:41 +0200 Subject: [PATCH 17/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index e3ec1872a55..4016fc9fdbf 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -214,10 +214,17 @@ Public Class ucrCore ''' (Currently only implemented for receivers) Protected strValuesToIgnore As String() - - ''' Updates the control, and the linked controls, based upon the values of the parameters in the command-parameter pair list. - ''' (Optional) Should the control reset to the default value if the parameter is not present in the code - ''' (Optional) Should the control control if needed when the parameter is 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 From 6f7b687a9f2b92e293b94470bfbaa9bd6d018b26 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:17:37 +0200 Subject: [PATCH 18/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 4016fc9fdbf..10a2dc4929e 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -281,7 +281,9 @@ Public Class ucrCore ''' 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 From 8ca4e7e3bebc6e9443708e5fe3edff5186b2c953 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:18:10 +0200 Subject: [PATCH 19/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 10a2dc4929e..a3d78837fb1 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -338,8 +338,23 @@ Public Class ucrCore End If End Function - ''' Updates all the controls linked to this control (hereafter called 'child' and 'parent' respectively) - ''' (Optional) The control should reset to the default value. + ''' 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() From 1031ca3f7677c59d6eb7556c91e930d387f26d68 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:18:47 +0200 Subject: [PATCH 20/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index a3d78837fb1..489d19fb967 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -396,8 +396,11 @@ Public Class ucrCore End Sub - ''' Update the R code by adding/removing parameter. - ''' (Optional) The control should reset to the default value. + ''' Updates the control’s R code to reflect the current state of the control’s + ''' parameters. + ''' + ''' (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()) From 01ad2660ebfa54829ea0ce227c8a102ce582d190 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 11:19:22 +0200 Subject: [PATCH 21/44] Update instat/ucrCore.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrCore.vb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 489d19fb967..db600b08ace 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -432,10 +432,16 @@ 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 - ''' Set the R syntax to the control. + ''' 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. - ''' If true reset to default - ''' (Optional) The control should reset to the 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). + ''' (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 From 9219df3f4dedd87a6718ff63384feb63af2c5838 Mon Sep 17 00:00:00 2001 From: N-thony Date: Mon, 17 Aug 2020 13:21:04 +0200 Subject: [PATCH 22/44] Updating the comment with suggestion made. --- instat/ucrCore.vb | 129 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 39 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index db600b08ace..a2011b4109c 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -22,21 +22,45 @@ Imports instat ''' Any class that inherits from ucrCore is called a core control. ''' There are also some non-core controls such as the selector (which does not correspond to any R command or parameter). ''' The comments for this class use the following terminology: -''' Control -''' Core control -''' Control's value -''' Control’s R code -''' Primary pair -''' Non-primary pair(s) -''' Linked control -''' Parent control +''' +''' 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. +''' +''' Parent control +''' This term is used in text about the linking mechanism to refer to the current control. +''' In the rest of the document the current control is referred to as ‘this control’. +''' But using ‘this control’ in the linking description proved confusing so the +''' term ‘parent control’ is used to be more explicit. +''' ''' ''' 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. @@ -84,18 +108,6 @@ Public Class ucrCore ''' 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 - - '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 - ''' 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 @@ -115,7 +127,6 @@ Public Class ucrCore ''' ''' 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. @@ -127,7 +138,6 @@ Public Class ucrCore ''' 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. @@ -136,7 +146,6 @@ Public Class ucrCore ''' 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() @@ -174,7 +183,6 @@ Public Class ucrCore ''' 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) @@ -186,7 +194,7 @@ Public Class ucrCore Public bUpdateRCodeFromControl As Boolean = False - ''' This dictionary is used to set the control’s value (i.e. the value displayed to + ''' 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 @@ -230,34 +238,51 @@ Public Class ucrCore 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 @@ -267,7 +292,7 @@ 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() @@ -277,8 +302,10 @@ Public Class ucrCore ''' 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. + ''' 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. @@ -361,6 +388,7 @@ Public Class ucrCore 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 @@ -369,7 +397,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 @@ -391,6 +421,7 @@ 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 @@ -398,6 +429,7 @@ Public Class ucrCore ''' 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). @@ -408,12 +440,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 @@ -1004,10 +1051,14 @@ Public Class ucrCore 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 From beae6caafc450fbdcdcf90de41589cecca953977 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:40:59 +0200 Subject: [PATCH 23/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 60 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index a2011b4109c..d50ba942056 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -16,47 +16,51 @@ Imports instat -''' The ucrCore class inherits from the 'System.Windows.Forms.UserControl' class. -''' It is an empty control that is used as the foundation class for the other R-Instat controls. -''' Each R-Instat user control class is prefixed with 'ucr' (e.g. ucrButtons, ucrCalculator, ucrCheck etc.). -''' Any class that inherits from ucrCore is called a core control. -''' There are also some non-core controls such as the selector (which does not correspond to any R command or parameter). +''' +''' 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) -''' +''' Refers to a core control (unless specifically stated) +''' ''' Core control -''' A control that inherits from ucrCore -''' +''' A control that inherits from ucrCore. +''' ''' Control's value -''' The value entered/updated by the user (e.g. the text in a text box) -''' +''' 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) -''' +''' 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). -''' +''' 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. -''' +''' 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. -''' -''' Parent control -''' This term is used in text about the linking mechanism to refer to the current control. -''' In the rest of the document the current control is referred to as ‘this control’. -''' But using ‘this control’ in the linking description proved confusing so the -''' term ‘parent control’ is used to be more explicit. -''' +''' (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. +''' ''' ''' From b63f756279b6146b394b4fcf0c96bb0bf67ed7c1 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:42:11 +0200 Subject: [PATCH 24/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index d50ba942056..7cebe26b5cf 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -121,8 +121,8 @@ Public Class ucrCore ''' If true then this user control may change the value of parameters. ''' Used in combination with 'bAddRemoveParameter'. - ''' (e.g. check box may not change parameter value, only add/remove it - ''' For this bAddRemoveParameter = True and bChangeParameterValue = False) + ''' (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 From 198080d631bf6ec8052d4a3da9d7aabeea8b1577 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:44:29 +0200 Subject: [PATCH 25/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 7cebe26b5cf..d7d3ef32848 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -126,7 +126,7 @@ Public Class ucrCore ''' Public bChangeParameterValue As Boolean = True - ''' If parameter has this value the it will be removed from the RCodeStructure + ''' If parameter has this value then it will be removed from the RCodeStructure Public objValueToRemoveParameter As Object ''' From c07f9f35cfe13a2ce766f75de818c46cdabc859e Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:45:05 +0200 Subject: [PATCH 26/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index d7d3ef32848..d524a1ee2a8 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -154,9 +154,11 @@ Public Class ucrCore Public Event ControlClicked() - ''' 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. 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())) From 05bc1b8fa99d6f771cd905695339c06db197c071 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:45:33 +0200 Subject: [PATCH 27/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index d524a1ee2a8..c2af9d48734 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -163,8 +163,8 @@ Public Class ucrCore Protected lstValuesAndControl As New List(Of KeyValuePair(Of ucrCore, Object())) - ''' If this control is in another control's lstLinkedControls then these booleans specify - ''' how the parent 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 From e5ee5bc234c8543d5389bdca0b80fe60983b8341 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:46:11 +0200 Subject: [PATCH 28/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index c2af9d48734..50e1ef54356 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -171,7 +171,8 @@ Public Class ucrCore ''' 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. + ''' 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 From 06d5494248bcbaeb66924a9ba53a7e90c13ffb40 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:46:54 +0200 Subject: [PATCH 29/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 50e1ef54356..479d7dc1abd 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -194,7 +194,7 @@ Public Class ucrCore Protected lstCtrLinkedDisplayControls As List(Of Control) - ''' If true then the control's value can be set from the control's R code (if false, then it cannot be set). + ''' 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. From ef3f9690b06323fa6f98a75da42f913154551c41 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:47:45 +0200 Subject: [PATCH 30/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 479d7dc1abd..64d6ae31053 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -197,7 +197,8 @@ Public Class ucrCore ''' 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. + ''' If true, then update the control's associated commands and parameters whenever + ''' the control's value changes. Public bUpdateRCodeFromControl As Boolean = False From c18e65d0dd76c91dc9d89ed8f77f7fe010f5b438 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:48:51 +0200 Subject: [PATCH 31/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 64d6ae31053..ddb27d2a7b2 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -207,8 +207,8 @@ Public Class ucrCore ''' 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 + ''' 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. From f9cbf114ca246a9f6ba791d5add92ea0cef8bc3a Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:49:17 +0200 Subject: [PATCH 32/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index ddb27d2a7b2..260eda6ec3b 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -217,8 +217,10 @@ Public Class ucrCore 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). + ''' 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 From 860c9ff95fc78500fd1be1df475262b34cbb0886 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:50:08 +0200 Subject: [PATCH 33/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 260eda6ec3b..1a38c92d32d 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -353,13 +353,17 @@ 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'. - ''' + ''' 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 From e126c7fc0292e4c32e9e77b55bc406b49bc78de1 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:50:45 +0200 Subject: [PATCH 34/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 1a38c92d32d..ec5fb1d3445 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -577,7 +577,8 @@ Public Class ucrCore ''' 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. + ''' (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 From 8b953c79b4f83ac9089729908c2247530410b7e6 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:52:00 +0200 Subject: [PATCH 35/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index ec5fb1d3445..35d01ba4910 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -605,9 +605,11 @@ Public Class ucrCore End Function - ''' Control the value contained in the control. - ''' The parameter of the control. - ''' Return False. + ''' 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 From 885acf18c38bb8773ddc1faeb135adb242f9a348 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:53:01 +0200 Subject: [PATCH 36/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 35d01ba4910..e2b36a16e13 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -674,10 +674,10 @@ Public Class ucrCore End Sub - ''' Check if the control is linked to another control. + ''' Returns true if is linked to this control. ''' - ''' parameter refering to the control - ''' Temporary control value. + ''' the control to search for + ''' true if is linked to this control. Public Function IsLinkedTo(ucrControl) As Boolean Dim bTemp As Boolean = False From 8ae6f391e2e5759f8eb5ab83ececad5d4b63f025 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:53:28 +0200 Subject: [PATCH 37/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index e2b36a16e13..a4f796a9d31 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -690,8 +690,8 @@ Public Class ucrCore Return bTemp End Function - ''' If the parameter is a default R code. - ''' Parameter. + ''' 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 From df0f8f8133f2dffbf45bb9da7a5099f076c42ff0 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:53:54 +0200 Subject: [PATCH 38/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index a4f796a9d31..1b8d2de1bab 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -696,8 +696,8 @@ Public Class ucrCore Return clsParameter IsNot Nothing AndAlso clsParameter.strArgumentValue IsNot Nothing AndAlso objRDefault IsNot Nothing AndAlso objRDefault.Equals(clsParameter.strArgumentValue) End Function - ''' Can add parameter in the R code. - ''' True if it's not a default R code. False otherwise. + ''' 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 From 23677d53ed48765d5b6cec29f0877797b3c56b64 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:54:19 +0200 Subject: [PATCH 39/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 1b8d2de1bab..fe703ef8315 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -703,8 +703,8 @@ Public Class ucrCore End Function - ''' True if the is a present linked controls parameters otherwise False. - ''' Temporary control value + ''' 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 From a20137507703bec296540011accc5151018da988 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:54:42 +0200 Subject: [PATCH 40/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index fe703ef8315..269f2411a78 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -717,10 +717,10 @@ Public Class ucrCore Return bTemp End Function - ''' Get the list of all the R parameters. + ''' Returns the parameter with index . ''' - ''' The position that needs to count the list of R parameters - ''' A list of All the R parameters or Nothing. + ''' 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) From 630df0e1487c2f4a20ca554ac75cb2b8788112f6 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:55:08 +0200 Subject: [PATCH 41/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 269f2411a78..d3c3cfb2c80 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -729,8 +729,8 @@ Public Class ucrCore End If End Function - ''' Get the R codes. - ''' R codes. + ''' Returns the primary R command. + ''' The primary R command. Public Overridable Function GetRCode() As RCodeStructure Return clsRCode End Function From feb2b027f927c2d70ee912cfcc7164676cb1806e Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:55:36 +0200 Subject: [PATCH 42/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index d3c3cfb2c80..146fa721add 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -735,10 +735,8 @@ Public Class ucrCore Return clsRCode End Function - ''' - ''' Set the link of the new control with other controls linked to display. - ''' - ''' The new control to be linked to other + ''' 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) From 79cce004d5d6f11a548e615e69a3d2f04bb07476 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:56:04 +0200 Subject: [PATCH 43/44] Update instat/ucrCore.vb --- instat/ucrCore.vb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index 146fa721add..d331e6b31ee 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -745,10 +745,8 @@ Public Class ucrCore End Sub - ''' - ''' Set the link of the new control with other controls linked to display to be visible. - ''' - ''' The list of new controls to be linked to other + ''' 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() From 00bc4d234a58fe514dcb9d0eb18a29fc030f8a17 Mon Sep 17 00:00:00 2001 From: lloyddewit <57253949+lloyddewit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:59:09 +0200 Subject: [PATCH 44/44] Apply suggestions from code review --- instat/ucrCore.vb | 173 +++++++++++++++++++++++++++------------------- 1 file changed, 101 insertions(+), 72 deletions(-) diff --git a/instat/ucrCore.vb b/instat/ucrCore.vb index d331e6b31ee..ca9371789e2 100644 --- a/instat/ucrCore.vb +++ b/instat/ucrCore.vb @@ -756,19 +756,20 @@ Public Class ucrCore SetLinkedDisplayControlVisibility() End Sub - ''' - ''' Set the linked control to display to be visible property and return the contains groupbox. - ''' + ''' Set each control to display linked to this control, to 'Visible'. Private Sub SetLinkedDisplayControlVisibility() SetLinkedDisplayControlVisibilityAndReturnContainsGroupBox(Visible) End Sub ''' - ''' Set the linked control to display to be visible property and return the contains groupbox. + ''' 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. ''' - ''' True then visible property of the controls. - ''' True is if the type of control is a groupbox. + ''' 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 @@ -787,14 +788,16 @@ Public Class ucrCore Return bContainsGroupBox End Function - ''' Set the value to the object. - ''' The parameter's object value. + ''' 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 - ''' Add a condition to the object. - ''' The parameter that control the state of the object - ''' The parameter of the condition to add + ''' 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) @@ -803,10 +806,12 @@ Public Class ucrCore End If End Sub - ''' Add the condition to the valus of the parameter - ''' The parameter that control the state of the object. + ''' Creates a new condition based on , + ''' and . + ''' Adds this condition to value . + ''' The value for this control. ''' The parameter's name. - ''' 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 @@ -816,8 +821,10 @@ Public Class ucrCore End Sub - ''' Add the condition to the valus of the parameter - ''' The parameter that control the state of the object. + ''' 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. @@ -829,9 +836,10 @@ Public Class ucrCore End Sub - ''' Add condition to the current parameter. - ''' - ''' The parameter that control the state of the object. + ''' 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) @@ -842,10 +850,11 @@ Public Class ucrCore End Sub - ''' Add condition to the current parameter. - ''' - ''' The parameter that control the state of the object. - ''' The parameter's list. + ''' 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 @@ -855,10 +864,11 @@ Public Class ucrCore End Sub - ''' Add condition name to the function. - ''' - ''' The parameter that control the state of the object. - ''' The parameter's function. + ''' 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 @@ -867,9 +877,9 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub - ''' Add condition to the R function is a R codes. - ''' - ''' The parameter that control the state of the object. + ''' 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 @@ -878,10 +888,11 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub - ''' Add condition name to the function. - ''' - ''' The parameter that control the state of the object. - ''' The parameter's function list. + ''' 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 @@ -890,9 +901,10 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub - ''' dd condition to the parameter is string. - ''' Set the parameter's name to . - ''' The parameter control the object in the R syntax. + ''' 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) @@ -903,10 +915,10 @@ Public Class ucrCore End Sub - ''' Add a condition to the parameter is the R function. - ''' Sets parameter's name to . - ''' - ''' The parameter control the object in the R codes. + ''' 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) @@ -917,10 +929,10 @@ Public Class ucrCore End Sub - ''' Add a condition to the parameter is the R opertor. - ''' Sets parameter's name to . - ''' - ''' The parameter control the object in the R codes. + ''' 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) @@ -931,9 +943,11 @@ Public Class ucrCore End Sub - ''' Add the condition to the parameter value and function names. - ''' Sets parameter's name to and function'name to . - ''' The parameter control the object in the R codes. + ''' 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. @@ -945,12 +959,12 @@ Public Class ucrCore End Sub - ''' Add a condition to the parameter value and function name of the R codes. - ''' Sets parameter's name to and function's name to . - ''' - ''' The parameter control the object in the R codes. + ''' Creates a new parameter type condition based on + ''' , and + ''' . + ''' The value for this control. ''' Name of the parameter. - ''' Name of the function. + ''' 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 @@ -960,10 +974,9 @@ Public Class ucrCore End Sub - ''' Add a conditon to the R syntax contains the function name. - ''' Set the function's name to . - ''' - ''' The parameter control the object in the R syntax. + ''' 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) @@ -973,8 +986,9 @@ Public Class ucrCore AddCondition(objControlState, clsTempCond) End Sub - ''' Add a condition to the code contain the R syntax. - ''' The parameter control the R state. + ''' 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 @@ -986,6 +1000,13 @@ Public Class ucrCore ''' 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 @@ -996,20 +1017,24 @@ Public Class ucrCore End Sub - ''' Set to default state an object. - ''' The object to set default. + ''' 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 - ''' Set to default state an object. + ''' 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. + ''' 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) @@ -1051,9 +1076,12 @@ Public Class ucrCore ''' 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 + ''' 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. @@ -1080,8 +1108,9 @@ Public Class ucrCore End Sub - ''' Update all the parameters in the R script. - '''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 @@ -1115,8 +1144,8 @@ Public Class ucrCore End If End Sub - ''' List of all the Parameters. - ''' List all Parameters. + ''' The primary parameter. + ''' The primary parameter. Private Property clsParameter As RParameter Get Return lstAllRParameters(0) @@ -1127,8 +1156,8 @@ Public Class ucrCore End Set End Property - ''' List of all the R codes. - ''' List all R codes + ''' The primary R command. + ''' The primary R command. Private Property clsRCode As RCodeStructure Get Return lstAllRCodes(0)