Prevent choosing invalid from/to dates

pull/70/head
Oleksii Holub 6 years ago
parent c2cebe99e3
commit 08da5d685b

@ -93,6 +93,12 @@ namespace DiscordChatExporter.Gui.ViewModels
// Save format // Save format
_settingsService.LastExportFormat = SelectedFormat; _settingsService.LastExportFormat = SelectedFormat;
// Clamp 'from' and 'to' values
if (From > To)
From = To;
if (To < From)
To = From;
// Start export // Start export
MessengerInstance.Send(new StartExportMessage(Channel, FilePath, SelectedFormat, From, To)); MessengerInstance.Send(new StartExportMessage(Channel, FilePath, SelectedFormat, From, To));
} }

@ -36,18 +36,22 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<DatePicker <DatePicker
x:Name="FromDatePicker"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
Margin="16,20,8,8" Margin="16,20,8,8"
materialDesign:HintAssist.Hint="From (optional)" materialDesign:HintAssist.Hint="From (optional)"
materialDesign:HintAssist.IsFloating="True" materialDesign:HintAssist.IsFloating="True"
DisplayDateEnd="{Binding SelectedDate, ElementName=ToDatePicker}"
SelectedDate="{Binding From}" /> SelectedDate="{Binding From}" />
<DatePicker <DatePicker
x:Name="ToDatePicker"
Grid.Row="0" Grid.Row="0"
Grid.Column="1" Grid.Column="1"
Margin="8,20,16,8" Margin="8,20,16,8"
materialDesign:HintAssist.Hint="To (optional)" materialDesign:HintAssist.Hint="To (optional)"
materialDesign:HintAssist.IsFloating="True" materialDesign:HintAssist.IsFloating="True"
DisplayDateStart="{Binding SelectedDate, ElementName=FromDatePicker}"
SelectedDate="{Binding To}" /> SelectedDate="{Binding To}" />
</Grid> </Grid>

Loading…
Cancel
Save