Inheritance: IGestureRecognizer
        /// <summary>
        /// Initialise the input system. Note that accelerometer input defaults to off.
        /// </summary>
        /// <param name="game"></param>
        public InputManager(Project2Game game) : base(game)
        {

            // initialisation
            useMouseDelta = false;
            accelerometerEnabled = false;
            mouseDelta = new Vector2();

            keyboardManager = new KeyboardManager(game);
            mouseManager = new MouseManager(game);
            pointerManager = new PointerManager(game);
            keyMapping = new KeyMapping();

            // get the accelerometer. Returns null if no accelerometer found
            accelerometer = Accelerometer.GetDefault();
            window = Window.Current.CoreWindow;

            // Set up the gesture recognizer.  In this game, it only responds to TranslateX, TranslateY and Tap events
            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | 
                GestureSettings.ManipulationTranslateY | GestureSettings.Tap;
            
            // Register event handlers for pointer events
            window.PointerPressed += OnPointerPressed;
            window.PointerMoved += OnPointerMoved;
            window.PointerReleased += OnPointerReleased;
            
            // automatically enable accelerometer if we have one
            this.AccelerometerEnabled(true);
            this.MouseDeltaEnabled(true);
            
        }
示例#2
0
        public ManipulationInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target, Windows.UI.Xaml.UIElement referenceframe)
        {
            this.gestureRecognizer = gr;
            this.element           = target;
            this.reference         = referenceframe;

            this.gestureRecognizer.GestureSettings =
                Windows.UI.Input.GestureSettings.Tap |
                Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
                Windows.UI.Input.GestureSettings.RightTap |
                Windows.UI.Input.GestureSettings.ManipulationTranslateX |
                Windows.UI.Input.GestureSettings.ManipulationTranslateY |
                Windows.UI.Input.GestureSettings.ManipulationRotate |
                Windows.UI.Input.GestureSettings.ManipulationScale |
                Windows.UI.Input.GestureSettings.ManipulationTranslateInertia |
                Windows.UI.Input.GestureSettings.ManipulationRotateInertia |
                Windows.UI.Input.GestureSettings.ManipulationMultipleFingerPanning | //reduces zoom jitter when panning with multiple fingers
                Windows.UI.Input.GestureSettings.ManipulationScaleInertia;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            this.element.PointerCanceled += OnPointerCanceled;
            this.element.PointerPressed  += OnPointerPressed;
            this.element.PointerReleased += OnPointerReleased;
            this.element.PointerMoved    += OnPointerMoved;

            // Set up event handlers to respond to gesture recognizer output
            this.gestureRecognizer.Tapped                += OnTapped;
            this.gestureRecognizer.RightTapped           += OnRightTapped;
            this.gestureRecognizer.ManipulationStarted   += OnManipulationStarted;
            this.gestureRecognizer.ManipulationUpdated   += OnManipulationUpdated;
            this.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
            InitializeTransforms();
        }
示例#3
0
        void MainPage_Loaded(object senderX, RoutedEventArgs e)
        {
            recognizer = new GestureRecognizer();
            recognizer.GestureSettings =
                GestureSettings.HoldWithMouse | GestureSettings.Hold;


            // Forward pointer input to the gesture recognizer.
            Rect1.PointerCanceled += OnPointerCanceled;
            Rect1.PointerPressed += OnPointerPressed;
            Rect1.PointerReleased += OnPointerReleased;
            Rect1.PointerMoved += OnPointerMoved;

            // Attach handlers for recognized gestures.
            // In each of these event handlers, args.PointerDeviceType
            // indicates the input device and 'sender' is GestureRecognizer.

            // args - TappedEventArgs
            recognizer.Tapped += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "Tapped raised"); };

            // args - RightTappedEventArgs
            recognizer.RightTapped += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "RightTapped raised"); };

            // The press-and-hold gesture.
            // args - HoldingEventArgs
            recognizer.Holding += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "Holding raised {0}", args.HoldingState); };

            // The slide or swipe gesture within a content area that supports 
            // panning along the perpendicular direction of the gesture.
            // args - CrossSlidingEventArgs
            recognizer.CrossSliding += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "CrossSliding raised"); };
        }
示例#4
0
        public ManipulationInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target, Windows.UI.Xaml.UIElement referenceframe)
        {
            this.gestureRecognizer = gr;
            this.element = target;
            this.reference = referenceframe;

            this.gestureRecognizer.GestureSettings =
                Windows.UI.Input.GestureSettings.Tap |
                Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
                Windows.UI.Input.GestureSettings.RightTap |
                Windows.UI.Input.GestureSettings.ManipulationTranslateX |
                Windows.UI.Input.GestureSettings.ManipulationTranslateY |
                Windows.UI.Input.GestureSettings.ManipulationRotate |
                Windows.UI.Input.GestureSettings.ManipulationScale |
                Windows.UI.Input.GestureSettings.ManipulationTranslateInertia |
                Windows.UI.Input.GestureSettings.ManipulationRotateInertia |
                Windows.UI.Input.GestureSettings.ManipulationMultipleFingerPanning | //reduces zoom jitter when panning with multiple fingers
                Windows.UI.Input.GestureSettings.ManipulationScaleInertia;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            this.element.PointerCanceled += OnPointerCanceled;
            this.element.PointerPressed += OnPointerPressed;
            this.element.PointerReleased += OnPointerReleased;
            this.element.PointerMoved += OnPointerMoved;

            // Set up event handlers to respond to gesture recognizer output
            this.gestureRecognizer.Tapped += OnTapped;
            this.gestureRecognizer.RightTapped += OnRightTapped;
            this.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            this.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            this.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
            InitializeTransforms();
        }
示例#5
0
        private void OnGameLoopStarting(ICanvasAnimatedControl sender, object args)
        {
            //
            // The GestureRecognizer needs to be created and accessed from the 
            // same thread -- in this case the game loop thread, so we use the GameLoopStarting event 
            // for this.
            //

            gestureRecognizer = new GestureRecognizer();
            gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateInertia | GestureSettings.ManipulationTranslateY;
                
            gestureRecognizer.ManipulationStarted += gestureRecognizer_ManipulationStarted;
            gestureRecognizer.ManipulationUpdated += gestureRecognizer_ManipulationUpdated;
            gestureRecognizer.ManipulationCompleted += gestureRecognizer_ManipulationCompleted;

            gestureRecognizer.InertiaTranslationDeceleration = -0.05f;

            //
            // When the GestureRecognizer goes into intertia mode (ie after the pointer is released)
            // we want it to generate ManipulationUpdated events in sync with the game loop's Update.
            // We do this by disabling AutoProcessIntertia and explicitly calling ProcessInertia() 
            // from the Update.
            //
            gestureRecognizer.AutoProcessInertia = false;

            inputSource = animatedControl.CreateCoreIndependentInputSource(CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch);

            inputSource.PointerPressed += Input_PointerPressed;
            inputSource.PointerMoved += Input_PointerMoved;
            inputSource.PointerReleased += Input_PointerReleased;
        }
        public AdnGestureManager(
            UIElement window, 
            AdnRenderer renderer)
        {
            _window = window;

            _renderer = renderer;

            _pointerMode = PointerMode.kIdleMode;

            _accumulator = new ValueAccumulator(
                -30.0 * 1000.0 / 5.0,
                -100.0 * 1000.0 / 5.0,
                -5.0 * 1000.0 / 5.0);

            _pointers = new Dictionary<uint, PointerPoint>();

            window.PointerMoved += OnPointerMoved;
            window.PointerPressed += OnPointerPressed;
            window.PointerReleased += OnPointerReleased;
            window.PointerWheelChanged += OnPointerWheelChanged;

            _gr = new GestureRecognizer();

            _gr.GestureSettings =
              GestureSettings.Tap |
              GestureSettings.Drag |
              GestureSettings.DoubleTap |
              GestureSettings.ManipulationScale;

            _gr.Tapped += OnTapped;
            _gr.ManipulationStarted += OnManipulationStarted;
            _gr.ManipulationUpdated += OnManipulationUpdated;
            _gr.ManipulationCompleted += OnManipulationCompleted;
        }
示例#7
0
        public void Attach(DependencyObject associatedObject)
        {
            Guard.Assert(associatedObject is UIElement, "associatedObject is UIElement");

            AssociatedObject = associatedObject;

            gestureRecognizer = new GestureRecognizer
            {
                GestureSettings = GestureSettings.CrossSlide
            };

            //CrossSliding distance thresholds are disabled by default. Use CrossSlideThresholds to set these values.   
            var cst = new CrossSlideThresholds
            {
                SelectionStart = 2,
                SpeedBumpStart = 3,
                SpeedBumpEnd = 4,
                RearrangeStart = 5
            };

            gestureRecognizer.CrossSlideHorizontally = true; //Enable horinzontal slide   
            gestureRecognizer.CrossSlideThresholds = cst;

            gestureRecognizer.CrossSliding += gestureRecognizer_CrossSliding;

            UIElement.PointerCanceled += OnPointerCanceled;
            UIElement.PointerPressed += OnPointerPressed;
            UIElement.PointerReleased += OnPointerReleased;
            UIElement.PointerMoved += OnPointerMoved;
        }
        void gr_Holding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.HoldingEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_Holding");
#endif
            var data = DataContext as ProgressViewModel;
            data.HoldTap();
        }
 public Scenario1()
 {
     this.InitializeComponent();
     Windows.UI.Input.GestureRecognizer gr1 = new Windows.UI.Input.GestureRecognizer();
     Windows.UI.Input.GestureRecognizer gr2 = new Windows.UI.Input.GestureRecognizer();
     GestureInputProcessor ShapeInput1 = new GestureInputProcessor(gr1, MyRect1);
     GestureInputProcessor ShapeInput2 = new GestureInputProcessor(gr2, MyRect2);
 }
示例#10
0
 public Scenario1()
 {
     this.InitializeComponent();
     Windows.UI.Input.GestureRecognizer gr1 = new Windows.UI.Input.GestureRecognizer();
     Windows.UI.Input.GestureRecognizer gr2 = new Windows.UI.Input.GestureRecognizer();
     GestureInputProcessor ShapeInput1      = new GestureInputProcessor(gr1, MyRect1);
     GestureInputProcessor ShapeInput2      = new GestureInputProcessor(gr2, MyRect2);
 }
示例#11
0
        /*
        * Windows.UI.Input.GestureSettings 是一个 flag 枚举,其值包括:
        * None, Tap, DoubleTap, Hold, HoldWithMouse, RightTap, Drag, CrossSlide, ManipulationTranslateX, ManipulationTranslateY, ManipulationTranslateRailsX, ManipulationTranslateRailsY, ManipulationRotate, ManipulationScale, ManipulationTranslateInertia, ManipulationRotateInertia, ManipulationScaleInertia
        */
        public GestureRecognizer GtGestureListener(UIElement ele)
        {
            _gestureRecognizer = new GestureRecognizer();

            ele.PointerMoved += GestureRecognizerDemo_PointerMoved;
            ele.PointerPressed += GestureRecognizerDemo_PointerPressed;
            ele.PointerReleased += GestureRecognizerDemo_PointerReleased;

            return _gestureRecognizer;
        }
示例#12
0
        public void Detach()
        {
            UIElement.PointerCanceled -= OnPointerCanceled;
            UIElement.PointerPressed -= OnPointerPressed;
            UIElement.PointerReleased -= OnPointerReleased;
            UIElement.PointerMoved -= OnPointerMoved;

            gestureRecognizer.CrossSliding -= gestureRecognizer_CrossSliding;
            gestureRecognizer = null;

            AssociatedObject = null;
        }
        public Scenario5()
        {
            this.InitializeComponent();

            InitOptions();

            // Create a GestureRecognizer which will be used to process the manipulations
            // done on the rectangle
            recognizer = new GestureRecognizer();

            // Create a ManipulationInputProcessor which will listen for events on the
            // rectangle, process them, and update the rectangle's position, size, and rotation
            manipulationProcessor = new ManipulationInputProcessor(recognizer, manipulateMe, mainCanvas);
        }
示例#14
0
        public GameInput()
        {
            // Get the accelerometer object
            accelerometer = Accelerometer.GetDefault();
            window = Window.Current.CoreWindow;

            // Set up the gesture recognizer.  In this example, it only responds to TranslateX, Scale and Tap events
            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | GestureSettings.ManipulationScale | GestureSettings.Tap;

            // Register event handlers for pointer events
            window.PointerPressed += OnPointerPressed;
            window.PointerMoved += OnPointerMoved;
            window.PointerReleased += OnPointerReleased;
        }
        public PlatformGestureEffect()
        {
            detector = new Windows.UI.Input.GestureRecognizer
            {
                GestureSettings     = GestureSettings.Tap | GestureSettings.Drag | GestureSettings.ManipulationTranslateInertia | GestureSettings.DoubleTap,
                ShowGestureFeedback = false,
                //CrossSlideHorizontally = true
            };

            detector.Dragging += (sender, args) => TriggerCommand(panCommand, new Point(args.Position.X, args.Position.Y));

            detector.Tapped += (sender, args) =>
            {
                if (args.TapCount == 1)
                {
                    TriggerCommand(tapCommand, null);
                    TriggerCommand(tapCommand2, new Point(args.Position.X, args.Position.Y));
                }
                else if (args.TapCount == 2)
                {
                    TriggerCommand(doubleTapCommand, new Point(args.Position.X, args.Position.Y));
                }
            };

            detector.ManipulationInertiaStarting += (sender, args) =>
            {
                var isHorizontalSwipe = Math.Abs(args.Delta.Translation.Y) < 20;
                var isVerticalSwipe   = Math.Abs(args.Delta.Translation.X) < 20;
                if (isHorizontalSwipe || isVerticalSwipe)
                {
                    if (isHorizontalSwipe)
                    {
                        var isLeftSwipe = args.Delta.Translation.X < 0;
                        TriggerCommand(isLeftSwipe ? swipeLeftCommand : swipeRightCommand, null);
                    }
                    else
                    {
                        var isTopSwipe = args.Delta.Translation.Y < 0;
                        TriggerCommand(isTopSwipe ? swipeTopCommand : swipeBottomCommand, null);
                    }
                }
            };

            //detector.CrossSliding += (sender, args) =>
            //{
            //    args.CrossSlidingState == CrossSlidingState.Started
            //};
        }
        void gr_ManipulationCompleted(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationCompletedEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_ManipulationCompleted");
#endif
            var data = DataContext as ProgressViewModel;

            if (Math.Abs(args.Cumulative.Translation.X) > Math.Abs(args.Cumulative.Translation.Y))
            {
                data.flick(Orientation.Horizontal, args.Cumulative.Translation.X);
            }
            else
            {
                data.flick(Orientation.Vertical, args.Cumulative.Translation.Y);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="element">
        /// Manipulation target.
        /// </param>
        /// <param name="reference">
        /// Element that contains the coordinate space used for expressing transformations
        /// during manipulations, usually the parent element of Target in the UI tree.
        /// </param>
        /// <remarks>
        /// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
        /// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
        /// will be an ancestor of <paramref name="element"/> in the UI tree.
        /// </remarks>
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            _target = element;
            _reference = reference;

            // Setup pointer event handlers for the element.
            // They are used to feed the gesture recognizer.
            _target.PointerMoved += OnPointerMoved;
            _target.PointerPressed += OnPointerPressed;
            _target.PointerReleased += OnPointerReleased;
            _target.PointerCanceled += OnPointerCanceled;
            _target.PointerWheelChanged += OnPointerWheelChanged;

            CrossSlideThresholds cst = new CrossSlideThresholds();
            //cst.RearrangeStart = 10;//cst.SelectionStart = 12;
            //cst.SpeedBumpStart = 12;//cst.SpeedBumpEnd = 24;

            // Create the gesture recognizer
            _gestureRecognizer = new GestureRecognizer();
            _gestureRecognizer.GestureSettings =
                GestureSettings.Hold |
                GestureSettings.ManipulationRotate |
                GestureSettings.ManipulationRotateInertia |
                GestureSettings.ManipulationScale |
                GestureSettings.ManipulationScaleInertia |
                GestureSettings.ManipulationTranslateInertia |
                GestureSettings.ManipulationTranslateX |
                GestureSettings.ManipulationTranslateY |
                GestureSettings.RightTap |
                GestureSettings.Tap |
                GestureSettings.CrossSlide;

            _gestureRecognizer.CrossSlideHorizontally = true;
            _gestureRecognizer.CrossSlideThresholds = cst;

            _gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            _gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            _gestureRecognizer.ManipulationInertiaStarting += OnManipulationInertiaStarting;
            _gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
            _gestureRecognizer.Dragging += OnDragging;
            _gestureRecognizer.Holding += OnHolding;
            _gestureRecognizer.RightTapped += OnRightTapped;
            _gestureRecognizer.Tapped += OnTapped;
            _gestureRecognizer.CrossSliding += OnCrossSliding;
        }
示例#18
0
        private void InitializeGesture()
        {
            Gesture = new GestureRecognizer();

            Gesture.GestureSettings =
                GestureSettings.Tap |
                GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
                GestureSettings.ManipulationTranslateInertia |
                GestureSettings.ManipulationTranslateX |
                GestureSettings.ManipulationTranslateY;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            PointerCanceled += OnPointerCanceled;
            PointerPressed += OnPointerPressed;
            PointerReleased += OnPointerReleased;
            PointerMoved += OnPointerMoved;

            // Set up event handlers to respond to gesture recognizer output
            Gesture.ManipulationUpdated += OnManipulationUpdated;
        }
        public GestureInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target)
        {
            this.gestureRecognizer = gr;
            this.element = target;

            this.gestureRecognizer.GestureSettings =
                Windows.UI.Input.GestureSettings.Tap |
                Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
                Windows.UI.Input.GestureSettings.RightTap;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            this.element.PointerCanceled += OnPointerCanceled;
            this.element.PointerPressed += OnPointerPressed;
            this.element.PointerReleased += OnPointerReleased;
            this.element.PointerMoved += OnPointerMoved;

            // Set up event handlers to respond to gesture recognizer output
            this.gestureRecognizer.Tapped += OnTapped;
            this.gestureRecognizer.RightTapped += OnRightTapped;
        }
示例#20
0
        public void GestureInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target)
        {
            this.gestureRecognizer = gr;
            //Targeted Ui element to be performing gestures on it.
            this.element = target;

            //Enable gesture settings for Tap,Hold,RightTap,CrossSlide
            this.gestureRecognizer.GestureSettings =
                Windows.UI.Input.GestureSettings.ManipulationTranslateX |
                Windows.UI.Input.GestureSettings.ManipulationTranslateY;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            this.element.PointerCanceled += OnPointerCanceled;
            this.element.PointerPressed  += OnPointerPressed;
            this.element.PointerReleased += OnPointerReleased;
            this.element.PointerMoved    += OnPointerMoved;

            gestureRecognizer.ManipulationCompleted += gestureRecognizer_ManipulationCompleted;
            gestureRecognizer.ManipulationStarted   += gestureRecognizer_ManipulationStarted;
        }
示例#21
0
        public GestureInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target)
        {
            this.gestureRecognizer = gr;
            this.element           = target;

            this.gestureRecognizer.GestureSettings =
                Windows.UI.Input.GestureSettings.Tap |
                Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
                Windows.UI.Input.GestureSettings.RightTap;

            // Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
            this.element.PointerCanceled += OnPointerCanceled;
            this.element.PointerPressed  += OnPointerPressed;
            this.element.PointerReleased += OnPointerReleased;
            this.element.PointerMoved    += OnPointerMoved;

            // Set up event handlers to respond to gesture recognizer output
            this.gestureRecognizer.Tapped      += OnTapped;
            this.gestureRecognizer.RightTapped += OnRightTapped;
        }
示例#22
0
        public MainPage()
        {
            this.InitializeComponent();
            _gestureRecognizer = new GestureService().GtGestureListener(this);

            // 监测手势
            _gestureRecognizer.GestureSettings = GestureSettings.Hold | GestureSettings.CrossSlide;
            _gestureRecognizer.CrossSliding += (sender, args) =>
            {
                {
                    lblMsg.Text += Environment.NewLine;
                    lblMsg.Text += " CrossSliding: " + args.CrossSlidingState + "; " + args.Position.ToString();
                }
            };

            _gestureRecognizer.Holding += (sender, args) =>
            {
                lblMsg.Text += Environment.NewLine;
                lblMsg.Text += " Holding: " + args.HoldingState + "; " + args.Position.ToString();
            };
        }
        public void GestureInputProcessor(GestureRecognizer gr,UIElement target)
        {
            this.gestureRecognizer = gr;
            this.element = target;
            this.gestureRecognizer.GestureSettings = GestureSettings.Tap | GestureSettings.Hold | GestureSettings.RightTap | GestureSettings.CrossSlide;
            this.element.PointerCanceled += MainPage_PointerCanceled;
            this.element.PointerPressed += MainPage_PointerPressed;
            this.element.PointerReleased += MainPage_PointerReleased;
            this.element.PointerMoved += Element_PointerMoved;
            gestureRecognizer.Holding += GestureRecognizer_Holding;
            gestureRecognizer.Tapped += GestureRecognizer_Tapped;
            gestureRecognizer.RightTapped += GestureRecognizer_RightTapped;

            CrossSlideThresholds cst = new CrossSlideThresholds();
            cst.SelectionStart = 2;
            cst.SpeedBumpStart = 3;
            cst.SpeedBumpEnd = 4;
            cst.RearrangeStart = 5;
            gestureRecognizer.CrossSlideHorizontally = true;
            gestureRecognizer.CrossSlideThresholds = cst;
            gestureRecognizer.CrossSliding += GestureRecognizer_CrossSliding;
        }
示例#24
0
        public PlatformGestureEffect()
        {
            detector = new Windows.UI.Input.GestureRecognizer
            {
                GestureSettings     = GestureSettings.Tap | GestureSettings.Drag | GestureSettings.ManipulationTranslateInertia,
                ShowGestureFeedback = false,
            };
            detector.Tapped += (sender, args) =>
            {
                TriggerCommand(tapCommand, GetScaledCoord(args.Position.X, args.Position.Y));
            };
            detector.Dragging += (sender, args) =>
            {
                switch (args.DraggingState)
                {
                case DraggingState.Started:
                    eventArgs.StartPosition = GetScaledCoord(args.Position.X, args.Position.Y);
                    eventArgs.StatusType    = GestureStatus.Running;
                    break;

                case DraggingState.Continuing:
                    eventArgs.StatusType = GestureStatus.Running;
                    break;

                case DraggingState.Completed:
                    eventArgs.StatusType = GestureStatus.Completed;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                eventArgs.CurrentPosition = GetScaledCoord(args.Position.X, args.Position.Y);
                eventArgs.TotalMove       = GetScaledCoord(eventArgs.CurrentPosition.X - eventArgs.StartPosition.X, eventArgs.CurrentPosition.Y - eventArgs.StartPosition.Y);
                TriggerCommand(panCommand, eventArgs);
            };
        }
示例#25
0
 public void OnManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
 {
     camera.OnManipulationUpdated(sender, args);
 }
示例#26
0
 // These virtual voids allow any object that extends GameObject to respond to tapped and manipulation events
 public virtual void Tapped(GestureRecognizer sender, TappedEventArgs args)
 {
 }
示例#27
0
 public virtual void OnManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
 {
 }
示例#28
0
        private void AddGestureRecognizer()
        {
            var gesture = new GestureRecognizer() {
                AutoProcessInertia = true,
                GestureSettings = GestureSettings.Drag | GestureSettings.CrossSlide,
                CrossSlideHorizontally = true,
                CrossSlideThresholds = new CrossSlideThresholds { SpeedBumpEnd = 30 }
            };

            Point lastDragLocation;
            var lastDragTime = DateTime.Now;
            gesture.Dragging += (sender, args) => {
                switch (args.DraggingState) {
                    case DraggingState.Started:
                        lastDragLocation = args.Position;
                        lastDragTime = DateTime.Now;
                        break;

                    case DraggingState.Continuing: {
                            if (swipeDisplayed) {
                                SwipeHelp.FadeOut();
                                swipeDisplayed = false;
                            }

                            var delta = args.Position.X - lastDragLocation.X;
                            var time = DateTime.Now.Subtract(lastDragTime).TotalSeconds;
                            if (Math.Abs(delta) > 30 && time > 0) {
                                var velocity = delta / time;

                                lastDragLocation = args.Position;
                                lastDragTime = DateTime.Now;

                                Model.Zoomed(velocity);
                            }
                            break;
                        }
                }
            };
            gesture.CrossSliding += (sender, args) => {
                switch (args.CrossSlidingState) {
                    case CrossSlidingState.Started:
                        lastDragLocation = args.Position;
                        lastDragTime = DateTime.Now;
                        break;

                    case CrossSlidingState.Dragging: {
                            if (swipeDisplayed) {
                                SwipeHelp.FadeOut();
                                swipeDisplayed = false;
                            }

                            var delta = args.Position.X - lastDragLocation.X;
                            var time = DateTime.Now.Subtract(lastDragTime).TotalSeconds;
                            if (Math.Abs(delta) > 30 && time > 0) {
                                var velocity = delta / time;

                                lastDragLocation = args.Position;
                                lastDragTime = DateTime.Now;

                                Model.Zoomed(velocity);
                            }
                            break;
                        }
                }
            };

            GraphView.PointerPressed += (sender, args) => {
                GraphView.CapturePointer(args.Pointer);
                gesture.ProcessDownEvent(args.GetCurrentPoint(GraphView));
            };
            GraphView.PointerMoved += (sender, args) => {
                gesture.ProcessMoveEvents(args.GetIntermediatePoints(GraphView));
            };
            GraphView.PointerReleased += (sender, args) => {
                gesture.ProcessUpEvent(args.GetCurrentPoint(GraphView));
                GraphView.ReleasePointerCapture(args.Pointer);
            };
        }
 private void OnCrossSlidingToAxe(GestureRecognizer sender, CrossSlidingEventArgs args)
 {
     //args.CrossSlidingState == CrossSlidingState.Started;
 }
 public void OnHolding(GestureRecognizer sender, HoldingEventArgs args)
 {
     //physics.OnHolding(sender, args);
 }
 public void OnManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs args)
 {
     physics.OnManipulationCompleted(sender, args);
 }
 public void Tapped(GestureRecognizer sender, TappedEventArgs args)
 {
     physics.Tapped(sender, args);
 }
示例#33
0
 public void Tapped(GestureRecognizer sender, TappedEventArgs args)
 {
     // Pass Manipulation events to the game objects.
     foreach (var obj in gameObjects)
     {
         obj.Tapped(sender, args);
     }
 }
示例#34
0
 public void OnManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
 {
     player.OnManipulationUpdated(sender, args);
     // Update camera position for all game objects
     foreach (var obj in gameObjects)
     {
         if (obj.basicEffect != null) { obj.basicEffect.View = player.View; }
         obj.OnManipulationUpdated(sender, args);
     }
 }
示例#35
0
 public Scenario2()
 {
     this.InitializeComponent();
     this.gr2         = new Windows.UI.Input.GestureRecognizer();
     this.ShapeInput2 = new ManipulationInputProcessor(gr2, ManipulateMe, Scenario2Output);
 }
        void gr_RightTapped(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.RightTappedEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_RightTapped");
#endif
        }
示例#37
0
 void gestureRecognizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs args)
 {
     velocity = 0;
     inManipulation = true;
 }
示例#38
0
文件: Camera.cs 项目: 2666fff/demo
 public void OnManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
 {
     if (main.focussld == false)
     {
         scaleFactor /= (float)args.Delta.Scale;
         AngleH += (float)args.Delta.Translation.X / 500;
         AngleV += (float)args.Delta.Translation.Y / 500;
     }
 }
        void gr_ManipulationInertiaStarting(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationInertiaStartingEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_ManipulationInertiaStarting");
#endif
        }
示例#40
0
 void gestureRecognizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs args)
 {
     inManipulation = false;
 }
        void gr_CrossSliding(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.CrossSlidingEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_CrossSliding");
#endif
        }
示例#42
0
 void gestureRecognizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
 {
     offset = offset - (float)args.Delta.Translation.Y;
     targetVelocity = -Math.Sign(args.Velocities.Linear.Y) * targetSpeed;
 }
        void gr_ManipulationUpdated(Windows.UI.Input.GestureRecognizer sender, Windows.UI.Input.ManipulationUpdatedEventArgs args)
        {
#if (DEBUG)
            System.Diagnostics.Debug.WriteLine("gr_ManipulationUpdated");
#endif
        }