fix a few issues around Date picker

This commit is contained in:
Florian Stinglmayr 2024-11-08 09:23:17 +01:00
parent 043808fe0a
commit 1693d8882d

View File

@ -153,8 +153,8 @@ public partial class MainWindow : Window {
// HOCHKULTUR // HOCHKULTUR
startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT"); startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT");
startdate.SelectedDateTime = today; startdate.SelectedDate = today;
enddate.SelectedDateTime = tomorrow; enddate.SelectedDate = tomorrow;
} }
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) { private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
@ -215,7 +215,10 @@ public partial class MainWindow : Window {
} }
private void HandleEntries(List<Entry> entries) { private void HandleEntries(List<Entry> entries) {
HandleEntries(entries, startdate.SelectedDateTime ?? DateTime.Now, enddate.SelectedDateTime ?? DateTime.Now); HandleEntries(entries,
startdate.SelectedDate?.Date ?? DateTime.Now,
enddate.SelectedDate?.Date ?? DateTime.Now
);
} }
private void Loadentries_EntriesLoaded(List<Entry> lines) { private void Loadentries_EntriesLoaded(List<Entry> lines) {
@ -226,21 +229,26 @@ public partial class MainWindow : Window {
try { try {
TransactionParser parser = new TransactionParser(); TransactionParser parser = new TransactionParser();
DateTime start = startdate.SelectedDateTime ?? DateTime.Now; DateTime start = startdate.SelectedDate?.Date ?? DateTime.Now;
DateTime end = enddate.SelectedDateTime ?? DateTime.Now; DateTime end = enddate.SelectedDate?.Date ?? DateTime.Now;
journal.Open(); // Load all files journal.Open(); // Load all files
// Log files only get rotated if you restart the game client. This means that there might // Log files only get rotated if you restart the game
// be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This // client. This means that there might be - say - entries
// happens if you happen to play a session late into the night. // from the 4th of May in the file with a timestamp of 3rd
// At first I tried extracting the first and last line of a file to see the date range, but // of May. This happens if you happen to play a session
// if you have a lot of files this becomes quite slow, and quite the memory hog (as journal // late into the night. At first I tried extracting the
// files have to be read in their entirety to check this). So we assume that you can't play // first and last line of a file to see the date range,
// three days straight, and keep the code fast. // but if you have a lot of files this becomes quite slow,
// and quite the memory hog (as journal files have to be
// read in their entirety to check this). So we assume
// that you can't play three days straight, and keep the
// code fast.
DateTime actualstart = start.AddDays(-3); DateTime actualstart = start.AddDays(-3);
DateTime actualend = end.AddDays(1); DateTime actualend = end.AddDays(1);
List<Entry> entries = journal.Files List<Entry> entries = journal.Files
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= actualend) .Where(f => f.NormalisedDateTime >= actualstart &&
f.NormalisedDateTime <= actualend)
.SelectMany(e => e.Entries) .SelectMany(e => e.Entries)
.ToList() .ToList()
; ;
@ -320,15 +328,11 @@ public partial class MainWindow : Window {
} }
private void browsejournallocation_Click(object sender, RoutedEventArgs e) { private void browsejournallocation_Click(object sender, RoutedEventArgs e) {
var dialog = new VistaFolderBrowserDialog(); // **TODO**
if ((bool)!dialog.ShowDialog()) { //Config.Global.JournalLocation = dialog.SelectedPath;
return; //journallocation.Text = Config.Global.JournalLocation;
} //journal = new PlayerJournal(Config.Global.JournalLocation);
Config.Global.JournalLocation = dialog.SelectedPath;
journallocation.Text = Config.Global.JournalLocation;
journal = new PlayerJournal(Config.Global.JournalLocation);
} }
private Objective GetObjectiveFromControl(object sender) { private Objective GetObjectiveFromControl(object sender) {
@ -515,14 +519,14 @@ public partial class MainWindow : Window {
} }
private void ResetTime_Click(object sender, RoutedEventArgs e) { private void ResetTime_Click(object sender, RoutedEventArgs e) {
DateTime? d = startdate.SelectedDateTime; DateTime? d = startdate.SelectedDate?.Date;
if (d != null) { if (d != null) {
startdate.SelectedDateTime = ResetTimeToZero(d.Value); startdate.SelectedDate = ResetTimeToZero(d.Value);
} }
d = enddate.SelectedDateTime; d = enddate.SelectedDate;
if (d != null) { if (d != null) {
enddate.SelectedDateTime = ResetTimeToZero(d.Value); enddate.SelectedDate = ResetTimeToZero(d.Value);
} }
} }