Пример #1
0
        private void ProcessManipulationInertiaDelta(Affine2DOperationDeltaEventArgs e)
        {
            if (MapManipulationMode == MapManipulationMode.PanZoomPivot)
            {
                if (IsPanEnabled)
                {
                    DoMapMove(e.Delta.X * PanSensitivity, e.Delta.Y * PanSensitivity);
                }
            }
            else
            {
                if (IsSpinEnabled)
                {
                    double deltaAngle = InfoStrat.VE.Utilities.MathHelper.MapValue(e.Delta.X, -20, 20, -1, 1);
                    DoMapYaw(deltaAngle);
                }
                if (IsTiltEnabled)
                {
                    double desiredPitch = ClampPitch(this.Pitch + e.Delta.Y * TiltSensitivity, this.Altitude);
                    DoMapTilt(desiredPitch);
                }
            }

            if (IsZoomEnabled)
            {
                DoMapZoom(e.ExpansionDelta * ZoomSensitivity, e.ManipulationOrigin);
            }

            if (IsPivotEnabled)
            {
                DoMapPivot(e.RotationDelta, e.ManipulationOrigin);
            }
        }
Пример #2
0
            //==========================================================//
            /// <summary>
            /// Event handler for the manipulation and inertia processor's delta events.
            /// Occurs whenever the manipulation or inertia processors processes or extrapolate
            /// manipulator data
            /// </summary>
            /// <param name="sender">The manipulation or inertia processor that raised the event</param>
            /// <param name="e">The event args for the event</param>
            private void OnAffine2DDelta(object sender, Affine2DOperationDeltaEventArgs e)
            {
                //Debug.Assert(manipulating && sender is Affine2DManipulationProcessor ||
                //    extrapolating && sender is Affine2DInertiaProcessor);

                openCOVER.manipulation(e);
                //Vector2 manipulationOrigin = new Vector2(e.ManipulationOriginX, e.ManipulationOriginY);
                //Vector2 manipulationDelta = new Vector2(e.DeltaX, e.DeltaY);
                //Vector2 previousOrigin = new Vector2(manipulationOrigin.X - manipulationDelta.X, manipulationOrigin.Y - manipulationDelta.Y);
                //float restrictedOrientation = RestrictOrientation(e.RotationDelta);
                //float restrictedScale = RestrictScale(e.ScaleDelta);

                // Adjust the position of the item based on change in rotation

                /*  if (restrictedOrientation != 0.0f)
                 * {
                 *    Vector2 manipulationOffset = transformedCenter - previousOrigin;
                 *    Vector2 rotatedOffset = GeometryHelper.RotatePointVector(manipulationOffset, restrictedOrientation);
                 *    Vector2 compensation = rotatedOffset - manipulationOffset;
                 *    transformedCenter += compensation;
                 * }
                 *
                 * // Adjust the position of the item based on change in scale
                 * if (restrictedScale != 1.0f)
                 * {
                 *    Vector2 manipulationOffset = manipulationOrigin - transformedCenter;
                 *    Vector2 scaledOffset = manipulationOffset * restrictedScale;
                 *    Vector2 compensation = manipulationOffset - scaledOffset;
                 *    transformedCenter += compensation;
                 * }
                 *
                 * // Rotate the item if it is allowed
                 * if (canRotate || canRotateFlick)
                 * {
                 *    orientation += restrictedOrientation;
                 * }
                 *
                 * // Scale the item if it is allowed
                 * if (canScale || canScaleFlick)
                 * {
                 *    scaleFactor *= restrictedScale;
                 * }
                 *
                 * // Translate the item if it is allowed
                 * if (canTranslate || canTranslateFlick)
                 * {
                 *    transformedCenter += new Vector2(e.DeltaX, e.DeltaY);
                 * }
                 *
                 * RestrictCenter();
                 *
                 * if (canRotate || canRotateFlick)
                 * {
                 *    manipulationProcessor.PivotX = transformedCenter.X;
                 *    manipulationProcessor.PivotY = transformedCenter.Y;
                 *    manipulationProcessor.PivotRadius = Math.Max(Width, Height) / 2.0f;
                 * }*/
            }
Пример #3
0
 private void OnManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     logoRotateTransform.Angle += e.RotationDelta;
     DeltaManipulationFinished(this, e);
 }
Пример #4
0
 /// <summary>
 /// Extract the Manipulation Data and write it into our Dictionary
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnAffine2DDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     ReadOnlyContactCollection currentContacts = contactTarget.GetState();
     foreach (Contact c in currentContacts)
     {
         if (c.X == e.ManipulationOriginX && c.Y == e.ManipulationOriginY)
         {
             _contactManipulationData.Add(c.Id, e);
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Update the position of the Value and the thumb each delta. 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnAffine2DInertiaDelta(object sender, Affine2DOperationDeltaEventArgs e)
        {
            float valueX = Value + ToValueSpace(e.DeltaX);

            valueX = FlickUtilities.Clamp(valueX, 0, 1);

            UpdatedValueInValueSpace(valueX);
        }
Пример #6
0
 /// <summary>
 /// Rotation of MenuCard using ManipulationProcessor
 /// </summary>
 /// <returns></returns>
 public void OnManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     cardRotateTransform.Angle += e.RotationDelta;
 }
 private void manipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
 }
Пример #8
0
            //==========================================================//
            /// <summary>
            /// Event handler for the manipulation and inertia processor's delta events. 
            /// Occurs whenever the manipulation or inertia processors processes or extrapolate 
            /// manipulator data
            /// </summary>
            /// <param name="sender">The manipulation or inertia processor that raised the event</param>
            /// <param name="e">The event args for the event</param>
            private void OnAffine2DDelta(object sender, Affine2DOperationDeltaEventArgs e)
            {
                //Debug.Assert(manipulating && sender is Affine2DManipulationProcessor ||
                //    extrapolating && sender is Affine2DInertiaProcessor);

                openCOVER.manipulation(e);
                //Vector2 manipulationOrigin = new Vector2(e.ManipulationOriginX, e.ManipulationOriginY);
                //Vector2 manipulationDelta = new Vector2(e.DeltaX, e.DeltaY);
                //Vector2 previousOrigin = new Vector2(manipulationOrigin.X - manipulationDelta.X, manipulationOrigin.Y - manipulationDelta.Y);
                //float restrictedOrientation = RestrictOrientation(e.RotationDelta);
                //float restrictedScale = RestrictScale(e.ScaleDelta);

                // Adjust the position of the item based on change in rotation
                  /*  if (restrictedOrientation != 0.0f)
                {
                    Vector2 manipulationOffset = transformedCenter - previousOrigin;
                    Vector2 rotatedOffset = GeometryHelper.RotatePointVector(manipulationOffset, restrictedOrientation);
                    Vector2 compensation = rotatedOffset - manipulationOffset;
                    transformedCenter += compensation;
                }

                // Adjust the position of the item based on change in scale
                if (restrictedScale != 1.0f)
                {
                    Vector2 manipulationOffset = manipulationOrigin - transformedCenter;
                    Vector2 scaledOffset = manipulationOffset * restrictedScale;
                    Vector2 compensation = manipulationOffset - scaledOffset;
                    transformedCenter += compensation;
                }

                // Rotate the item if it is allowed
                if (canRotate || canRotateFlick)
                {
                    orientation += restrictedOrientation;
                }

                // Scale the item if it is allowed
                if (canScale || canScaleFlick)
                {
                    scaleFactor *= restrictedScale;
                }

                // Translate the item if it is allowed
                if (canTranslate || canTranslateFlick)
                {
                    transformedCenter += new Vector2(e.DeltaX, e.DeltaY);
                }

                RestrictCenter();

                if (canRotate || canRotateFlick)
                {
                    manipulationProcessor.PivotX = transformedCenter.X;
                    manipulationProcessor.PivotY = transformedCenter.Y;
                    manipulationProcessor.PivotRadius = Math.Max(Width, Height) / 2.0f;
                }*/
            }
 /// <summary>
 /// Handles the Affine2DManipulationDelta event of the ScatterManipulationProcessor control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Microsoft.Surface.Presentation.Manipulations.Affine2DOperationDeltaEventArgs"/> instance containing the event data.</param>
 private void ScatterManipulationProcessor_Affine2DManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     if (!_overridingScatterViewItem && e.ScaleDelta >= 1 &&
         GetMaxScale() > 1 &&
         (Math.Abs(ScatterViewItem.ActualWidth - ScatterViewItem.MaxWidth) <= .1 || Math.Abs(ScatterViewItem.ActualHeight - ScatterViewItem.MaxHeight) <= .1))
     {
         // If the SVI is scalled up to its maximum, steal its contacts and begin scaling the content.
         _overridingScatterViewItem = true;
         ScatterViewItem.ContactsCaptured.ToList().ForEach(c => c.Capture(this));
     }
 }
        /// <summary>
        /// Translate and scale the content when it is manipulated.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.Surface.Presentation.Manipulations.Affine2DOperationDeltaEventArgs"/> instance containing the event data.</param>
        private void ContentManipulationProcessor_Affine2DManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
        {
            if (GetMaxScale() == 1)
            {
                return;
            }

            // The inertia processor can move the content out of bounds.
            if (sender == _inertiaProcessor)
            {
                _translate.X += e.Delta.X;
                _translate.Y += e.Delta.Y;
                _scale.ScaleX *= e.ScaleDelta;
                _scale.ScaleY *= e.ScaleDelta;
                return;
            }

            _spring.Stop(this);

            // Determine what scale to apply to the content.
            bool returnControlToScatterViewItem = false;
            double scaleDelta = 1;
            double newScale = _scale.ScaleX * e.ScaleDelta;
            if (_content.ActualWidth * newScale >= ActualWidth && newScale <= GetMaxScale())
            {
                // If the new scale is within the bounds, just use it directly.
                scaleDelta = e.ScaleDelta;
            }
            else if (e.ScaleDelta > 1)
            {
                // Apply friction to an increasing scale.
                scaleDelta = 1 + ((e.ScaleDelta - 1) * _friction);
            }
            else if (e.ScaleDelta < 1)
            {
                // Apply friction to a decreasing scale.
                scaleDelta = 1 - ((1 - e.ScaleDelta) * _friction);
                returnControlToScatterViewItem = _scale.ScaleX <= .95;
            }

            _scale.ScaleX *= scaleDelta;
            _scale.ScaleY *= scaleDelta;

            if (returnControlToScatterViewItem)
            {
                // If the content is scaled down to less than the default size, return control back to the ScatterViewItem.
                if (ScatterViewItem != null)
                {
                    ContactsCaptured.ToList().ForEach(c => c.Capture(ScatterViewItem));
                    _overridingScatterViewItem = false;
                }
            }

            // Move the content.
            _translate.X += e.Delta.X;
            _translate.Y += e.Delta.Y;

            // Get the new bounds of the image.
            Rect bounds = GetContentBounds();

            if (bounds.TopLeft.X > 0 || bounds.BottomRight.X < ActualWidth)
            {
                // Apply friction if the content is out of bounds on the x-axis.
                _translate.X -= e.Delta.X;
                _translate.X += e.Delta.X * _friction;
            }

            if (bounds.TopLeft.Y > 0 || bounds.BottomRight.Y < ActualHeight)
            {
                // Apply friction if the content is out of bounds on the y-axis.
                _translate.Y -= e.Delta.Y;
                _translate.Y += e.Delta.Y * _friction;
            }
        }
Пример #11
0
 void manipulationProcessor_Affine2DManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     ProcessManipulationInertiaDelta(e);
 }
Пример #12
0
 void inertiaProcessorZoom_Affine2DInertiaDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
 }
 public void OnManipulationDelta(object sender, Affine2DOperationDeltaEventArgs e)
 {
     particleSystem.particleGridTransform.Angle += e.RotationDelta;
 }
        private void Rotate(object sender, Affine2DOperationDeltaEventArgs eventArgs)
        {
            particleSystem.particleGridTransform.Angle += eventArgs.RotationDelta;

            foreach (MenuCard card in MenuCardHolder)
            {
                card.OnManipulationDelta(sender, eventArgs);
            }

            particleSystem.ToggleControlPanel();
        }
Пример #15
0
        /// <summary>
        /// Update the changes to inertia processing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAffine2DInertiaDelta(object sender, Affine2DOperationDeltaEventArgs e)
        {
            if ((Orientation & Orientation.Horizontal) != 0)
            {
                // Inertia and Manipulations are both processed in ScreenSpace so we need to convert to value space and updated.
                float valueX = horizontalScrollBarStateMachine.Value + ConvertFromHorizontalScreenToValueSpace(e.DeltaX);

                // Clamp X
                valueX = FlickUtilities.Clamp(valueX, 0, 1);

                horizontalScrollBarStateMachine.Value = valueX;
            }

            if ((Orientation & Orientation.Vertical) != 0)
            {
                float valueY = verticalScrollBarStateMachine.Value + ConvertFromVerticalScreenToValueSpace(e.DeltaY);

                // Clamp Y
                valueY = FlickUtilities.Clamp(valueY, 0, 1);

                // Update the scrollbars which will update the scroll viewer.

                verticalScrollBarStateMachine.Value = valueY;
            }
        }