Skip to content

Commit

Permalink
Merge pull request #9389 from N-thony/define_climatic
Browse files Browse the repository at this point in the history
Fix Bug in Define Climatic Loading and Address Usability Inconvenience
  • Loading branch information
Patowhiz authored Feb 19, 2025
2 parents b4ea261 + f790e8d commit 706e61d
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions instat/DlgDefineClimaticData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ Public Class DlgDefineClimaticData
clsDummyFunction = New RFunction
clsNewDefautFunction = New RFunction

ucrSelectorDefineClimaticData.Reset()
ucrSelectorLinkedDataFrame.Reset()
ucrInputCheckInput.Reset()
ucrReceiverDate.SetMeAsReceiver()

Expand Down Expand Up @@ -230,17 +228,17 @@ Public Class DlgDefineClimaticData
Dim bFound As Boolean = False

ucrCurrentReceiver = ucrSelectorDefineClimaticData.CurrentReceiver

Dim strData As String = ucrSelectorDefineClimaticData.ucrAvailableDataFrames.cboAvailableDataFrames.Text
For Each ucrTempReceiver As ucrReceiver In lstReceivers
ucrTempReceiver.SetMeAsReceiver()
lstRecognisedValues = GetRecognisedValues(ucrTempReceiver.Tag)

If lstRecognisedValues.Count > 0 Then
For Each lviTempVariable As ListViewItem In ucrSelectorDefineClimaticData.lstAvailableVariable.Items
Dim strClimaticType As String = GetClimaticTypeFromRCommand(lviTempVariable.Text)
Dim strClimaticType As String = GetClimaticTypeFromRCommand(lviTempVariable.Text, strData)
For Each strValue As String In lstRecognisedValues
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]|_", String.Empty).Contains(strValue) OrElse (strClimaticType IsNot Nothing AndAlso strClimaticType.Contains(strValue)) Then
ucrTempReceiver.Add(lviTempVariable.Text, ucrSelectorDefineClimaticData.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
ucrTempReceiver.Add(lviTempVariable.Text, strData)
bFound = True
Exit For
End If
Expand All @@ -263,43 +261,46 @@ Public Class DlgDefineClimaticData
Dim ucrCurrentReceiver As ucrReceiver
Dim bFound As Boolean = False

ucrCurrentReceiver = ucrSelectorLinkedDataFrame.CurrentReceiver

For Each ucrTempReceiver As ucrReceiver In lstNewReceivers
ucrTempReceiver.SetMeAsReceiver()
lstRecognisedValues = GetNewRecognisedValues(ucrTempReceiver.Tag)

If lstRecognisedValues.Count > 0 Then
For Each lviTempVariable As ListViewItem In ucrSelectorLinkedDataFrame.lstAvailableVariable.Items
Dim strClimaticType As String = GetClimaticTypeFromRCommand(lviTempVariable.Text)
For Each strValue As String In lstRecognisedValues
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]|_", String.Empty).Contains(strValue) OrElse (strClimaticType IsNot Nothing AndAlso strClimaticType.Contains(strValue)) Then
ucrTempReceiver.Add(lviTempVariable.Text, ucrSelectorLinkedDataFrame.ucrAvailableDataFrames.cboAvailableDataFrames.Text)
bFound = True
If ucrChkLinkedMetaData.Checked Then
ucrCurrentReceiver = ucrSelectorLinkedDataFrame.CurrentReceiver
Dim strData As String = ucrSelectorLinkedDataFrame.ucrAvailableDataFrames.cboAvailableDataFrames.Text

For Each ucrTempReceiver As ucrReceiver In lstNewReceivers
ucrTempReceiver.SetMeAsReceiver()
lstRecognisedValues = GetNewRecognisedValues(ucrTempReceiver.Tag)

If lstRecognisedValues.Count > 0 Then
For Each lviTempVariable As ListViewItem In ucrSelectorLinkedDataFrame.lstAvailableVariable.Items
Dim strClimaticType As String = GetClimaticTypeFromRCommand(lviTempVariable.Text, strData)
For Each strValue As String In lstRecognisedValues
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]|_", String.Empty).Contains(strValue) OrElse (strClimaticType IsNot Nothing AndAlso strClimaticType.Contains(strValue)) Then
ucrTempReceiver.Add(lviTempVariable.Text, strData)
bFound = True
Exit For
End If
Next
If bFound Then
bFound = False
Exit For
End If
Next
If bFound Then
bFound = False
Exit For
End If
Next
End If
Next
End If
Next

If ucrCurrentReceiver IsNot Nothing Then
ucrCurrentReceiver.SetMeAsReceiver()
If ucrCurrentReceiver IsNot Nothing Then
ucrCurrentReceiver.SetMeAsReceiver()
End If
End If
End Sub

Private Function GetClimaticTypeFromRCommand(strName As String) As String
Private Function GetClimaticTypeFromRCommand(strName As String, strDataName As String) As String
Try
Dim clsGetClimaticTypeFunction As New RFunction

clsGetClimaticTypeFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_column_climatic_type")
clsGetClimaticTypeFunction.AddParameter("attr_name", Chr(34) & "Climatic_Type" & Chr(34))
clsGetClimaticTypeFunction.AddParameter("col_name", Chr(34) & strName & Chr(34))
clsGetClimaticTypeFunction.AddParameter("data_name", Chr(34) & ucrSelectorLinkedDataFrame.strCurrentDataFrame & Chr(34))
clsGetClimaticTypeFunction.AddParameter("data_name", Chr(34) & strDataName & Chr(34))

Dim result As SymbolicExpression
result = frmMain.clsRLink.RunInternalScriptGetValue(clsGetClimaticTypeFunction.ToScript())
Expand Down Expand Up @@ -402,13 +403,11 @@ Public Class DlgDefineClimaticData
strCurrentDataframeName = ucrSelectorDefineClimaticData.strCurrentDataFrame
clsGetColFunction.AddParameter("data_name", Chr(34) & strCurrentDataframeName & Chr(34), iPosition:=0)
AutoFillReceivers()
SetRSelector()
End Sub

Private Sub ucrSelectorLinkedDataFrame_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorLinkedDataFrame.ControlValueChanged
Private Sub ucrSelectorLinkedDataFrame_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorLinkedDataFrame.ControlValueChanged, ucrChkLinkedMetaData.ControlValueChanged
clsGetColFunction.AddParameter("data_name", Chr(34) & ucrSelectorLinkedDataFrame.strCurrentDataFrame & Chr(34), iPosition:=1)
NewAutoFillReceivers()
NewSetRSelector()
End Sub

Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverDate.ControlContentsChanged
Expand Down

0 comments on commit 706e61d

Please sign in to comment.