Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the Climatic >Prepare>Length of Season dialog #9427

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions instat/dlgClimaticLengthOfSeason.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 31 additions & 10 deletions instat/dlgClimaticLengthOfSeason.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Public Class dlgClimaticLengthOfSeason
Private bReset As Boolean = True
Private strCurrDataName As String = ""

Private clsLengthOfSeasonFunction, clsLengthmoreFunction, clsListFunction, clsAscharactermoreFunction, clsConvertColumnTypeFunction, clsElseIfMoreFunction, clsApplyInstatCalcFunction, clsAsCharacterFunction, clsCombinationCalcFunction, clsStartEndStatusFunction, clsCaseWhenFunction, clsIsNAFunction, clsIsNA1Function, clsCombinationListFunction As New RFunction
Private clsMinusOpertor, clsAssignMoreOperator, clsMinusmoreOPerator, clsAndOperator, clsOROperator, clsCaseWhenOperator, clsCaseWhen1Operator, clsCaseWhen2Operator, clsCaseWhen3Operator, clsAssignOperator, clsAssign1Operator, clsAssign2Operator, clsAssign3Operator, clsAssign4Operator, clsAnd1Operator, clsAnd2Operator As New ROperator
Private clsLengthOfSeasonFunction, clsDayFromAndToFunction, clsLengthmoreFunction, clsListFunction, clsAscharactermoreFunction, clsIfElseFirstDoyFilledFunction, clsConvertColumnTypeFunction, clsElseIfMoreFunction, clsApplyInstatCalcFunction, clsAsCharacterFunction, clsDayFilterCalcFromListFunction, clsCombinationCalcFunction, clsStartEndStatusFunction, clsCaseWhenFunction, clsIsNAFunction, clsIsNA1Function, clsCombinationListFunction As New RFunction
Private clsMinusOpertor, clsAssignMoreOperator, clsDayToOperator, clsMinusmoreOPerator, clsAndOperator, clsOROperator, clsCaseWhenOperator, clsCaseWhen1Operator, clsDayFromOperator, clsCaseWhen2Operator, clsCaseWhen3Operator, clsAssignOperator, clsAssign1Operator, clsAssign2Operator, clsAssign3Operator, clsAssign4Operator, clsAnd1Operator, clsAnd2Operator As New ROperator

Private Sub dlgClimaticLengthOfSeason_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If bFirstLoad Then
Expand Down Expand Up @@ -81,24 +81,23 @@ Public Class dlgClimaticLengthOfSeason
ucrChkLengthmore.SetText("Length_More")
ucrChkLengthmore.AddParameterPresentCondition(True, "sub3", True)
ucrChkLengthmore.AddParameterPresentCondition(False, "sub3", False)
ucrChkLengthmore.AddToLinkedControls(ucrNudLenghtmore, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=366)
ucrChkLengthmore.AddToLinkedControls(ucrInputFilterPreview, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=366)

ucrNudLenghtmore.SetParameter(New RParameter("left", 0, False))
ucrNudLenghtmore.DecimalPlaces = 0
ucrNudLenghtmore.Increment = 1
ucrNudLenghtmore.Minimum = 1
ucrNudLenghtmore.Maximum = 366
EnableLengthmore()
ucrInputFilterPreview.IsReadOnly = True
End Sub

Private Sub SetDefaults()
Dim strLengthName As String = "length"
Dim strTypeName As String = "length_status"

clsDayFilterCalcFromListFunction = New RFunction
clsAscharactermoreFunction = New RFunction
clsListFunction = New RFunction
clsMinusmoreOPerator =New ROperator
clsMinusmoreOPerator = New ROperator

clsDayToOperator.Clear()
clsDayFromAndToFunction.Clear()
clsLengthOfSeasonFunction.Clear()
clsCombinationCalcFunction.Clear()
clsApplyInstatCalcFunction.Clear()
Expand Down Expand Up @@ -260,6 +259,10 @@ Public Class dlgClimaticLengthOfSeason

clsMinusmoreOPerator.SetOperation("-")

clsDayToOperator.SetOperation("")
clsDayToOperator.AddParameter("to", 366)
clsDayToOperator.bAllBrackets = False

'Base Function
ucrBase.clsRsyntax.ClearCodes()
ucrBase.clsRsyntax.SetBaseRFunction(clsApplyInstatCalcFunction)
Expand Down Expand Up @@ -287,7 +290,7 @@ Public Class dlgClimaticLengthOfSeason
ucrChkLengthofSeason.SetRCode(clsCombinationListFunction, bReset)
ucrChkType.SetRCode(clsCombinationListFunction, bReset)
ucrChkLengthmore.SetRCode(clsCombinationListFunction, bReset)
ucrNudLenghtmore.SetRCode(clsMinusmoreOPerator, bReset)
ucrInputFilterPreview.SetRCode(clsMinusmoreOPerator, bReset)
End Sub

Private Sub TestOKEnabled()
Expand Down Expand Up @@ -364,6 +367,7 @@ Public Class dlgClimaticLengthOfSeason

Private Sub EnableLengthmore()
ucrChkLengthmore.Enabled = ucrChkType.Checked
cmdDoyRange.Visible = ucrChkLengthmore.Checked
End Sub

Private Sub ucrInputLengthofSeason_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputLengthofSeason.ControlValueChanged
Expand All @@ -383,4 +387,21 @@ Public Class dlgClimaticLengthOfSeason
clsAscharactermoreFunction.RemoveParameterByName("x")
End If
End Sub

Private Sub cmdDoyRange_Click(sender As Object, e As EventArgs) Handles cmdDoyRange.Click
Dim newSdgDoyRange As New sdgDoyRange()
newSdgDoyRange.isFromDlgClimaticLengthOfSeason = True
newSdgDoyRange.Setup(clsNewDoyFilterCalc:=clsDayFromAndToFunction, clsNewIfElseFirstDoyFilledFunction:=clsIfElseFirstDoyFilledFunction, clsNewDayFromOperator:=clsDayFromOperator, clsNewDayToOperator:=clsDayToOperator, clsNewCalcFromList:=clsDayFilterCalcFromListFunction, strNewMainDataFrame:=ucrSelectorLengthofSeason.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strNewDoyColumn:="")
newSdgDoyRange.ShowDialog()
newSdgDoyRange.Desablecontrols()
ucrInputFilterPreview.SetName(clsDayToOperator.ToScript())
End Sub

Private Sub ucrInputFilterPreview_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputFilterPreview.ControlValueChanged
If Not ucrInputFilterPreview.IsEmpty Then
clsMinusmoreOPerator.AddParameter("left", ucrInputFilterPreview.GetText(), iPosition:=0, bIncludeArgumentName:=False)
Else
clsMinusmoreOPerator.RemoveParameterByName("left")
End If
End Sub
End Class
1 change: 0 additions & 1 deletion instat/sdgDoyRange.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions instat/sdgDoyRange.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Imports instat.Translations
Imports RDotNet

Public Class sdgDoyRange
Public isFromDlgClimaticLengthOfSeason As Boolean = False
Private clsDoyFilterCalc As RFunction
Private clsCalcFromList As RFunction
Private clsCalcFromMainDataFrame As RFunction
Expand All @@ -31,6 +32,7 @@ Public Class sdgDoyRange

Private Sub sdgDoyRange_Load(sender As Object, e As EventArgs) Handles MyBase.Load
autoTranslate(Me)
Desablecontrols()
End Sub

Public Sub Setup(clsNewDoyFilterCalc As RFunction, clsNewDayFromOperator As ROperator, clsNewDayToOperator As ROperator, clsNewCalcFromList As RFunction, strNewMainDataFrame As String, strNewDoyColumn As String, Optional clsNewIfElseFirstDoyFilledFunction As RFunction = Nothing)
Expand Down Expand Up @@ -264,4 +266,22 @@ Public Class sdgDoyRange
UpdateFromValues()
UpdateToValues()
End Sub

Public Sub Desablecontrols()
If Me.isFromDlgClimaticLengthOfSeason Then
Me.rdoFromFixed.Enabled = False
Me.rdoFromVariable.Enabled = False
Me.ucrDoyFrom.Enabled = False
Me.ucrReceiverFrom.Enabled = False
Me.rdoToVariable.Enabled = False
Me.rdoLength.Enabled = False
Me.ucrReceiverTo.Enabled = False
Me.ucrNudToDiff.Enabled = False
Me.ucrSelectorDoy.Enabled = False
Me.Size = New Size(603, 218)
Me.grpFrom.Location = New Size(10, 12)
Me.grpTo.Location = New Size(269, 12)
Me.ucrBaseSub.Location = New Size(185, 140)
End If
End Sub
End Class
Loading