Skip to content
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 @@ -191,7 +191,7 @@ void HandleDragLeave(object sender, Microsoft.UI.Xaml.DragEventArgs e)
// for example
// e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
// Even if AcceptedOperation is already set to Copy it will cause the copy animation
// to remain even after the the dragged element has left
// to remain even after the dragged element has left
if (!dragEventArgs.PlatformArgs?.Handled ?? true && operationPriorToSend != dragEventArgs.AcceptedOperation)
{
var result = (int)dragEventArgs.AcceptedOperation;
Expand Down Expand Up @@ -261,21 +261,18 @@ void HandleDragStarting(UIElement sender, Microsoft.UI.Xaml.DragStartingEventArg
{
SendEventArgs<DragGestureRecognizer>(rec =>
{
var view = Element as View;

if (!rec.CanDrag || view is null)
if (!rec.CanDrag || Element is not View view)
{
e.Cancel = true;
return;
}

var handler = sender as IViewHandler;
var args = rec.SendDragStarting(view, (relativeTo) => GetPosition(relativeTo, e), new PlatformDragStartingEventArgs(sender, e));

e.Data.Properties[_doNotUsePropertyString] = args.Data;

#pragma warning disable CS0618 // Type or member is obsolete
if ((!args.Handled || (!args.PlatformArgs?.Handled ?? true)) && handler != null)
if ((!args.Handled || (!args.PlatformArgs?.Handled ?? true)) && sender is IViewHandler handler)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (handler?.PlatformView is UI.Xaml.Controls.Image nativeImage &&
Expand Down Expand Up @@ -509,8 +506,6 @@ void HandlePinch(ManipulationDeltaRoutedEventArgs e, View view)
return;
}

_isPinching = true;

if (e.OriginalSource is UIElement container)
{
global::Windows.Foundation.Point translationPoint = container.TransformToVisual(Container).TransformPoint(e.Position);
Expand Down Expand Up @@ -541,13 +536,13 @@ void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs
SwipeComplete(true);
PinchComplete(true);
PanComplete(true);

_fingers.Clear();
}

void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
var view = Element as View;

if (view == null)
if (Element is not View view)
{
return;
}
Expand All @@ -559,40 +554,33 @@ void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)

void OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
var view = Element as View;
if (view == null)
if (Element is not View view)
{
return;
}

_isPinching = true;
_wasPinchGestureStartedSent = false;
_wasPanGestureStartedSent = false;
}

void OnPointerCanceled(object sender, PointerRoutedEventArgs e)
{
uint id = e.Pointer.PointerId;
if (_fingers.Contains(id))
{
_fingers.Remove(id);
}

SwipeComplete(false);
PinchComplete(false);
PanComplete(false);

_fingers.Clear();
}

void OnPointerExited(object sender, PointerRoutedEventArgs e)
{
SwipeComplete(true);

if (!_isPanning)
{
uint id = e.Pointer.PointerId;
if (_fingers.Contains(id))
_fingers.Remove(id);
_fingers.Remove(e.Pointer.PointerId);
}

SwipeComplete(true);
PinchComplete(true);
}

void OnPointerPressed(object sender, PointerRoutedEventArgs e)
Expand All @@ -606,15 +594,10 @@ void OnPointerPressed(object sender, PointerRoutedEventArgs e)

void OnPointerReleased(object sender, PointerRoutedEventArgs e)
{
uint id = e.Pointer.PointerId;
if (_fingers.Contains(id))
{
_fingers.Remove(id);
}

SwipeComplete(true);
PinchComplete(true);
PanComplete(true);

_fingers.Remove(e.Pointer.PointerId);
}

void OnPgrPointerEntered(object sender, PointerRoutedEventArgs e)
Expand Down Expand Up @@ -708,8 +691,7 @@ void OnPgrPointerReleased(object sender, PointerRoutedEventArgs e)

private void HandlePgrPointerEvent(PointerRoutedEventArgs e, Action<View, PointerGestureRecognizer> SendPointerEvent)
{
var view = Element as View;
if (view == null)
if (Element is not View view)
{
return;
}
Expand Down Expand Up @@ -776,8 +758,7 @@ bool IsPointerEventRelevantToCurrentElement(PointerRoutedEventArgs e)

void OnTap(object sender, RoutedEventArgs e)
{
var view = Element as View;
if (view == null)
if (Element is not View view)
{
return;
}
Expand Down Expand Up @@ -853,8 +834,7 @@ bool ValidateGesture(TapGestureRecognizer g)

void SwipeComplete(bool success)
{
var view = Element as View;
if (view == null || !_isSwiping)
if (Element is not View view || !_isSwiping)
{
return;
}
Expand All @@ -872,8 +852,7 @@ void SwipeComplete(bool success)

void PanComplete(bool success)
{
var view = Element as View;
if (view == null || !_isPanning)
if (Element is not View view || !_isPanning)
{
return;
}
Expand All @@ -896,8 +875,7 @@ void PanComplete(bool success)

void PinchComplete(bool success)
{
var view = Element as View;
if (view is null || !_isPinching)
if (Element is not View view || !_isPinching)
{
return;
}
Expand Down
Loading