Skip to content

Commit

Permalink
ValidationRule for Emergency retry and limit
Browse files Browse the repository at this point in the history
  • Loading branch information
daleghent committed Nov 26, 2022
1 parent 9d0fbe0 commit 44304bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
20 changes: 14 additions & 6 deletions GroundStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,26 @@ public Priority PushoverDefaultFailurePriority {
public int PushoverEmergRetryInterval {
get => Properties.Settings.Default.PushoverEmergRetryInterval;
set {
Properties.Settings.Default.PushoverEmergRetryInterval = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
if (value >= 30 && value <= 86400) {
Properties.Settings.Default.PushoverEmergRetryInterval = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
} else {
RaisePropertyChanged();
}
}
}

public int PushoverEmergExpireAfter {
get => Properties.Settings.Default.PushoverEmergExpireAfter;
set {
Properties.Settings.Default.PushoverEmergExpireAfter = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
if (value >= 30 && value <= 86400) {
Properties.Settings.Default.PushoverEmergExpireAfter = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
} else {
RaisePropertyChanged();
}
}
}

Expand Down
16 changes: 12 additions & 4 deletions Options.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
HorizontalAlignment="Right"
VerticalAlignment="Center">
<TextBlock.Text>Emergency retry interval</TextBlock.Text>
<TextBlock.ToolTip>The interval in which a message with an Emergency prioity will alert in the Pushover client until it is acknowledged</TextBlock.ToolTip>
<TextBlock.ToolTip>The interval in which a message with an Emergency prioity will alert in the Pushover client until it is acknowledged. Minimum = 30 seconds. Maximum = 86400 seconds (24 hours)</TextBlock.ToolTip>
</TextBlock>
<ninactrl:UnitTextBox
Width="75"
Expand All @@ -147,7 +147,11 @@
<TextBox.Text>
<Binding Mode="TwoWay" Path="PushoverEmergRetryInterval">
<Binding.ValidationRules>
<rules:GreaterThanZeroRule />
<rules:IntRangeRuleWithDefault>
<rules:IntRangeRuleWithDefault.ValidRange>
<rules:IntRangeChecker Minimum="30" Maximum="86400" />
</rules:IntRangeRuleWithDefault.ValidRange>
</rules:IntRangeRuleWithDefault>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
Expand All @@ -160,7 +164,7 @@
HorizontalAlignment="Right"
VerticalAlignment="Center">
<TextBlock.Text>Emergency retry limit</TextBlock.Text>
<TextBlock.ToolTip>The time limit for which Emergency priority messages will alert for after being received</TextBlock.ToolTip>
<TextBlock.ToolTip>The time limit for which Emergency priority messages will alert for after being received. Minimum = 30 seconds. Maximum = 86400 seconds (24 hours)</TextBlock.ToolTip>
</TextBlock>
<ninactrl:UnitTextBox
Width="75"
Expand All @@ -171,7 +175,11 @@
<TextBox.Text>
<Binding Mode="TwoWay" Path="PushoverEmergExpireAfter">
<Binding.ValidationRules>
<rules:GreaterThanZeroRule />
<rules:IntRangeRuleWithDefault>
<rules:IntRangeRuleWithDefault.ValidRange>
<rules:IntRangeChecker Minimum="30" Maximum="86400" />
</rules:IntRangeRuleWithDefault.ValidRange>
</rules:IntRangeRuleWithDefault>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
Expand Down

0 comments on commit 44304bf

Please sign in to comment.