Skip to content

Commit

Permalink
Merge pull request #31 from Lunalo/Regular-Alex
Browse files Browse the repository at this point in the history
Regular alex
  • Loading branch information
AlexSananka authored Apr 13, 2017
2 parents 2724627 + cc51cf9 commit 75ef4e3
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions instat/dlgRegularSequence.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
' You should have received a copy of the GNU General Public License k
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports instat
Imports instat.Translations
Imports RDotNet
Public Class dlgRegularSequence
Dim bIsExtended As Boolean = False
Public bFirstLoad As Boolean = True
Private bReset As Boolean = True
Private clsSeqFunction, clsRepFunction As New RFunction
Private bUpdateBy As Boolean = False
Private Sub dlgRegularSequence_Load(sender As Object, e As EventArgs) Handles MyBase.Load
autoTranslate(Me)
If bFirstLoad Then
Expand All @@ -35,13 +37,15 @@ Public Class dlgRegularSequence
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
bUpdateBy = False
ucrNewColumnName.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
ucrPnlSequenceType.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
ucrInputFrom.SetRCode(clsSeqFunction, bReset)
ucrInputTo.SetRCode(clsSeqFunction, bReset)
ucrNudRepeatValues.SetRCode(clsRepFunction, bReset)
ucrNudRepeatValues.SetRCode(clsSeqFunction, bReset)
ucrInputInStepsOf.SetRCode(clsSeqFunction, bReset)
ucrPnlSequenceType.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
ucrInputFrom.SetRCode(clsSeqFunction, bReset)
ucrInputTo.SetRCode(clsSeqFunction, bReset)
ucrNudRepeatValues.SetRCode(clsRepFunction, bReset)
ucrNudRepeatValues.SetRCode(clsSeqFunction, bReset)
ucrInputInStepsOf.SetRCode(clsSeqFunction, bReset)
bUpdateBy = True

End Sub

Expand All @@ -61,7 +65,7 @@ Public Class dlgRegularSequence
ucrNudRepeatValues.SetMinMax(1, Integer.MaxValue)
ucrInputInStepsOf.SetParameter(New RParameter("by", 2))
ucrInputInStepsOf.AddQuotesIfUnrecognised = False
ucrInputInStepsOf.SetValidationTypeAsNumeric(dcmMin:=0)
ucrInputInStepsOf.SetValidationTypeAsNumeric()
ucrDataFrameLengthForRegularSequence.SetDataFrameSelector(ucrSelectDataFrameRegularSequence)

ucrPnlSequenceType.AddToLinkedControls(ucrInputFrom, {rdoNumeric}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, objNewDefaultState:=1)
Expand All @@ -86,7 +90,6 @@ Public Class dlgRegularSequence
ucrNewColumnName.SetLabelText("New Column Name:")

'TODO complete dates option
rdoDates.Enabled = False
dtpSelectorB.Visible = False
dtpSelectorA.Visible = False
ucrChkDefineAsFactor.SetText("Define As Factor")
Expand All @@ -103,6 +106,7 @@ Public Class dlgRegularSequence
clsSeqFunction = New RFunction
ucrSelectDataFrameRegularSequence.Reset()
ucrNewColumnName.Reset()
rdoNumeric.Checked = True
clsSeqFunction.SetRCommand("seq")
clsSeqFunction.AddParameter("from", 1)
clsSeqFunction.AddParameter("to", ucrSelectDataFrameRegularSequence.iDataFrameLength)
Expand Down Expand Up @@ -142,17 +146,14 @@ Public Class dlgRegularSequence
End Sub

Private Sub SetInStepsOfParameter()
If rdoNumeric.Checked Then
If ucrInputInStepsOf.GetText <> "" Then
If (ucrInputInStepsOf.GetText = 1 AndAlso frmMain.clsInstatOptions.bIncludeRDefaultParameters) OrElse ucrInputInStepsOf.GetText <> 1 Then
If ucrInputTo.GetText >= ucrInputFrom.GetText Then
clsSeqFunction.AddParameter("by", ucrInputInStepsOf.GetText)
Else
clsSeqFunction.AddParameter("by", "-" & ucrInputInStepsOf.GetText)
End If
End If
If Not ucrInputTo.IsEmpty AndAlso Not ucrInputFrom.IsEmpty Then
If Convert.ToDecimal(ucrInputTo.GetText) >= Convert.ToDecimal(ucrInputFrom.GetText) Then
clsSeqFunction.AddParameter("by", ucrInputInStepsOf.GetText)
Else
clsSeqFunction.AddParameter("by", "-" & ucrInputInStepsOf.GetText)
End If
End If
CheckSequenceLength()
End Sub

Private Sub SetBaseFunction()
Expand Down Expand Up @@ -233,18 +234,16 @@ Public Class dlgRegularSequence
CheckSequenceLength()
End Sub

Private Sub ucrInputFrom_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputFrom.ControlContentsChanged, ucrInputTo.ControlContentsChanged, ucrInputInStepsOf.ControlContentsChanged
CheckSequenceLength()
Private Sub ucrInputFrom_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputFrom.ControlValueChanged, ucrInputTo.ControlValueChanged, ucrInputInStepsOf.ControlValueChanged
If bUpdateBy Then
SetInStepsOfParameter()
End If
End Sub

Private Sub ucrNewColumnName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrNewColumnName.ControlContentsChanged, ucrInputTo.ControlContentsChanged, ucrInputFrom.ControlContentsChanged, ucrInputInStepsOf.ControlContentsChanged, ucrNudRepeatValues.ControlContentsChanged, ucrPnlSequenceType.ControlContentsChanged, ucrSelectDataFrameRegularSequence.ControlContentsChanged
TestOKEnabled()
End Sub

Private Sub ucrInputFrom_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputInStepsOf.ControlContentsChanged, ucrPnlSequenceType.ControlContentsChanged
SetInStepsOfParameter()
End Sub

Private Sub txtGetPreview_TextChanged(sender As Object, e As EventArgs) Handles txtGetPreview.TextChanged
TestOKEnabled()
End Sub
Expand Down

0 comments on commit 75ef4e3

Please sign in to comment.