Exemplo n.º 1
0
        /// <summary>
        /// save pointer state from ManipulationDeltaRoutedEventArgs
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="remarks"></param>
        /// <param name="atMove">pointer state at OnMove to copy key</param>
        /// <returns></returns>
        public static PointerState _(Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e, object sender, string remarks, PointerState atMove)
        {
            var ret = new PointerState
            {
                Sender       = sender,
                Remarks      = remarks,
                Position     = ScreenPos.From(e.Position.X, e.Position.Y),
                IsInContact  = true,
                IsKeyControl = atMove?.IsKeyControl ?? false,
                IsKeyMenu    = atMove?.IsKeyMenu ?? false,
                IsKeyShift   = atMove?.IsKeyShift ?? false,
                IsKeyWindows = atMove?.IsKeyWindows ?? false,
                Scale        = e.Cumulative.Scale,
                Rotation     = Angle.FromDeg(e.Cumulative.Rotation),
                Time         = DateTime.Now,
            };

            switch (e.PointerDeviceType)
            {
            case PointerDeviceType.Pen:
                ret.DeviceType = PointerState.DeviceTypes.Pen;
                break;

            case PointerDeviceType.Touch:
                ret.DeviceType = PointerState.DeviceTypes.Touch;
                break;

            case PointerDeviceType.Mouse:
                ret.DeviceType = PointerState.DeviceTypes.Mouse;
                break;
            }
            return(ret);
        }
Exemplo n.º 2
0
 private static void FrameworkElement_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (PointerDeviceType.Touch.Equals(e.PointerDeviceType))
     {
         System.Diagnostics.Debug.WriteLine($"FrameworkElement_ManipulationDelta{e.Position.X},{e.Position.Y}");
     }
 }
Exemplo n.º 3
0
 private void Popup_DrogBtn_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     scalreTransform.ScaleX *= e.Delta.Scale;
     scalreTransform.ScaleY *= e.Delta.Scale;
     translateTransform.X   += e.Delta.Translation.X;
     translateTransform.Y   += e.Delta.Translation.Y;
 }
Exemplo n.º 4
0
        private void PaneContent_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            DebugWrite($"OpenCloseMode {OpenCloseMode}");

            if (OpenCloseMode.HasFlag(OpenCloseModes.None))
            {
                return;
            }
            else if (OpenCloseMode.HasFlag(OpenCloseModes.Auto))
            {
                switch (e.PointerDeviceType)
                {
                case Windows.Devices.Input.PointerDeviceType.Pen:
                case Windows.Devices.Input.PointerDeviceType.Mouse:
                    return;
                }
            }
            else if (!OpenCloseMode.HasFlag(OpenCloseModes.Swipe))
            {
                return;
            }

            var threhold = 24;
            var delta    = e.Cumulative.Translation.X;

            if (delta < -threhold)
            {
                IsOpen = false;
            }
            else if (delta > threhold)
            {
                IsOpen = true;
            }
        }
Exemplo n.º 5
0
 public UwpPinchEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
 {
     ViewPosition = element.GetXfViewFrame();
     Touches      = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     DeltaScale   = args.Delta.Scale;
     TotalScale   = args.Cumulative.Scale;
 }
Exemplo n.º 6
0
        /// <summary>
        /// 手势
        /// </summary>
        private void border_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            e.Handled = true;
            double Y = e.Delta.Translation.Y;
            double X = e.Delta.Translation.X;

            if (Math.Abs(X) > (Math.Abs(Y) + 5))
            {
                isX = true;
                media.Pause();
                icon.Symbol = Symbol.Play;
                double actual = X / this.ActualWidth;
                //横跨屏幕的TimeSpan:150s(两分半)
                sli_main.Value += actual * 150;
                TimeSpan time     = new TimeSpan(0, 0, (int)sli_main.Value);
                string   posttime = string.Empty;
                if (time.Hours > 0)
                {
                    posttime = time.Hours.ToString("00") + ":" + time.Minutes.ToString("00") + ":" + time.Seconds.ToString("00");
                }
                else
                {
                    posttime = time.Minutes.ToString("00") + ":" + time.Seconds.ToString("00");
                }
                messagepop.Show(posttime);
            }
            else if ((Math.Abs(Y) > (Math.Abs(X) + 5)))
            {
                isX              = false;
                sli_light.Value -= 0.01 * (int)(Y / 10);
                messagepop.Show("亮度:" + (sli_light.Value * 100).ToString("00") + "%");
            }
        }
Exemplo n.º 7
0
        private void TimelinePanel_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            var value        = Orientation == Orientation.Horizontal ? e.Cumulative.Translation.X : e.Cumulative.Translation.Y;
            var scalledValue = (int)(value / _scrollRate) * -1;

            ItemIndex = _originalIndex + scalledValue;
        }
Exemplo n.º 8
0
        private void OnPicturesContainerControlManipulationDelta(Object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
        {
            if (DetailsControl.Opacity == 1)
            {
                return;
            }

            var positionY = args.Position.Y + args.Cumulative.Translation.Y;

            if ((positionY < 0) || (positionY > Window.Current.Bounds.Height))
            {
                args.Complete();
                return;
            }

            var transform = (CompositeTransform)((FrameworkElement)sender).RenderTransform;

            transform.TranslateY += args.Delta.Translation.Y;
            var opacity = 1 - Math.Abs(transform.TranslateY) / 170;

            if (opacity < 0)
            {
                opacity = 0;
            }
            BackgroundControl.Opacity = opacity;
            CommandBar.Visibility     = Visibility.Collapsed;
        }
Exemplo n.º 9
0
        // private void _root_ManipulationStarted(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        // {
        //     DisplayContent();
        //     // CompositionTarget.Rendering -= CompositionTarget_Rendering;
        //     // CompositionTarget.Rendering += CompositionTarget_Rendering;
        // }

        // 为什么触控无法触发此事件?只有PC上能用这不科学啊
        private void _root_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (e.Cumulative.Translation.Y < 0)
            {
                return;
            }
            if (Value > 0)
            {
                return;
            }
            int    MaxDrag = 100;
            double trans   = Math.Abs(e.Cumulative.Translation.Y / 3);
            double delta   = Math.Min(trans, MaxDrag) / MaxDrag;
            double f       = delta - 1;
            // Sin(傅里叶)
            double easing = 1 + (f * f * f * (1 - delta));
            double x      = easing * 100;

            _contentTransform.TranslateY = x;
            if (x > 50)
            {
                _pullcontent.Visibility    = Visibility.Collapsed;
                _releasecontent.Visibility = Visibility.Visible;
            }
            else
            {
                _pullcontent.Visibility    = Visibility.Visible;
                _releasecontent.Visibility = Visibility.Collapsed;
            }
            _headerTransform.TranslateY = x;
        }
Exemplo n.º 10
0
 void toastGrid_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     toastTransform.X = this.toastTransform.X + e.Delta.Translation.X;
     if (toastTransform.X < 0)
     {
         toastTransform.X = 0;
     }
 }
Exemplo n.º 11
0
 public UwpRotateEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
 {
     ViewPosition = element.GetXfViewFrame();
     Touches      = new Xamarin.Forms.Point[] { args.Position.ToXfPoint() };
     Angle        = 0;
     DeltaAngle   = args.Delta.Rotation;
     TotalAngle   = args.Cumulative.Rotation;
 }
Exemplo n.º 12
0
        private void SplitviewLayer_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            double dx = e.Delta.Translation.X;

            if (SplitviewLayer.Width + dx < 220 && SplitviewLayer.Width + dx > 0)
            {
                SplitviewLayer.Width += dx;
            }
        }
        private void Page_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            Point finalPoint = e.Position;

            if (finalPoint.X - initialPoint.X > 50)
            {
                this.Frame.Navigate(typeof(HistoryTab));
            }
        }
Exemplo n.º 14
0
        private void AssociatedObject_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (_IsSkipSwipe)
            {
                return;
            }

            UpdateSwipe(e.Cumulative);
            e.Handled = true;
        }
Exemplo n.º 15
0
        public UwpPinchEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs args)
        {
            ElementPosition = element.GetXfViewFrame();
            var point = args.Position;

            ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() };
            WindowTouches  = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() };
            DeltaScale     = args.Delta.Scale;
            TotalScale     = args.Cumulative.Scale;
        }
Exemplo n.º 16
0
        private void Drawer_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (this.shouldAnimate)
            {
                double cumulativeTranslation = 0;
                double animationDistance     = 0;
                switch (this.DrawerLocation)
                {
                case DrawerLocation.Left:
                    cumulativeTranslation = -e.Cumulative.Translation.X;
                    animationDistance     = this.drawer.Width;
                    break;

                case DrawerLocation.Right:
                    cumulativeTranslation = e.Cumulative.Translation.X;
                    animationDistance     = this.drawer.Width;
                    break;

                case DrawerLocation.Top:
                    cumulativeTranslation = -e.Cumulative.Translation.Y;
                    animationDistance     = this.drawer.Height;
                    break;

                case DrawerLocation.Bottom:
                    cumulativeTranslation = e.Cumulative.Translation.Y;
                    animationDistance     = this.drawer.Height;
                    break;
                }

                var offset = (cumulativeTranslation / animationDistance) * this.AnimationDuration.TimeSpan.Milliseconds;

                if (offset > this.AnimationDuration.TimeSpan.Milliseconds)
                {
                    offset = this.AnimationDuration.TimeSpan.Milliseconds;
                }
                else if (offset < 0)
                {
                    offset = 0;
                }

                this.Context.MainContentStoryBoardReverse.Seek(TimeSpan.FromMilliseconds(offset));
                this.Context.DrawerStoryBoardReverse.Seek(TimeSpan.FromMilliseconds(offset));

                if (offset == this.AnimationDuration.TimeSpan.Milliseconds && e.IsInertial)
                {
                    this.IsOpen        = false;
                    this.shouldAnimate = false;
                }
                else if (offset == 0 && e.IsInertial)
                {
                    this.IsOpen        = true;
                    this.shouldAnimate = false;
                }
            }
        }
Exemplo n.º 17
0
 private void GestureRect_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (ContentGridTrans != null && ContentGrid != null)
     {
         ContentGridTrans.X = Math.Min(Math.Max(e.Cumulative.Translation.X, 0), ContentGrid.ActualWidth);
         if (LightDismissLayer != null && ContentGrid.ActualWidth > 0)
         {
             LightDismissLayer.Opacity = Math.Max(0, 1 - (ContentGridTrans.X / (ContentGrid.ActualWidth)));
         }
     }
 }
Exemplo n.º 18
0
 private void Rating_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (!ReadOnly)
     {
         PerformValueCalculation(e.Position, e.Container);
         UpdateDragHelper();
         if (ShowSelectionHelper)
         {
             ChangeDragHelperVisibility(true);
         }
     }
 }
Exemplo n.º 19
0
        private async void Weather_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (e.IsInertial && !_isSwiped && !_animationRunning)
            {
                var distance = e.Cumulative.Translation.X;
                if (Math.Abs(distance) <= 2)
                {
                    return;
                }

                _isSwiped = true;
                var        translateTransform = CurrentWeatherGrid.RenderTransform = new TranslateTransform();
                Storyboard storyboard         = new Storyboard();

                DoubleAnimationUsingKeyFrames animationKeyFrames = new DoubleAnimationUsingKeyFrames();

                var keyFrame = new LinearDoubleKeyFrame();
                keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(750));
                keyFrame.Value   = distance > 0 ? ActualWidth : -ActualWidth;
                animationKeyFrames.KeyFrames.Add(keyFrame);

                keyFrame         = new LinearDoubleKeyFrame();
                keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(751));
                keyFrame.Value   = distance > 0 ? -ActualWidth : ActualWidth;
                animationKeyFrames.KeyFrames.Add(keyFrame);

                keyFrame         = new LinearDoubleKeyFrame();
                keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(1500));
                keyFrame.Value   = 0;
                animationKeyFrames.KeyFrames.Add(keyFrame);

                Storyboard.SetTargetProperty(animationKeyFrames, "X");
                Storyboard.SetTarget(animationKeyFrames, translateTransform);
                storyboard.Children.Add(animationKeyFrames);

                storyboard.Completed += Animation_Completed;
                _animationRunning     = true;
                storyboard.Begin();

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    await Task.Delay(751);
                    if (distance > 0)
                    {
                        _viewModel.SwitchDay(false);
                    }
                    else
                    {
                        _viewModel.SwitchDay(true);
                    }
                });
            }
        }
 void CatrobatListViewWorker_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (e.IsInertial)
     {
         e.Complete();
     }
     if (_dragging == CatrobatListViewDragStaus.Dragging)
     {
         DeltaDrag(e.Position.Y);
     }
     e.Handled = true;
 }
 private void Sv_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     movedX = e.Position.X;
     movedY = e.Position.Y;
     if (xsv.Orientation == ScrollOrientation.Horizontal)
     {
         xsv.ScrollToAsync((movedX - currentX) * -1, 0, true);
     }
     else
     {
         xsv.ScrollToAsync(0, (movedY + currentY) * -1, true);
     }
 }
Exemplo n.º 22
0
        private void ScrollViewer_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            Debug.WriteLine("------------------Manipulation Delta NavMan--------------------------------");
            Debug.WriteLine(e.IsInertial);
            Debug.WriteLine(e.Velocities.Linear.Y);

            Debug.WriteLine(e.Cumulative.Translation.Y);
            Debug.WriteLine(e.Delta.Translation.Y);
            Debug.WriteLine("--------------------------------------------------");

            //if (scrollViewer.VerticalOffset <= 0 || scrollViewer.VerticalOffset >= scrollViewer.ActualHeight - 48 - 48)
            //e.Handled = true;
        }
Exemplo n.º 23
0
 void ImageSwitch_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (e.Cumulative.Translation.X > 1d)
     {
         CheckStateChanged(this, true);
         this.ManipulationDelta -= ImageSwitch_ManipulationDelta;
     }
     else if (e.Cumulative.Translation.X < -1d)
     {
         CheckStateChanged(this, false);
         this.ManipulationDelta -= ImageSwitch_ManipulationDelta;
     }
 }
        private void LayoutRoot_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (FingerCount != 2 || e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch)
            {
                return;
            }

            MultiTouch = true;

            if (_lastMultiPoint.Count() != 2 || _currentMutilPoint.Count() != 2)
            {
                SaveMultiTouch();
                return;
            }

            //Debug.WriteLine($"LayoutRoot_ManipulationDelta vel:{e.Velocities.Expansion} scale:{e.Cumulative.Scale}");

            List <Point> points = new List <Point>();

            foreach (var l in _lastMultiPoint)
            {
                points.Add(l.Value);

                if (_currentMutilPoint.TryGetValue(l.Key, out Point p))
                {
                    points.Add(p);
                }
            }

            if (points.Count != 4)
            {
                Debug.WriteLine("Problems");
                return;
            }

            Element.MultiTouchDelta?.Invoke(new InputHandler.MultiTouchEventArgs
            {
                f1StartX = points[0].X,
                f1StartY = points[0].Y,
                f1EndX   = points[1].X,
                f1EndY   = points[1].Y,
                f2StartX = points[2].X,
                f2StartY = points[2].Y,
                f2EndX   = points[3].X,
                f2EndY   = points[3].Y,
            });


            SaveMultiTouch();
        }
Exemplo n.º 25
0
 private void OnManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (SelectedAnnotation != null && !e.IsInertial && OnEnableDrag(e.Position))
     {
         if (SelectedAnnotation.XAxis.Orientation == Orientation.Vertical && SelectedAnnotation.CoordinateUnit == CoordinateUnit.Axis)
         {
             AnnotationDrag(-e.Delta.Translation.Y, -e.Delta.Translation.X);
         }
         else
         {
             AnnotationDrag(e.Delta.Translation.X, e.Delta.Translation.Y);
         }
     }
 }
Exemplo n.º 26
0
        private void ThreadAndReplyPage_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (ActualWidth > 720)
            {
                _tt.X = 0;
                return;
            }

            if (_tt.X + e.Delta.Translation.X < 0)
            {
                _tt.X = 0;
                return;
            }
            _tt.X += e.Delta.Translation.X;
        }
Exemplo n.º 27
0
        void shape_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            var t  = (Shape.Parent as Canvas).RenderTransform as CompositeTransform;
            var tr = new CompositeTransform()
            {
                ScaleX   = t.ScaleX,
                ScaleY   = t.ScaleY,
                Rotation = t.Rotation
            };

            currentPoint    = currentPoint.Add(tr.Inverse.TransformPoint(e.Delta.Translation));
            Target.Position = currentPoint;

            Parent.UpdateShape();
            e.Handled = true;
        }
        private void _element_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (_element == null)
            {
                return;
            }

            if (_dragTransition == null)
            {
                _dragTransition = new TranslateTransform();
            }

            _element.RenderTransform = _dragTransition;
            _dragTransition.X       += e.Delta.Translation.X;
            _dragTransition.Y       += e.Delta.Translation.Y;
        }
Exemplo n.º 29
0
        private void LayoutController_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (!_manipulationsEnabled)
            {
                return;
            }
            double dx = e.Delta.Translation.X;

            if (SplitviewLayer.Width + dx <= 220 &&
                SplitviewLayer.Width + dx >= 0 &&
                LayoutController.Width + dx < 220)
            {
                LayoutController.Width += dx;
                SplitviewLayer.Width   += dx;
            }
        }
Exemplo n.º 30
0
 private void Page_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
 {
     if (e.IsInertial)
     {
         Point finalPoint = e.Position;
         if (finalPoint.X - initialPoint.X > 50)
         {
             e.Complete();
             this.Frame.Navigate(typeof(DownloadsTab));
         }
         else if (initialPoint.X - finalPoint.X > 100)
         {
             e.Complete();
             this.Frame.Navigate(typeof(BookmarksTab));
         }
     }
 }