-
Notifications
You must be signed in to change notification settings - Fork 103
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
Autofill of summary variables in the Climograph dialog. #9192
base: master
Are you sure you want to change the base?
Autofill of summary variables in the Climograph dialog. #9192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MeSophie I have made some code improvement, have a look and try it if it works well.
instat/dlgClimograph.vb
Outdated
ucrCurrentReceiver.SetMeAsReceiver() | ||
End If | ||
|
||
' Re-enable the event handler | ||
AddHandler ucrSelectorClimograph.ControlValueChanged, AddressOf AutoFillTmaxReceivers | ||
|
||
isFilling = False | ||
End Sub | ||
|
||
Private Sub AutoFillTminReceivers() | ||
If isFilling Then | ||
Exit Sub | ||
End If | ||
isFilling = True | ||
|
||
' Temporarily remove the event handler | ||
RemoveHandler ucrSelectorClimograph.ControlValueChanged, AddressOf AutoFillTminReceivers | ||
|
||
Dim lstRecognisedValues As List(Of String) | ||
Dim ucrCurrentReceiver As ucrReceiver | ||
Dim bFound As Boolean = False | ||
|
||
ucrCurrentReceiver = ucrSelectorClimograph.CurrentReceiver | ||
|
||
For Each ucrTempReceiver As ucrReceiver In lstTminReceivers | ||
ucrTempReceiver.SetMeAsReceiver() | ||
lstRecognisedValues = GetRecognisedValues(ucrTempReceiver.Tag) | ||
|
||
If lstRecognisedValues.Count > 0 Then | ||
For Each lviTempVariable As ListViewItem In ucrSelectorClimograph.lstAvailableVariable.Items | ||
For Each strValue As String In lstRecognisedValues | ||
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]", String.Empty).Equals(strValue) Then | ||
ucrTempReceiver.Add(lviTempVariable.Text, ucrSelectorClimograph.ucrAvailableDataFrames.cboAvailableDataFrames.Text) | ||
bFound = True | ||
Exit For | ||
End If | ||
Next | ||
If bFound Then | ||
bFound = False | ||
Exit For | ||
End If | ||
Next | ||
End If | ||
Next | ||
|
||
If ucrCurrentReceiver IsNot Nothing Then | ||
ucrCurrentReceiver.SetMeAsReceiver() | ||
End If | ||
|
||
' Re-enable the event handler | ||
AddHandler ucrSelectorClimograph.ControlValueChanged, AddressOf AutoFillTminReceivers | ||
|
||
isFilling = False | ||
End Sub | ||
|
||
Private Sub AutoFillTminminReceivers() | ||
If isFilling Then | ||
Exit Sub | ||
End If | ||
isFilling = True | ||
|
||
' Temporarily remove the event handler | ||
RemoveHandler ucrSelectorClimograph.ControlValueChanged, AddressOf AutoFillTminminReceivers | ||
|
||
Dim lstRecognisedValues As List(Of String) | ||
Dim ucrCurrentReceiver As ucrReceiver | ||
Dim bFound As Boolean = False | ||
|
||
ucrCurrentReceiver = ucrSelectorClimograph.CurrentReceiver | ||
|
||
For Each ucrTempReceiver As ucrReceiver In lstTminminReceivers | ||
ucrTempReceiver.SetMeAsReceiver() | ||
lstRecognisedValues = GetRecognisedValues(ucrTempReceiver.Tag) | ||
|
||
If lstRecognisedValues.Count > 0 Then | ||
For Each lviTempVariable As ListViewItem In ucrSelectorClimograph.lstAvailableVariable.Items | ||
For Each strValue As String In lstRecognisedValues | ||
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]", String.Empty).Equals(strValue) Then | ||
ucrTempReceiver.Add(lviTempVariable.Text, ucrSelectorClimograph.ucrAvailableDataFrames.cboAvailableDataFrames.Text) | ||
bFound = True | ||
Exit For | ||
End If | ||
Next | ||
If bFound Then | ||
bFound = False | ||
Exit For | ||
End If | ||
Next | ||
End If | ||
Next | ||
|
||
If ucrCurrentReceiver IsNot Nothing Then | ||
ucrCurrentReceiver.SetMeAsReceiver() | ||
End If | ||
|
||
' Re-enable the event handler | ||
AddHandler ucrSelectorClimograph.ControlValueChanged, AddressOf AutoFillTminminReceivers | ||
|
||
isFilling = False | ||
End Sub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about reducing the four subs to one like this?
Private Sub AutoFillReceivers(lstReceivers As List(Of ucrReceiverSingle ))
Dim lstRecognisedValues As List(Of String)
Dim ucrCurrentReceiver As ucrReceiver = ucrSelectorClimograph.CurrentReceiver
Dim bFound As Boolean = False
For Each ucrTempReceiver As ucrReceiver In lstReceivers
ucrTempReceiver.SetMeAsReceiver()
lstRecognisedValues = GetRecognisedValues(ucrTempReceiver.Tag)
If lstRecognisedValues.Count > 0 Then
For Each lviTempVariable As ListViewItem In ucrSelectorClimograph.lstAvailableVariable.Items
For Each strValue As String In lstRecognisedValues
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]", String.Empty).Equals(strValue) Then
ucrTempReceiver.Add(lviTempVariable.Text, ucrSelectorClimograph.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
bFound = True
Exit For
End If
Next
If bFound Then
bFound = False
Exit For
End If
Next
End If
Next
If ucrCurrentReceiver IsNot Nothing Then
ucrCurrentReceiver.SetMeAsReceiver()
End If
End Sub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is solved.
instat/dlgClimograph.vb
Outdated
AutoFillRainReceivers() | ||
AutoFillTmaxReceivers() | ||
AutoFillTminReceivers() | ||
AutoFillTminminReceivers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then replace this with
If isFilling Then
Exit Sub
End If
isFilling = True
Dim lstReceivers As List(Of ucrReceiverSingle ) = Nothing
If ucrSelectorClimograph.CurrentReceiver IsNot Nothing Then
Select Case ucrSelectorClimograph.CurrentReceiver.Tag ' Or any property that differentiates the lists
Case "Rain"
lstReceivers = lstRainReceivers
Case "Tmax"
lstReceivers = lstTmaxReceivers
Case "Tmin"
lstReceivers = lstTminReceivers
Case "Tminmin"
lstReceivers = lstTminminReceivers
' Add additional cases as necessary
End Select
End If
If lstReceivers IsNot Nothing Then
AutoFillReceivers(lstReceivers)
End If
isFilling = False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-thony I wasn't able to test the new change because of this code. lstTminminReceivers, lstTminReceivers, lstTmaxReceivers and lstRainReceivers are producing errors saying 'Unable to convert “List(Of ucrReceiverSingle)” to “List(Of ucrReceiver)”. So I changed ucrReceiver to ucrReceiverSingle then I obtained this message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-thony I wasn't able to test the new change because of this code. lstTminminReceivers, lstTminReceivers, lstTmaxReceivers and lstRainReceivers are producing errors saying 'Unable to convert “List(Of ucrReceiverSingle)” to “List(Of ucrReceiver)”. So I changed ucrReceiver to ucrReceiverSingle then I obtained this message
@MeSophie I have made a small change in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-thony I wasn't able to test the new change because of this code. lstTminminReceivers, lstTminReceivers, lstTmaxReceivers and lstRainReceivers are producing errors saying 'Unable to convert “List(Of ucrReceiverSingle)” to “List(Of ucrReceiver)”. So I changed ucrReceiver to ucrReceiverSingle then I obtained this message
@MeSophie I have made a small change in the code
@N-thony I still have this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check again, an If was missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-thony the Autofill is not working anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is solved.
instat/dlgClimograph.vb
Outdated
AutoFillRainReceivers() | ||
AutoFillTmaxReceivers() | ||
AutoFillTminReceivers() | ||
AutoFillTminminReceivers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MeSophie pull my branch MeSophie-SummaryClimaticissue9067 and have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is solved.
@MeSophie can you push the changes? |
Fixes #9067
@rdstern I ensured the Autofill of summary variables in the Climograph dialog. Please have a look.