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
startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT");
startdate.SelectedDateTime = today;
enddate.SelectedDateTime = tomorrow;
startdate.SelectedDate = today;
enddate.SelectedDate = tomorrow;
}
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
@ -215,7 +215,10 @@ public partial class MainWindow : Window {
}
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) {
@ -226,21 +229,26 @@ public partial class MainWindow : Window {
try {
TransactionParser parser = new TransactionParser();
DateTime start = startdate.SelectedDateTime ?? DateTime.Now;
DateTime end = enddate.SelectedDateTime ?? DateTime.Now;
DateTime start = startdate.SelectedDate?.Date ?? DateTime.Now;
DateTime end = enddate.SelectedDate?.Date ?? DateTime.Now;
journal.Open(); // Load all files
// Log files only get rotated if you restart the game client. This means that there might
// be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This
// happens if you happen to play a session late into the night.
// At first I tried extracting the first and last line of a file to see the date range, 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.
// Log files only get rotated if you restart the game
// client. This means that there might be - say - entries
// from the 4th of May in the file with a timestamp of 3rd
// of May. This happens if you happen to play a session
// late into the night. At first I tried extracting the
// first and last line of a file to see the date range,
// 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 actualend = end.AddDays(1);
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)
.ToList()
;
@ -320,15 +328,11 @@ public partial class MainWindow : Window {
}
private void browsejournallocation_Click(object sender, RoutedEventArgs e) {
var dialog = new VistaFolderBrowserDialog();
// **TODO**
if ((bool)!dialog.ShowDialog()) {
return;
}
Config.Global.JournalLocation = dialog.SelectedPath;
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) {
@ -515,14 +519,14 @@ public partial class MainWindow : Window {
}
private void ResetTime_Click(object sender, RoutedEventArgs e) {
DateTime? d = startdate.SelectedDateTime;
DateTime? d = startdate.SelectedDate?.Date;
if (d != null) {
startdate.SelectedDateTime = ResetTimeToZero(d.Value);
startdate.SelectedDate = ResetTimeToZero(d.Value);
}
d = enddate.SelectedDateTime;
d = enddate.SelectedDate;
if (d != null) {
enddate.SelectedDateTime = ResetTimeToZero(d.Value);
enddate.SelectedDate = ResetTimeToZero(d.Value);
}
}