private void StackPanel_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     /* if (e.DeltaManipulation.Translation.Y != 0)
          return;
      if (Event != null)
          Event(this, e);*/
 }
Пример #2
0
        void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (e.PinchManipulation != null)
            {
                e.Handled = true;

                if (!_pinching)
                {
                    _pinching = true;
                    Point center = e.PinchManipulation.Original.Center;
                    _relativeMidpoint = new Point(center.X / SystemMapImage.ActualWidth, center.Y / SystemMapImage.ActualHeight);

                    var xform = SystemMapImage.TransformToVisual(ImageViewPort);
                    _screenMidpoint = xform.Transform(center);
                }

                _scale = _originalScale * e.PinchManipulation.CumulativeScale;

                CoerceScale(false);
                ResizeImage(false);
            }
            else if (_pinching)
            {
                _pinching = false;
                _originalScale = _scale = _coercedScale;
            }
        }
        void Button_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            e.Handled = true;


            bool isInBounds = true;

            Rect bounds = new Rect(new Point(0, 0), Button.RenderSize);

            foreach (IManipulator manipulator in e.Manipulators)
            {
                Point p = manipulator.GetPosition(Button);
                if (!bounds.Contains(p))
                {
                    isInBounds = false;
                    break;
                }
            }


            if (!isInBounds)
            {
                e.Cancel();
            }
        }
        private void Element_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (!IsEnabled)
            return;

              if (!IsActive)
              {
            // has the user dragged far enough?
            if (Math.Abs(e.CumulativeManipulation.Translation.X) < DragStartedDistance)
              return;

            IsActive = true;

            // initialize the drag
            FrameworkElement fe = sender as FrameworkElement;
            fe.SetHorizontalOffset(0);

            // find the container for the tick and cross graphics
            _tickAndCrossContainer = fe.Descendants()
                                   .OfType<FrameworkElement>()
                                   .Single(i => i.Name == "tickAndCross");
              }
              else
              {
            // handle the drag to offset the element
            FrameworkElement fe = sender as FrameworkElement;
            double offset = fe.GetHorizontalOffset().Value + e.DeltaManipulation.Translation.X;
            fe.SetHorizontalOffset(offset);

            _tickAndCrossContainer.Opacity = TickAndCrossOpacity(offset);
              }
        }
Пример #5
0
        private void ImageGrid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (e.PinchManipulation != null)
            {
                //缩放
                _bokehManger.ScaleChange(e.PinchManipulation.DeltaScale);

                _bokehManger.RotationChange(e.PinchManipulation.Current, e.PinchManipulation.Original);

                TouchPanel.EnabledGestures = GestureType.None;
            }
            else
            {
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample sample = TouchPanel.ReadGesture();
                    Point sampleDelta = new Point(sample.Delta.X, sample.Delta.Y);
                    _bokehManger.PositionChange(sampleDelta);
                }
                if (!TouchPanel.IsGestureAvailable)
                {
                    _bokehManger.SetPreAngel();
                }
            }
            _bokehManger.SetGradient();
        }
        private void cropArea_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            drag.X += e.DeltaManipulation.Translation.X;
            if (drag.X < 0)
                drag.X = 0;
            if (drag.X > max)
                drag.X = max;

            int temp = current + (int)e.DeltaManipulation.Translation.X;
            if (temp < min)
            {
                rightBound.Width = originalPhoto.Width - cropArea.Width;
                leftBound.Width = 0;
                current = min;
            }
            else if (temp > max)
            {
                leftBound.Width = originalPhoto.Width - cropArea.Width;
                rightBound.Width = 0;
                current = max;
            }
            else
            {
                leftBound.Width = temp;
                rightBound.Width = max - temp;
                current = temp;
            }
        }
Пример #7
0
        private void image_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            // Get the image that's being manipulated.            
            FrameworkElement element = (FrameworkElement)e.Source;

            // Use the matrix to manipulate the element.
            Matrix matrix = ((MatrixTransform)element.RenderTransform).Matrix;

            var deltaManipulation = e.DeltaManipulation;
            // Find the old center, and apply the old manipulations.
            Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
            center = matrix.Transform(center);

            // Apply zoom manipulations.
            matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);

            // Apply rotation manipulations.
            matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y);

            // Apply panning.
            matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);

            // Set the final matrix.
            ((MatrixTransform)element.RenderTransform).Matrix = matrix;

        }
 private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     // suppress zoom
     if (e.DeltaManipulation.Scale.X != 0.0 ||
         e.DeltaManipulation.Scale.Y != 0.0)
         e.Handled = true;
 }
Пример #9
0
 private void OnManipulationDelta(object Sender, ManipulationDeltaEventArgs DeltaRoutedEventArgs)
 {
     if (DeltaRoutedEventArgs.CumulativeManipulation.Translation.X < -30)
     {
         _gameGrid.HandleMove(MoveDirection.Left);
         DeltaRoutedEventArgs.Complete();
         DeltaRoutedEventArgs.Handled = true;
     }
     else if (DeltaRoutedEventArgs.CumulativeManipulation.Translation.X > 30)
     {
         _gameGrid.HandleMove(MoveDirection.Right);
         DeltaRoutedEventArgs.Complete();
         DeltaRoutedEventArgs.Handled = true;
     }
     else if (DeltaRoutedEventArgs.CumulativeManipulation.Translation.Y < -30)
     {
         _gameGrid.HandleMove(MoveDirection.Up);
         DeltaRoutedEventArgs.Complete();
         DeltaRoutedEventArgs.Handled = true;
     }
     else if (DeltaRoutedEventArgs.CumulativeManipulation.Translation.Y > 30)
     {
         _gameGrid.HandleMove(MoveDirection.Down);
         DeltaRoutedEventArgs.Complete();
         DeltaRoutedEventArgs.Handled = true;
     }
 }
Пример #10
0
        public override void Manipulate(System.Windows.Input.ManipulationDeltaEventArgs args, ref System.Windows.Media.Matrix matrix)
        {
            base.Manipulate(args, ref matrix);

            ManipulationDelta delta  = args.DeltaManipulation;
            Point             center = args.ManipulationOrigin;


            Vector scale = new Vector(matrix.M11, matrix.M22);

            if (MaxScale == 0.0 || MaxScale > scale.Length)
            {
                //matrix.ScaleAtPrepend(delta.Scale.X, delta.Scale.Y, center.X, center.Y);
                System.Windows.Media.Matrix m = new System.Windows.Media.Matrix(matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.OffsetX, matrix.OffsetY);
                //m.ScalePrepend(delta.Scale.X, delta.Scale.Y);

                matrix.ScalePrepend(delta.Scale.X, delta.Scale.Y);

                if (!this.ElementInsideContainer() && (delta.Scale.X > 1 || delta.Scale.Y > 1))
                {
                    if (lastPositionInside != null)
                    {
                        matrix = m;
                        //matrix = new System.Windows.Media.Matrix(lastPositionInside.M11, lastPositionInside.M12, lastPositionInside.M21, lastPositionInside.M22, lastPositionInside.OffsetX, lastPositionInside.OffsetY);
                    }
                    args.Handled = true;
                }
                else
                {
                    lastPositionInside = new System.Windows.Media.Matrix(matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.OffsetX, matrix.OffsetY);
                }
            }
        }
Пример #11
0
 // Al arrastrar el circulo.
 private void negro_ManipulationDelta_1(object sender, ManipulationDeltaEventArgs e)
 {
     FrameworkElement elipse = sender as FrameworkElement;
     elipse.RenderTransform = dragTranslation;
     dragTranslation.TranslateX = dragTranslation.TranslateX + e.DeltaManipulation.Translation.X;
     dragTranslation.TranslateY = dragTranslation.TranslateY + e.DeltaManipulation.Translation.Y;
 }
        /// <summary>
        /// Step: 4
        /// ManipulationDelta event occurs multiple times when the user drags a finger over the screen during manipulation.
        /// CumulativeManipulation property contains the total changes that occurred for the current manipulation.
        /// It further provides more details of the type of manipulation, e.g., translation, scaling, rotation, etc.
        /// The Velocities property give details on the current speed of manipulation and direction.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void centerImageView_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            //store values of horizontal & vertical cumulative translation
            cumulativeDeltaX = e.CumulativeManipulation.Translation.X;
            cumulativeDeltaY = e.CumulativeManipulation.Translation.Y;
            //store value of linear velocity into horizontal direction
            linearVelocity = e.Velocities.LinearVelocity.X;

            /// Added from part 2. Scale part.
            // get current matrix of the element.
            Matrix borderMatrix = ((MatrixTransform)centerImageView.RenderTransform).Matrix;
            //determine if action is zoom or pinch
            var maxScale = Math.Max(e.DeltaManipulation.Scale.X, e.DeltaManipulation.Scale.Y);

            //check if not crossing minimum and maximum zoom limit
            if ((maxScale < 1 && borderMatrix.M11 * maxScale > MinimumZoom) ||
                (maxScale > 1 && borderMatrix.M11 * maxScale < MaximumZoom))
            {
                //scale to most recent change (delta) in X & Y
                borderMatrix.ScaleAt(e.DeltaManipulation.Scale.X,
                                     e.DeltaManipulation.Scale.Y,
                                     centerImageView.ActualWidth / 2,
                                     centerImageView.ActualHeight / 2);
                //render new matrix
                centerImageView.RenderTransform = new MatrixTransform(borderMatrix);
            }
        }
Пример #13
0
 private void canvas_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     if (e.DeltaManipulation.Translation.X != 0)
     {
         Canvas.SetLeft(LayoutRoot, Math.Min(Math.Max(-840, Canvas.GetLeft(LayoutRoot) + e.DeltaManipulation.Translation.X), 0));
     }
 }
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            Card element = e.Source as Card;
            ManipulationDelta delta = e.DeltaManipulation;
            Point center = e.ManipulationOrigin;
            Matrix matrix = new Matrix();
            if (STATICS.MIN_CARD_SCALE < element.CurrentScale * delta.Scale.X && element.CurrentScale * delta.Scale.X < STATICS.MAX_CARD_SCALE)
            {
                element.CurrentScale = element.CurrentScale * delta.Scale.X;
                matrix.Scale(element.CurrentScale, element.CurrentScale);
            }
            else
            {
                matrix.Scale(element.CurrentScale, element.CurrentScale);
            }
            element.CurrentPosition = new Point(element.CurrentPosition.X + delta.Translation.X, element.CurrentPosition.Y + delta.Translation.Y);
            element.CurrentRotation += delta.Rotation;

            matrix.Rotate(element.CurrentRotation);
            matrix.Translate(element.CurrentPosition.X, element.CurrentPosition.Y);

            element.RenderTransform = new MatrixTransform(matrix);

            mainWindow.LinkingGestureLayer.Move(element);
            e.Handled = true;
            base.OnManipulationDelta(e);
        }
        private void cropArea_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            /**
             *  all of this code keeps the picture within the boundaries
             */

            drag.Y += e.DeltaManipulation.Translation.Y;
            if (drag.Y < 0)
                drag.Y = 0;
            if (drag.Y > max)
                drag.Y = max;

            int temp = current + (int)e.DeltaManipulation.Translation.Y;
            if (temp < min)
            {
                lowerBound.Height = originalPhoto.Height - cropArea.Height;
                upperBound.Height = 0;
                current = min;
            }
            else if (temp > max)
            {
                upperBound.Height = originalPhoto.Height - cropArea.Height;
                lowerBound.Height = 0;
                current = max;
            }
            else
            {
                upperBound.Height = temp;
                lowerBound.Height = max - temp;
                current = temp;
            }
        }
        private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (Math.Abs(e.DeltaManipulation.Translation.X) > Math.Abs(e.DeltaManipulation.Translation.Y))
                e.Handled = true;

            if (e.CumulativeManipulation.Scale.X != 0.0 || e.CumulativeManipulation.Scale.Y != 0.0)
                e.Handled = true;
        }
Пример #17
0
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            base.OnManipulationDelta(e);

            TransformMap(e.ManipulationOrigin,
                (Point)e.DeltaManipulation.Translation, e.DeltaManipulation.Rotation,
                (e.DeltaManipulation.Scale.X + e.DeltaManipulation.Scale.Y) / 2d);
        }
Пример #18
0
        public void ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            Manipulation(e);

            updateUserCursor();

            SetMarkers();
            e.Handled = true;
        }
        private void btnFull_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs args)
        {
            double dCX = args.ManipulationOrigin.X - m_ptDragStart.X;

            //Smaller movement...
            dCX = dCX / 5;

            imgFull.Margin = new Thickness(dCX, 0, -dCX, 0);
        }
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs args)
        {
            if (!manipulationDeltaInProgress)
            {
                IsActive = true;

                if (!tapInertiaInProgess)
                    SelectedIndex = -1;
            }

            manipulationDeltaInProgress = true;

            // This is the fake inertia from a tap
            if (tapInertiaInProgess)
            {
                VerticalOffset -= args.DeltaManipulation.Translation.Y;
            }

            // All other direct manipulation and inertia
            else
            {
                // For non-wrappable panel, check for end of the line
                if (!isWrappableStackPanel)
                {
                    double newVerticalOffset = VerticalOffset - inertiaDirection * args.DeltaManipulation.Translation.Y;

                    if (FractionalCenteredIndexFromVerticalOffset(newVerticalOffset, false) < 0)
                    {
                        double verticalOffsetIncrement = VerticalOffset - VerticalOffsetFromCenteredIndex(0);
                        double verticalOffsetExcess = args.DeltaManipulation.Translation.Y - verticalOffsetIncrement;
                        VerticalOffset -= verticalOffsetIncrement;
                        SelectedIndex = 0;
                        args.ReportBoundaryFeedback(new ManipulationDelta(new Vector(0, verticalOffsetExcess), 0, new Vector(), new Vector()));
                        args.Complete();
                    }
                    else if (FractionalCenteredIndexFromVerticalOffset(newVerticalOffset, false) > Items.Count - 1)
                    {
                        double verticalOffsetIncrement = VerticalOffsetFromCenteredIndex(Items.Count - 1) - VerticalOffset;
                        double verticalOffsetExcess = args.DeltaManipulation.Translation.Y - verticalOffsetIncrement;
                        VerticalOffset += verticalOffsetIncrement;
                        SelectedIndex = Items.Count - 1;
                        args.ReportBoundaryFeedback(new ManipulationDelta(new Vector(0, verticalOffsetExcess), 0, new Vector(), new Vector()));
                        args.Complete();
                    }
                }

                // Here's where scrolling might reverse itself
                if (args.IsInertial && inertiaToUnknownIndex && !reverseInertiaChecked)
                    CheckForBackupManeuver(VerticalOffset, args.DeltaManipulation.Translation.Y, args.Velocities.LinearVelocity.Y);

                // This is the normal direct manipulation and inertia
                VerticalOffset -= inertiaDirection * args.DeltaManipulation.Translation.Y;
            }

            base.OnManipulationDelta(args);
        }
Пример #21
0
        void rect_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            Rectangle croppingRectangle = (Rectangle)sender;

            if (croppingRectangle.Width >= (int)e.DeltaManipulation.Translation.X)
                croppingRectangle.Width -= (int)e.DeltaManipulation.Translation.X;

            if (croppingRectangle.Height >= (int)e.DeltaManipulation.Translation.Y)
                croppingRectangle.Height -= (int)e.DeltaManipulation.Translation.Y;
        }
        void MonitorManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (Movement != null)
                Movement(this, new MovementMonitorEventArgs { 
                    X = _xOffsetStartValue + e.CumulativeManipulation.Translation.X,
                    Y = _yOffsetStartValue + e.CumulativeManipulation.Translation.Y
                });

			e.Handled = true;
        }
Пример #23
0
 protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
 {
     UIElement element = e.OriginalSource as UIElement;
     Point translation = e.DeltaManipulation.Translation;
     Canvas.SetLeft(element, Canvas.GetLeft(element) + translation.X);
     Canvas.SetTop(element, Canvas.GetTop(element) + translation.Y);
     jolidessin.Points.Add(new Point(Canvas.GetLeft(element) + translation.X, Canvas.GetTop(element) + translation.Y));
     e.Handled = true;
     base.OnManipulationDelta(e);
 }
        private void deleteButton_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (dmove.X > 260)
            {
                deleteButton.Background = transformingBrush;
            }

            // move it
            dmove.X += e.DeltaManipulation.Translation.X;
        }
        private void Image_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            double previousRotation = transform.Rotation;
            transform.Rotation = 0.0;

            transform.TranslateX = e.CumulativeManipulation.Translation.X * transform.ScaleX + startingPositionOfImageX;
            transform.TranslateY = e.CumulativeManipulation.Translation.Y * transform.ScaleY + startingPositionOfImageY;

            transform.Rotation = previousRotation;
        }
Пример #26
0
        /// <summary>
        /// Called when the <see cref="E:System.Windows.UIElement.ManipulationDelta" /> event occurs.
        /// </summary>
        /// <param name="e">The data for the event.</param>
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            base.OnManipulationDelta(e);
            if (e.Handled)
            {
                return;
            }

            e.Handled = this.Controller.HandleTouchDelta(this, e.ToTouchEventArgs(this));
        }
Пример #27
0
 private void ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     // ignore delta event for Thumb
     // and derived.
     if (!_is_thumb)
     {
         // forward manipulation event
         _delta(e);
     }
 }
Пример #28
0
        private void Canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            var m = e.DeltaManipulation;

            var mx = tx.Matrix;
            mx.Translate(m.Translation.X, m.Translation.Y);
            mx.ScaleAt(m.Scale.X, m.Scale.X, e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
            mx.RotateAt(m.Rotation, e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
            tx.Matrix = mx;
        }
Пример #29
0
        /// <summary>
        /// 页面设备更改期间时间 此处用于平移图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MainPage_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            //if (e.DeltaManipulation.Scale.X > 0 && e.DeltaManipulation.Scale.Y > 0)
            //{
            //    this.imgScale.ScaleX *= e.DeltaManipulation.Scale.X;
            //    this.imgScale.ScaleY *= e.DeltaManipulation.Scale.Y;
            //}

            this.imgTrans.X += e.DeltaManipulation.Translation.X;
            this.imgTrans.Y += e.DeltaManipulation.Translation.Y;
        } 
Пример #30
0
        void Manipulation(ManipulationDeltaEventArgs e)
        {
            var mt = new MatrixTransform(ShapeUtils.GetTransform(e));

            var Point1 = mt.Transform(new Point(line.X1, line.Y1));
            var Point2 = mt.Transform(new Point(line.X2, line.Y2));
            line.X1 = Point1.X;
            line.Y1 = Point1.Y;
            line.X2 = Point2.X;
            line.Y2 = Point2.Y;            
        }
Пример #31
0
 protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
 {
     base.OnManipulationDelta(e);
     var element = e.OriginalSource as UIElement;
     var transformation = this.mainCanvas.RenderTransform as MatrixTransform;
     var matrix = transformation == null ? Matrix.Identity : transformation.Matrix;
     matrix.ScaleAt(e.DeltaManipulation.Scale.X, e.DeltaManipulation.Scale.Y, e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
     matrix.RotateAt(e.DeltaManipulation.Rotation, e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
     matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
     this.mainCanvas.RenderTransform = new MatrixTransform(matrix);
 }
        private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (DateTime.Now.Subtract(_LastOnManipulationDelta).TotalMilliseconds < 500) return;  // throttle
            _LastOnManipulationDelta = DateTime.Now;

            InfoBox.Text =
                  "Expansion: " + e.CumulativeManipulation.Expansion.ToString() + Environment.NewLine +
                  "Rotation: " + e.CumulativeManipulation.Rotation.ToString() + Environment.NewLine +
                  "Scale: " + e.CumulativeManipulation.Scale.ToString() + Environment.NewLine +
                  "Translation: " + e.CumulativeManipulation.Translation.ToString() + Environment.NewLine +
                  "Exp " + e.CumulativeManipulation.Expansion.X + "/" + e.CumulativeManipulation.Expansion.Y;
        } //
Пример #33
0
 private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     if (!ReadOnly)
     {
         PerformValueCalculation(e.ManipulationOrigin, e.ManipulationContainer);
         UpdateDragHelper();
         if (ShowSelectionHelper)
         {
             ChangeDragHelperVisibility(true);
         }
     }
 }
Пример #34
0
        // UIElement.ManipulationDelta represents either a drag or a pinch.
        // If PinchManipulation == null, then we have a drag, corresponding to GestureListener.DragStarted, 
        // GestureListener.DragDelta, or GestureListener.DragCompleted.
        // If PinchManipulation != null, then we have a pinch, corresponding to GestureListener.PinchStarted, 
        // GestureListener.PinchDelta, or GestureListener.PinchCompleted.
        // 
        // In this sample we track drag and pinch state to illustrate how to manage transitions between 
        // pinching and dragging, but commonly only the pinch or drag deltas will be of interest, in which 
        // case determining when pinches and drags begin and end is not necessary.
        //
        // Note that the exact APIs for the event args are not quite the same as the ones in GestureListener.
        // Comments inside methods called from here will note where they diverge.
        private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            bool oldIsPinch = isPinch;
            bool oldIsDrag = isDrag;
            isPinch = e.PinchManipulation != null;

            // The origin of the first manipulation after a pinch is completed always corresponds to the
            // primary touch point from the pinch, even if the secondary touch point is the one that 
            // remains active. In this sample we only want a drag to affect the rectangle if the finger
            // on the screen falls inside the rectangle's bounds, so if we've just finished a pinch,
            // we have to defer until the next ManipulationDelta to determine whether or not a new 
            // drag has started.
            isDrag = e.PinchManipulation == null && !oldIsPinch;
  
            // check for ending gestures
            if (oldIsDrag && !isDrag)
            {
                this.OnDragCompleted();
            }
            if (oldIsPinch && !isPinch)
            {
                this.OnPinchCompleted();
            }

            // check for continuing gestures
            if (oldIsDrag && isDrag)
            {
                this.OnDragDelta(sender, e);
            }
            if (oldIsPinch && isPinch)
            {
                this.OnPinchDelta(sender, e);
            }

            // check for starting gestures
            if (!oldIsDrag && isDrag)
            {
                // Once a manipulation has started on the UIElement, that element will continue to fire ManipulationDelta
                // events until all fingers have left the screen and we get a ManipulationCompleted. In this sample
                // however, we treat each transition between pinch and drag as a new gesture, and we only want to 
                // apply effects to our border control if the the gesture begins within the bounds of the border.
                isGestureOnTarget = e.ManipulationContainer == border && 
                        new Rect(0, 0, border.ActualWidth, border.ActualHeight).Contains(e.ManipulationOrigin);
                this.OnDragStarted();
            }
            if (!oldIsPinch && isPinch)
            {
                isGestureOnTarget = e.ManipulationContainer == border && 
                        new Rect(0, 0, border.ActualWidth, border.ActualHeight).Contains(e.PinchManipulation.Original.PrimaryContact);
                this.OnPinchStarted(sender, e);
            }
        }
Пример #35
0
    void OnManipDelta(object sender, ManipulationDeltaEventArgs e)
    {
      var pt = e.ManipulationOrigin;
      if (pt.X < 0
        || pt.X > this.Width
        || pt.Y < 0
        || pt.Y > this.Height)
        _imgbrush.ImageSource = _normalimg;
      else
        _imgbrush.ImageSource = _focusimg;

      e.Handled = true;
    }
 void RatingControl_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     if (IsEditable && AllowHover && IsEnabled && Visibility == Visibility.Visible && e != null && e.ManipulationOrigin != null)
     {
         e.Handled = true;
         if (DEBUG_MODE)
         {
             System.Diagnostics.Debug.WriteLine("ManipulationDelta {0} - {1}", DateTime.Now, e.ManipulationOrigin.X);
         }
         double x = e.ManipulationOrigin.X;
         ChangeItemsValue(x);
     }
 }
        private void OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            var maxSize = _heights[ApplicationBarState.Full];
            var minSize = (ApplicationBarMinimizedStateView == ApplicationBarMinimizedState.Minimized
                              ? _heights[ApplicationBarState.Minimized]
                              : 0);

            var desiredTransform    = TranslateTransform.Y + e.DeltaManipulation.Translation.Y;
            var normalizedTransform = -Math.Max(minSize, Math.Min(maxSize, -desiredTransform));

            TranslateTransform.Y = normalizedTransform;

            e.Handled = true;
        }
Пример #38
0
 private void OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     if (e.ManipulationOrigin.Y >= 400)
     {
         x1Distance = e.CumulativeManipulation.Translation.X;
         y1Distance = e.CumulativeManipulation.Translation.Y;
         base.OnManipulationDelta(e);
     }
     if (e.ManipulationOrigin.Y < 400)
     {
         x2Distance = e.CumulativeManipulation.Translation.X;
         y2Distance = e.CumulativeManipulation.Translation.Y;
         base.OnManipulationDelta(e);
     }
 }
Пример #39
0
        public override void Manipulate(System.Windows.Input.ManipulationDeltaEventArgs args, ref System.Windows.Media.Matrix matrix)
        {
            base.Manipulate(args, ref matrix);

            Vector trans;
            bool   contain = true;

            if (DisableBounce)
            {
                matrix.Translate(args.DeltaManipulation.Translation.X, args.DeltaManipulation.Translation.Y);
            }
            else
            {
                contain = Contains(this.Manipulator.ContainerControl as FrameworkElement, args.DeltaManipulation, out trans);
                matrix.Translate(trans.X, trans.Y);
            }
        }
Пример #40
0
        /// <summary>
        /// Tell the gestures to make the manipulation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void element_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs args)
        {
            if (this.Element == null)
            {
                args.Cancel();
                return;
            }
            ApplyTransformForcedByGesture = null;
            Transform transform = Utility.GetMatrixTransformFromTransform(this.ElementTransform);

            //apply gestures
            if (transform is MatrixTransform)
            {
                Matrix matrix = (transform as MatrixTransform).Matrix;

                foreach (aGesture gest in Gestures)
                {
                    if (gest.IsEnabled)
                    {
                        if (args.Handled)
                        {
                            break;
                        }

                        gest.Manipulate(args, ref matrix);

                        // refresh matrix if gesture forced it. exept if it is the the last gesture of the list.
                        if (ApplyTransformForcedByGesture == gest && Gestures.Last() != gest)
                        {
                            transform = Utility.GetMatrixTransformFromTransform(this.ElementTransform);
                            matrix    = (transform as MatrixTransform).Matrix;

                            ApplyTransformForcedByGesture = null;
                        }
                    }
                }

                // do not apply it twice
                if (ApplyTransformForcedByGesture == null)
                {
                    ApplyTransform(matrix);
                }
            }

            args.Handled = true;
        }
Пример #41
0
        public override void Manipulate(System.Windows.Input.ManipulationDeltaEventArgs args, ref System.Windows.Media.Matrix matrix)
        {
            base.Manipulate(args, ref matrix);
            ManipulationDelta delta  = args.DeltaManipulation;
            Point             center = args.ManipulationOrigin;

            Debug.WriteLine("==============================");
            Debug.WriteLine("0: " + center);

            System.Windows.Media.Matrix m = new System.Windows.Media.Matrix(matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.OffsetX, matrix.OffsetY);

            matrix.RotatePrepend(delta.Rotation);

            if (!this.ElementInsideContainer())
            {
                matrix = m;
            }
        }
        public override void Manipulate(System.Windows.Input.ManipulationDeltaEventArgs args, ref System.Windows.Media.Matrix matrix)
        {
            //base.Manipulate(args, ref matrix);

            var manipulators = from tm in ManipulatorContainer.Instance.Manipulators
                               where
                               tm != this.Manipulator &&
                               tm.ContainerControl == this.Manipulator.ContainerControl &&
                               (from gest in tm.Gestures
                                where
                                gest.IsEnabled &&
                                gest is TranslateWithCollision &&

                                ((TranslateWithCollision)gest).CollisionGroup.Equals(this.CollisionGroup)
                                select gest).Count() > 0
                               select tm;

            foreach (TouchManipulator tm in manipulators)
            {
                Vector trans;
                bool   contain = true;
                contain = Collide(this.Manipulator.Element, tm.Element, args.DeltaManipulation.Translation, out trans);

                if (contain)
                {
                    //manipulator2.Element.

                    //Manipulation.SetManipulationParameter(tm.Element
                    //Manipulation.StartInertia(tm.Element);
                    //System.Windows.Input.ManipulationDeltaEventArgs a = new ManipulationDeltaEventArgs

                    //MatrixAnimation animation = new MatrixAnimation(oldMatrix, newMatrix, new Duration(new TimeSpan(0, 0, 1)))
                    //{
                    //    EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut, Power = 2 }
                    //};

                    // Manipulation.
                }


                //  if (contain)
                matrix.Translate(trans.X, trans.Y);
            }
        }
Пример #43
0
        private void _internetAccessBrowser_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            if (!e.Handled)
            {
                var point = e.ManipulationOrigin;

                var browser = sender as ChromiumWebBrowser;

                if (browser != null)
                {
                    browser.SendMouseWheelEvent(
                        (int)point.X,
                        (int)point.Y,
                        deltaX: (int)e.DeltaManipulation.Translation.X,
                        deltaY: (int)e.DeltaManipulation.Translation.Y,
                        modifiers: CefEventFlags.None);
                }
            }
        }
Пример #44
0
        private void viewport_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            if (e.PinchManipulation != null)
            {
                double newWidth, newHieght;


                if (m_Width < m_Height)  // box new size between image size and viewport actual size
                {
                    newHieght = m_Height * m_Zoom * e.PinchManipulation.CumulativeScale;
                    newHieght = Math.Max(viewport.ActualHeight, newHieght);
                    newHieght = Math.Min(newHieght, m_Height);
                    newWidth  = newHieght * m_Width / m_Height;
                }
                else
                {
                    newWidth  = m_Width * m_Zoom * e.PinchManipulation.CumulativeScale;
                    newWidth  = Math.Max(viewport.ActualWidth, newWidth);
                    newWidth  = Math.Min(newWidth, m_Width);
                    newHieght = newWidth * m_Height / m_Width;
                }


                if (newWidth < m_Width && newHieght < m_Height)
                {
                    // Tells image positione in viewport (offset)
                    MatrixTransform transform = image.TransformToVisual(viewport) as MatrixTransform;
                    // Calculate center of pinch gesture on image (not screen)
                    Point pinchCenterOnImage = transform.Transform(e.PinchManipulation.Original.Center);
                    // Calculate relative point (0-1) of pinch center in image
                    Point relativeCenter = new Point(e.PinchManipulation.Original.Center.X / image.Width, e.PinchManipulation.Original.Center.Y / image.Height);
                    // Calculate and set new origin point of viewport
                    Point newOriginPoint = new Point(relativeCenter.X * newWidth - pinchCenterOnImage.X, relativeCenter.Y * newHieght - pinchCenterOnImage.Y);
                    viewport.SetViewportOrigin(newOriginPoint);
                }

                image.Width  = newWidth;
                image.Height = newHieght;

                // Set new view port bound
                viewport.Bounds = new Rect(0, 0, newWidth, newHieght);
            }
        }
Пример #45
0
        protected virtual void OnBorderManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            // suppress zoom
            if (e.DeltaManipulation.Scale.X != 0.0 ||
                e.DeltaManipulation.Scale.Y != 0.0)
            {
                e.Handled = true;
            }

            // optionally suppress scrolling
            if (ScrollDisabled)
            {
                if (e.DeltaManipulation.Translation.X != 0.0 ||
                    e.DeltaManipulation.Translation.Y != 0.0)
                {
                    e.Handled = true;
                }
            }
        }
Пример #46
0
        private void centerImageView_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            // get current matrix of the element.
            Matrix borderMatrix = ((System.Windows.Media.MatrixTransform)MapImage.RenderTransform).Matrix;
            //determine if action is zoom or pinch
            var maxScale = Math.Max(e.DeltaManipulation.Scale.X, e.DeltaManipulation.Scale.Y);

            //check if not crossing minimum and maximum zoom limit
            if ((maxScale < 1 && borderMatrix.M11 * maxScale > 0) ||
                (maxScale > 1 && borderMatrix.M11 * maxScale < 100))
            {
                //scale to most recent change (delta) in X & Y
                borderMatrix.ScaleAt(e.DeltaManipulation.Scale.X,
                                     e.DeltaManipulation.Scale.Y,
                                     MapImage.ActualWidth / 2,
                                     MapImage.ActualHeight / 2);
                //render new matrix
                MapImage.RenderTransform = new MatrixTransform(borderMatrix);
            }
        }
Пример #47
0
        /// <summary>
        /// override this to make manipulation on the Matrix (rotate, translate, etc).
        /// Call "base.Manipulate(delta)" in any case the top of the method when override. it makes some filter and validation
        /// </summary>
        /// <param name="delta"></param>
        public virtual void Manipulate(System.Windows.Input.ManipulationDeltaEventArgs args, ref Matrix matrix)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            if (Manipulator == null)
            {
                throw new Exception("Please set the Manipulator of the Gesture!");
            }

            //find guestures witch has this gesture in there omit list and skip this gesture if founded
            if (ManipulatorContainer.Instance.Manipulators.FirstOrDefault(a =>
                                                                          a.Gestures.FirstOrDefault(b => b.IsEnabled && b.OmitGestures.Contains(this.GetType())) != null)
                != null)
            {
                return;
            }
        }
Пример #48
0
 public virtual void OnManipulationDelta(System.Windows.Input.ManipulationDeltaEventArgs manipulationEventArgs, int width, int height)
 {
     Console.WriteLine("Got manipulation delta.");
 }
 private void slider_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     player.Position = TimeSpan.FromSeconds(slider.Value);
 }
Пример #50
0
 private void wb_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     e.Handled = false;
 }
Пример #51
0
 private void OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     xDistance = e.CumulativeManipulation.Translation.X;
     yDistance = e.CumulativeManipulation.Translation.Y;
     base.OnManipulationDelta(e);
 }
Пример #52
0
 public void OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
 {
     Console.WriteLine("ViewerContext got manipulation delta event.");
 }
Пример #53
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            InputEventArgs inputEventArgs = e.StagingItem.Input;

            if (inputEventArgs.Device == this)
            {
                RoutedEvent routedEvent = inputEventArgs.RoutedEvent;
                if (routedEvent == Manipulation.ManipulationDeltaEvent)
                {
                    ManipulationDeltaEventArgs deltaEventArgs = inputEventArgs as ManipulationDeltaEventArgs;
                    if (deltaEventArgs != null)
                    {
                        // During deltas, see if panning feedback is needed on the window
                        ManipulationDelta unusedManipulation = deltaEventArgs.UnusedManipulation;
                        _manipulationLogic.RaiseBoundaryFeedback(unusedManipulation, deltaEventArgs.RequestedComplete);
                        _manipulationLogic.PushEventsToDevice();

                        // If a Complete is requested, then pass it along to the manipulation processor
                        if (deltaEventArgs.RequestedComplete)
                        {
                            _manipulationLogic.Complete(/* withInertia = */ deltaEventArgs.RequestedInertia);
                            _manipulationLogic.PushEventsToDevice();
                        }
                        else if (deltaEventArgs.RequestedCancel)
                        {
                            Debug.Assert(!deltaEventArgs.IsInertial);
                            OnManipulationCancel();
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationStartingEvent)
                {
                    ManipulationStartingEventArgs startingEventArgs = inputEventArgs as ManipulationStartingEventArgs;
                    if (startingEventArgs != null && startingEventArgs.RequestedCancel)
                    {
                        OnManipulationCancel();
                    }
                }
                else if (routedEvent == Manipulation.ManipulationStartedEvent)
                {
                    ManipulationStartedEventArgs startedEventArgs = inputEventArgs as ManipulationStartedEventArgs;
                    if (startedEventArgs != null)
                    {
                        if (startedEventArgs.RequestedComplete)
                        {
                            // If a Complete is requested, pass it along to the manipulation processor
                            _manipulationLogic.Complete(/* withInertia = */ false);
                            _manipulationLogic.PushEventsToDevice();
                        }
                        else if (startedEventArgs.RequestedCancel)
                        {
                            OnManipulationCancel();
                        }
                        else
                        {
                            // Start ticking to produce delta events
                            ResumeAllTicking(); // Resumes the ticking of all the suspended devices on the thread
                            StartTicking();     // Ensures that we continue ticking or restart ticking for this device
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationInertiaStartingEvent)
                {
                    // Switching from using rendering for ticking to a timer at lower priority (handled by ManipulationLogic)
                    StopTicking();

                    // Remove all the manipulators so that we dont re-start manipulations accidentally
                    RemoveAllManipulators();

                    // Initialize inertia
                    ManipulationInertiaStartingEventArgs inertiaEventArgs = inputEventArgs as ManipulationInertiaStartingEventArgs;
                    if (inertiaEventArgs != null)
                    {
                        if (inertiaEventArgs.RequestedCancel)
                        {
                            OnManipulationCancel();
                        }
                        else
                        {
                            _manipulationLogic.BeginInertia(inertiaEventArgs);
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationCompletedEvent)
                {
                    _manipulationLogic.OnCompleted();
                    ManipulationCompletedEventArgs completedEventArgs = inputEventArgs as ManipulationCompletedEventArgs;
                    if (completedEventArgs != null)
                    {
                        if (completedEventArgs.RequestedCancel)
                        {
                            Debug.Assert(!completedEventArgs.IsInertial);
                            OnManipulationCancel();
                        }
                        else if (!(completedEventArgs.IsInertial && _ticking))
                        {
                            // Remove the manipulation device only if
                            // another manipulation didnot start
                            OnManipulationComplete();
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationBoundaryFeedbackEvent)
                {
                    ManipulationBoundaryFeedbackEventArgs boundaryEventArgs = inputEventArgs as ManipulationBoundaryFeedbackEventArgs;
                    if (boundaryEventArgs != null)
                    {
                        _compensateForBoundaryFeedback = boundaryEventArgs.CompensateForBoundaryFeedback;
                    }
                }
            }
        }