Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZoomContentControl: Switch pointer handling from events to overridden methods #1351

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public ZoomContentControl()
DefaultStyleKey = typeof(ZoomContentControl);

SizeChanged += OnSizeChanged;
PointerPressed += OnPointerPressed;
PointerReleased += OnPointerReleased;
PointerMoved += OnPointerMoved;
PointerWheelChanged += OnPointerWheelChanged;
}

protected override void OnApplyTemplate()
Expand Down Expand Up @@ -275,8 +271,10 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs args)
}
}

private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
base.OnPointerPressed(e);

if (!IsAllowedToWork || _translation is null) return;
var pointerPoint = e.GetCurrentPoint(this);
var pointerProperties = pointerPoint.Properties;
Expand Down Expand Up @@ -306,15 +304,19 @@ private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
}
}

private void OnPointerReleased(object sender, PointerRoutedEventArgs e)
protected override void OnPointerReleased(PointerRoutedEventArgs e)
{
base.OnPointerReleased(e);

ReleasePointerCaptures();
_capturedPointerContext = default;
}

private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
protected override void OnPointerMoved(PointerRoutedEventArgs e)
{
if (!IsAllowedToWork ||!IsPanAllowed) return;
base.OnPointerMoved(e);

if (!IsAllowedToWork || !IsPanAllowed) return;

if (_capturedPointerContext is { } context)
{
Expand All @@ -326,8 +328,10 @@ private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
}
}

private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
{
base.OnPointerWheelChanged(e);

if (!IsAllowedToWork) return;
if (Viewport is not { } vp) return;

Expand Down
Loading