Beispiel #1
0
        private void C1TouchEventProvider1_ManipulationStarting(object sender, C1.Win.TouchToolKit.ManipulationStartingEventArgs e)
        {
            Point pointerPosition = e.Position;
            bool  hitTest         = this.paintPanel1.HitTest(pointerPosition);

            if (this.TouchMode == MyTouchMode.Default)
            {
                if (hitTest)
                {
                    e.Mode = ManipulationModes.All;
                }
                else
                {
                    e.Mode = ManipulationModes.Rotate | ManipulationModes.RotateInertia;
                }
            }
            else
            {
                if (this.paintPanel1.ActiveImageIndex != -1)
                {
                    ManipulationPivot pivot = new ManipulationPivot();
                    pivot.Center = this.paintPanel1.GetImageCenter(this.paintPanel1.ActiveImageIndex);
                    pivot.Radius = this.paintPanel1.GetImageRadius(this.paintPanel1.ActiveImageIndex);
                    e.Pivot      = pivot;
                }
                e.Mode = ManipulationModes.Rotate | ManipulationModes.RotateInertia;
            }
            manipulationMode = e.Mode;
            if (e.Mode == ManipulationModes.All)
            {
                e.Handled = true;
            }
        }
        void PivotDebugMessage(ManipulationPivot pivot)
        {
            if (pivot == null)
            {
                return;
            }
            var result = " x=[" + pivot.Center.X + "] y=[" + pivot.Center.Y + "] r=[" + pivot.Radius + "]";

            DebugMessage("Pivot:" + result);
        }
        //<SnippetManipulationPivot>
        void Window_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
        {
            // Set the ManipulationPivot so that the element rotates as it is
            // moved with one finger.
            FrameworkElement  element = e.OriginalSource as FrameworkElement;
            ManipulationPivot pivot   = new ManipulationPivot();

            pivot.Center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
            pivot.Radius = 20;
            e.Pivot      = pivot;

            e.ManipulationContainer = this;
            e.Handled = true;
        }
 /// <summary>
 /// Sets an object that describes the pivot for a single-point manipulation.
 /// </summary>
 /// <param name="e">The requested <see cref="ManipulationStartingRoutedEventArgs"/>.</param>
 /// <param name="pivot">An object that describes the pivot for a single-point manipulation.</param>
 public static void Pivot(this ManipulationStartingRoutedEventArgs e, ManipulationPivot pivot) => Resolver.Pivot(e, pivot);
 void IManipulationStartingRoutedEventArgsResolver.Pivot(ManipulationStartingRoutedEventArgs e, ManipulationPivot pivot) => e.Pivot = pivot;