private void ContentBorder_PointerPressed(object sender, PointerRoutedEventArgs e) { if (IsRedirectForManipulationEnable) { if (m_source != null) { if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch) { //Mobile RengeBase导致VisualInteractionSource.TryRedirectForManipulation出错 //if (e.OriginalSource is Rectangle rect && rect.Name.Contains("TrackRect")) //{ // return; //} if (ContentBorder.CapturePointer(e.Pointer)) { ContentBorder.ReleasePointerCapture(e.Pointer); m_source.TryRedirectForManipulation(e.GetCurrentPoint(ContentBorder)); } } } } }
private void OnPointerPressed(object sender, PointerRoutedEventArgs e) { _pressed = true; Spectrum.CapturePointer(e.Pointer); UpdateSpectrumPointer(e.GetCurrentPoint(Spectrum)); }
private void Border_PointerEntered(object sender, PointerRoutedEventArgs e) { Border border = sender as Border; Point position = e.GetCurrentPoint(border).Position; double grabSize = 5; bool mouseCaptured = false; PointerEventHandler pointerMoved = null; PointerEventHandler pointerExited = null; PointerEventHandler pointerPressed = null; PointerEventHandler pointerReleased = null; bool sizeableX = false; bool sizeableY = false; double originalWidth = border.Width; double originalHeight = border.Height; Point pointMouseDown = position; CompositeTransform ct = border.RenderTransform as CompositeTransform; pointerPressed = (object s, PointerRoutedEventArgs eMove) => { this.TraceMessage("PointerPressed"); border.PointerReleased += pointerReleased; if (sizeableX == true) { mouseCaptured = true; border.CapturePointer(e.Pointer); this.TraceMessage("resize X"); } if (sizeableY == true) { mouseCaptured = true; border.CapturePointer(e.Pointer); this.TraceMessage("resize Y"); } }; pointerReleased = (object s, PointerRoutedEventArgs eMove) => { this.TraceMessage($"PointerReleased"); border.PointerPressed -= pointerPressed; border.PointerReleased -= pointerReleased; border.PointerMoved -= pointerMoved; if (mouseCaptured) { border.ReleasePointerCapture(e.Pointer); } }; pointerMoved = (object s, PointerRoutedEventArgs eMove) => { position = eMove.GetCurrentPoint(border).Position; if (mouseCaptured) { double ratioX = position.X / originalWidth; double ratioY = position.Y / originalHeight; this.TraceMessage($"pointerMoved: {position} RatioX:{ratioX} RatioY:{ratioY}"); // // find how much the mouse has moved and resize the window as appropriate..I think this should be a trasnform, not a width // // this is the money clause -- resize the window! if (sizeableX) { if (ratioX > .5) { ct.ScaleX = ratioX; } } if (sizeableY) { if (ratioY > .5) { ct.ScaleY = ratioY; } } return; } if (position.Y < grabSize || position.Y > border.Height - grabSize) { sizeableY = true; sizeableX = false; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeNorthSouth, 1); } else if (position.X < grabSize || position.X > border.Width - grabSize) { sizeableX = true; sizeableY = false; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeWestEast, 1); } else { sizeableX = false; sizeableY = false; Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1); } }; pointerExited = (s, eExit) => { this.TraceMessage($"pointerMoved"); Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1); border.PointerMoved -= pointerMoved; border.PointerExited -= pointerExited; border.PointerPressed -= pointerPressed; }; border.PointerMoved += pointerMoved; border.PointerExited += pointerExited; border.PointerPressed += pointerPressed; }