feat: support ctrl + A to select all current section

This commit is contained in:
LiWenhao
2024-04-16 17:23:32 +08:00
parent 472a48ec12
commit 36b01902c7

View File

@@ -212,7 +212,7 @@ public class TimeBox : TemplatedControl
//_milliSecondText.Text = Time != null ? ClampMilliSecond(Time.Value.Milliseconds).ToString() : "0"; //_milliSecondText.Text = Time != null ? ClampMilliSecond(Time.Value.Milliseconds).ToString() : "0";
_milliSecondText.Text = Time != null ? Time.Value.Milliseconds.ToString() : "0"; _milliSecondText.Text = Time != null ? Time.Value.Milliseconds.ToString() : "0";
ParseTimeSpan(ShowLeadingZero); ParseTimeSpan(ShowLeadingZero);
PointerMovedEvent.AddHandler(OnDragPanelPointerMoved, _dragPanels[0], _dragPanels[1], _dragPanels[2], _dragPanels[3]); PointerMovedEvent.AddHandler(OnDragPanelPointerMoved, _dragPanels[0], _dragPanels[1], _dragPanels[2], _dragPanels[3]);
} }
@@ -221,6 +221,13 @@ public class TimeBox : TemplatedControl
if (_currentActiveSectionIndex is null) return; if (_currentActiveSectionIndex is null) return;
var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration; var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration;
bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e)); bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e));
if (keymap is not null && Match(keymap.SelectAll))
{
_presenters[_currentActiveSectionIndex.Value].SelectionStart = 0;
_presenters[_currentActiveSectionIndex.Value].SelectionEnd = _presenters[_currentActiveSectionIndex.Value].Text?.Length ?? 0;
return;
}
if (e.Key is Key.Enter or Key.Return) if (e.Key is Key.Enter or Key.Return)
{ {
ParseTimeSpan(ShowLeadingZero); ParseTimeSpan(ShowLeadingZero);
@@ -405,7 +412,7 @@ public class TimeBox : TemplatedControl
_secondText?.SetValue(TextPresenter.TextProperty,_values[2].ToString(format)); _secondText?.SetValue(TextPresenter.TextProperty,_values[2].ToString(format));
_milliSecondText?.SetValue(TextPresenter.TextProperty,_values[3].ToString(millisecondformat)); _milliSecondText?.SetValue(TextPresenter.TextProperty,_values[3].ToString(millisecondformat));
} }
private void OnDragPanelPointerMoved(object sender, PointerEventArgs e) private void OnDragPanelPointerMoved(object sender, PointerEventArgs e)
{ {
if (!AllowDrag) return; if (!AllowDrag) return;
@@ -427,7 +434,7 @@ public class TimeBox : TemplatedControl
_lastDragPoint = point; _lastDragPoint = point;
} }
private int GetDelta(Point point) private int GetDelta(Point point)
{ {
switch (DragOrientation) switch (DragOrientation)