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

Fix Bug in Define Climatic Loading and Address Usability Inconvenience #9389

Merged
merged 2 commits into from
Feb 19, 2025
Merged
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
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
Loading