feat: add localization. add realtime derivation of period from hour in NeedConfirm mode.
This commit is contained in:
@@ -21,8 +21,9 @@
|
||||
Width="300"
|
||||
Classes="ClearButton"
|
||||
DisplayFormat="HH 时 mm 分 ss 秒"
|
||||
PanelFormat="HH mm ss tt"
|
||||
PanelFormat="tt HH mm ss"
|
||||
HorizontalAlignment="Left"
|
||||
NeedConfirmation="True"
|
||||
InnerLeftContent="时刻"
|
||||
InnerRightContent="截止" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding $parent[u:TimePicker].Confirm}"
|
||||
Content="Confirm" />
|
||||
Content="{DynamicResource STRING_DATE_TIME_CONFIRM}" />
|
||||
</StackPanel>
|
||||
<ContentPresenter
|
||||
Name="PART_PopupHeader"
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_DARK">Dark</x:String>
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_LIGHT">Light</x:String>
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_SYSTEM">System</x:String>
|
||||
<x:String x:Key="STRING_DATE_TIME_CONFIRM">Confirm</x:String>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_DARK">暗色</x:String>
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_LIGHT">亮色</x:String>
|
||||
<x:String x:Key="STRING_THEME_TOGGLE_SYSTEM">跟随系统</x:String>
|
||||
<x:String x:Key="STRING_DATE_TIME_CONFIRM">确认</x:String>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -220,6 +220,7 @@ public class TimePickerPresenter : TemplatedControl
|
||||
private void OnPanelSelectionChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
if (_updateFromTimeChange) return;
|
||||
if (!_use12Clock && sender == _ampmSelector) return;
|
||||
var time = NeedsConfirmation ? _timeHolder : Time ?? DateTime.Now.TimeOfDay;
|
||||
var hour = _hourSelector?.SelectedValue ?? time.Hours;
|
||||
var minute = _minuteSelector?.SelectedValue ?? time.Minutes;
|
||||
@@ -232,6 +233,15 @@ public class TimePickerPresenter : TemplatedControl
|
||||
1 when hour < 12 => hour + 12,
|
||||
_ => hour
|
||||
};
|
||||
else
|
||||
{
|
||||
ampm = hour switch
|
||||
{
|
||||
>= 12 => 1,
|
||||
_ => 0
|
||||
};
|
||||
_ampmSelector.SelectedValue = ampm;
|
||||
}
|
||||
var newTime = new TimeSpan(hour, minute, second);
|
||||
if (NeedsConfirmation)
|
||||
_timeHolder = newTime;
|
||||
|
||||
Reference in New Issue
Block a user