示例#1
0
        private void Grid_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            double minInitialVelocity = 0.5;
            double flickVelocity      = 3;
            double initialVelocity    = e.InitialVelocities.LinearVelocity.Y;

            if (Math.Abs(initialVelocity) <= 0.01)
            {
                if (BarYPosition > transitionPosition)
                {
                    e.TranslationBehavior.DesiredDisplacement = closePosition - BarYPosition;
                    e.TranslationBehavior.InitialVelocity     = new Vector(0, minInitialVelocity);
                }
            }
            else if (BarYPosition > transitionPosition &&
                     initialVelocity < 0.0)
            {
                e.TranslationBehavior.DesiredDisplacement = BarYPosition - openPosition;
                e.TranslationBehavior.InitialVelocity     = new Vector(0, -flickVelocity);
            }
            else if (initialVelocity < 0.02 && BarYPosition > 0)
            {
                e.TranslationBehavior.DesiredDisplacement = BarYPosition;
                e.TranslationBehavior.InitialVelocity     = new Vector(0, -flickVelocity);
            }
            else if (initialVelocity > 0.02 && BarYPosition > 0)
            {
                e.TranslationBehavior.DesiredDisplacement = closePosition - BarYPosition;
                e.TranslationBehavior.InitialVelocity     = new Vector(0, flickVelocity);
            }
            else
            {
                e.TranslationBehavior.DesiredDeceleration = 0.004;
            }
        }
示例#2
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
        {
            if (e != null)
            {
                if (e.TranslationBehavior != null)
                {
                    // Decrease the velocity of the Rectangle's movement by
                    // 10 inches per second every second.
                    // (10 inches * 96 pixels per inch / 1000ms^2)
                    e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);
                }

                if (e.ExpansionBehavior != null)
                {
                    // Decrease the velocity of the Rectangle's resizing by
                    // 0.1 inches per second every second.
                    // (0.1 inches * 96 pixels per inch / (1000ms^2)
                    e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);
                }

                if (e.RotationBehavior != null)
                {
                    // Decrease the velocity of the Rectangle's rotation rate by
                    // 2 rotations per second every second.
                    // (2 * 360 degrees / (1000ms^2)
                    e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);
                }
            }

            base.OnManipulationInertiaStarting(e);
        }
示例#3
0
 void ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.TranslationBehavior.DesiredDeceleration = 100.0f / (1000.0f * 1000.0f);
     e.RotationBehavior.DesiredDeceleration    = 360.0f / (1000.0f * 1000.0f);
     e.ExpansionBehavior.DesiredDeceleration   = 300.0f / (1000.0f * 1000.0f);
     e.Handled = true;
 }
示例#4
0
        private void ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // deceleration is pixels per ms^2
            // the translate factor is in the range of [0,1], with 0 being no deceleration, and 1 being instant deceleration.
            // We use log because the curve has good characteristics over the input range.
            double translateFactor       = this.TranslateFriction == 1 ? 1.0 : -.00666 * Math.Log(1 - this.TranslateFriction);
            double translateDeceleration = e.InitialVelocities.LinearVelocity.Length * translateFactor;

            e.TranslationBehavior = new InertiaTranslationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.LinearVelocity,
                DesiredDeceleration = Math.Max(translateDeceleration, 0)
            };

            double rotateFactor       = this.RotationalFriction == 1 ? 1.0 : -.00666 * Math.Log(1 - this.RotationalFriction);
            double rotateDeceleration = Math.Abs(e.InitialVelocities.AngularVelocity) * rotateFactor;

            e.RotationBehavior = new InertiaRotationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.AngularVelocity,
                DesiredDeceleration = Math.Max(rotateDeceleration, 0)
            };

            e.Handled = true;
        }
示例#5
0
 void TouchableThing_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.RotationBehavior = new InertiaRotationBehavior();
     e.RotationBehavior.InitialVelocity = e.InitialVelocities.AngularVelocity;
     // 720 degrees per second squared.
     e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);
 }
示例#6
0
 private void container_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     if (mTranslate.X < -(mCards.Count() - 2) * (mCardWidth + Gap))
     {
         e.TranslationBehavior = new InertiaTranslationBehavior
         {
             InitialVelocity     = new Vector(0.8, 0),
             DesiredDisplacement = 2 * mCardWidth,
         };
     }
     else if (mTranslate.X > mCardWidth * 2)
     {
         e.TranslationBehavior = new InertiaTranslationBehavior
         {
             InitialVelocity     = new Vector(-0.8, 0),
             DesiredDisplacement = 2 * mCardWidth,
         };
     }
     else
     {
         e.TranslationBehavior = new InertiaTranslationBehavior
         {
             InitialVelocity     = e.InitialVelocities.LinearVelocity,
             DesiredDeceleration = 0.01
         };
     }
 }
示例#7
0
        private void OnInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // Decrease the velocity of the Rectangle's movement by
            // 10 inches per second every second.
            // (10 inches * 96 DIPS per inch / 1000ms^2)
            e.TranslationBehavior = new InertiaTranslationBehavior
            {
                InitialVelocity     = e.InitialVelocities.LinearVelocity,
                DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0)
            };

            // Decrease the velocity of the Rectangle's resizing by
            // 0.1 inches per second every second.
            // (0.1 inches * 96 DIPS per inch / (1000ms^2)
            e.ExpansionBehavior = new InertiaExpansionBehavior
            {
                InitialVelocity     = e.InitialVelocities.ExpansionVelocity,
                DesiredDeceleration = 0.1 * 96 / 1000.0 * 1000.0
            };

            // Decrease the velocity of the Rectangle's rotation rate by
            // 2 rotations per second every second.
            // (2 * 360 degrees / (1000ms^2)
            e.RotationBehavior = new InertiaRotationBehavior
            {
                InitialVelocity     = e.InitialVelocities.AngularVelocity,
                DesiredDeceleration = 720 / (1000.0 * 1000.0)
            };

            e.Handled = true;
        }
        void WPFTouchVEMap_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            //panning
            e.TranslationBehavior = new InertiaTranslationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.LinearVelocity,
                DesiredDeceleration = 0.002 //10.0 * 96.0 / (1000.0 * 1000.0)
            };

            //Expansion (zoom)
            e.ExpansionBehavior = new InertiaExpansionBehavior()
            {
                InitialVelocity     = e.InitialVelocities.ExpansionVelocity,
                DesiredDeceleration = 0.0005
            };

            //rotation
            e.RotationBehavior = new InertiaRotationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.AngularVelocity,
                DesiredDeceleration = 0.0002
            };

            e.Handled = true;
        }
示例#9
0
 protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
 {
     base.OnManipulationInertiaStarting(e);
     e.TranslationBehavior.DesiredDeceleration = 0.001;
     e.RotationBehavior.DesiredDeceleration    = 0.01;
     e.ExpansionBehavior.DesiredDeceleration   = 0.01;
 }
示例#10
0
 void ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.TranslationBehavior.DesiredDeceleration = 100.0f / (1000.0f * 1000.0f);
     e.RotationBehavior.DesiredDeceleration = 360.0f / (1000.0f * 1000.0f);
     e.ExpansionBehavior.DesiredDeceleration = 300.0f / (1000.0f * 1000.0f);
     e.Handled = true;
 }
        // When a manipulation that's a result of inertia begins, change the color of the
        // the object to reflect that inertia has taken over
        void OnManipulationInertiaStarting(object sender,
                                           ManipulationInertiaStartingEventArgs e)
        {
            JobControl jc = element as JobControl;

            jc.Highlight = new SolidColorBrush(Colors.Green);
        }
 void Window_InertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);
     //e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);
     //e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);
     e.Handled = true;
 }
示例#13
0
 protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
 {
     // 10 inches per second every second.
     // (10 inches * 96 pixels per inch / 1000ms^2)
     e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);
     base.OnManipulationInertiaStarting(e);
 }
示例#14
0
        private void canvas_PadControl_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // 移动惯性
            //e.TranslationBehavior = new InertiaTranslationBehavior()
            //{
            //    InitialVelocity = e.InitialVelocities.LinearVelocity,
            //    DesiredDeceleration = 1 / (1000.0 * 1000.0)   // 单位:一个WPF单位 / ms
            //};

            // 缩放惯性
            //e.ExpansionBehavior = new InertiaExpansionBehavior()
            //{
            //    InitialVelocity = e.InitialVelocities.ExpansionVelocity,
            //    DesiredDeceleration = 1 / 1000.0 * 1000.0   // 单位:一个WPF单位 / ms
            //};

            // 旋转惯性
            e.RotationBehavior = new InertiaRotationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.AngularVelocity,
                DesiredDeceleration = 720 / (1000.0 * 1000.0)  //单位:一个角度 / ms
            };
            e.Handled = true;
            canvas_PadControl_wheel_ManipulationInertiaStarting(sender, e);
        }
示例#15
0
 private void Viewer_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.TranslationBehavior = new InertiaTranslationBehavior
     {
         InitialVelocity     = e.InitialVelocities.LinearVelocity,
         DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0)
     };
 }
示例#16
0
        internal ManipulationInertiaStartingRoutedEventArgs(UIElement container, ManipulationInertiaStartingEventArgs args)
            : base(container)
        {
            Container = container;

            PointerDeviceType = args.PointerDeviceType;
            Delta             = args.Delta;
            Cumulative        = args.Cumulative;
        }
示例#17
0
        void OnOwnerManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport;

            if (sms != null)
            {
                e.TranslationBehavior.DesiredDeceleration = sms.DesiredDeseleration;
            }
            e.Handled = true;
        }
        private void OnManipulationInertia(object sender, ManipulationInertiaStartingEventArgs e)
        {
            e.TranslationBehavior.DesiredDeceleration = Deceleration(TranslateFriction,
                                                                     ((Vector)e.InitialVelocities.LinearVelocity).Length);

            e.RotationBehavior.DesiredDeceleration = Deceleration(RotationalFriction,
                                                                  Math.Abs(e.InitialVelocities.AngularVelocity));

            e.Handled = true;
        }
示例#19
0
        protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
        {
            if (_disableManipulationCount > 0)
            {
                return;
            }

            base.OnManipulationInertiaStarting(e);
            RaiseParent(e);
        }
示例#20
0
        void child_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            //Smooth deceleration at .001 DIP/millisecond
            //e.TranslationBehavior.DesiredDeceleration = .001;

            //Smooth deceleration at .001 degrees/millisecond
            //e.RotationBehavior.DesiredDeceleration = .001;

            e.Handled = true;
        }
        protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs args)
        {
            // Check to see if there have been any deltas; if not, it's a tap
            if (!manipulationDeltaInProgress)
            {
                // This might be negative or beyond bounds!
                var tappedItemIndex           = (int)Math.Floor((args.ManipulationOrigin.Y + VerticalOffset) / itemsHeight);
                var destinationVerticalOffset = VerticalOffsetFromCenteredIndex(tappedItemIndex);
                var displacement = VerticalOffset - destinationVerticalOffset;

                // Set SelectedIndex
                SelectedIndex = NormalizeIndex(tappedItemIndex);

                // Now start inertia to slide into place
                if (displacement != 0)
                {
                    double localVelocity = 2 * displacement / SLIDE_TIME;
                    args.TranslationBehavior.DesiredDisplacement = Math.Abs(displacement);
                    args.TranslationBehavior.InitialVelocity     = new Vector(0, localVelocity);
                    tapInertiaInProgess = true;
                }
            }
            // Not a tap -- there has been some movement and now the finger has lifted
            else
            {
                // Check for insufficient velocity
                var closestIndex = (int)Math.Round(FractionalCenteredIndexFromVerticalOffset(VerticalOffset, false));
                var verticalOffsetOfClosestIndex = VerticalOffsetFromCenteredIndex(closestIndex);
                var displacement  = VerticalOffset - verticalOffsetOfClosestIndex;
                var localVelocity = 2 * displacement / SLIDE_TIME;

                // Band has been slid precisely into place
                if (displacement == 0)
                {
                    SelectedIndex = NormalizeIndex(closestIndex);
                }
                // Insufficient velocity to move beyond "destinationIndex"
                else if (Math.Abs(args.TranslationBehavior.InitialVelocity.Y) < Math.Abs(localVelocity))
                {
                    SelectedIndex = NormalizeIndex(closestIndex);
                    args.TranslationBehavior.DesiredDisplacement = Math.Abs(displacement);
                    args.TranslationBehavior.InitialVelocity     = new Vector(0, localVelocity);
                }
                // Enough velocity for inertia to some unknown index
                else
                {
                    inertiaToUnknownIndex = true;
                    args.TranslationBehavior.DesiredDeceleration = DECELERATION;
                }
            }

            args.Handled = true;
            base.OnManipulationInertiaStarting(args);
        }
示例#22
0
        private void touchPad_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // 移动惯性
            e.TranslationBehavior = new InertiaTranslationBehavior()
            {
                InitialVelocity     = e.InitialVelocities.LinearVelocity,
                DesiredDeceleration = 3 * 10.0 * 96.0 / (1000.0 * 1000.0)
            };

            e.Handled = true;
        }
 protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
 {
     base.OnManipulationInertiaStarting(e);
     e.TranslationBehavior = new InertiaTranslationBehavior {
         DesiredDeceleration = 0.0096
     };
     e.ExpansionBehavior = new InertiaExpansionBehavior {
         DesiredDeceleration = 0.000096
     };
     e.Handled = true;
 }
示例#24
0
        private void Window_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // desaceleracion para la traslacion
            e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);

            // desaceleracion para la expansion
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);;

            // desaceleracion para la rotacion
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);

            e.Handled = true;
        }
示例#25
0
        protected override void OnManipulationInertiaStarting(ManipulationInertiaStartingEventArgs e)
        {
            // 10 inches * 96 pixels / 1000ms^2
            e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);

            // .1 inch * 96 pixels / 1000ms^2
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96.0 / (1000.0 * 1000.0);

            // 2 rotations (360 * 2) per second (1000ms^2)
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);
            e.Handled = true;
            base.OnManipulationInertiaStarting(e);
        }
示例#26
0
        private void DrawingCanvas_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            e.TranslationBehavior = new System.Windows.Input.InertiaTranslationBehavior();
            e.TranslationBehavior.InitialVelocity     = e.InitialVelocities.LinearVelocity;
            e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);

            e.ExpansionBehavior = new System.Windows.Input.InertiaExpansionBehavior();
            e.ExpansionBehavior.InitialVelocity     = e.InitialVelocities.ExpansionVelocity;
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);

            e.RotationBehavior = new InertiaRotationBehavior();
            e.RotationBehavior.InitialVelocity     = e.InitialVelocities.AngularVelocity;
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);
        }
示例#27
0
        //https://github.com/noureldien/Pen/blob/d443d27a48c3be1b8a2b0443f2191659829be424/Pen.Tools/WebfilePanel.xaml.cs
        void source_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            //Debug.WriteLine("==================source_ManipulationInertiaStarting");

            // adjust the dispalcement behaviour
            // (10 inches * 96 DIPS per inch / 1000ms^2)
            //e.TranslationBehavior = new InertiaTranslationBehavior();¡¡
            //e.TranslationBehavior.InitialVelocity = e.InitialVelocities.LinearVelocity;
            if (!this.ViewArea.PdfRenderer.EnableAnnot)
            {
                e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);
            }
            //e.TranslationBehavior.DesiredDisplacement = Math.Abs(e.InitialVelocities.LinearVelocity.Y) * 300;
        }
        internal ManipulationInertiaStartingRoutedEventArgs(UIElement container, ManipulationInertiaStartingEventArgs args)
            : base(container)
        {
            Container = container;

            Pointers          = args.Pointers;
            PointerDeviceType = args.PointerDeviceType;
            Delta             = args.Delta;
            Cumulative        = args.Cumulative;
            Velocities        = args.Velocities;

            TranslationBehavior = new InertiaTranslationBehavior(args.Processor);
            RotationBehavior    = new InertiaRotationBehavior(args.Processor);
            ExpansionBehavior   = new InertiaExpansionBehavior(args.Processor);
        }
示例#29
0
 void ManipulationElement_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     foreach (var m in mouseProcessors)
     {
         if (e.Handled)
         {
             break;
         }
         (m as IMouseProcessor2)?.PreprocessManipulationInertiaStarting(e);
     }
     if (!e.Handled)
     {
         defaultMouseProcessor.OnManipulationInertiaStarting(sender, e);
     }
     foreach (var m in mouseProcessors)
     {
         (m as IMouseProcessor2)?.PostprocessManipulationInertiaStarting(e);
     }
 }
示例#30
0
        void Window_InertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            // Decrease the velocity of the Rectangle's movement by
            // 10 inches per second every second.
            // (10 inches * 96 pixels per inch / 1000ms^2)
            e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);

            // Decrease the velocity of the Rectangle's resizing by
            // 0.1 inches per second every second.
            // (0.1 inches * 96 pixels per inch / (1000ms^2)
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);

            // Decrease the velocity of the Rectangle's rotation rate by
            // 2 rotations per second every second.
            // (2 * 360 degrees / (1000ms^2)
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);

            e.Handled = true;
        }
示例#31
0
 void canvas_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
 {
     e.TranslationBehavior = new InertiaTranslationBehavior()
     {
         InitialVelocity     = e.InitialVelocities.LinearVelocity,
         DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0)
     };
     e.ExpansionBehavior = new InertiaExpansionBehavior()
     {
         InitialVelocity     = e.InitialVelocities.ExpansionVelocity,
         DesiredDeceleration = 0.1 * 96 / 1000.0 * 1000.0
     };
     e.RotationBehavior = new InertiaRotationBehavior()
     {
         InitialVelocity     = e.InitialVelocities.AngularVelocity,
         DesiredDeceleration = 720 / (1000.0 * 1000.0)
     };
     e.Handled = true;
 }