use datetimepicker for more carefull transaction picking

This commit is contained in:
Florian Stinglmayr 2022-12-14 18:44:39 +01:00
parent 44410e86c8
commit 65d12cb052
3 changed files with 21 additions and 10 deletions

View File

@ -55,11 +55,12 @@
<Resource Include="EliteBGS.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
</ItemGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:abc="http://wpfcontrols.com/"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:EliteBGS"
xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
mc:Ignorable="d"
@ -39,10 +40,10 @@
<ToolBar VerticalAlignment="Top" Grid.Row="0" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Label Content="From:" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Content="From (UTC):" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
<xctk:DateTimePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<xctk:DateTimePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
</ToolBar>

View File

@ -11,6 +11,7 @@ using EDPlayerJournal.BGS;
using EDPlayerJournal.Entries;
using EliteBGS.BGS;
using EliteBGS.Util;
using System.Globalization;
using System.Windows.Forms;
namespace EliteBGS;
@ -56,11 +57,20 @@ public partial class MainWindow : Window {
journal = new PlayerJournal(Config.Global.JournalLocation);
// Set both to now
startdate.SelectedDate = DateTime.Now;
enddate.SelectedDate = DateTime.Now;
startdate.CultureInfo = enddate.CultureInfo = CultureInfo.InvariantCulture;
ResetTime();
journallocation.Text = Config.Global.JournalLocation;
}
private void ResetTime() {
DateTime today = DateTime.Today;
DateTime tomorrow = today.AddDays(1);
startdate.Value = today;
enddate.Value = tomorrow;
}
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
GenerateLog();
}
@ -86,9 +96,8 @@ public partial class MainWindow : Window {
List<Transaction> transactions = parser.Parse(entries);
// Filter the transactions down to the given time frame
DateTime actualend = end.AddDays(1);
transactions = transactions
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= actualend)
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= end)
.ToList()
;
@ -120,8 +129,8 @@ public partial class MainWindow : Window {
try {
TransactionParser parser = new TransactionParser();
DateTime start = startdate.SelectedDate ?? DateTime.Now;
DateTime end = enddate.SelectedDate ?? DateTime.Now;
DateTime start = startdate.Value ?? DateTime.Now;
DateTime end = enddate.Value ?? DateTime.Now;
journal.Open(); // Load all files
// Log files only get rotated if you restart the game client. This means that there might