add a button to reset time
This commit is contained in:
parent
c2082df6f1
commit
0cb8641056
@ -42,9 +42,11 @@
|
|||||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||||
<Label Content="From (UTC):" VerticalAlignment="Center" VerticalContentAlignment="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"/>
|
<xctk:DateTimePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
<Label Content="To (UTC):" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||||
<xctk:DateTimePicker 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"/>
|
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||||
|
<Button x:Name="ResetTime" Content="Reset Time" Click="ResetTime_Click" />
|
||||||
|
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||||
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ToolBar Grid.Row="1" HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="2">
|
<ToolBar Grid.Row="1" HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="2">
|
||||||
|
@ -57,16 +57,17 @@ public partial class MainWindow : Window {
|
|||||||
journal = new PlayerJournal(Config.Global.JournalLocation);
|
journal = new PlayerJournal(Config.Global.JournalLocation);
|
||||||
|
|
||||||
// Set both to now
|
// Set both to now
|
||||||
startdate.CultureInfo = enddate.CultureInfo = CultureInfo.InvariantCulture;
|
InitialiseTime();
|
||||||
ResetTime();
|
|
||||||
|
|
||||||
journallocation.Text = Config.Global.JournalLocation;
|
journallocation.Text = Config.Global.JournalLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetTime() {
|
private void InitialiseTime() {
|
||||||
DateTime today = DateTime.Today;
|
DateTime today = DateTime.Today;
|
||||||
DateTime tomorrow = today.AddDays(1);
|
DateTime tomorrow = today.AddDays(1);
|
||||||
|
|
||||||
|
startdate.CultureInfo = enddate.CultureInfo = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
startdate.Value = today;
|
startdate.Value = today;
|
||||||
enddate.Value = tomorrow;
|
enddate.Value = tomorrow;
|
||||||
}
|
}
|
||||||
@ -372,4 +373,26 @@ public partial class MainWindow : Window {
|
|||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DateTime ResetTimeToZero(DateTime d) {
|
||||||
|
DateTime obj = d;
|
||||||
|
|
||||||
|
obj = obj.AddHours(d.Hour * -1);
|
||||||
|
obj = obj.AddMinutes(d.Minute * -1);
|
||||||
|
obj = obj.AddSeconds(d.Second * -1);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetTime_Click(object sender, RoutedEventArgs e) {
|
||||||
|
DateTime? d = startdate.Value;
|
||||||
|
if (d != null) {
|
||||||
|
startdate.Value = ResetTimeToZero(d.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
d = enddate.Value;
|
||||||
|
if (d != null) {
|
||||||
|
enddate.Value = ResetTimeToZero(d.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user