示例#1
0
        protected override void OnAttached()
        {
            base.OnAttached();

            this.timer = new DispatcherTimer();
            this.AssociatedObject.IsManipulationEnabled = true;
            // Insert code that you would want run when the Behavior is attached to an object.
            this.AssociatedObject.PreviewTouchDown += AssociatedObject_PreviewTouchDown;
            this.AssociatedObject.PreviewTouchMove += AssociatedObject_PreviewTouchMove;
            this.AssociatedObject.PreviewTouchUp   += AssociatedObject_PreviewTouchUp;

            this.sensitiveFactor = new GestureSensitive(1.0, 1.0);
            this.timer.Tick     += new EventHandler(timer_Tick);
            this.timer.Interval  = new TimeSpan(0, 0, 0, 0, GestureConsts.Current.PressAndHoldInterval);
        }
示例#2
0
 public void SetSensitiveCallBack(GestureSensitive sensitiveFactor)
 {
     this.sensitiveFactor = sensitiveFactor;
 }
示例#3
0
        public static void AttachTouchOperation(this FrameworkElement element, Action <GestureArg> callback, GestureSensitive sensiveFactor, Action <GestureArg, Vector, Vector> gestureDetalBehavior = null)
        {
            GestureCheckBehavior behavior = new GestureCheckBehavior();

            behavior.OnGestureDetector += (ele, arg) =>
            {
                callback((GestureArg)arg);
            };
            behavior.SetCallBack(gestureDetalBehavior);
            Interaction.GetBehaviors(element).Add(behavior);
        }
示例#4
0
 public GestureDetectorBehavior()
 {
     this.sensitiveFactor = new GestureSensitive(1.0, 1.0);
 }
示例#5
0
        public static void AttachGestureDetector(this FrameworkElement element, Action <GestureArg> callback, GestureSensitive sensiveFactor, Action <GestureArg, ManipulationDelta, ManipulationDelta> gestureDetalBehavior = null, Action <GestureArg> gestureStatusBehavior = null)
        {
            GestureDetectorBehavior behavior = new GestureDetectorBehavior();

            if (gestureDetalBehavior != null)
            {
                behavior.SetContinueCallBack(gestureDetalBehavior);
            }

            if (gestureStatusBehavior != null)
            {
                behavior.SetStatusCallBack(gestureStatusBehavior);
            }

            if (sensiveFactor != null)
            {
                behavior.SetSensitiveCallBack(sensiveFactor);
            }

            behavior.OnGestureDetector += (ele, arg) =>
            {
                callback((GestureArg)arg);
            };
            Interaction.GetBehaviors(element).Add(behavior);
        }