Ejemplo n.º 1
0
        public void Zoom(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var mousePoint = e.GetCurrentPoint(null).Position;
            var wheel = e.GetCurrentPoint(null).Properties.MouseWheelDelta / 120;
            var zoom = Math.Exp(wheel * ZoomIntensity);

            _zoom(zoom, mousePoint.X, mousePoint.Y);
        }
Ejemplo n.º 2
0
        protected virtual void uiElement_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (moveD3dCanvas)
            {
                var newPosition = e.GetCurrentPoint(null);
                double deltaX = newPosition.Position.X - lastPos.Position.X;
                double deltaY = newPosition.Position.Y - lastPos.Position.Y;

                // Only support CompositeTransform and TranslateTransform
                // Is there any better way to handle this?
                if (uiElement.RenderTransform is CompositeTransform)
                {
                    var compositeTransform = (CompositeTransform)uiElement.RenderTransform;
                    compositeTransform.TranslateX += deltaX;
                    compositeTransform.TranslateY += deltaY;
                }
                else if (uiElement.RenderTransform is TranslateTransform)
                {
                    var translateTransform = (TranslateTransform)uiElement.RenderTransform;
                    translateTransform.X += deltaX;
                    translateTransform.Y += deltaY;
                }

                lastPos = newPosition;
            }
        }
Ejemplo n.º 3
0
        void DynamicArea_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if(_firstPoint == null)
            {
                return;
            }

            var secondPoint = e.GetCurrentPoint(null);

            if(secondPoint.PointerId == _firstPoint.PointerId)
            {
                var deltaX = secondPoint.Position.X - _firstPoint.Position.X;
                var deltaY = secondPoint.Position.Y - _firstPoint.Position.Y;
               
                // Horizontal scrolling
                if(Math.Abs(deltaX) >  Math.Abs(deltaY))
                {
                    var left = deltaX > 0;
                    if(left)
                    {
                        ((BasicMonthViewModel)this.DataContext).ExecutePrevious(null);
                    }
                    else
                    {
                        ((BasicMonthViewModel)this.DataContext).ExecuteNext(null);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void OnPointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs args)
        {
            Windows.UI.Input.PointerPoint currentPoint = args.GetCurrentPoint(this._reference);
            this._gestureRecognizer.ProcessUpEvent(currentPoint);
            this._target.ReleasePointerCapture(args.Pointer);

            // Mark event handled, to prevent execution of default event handlers
            args.Handled = true;
        }
 void OnPointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs args)
 {
     // Route teh events to the gesture recognizer
     this.gestureRecognizer.ProcessDownEvent(args.GetCurrentPoint(this.element));
     // Set the pointer capture to the element being interacted with
     this.element.CapturePointer(args.Pointer);
     // Mark the event handled to prevent execution of default handlers
     args.Handled = true;
 }
Ejemplo n.º 6
0
        private void OnPointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs args)
        {
            // Obtain current point in the coordinate system of the reference element
            Windows.UI.Input.PointerPoint currentPoint = args.GetCurrentPoint(this._reference);
            this._gestureRecognizer.ProcessDownEvent(currentPoint);
            this._target.CapturePointer(args.Pointer);

            args.Handled = true;
        }
Ejemplo n.º 7
0
 public override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     PointerPoint point = e.GetCurrentPoint(Map);
     oldMouseX = point.Position.X;
     oldMouseY = point.Position.Y;
     isMouseCaptured = true;
     Map.CapturePointer(e.Pointer);
     e.Handled = true;
     base.OnPointerPressed(e);
 }
Ejemplo n.º 8
0
    public static bool EventIsSelect(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
    {
        var pointerProperties = e.GetCurrentPoint(null).Properties;

        bool rval = false
            || (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen && pointerProperties.IsBarrelButtonPressed)
            || (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && pointerProperties.IsLeftButtonPressed && e.KeyModifiers == Windows.System.VirtualKeyModifiers.Control);

        return rval;
    }
Ejemplo n.º 9
0
    public static bool EventIsErase(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
    {
        var pointerProperties = e.GetCurrentPoint(null).Properties;

        bool rval = false
            || (pointerProperties.IsEraser)
            || (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen && !pointerProperties.IsBarrelButtonPressed && pointerProperties.IsRightButtonPressed)
            || (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && pointerProperties.IsRightButtonPressed);

        return rval;
    }
Ejemplo n.º 10
0
        private void OnPointerWheelChanged(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs args)
        {
            Windows.UI.Input.PointerPoint currentPoint = args.GetCurrentPoint(this._reference);

            bool shift = (args.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) == Windows.System.VirtualKeyModifiers.Shift;
            bool ctrl = (args.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) == Windows.System.VirtualKeyModifiers.Control;

            // Route the event to the gesture recognizer
            this._gestureRecognizer.ProcessMouseWheelEvent(currentPoint, shift, ctrl);
            args.Handled = true;
        }
Ejemplo n.º 11
0
        private void OnPointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var currentPoint = e.GetCurrentPoint(MapCanvas);

            HighlightedTile = ScreenToMap(
                new Vector2((float)currentPoint.Position.X,
                            (float)currentPoint.Position.Y));

            MapCanvas.Invalidate();

            e.Handled = true;
        }
Ejemplo n.º 12
0
        private async void OnPointerWheelChanged(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var point = e.GetCurrentPoint(this);

            double offset = -point.Properties.MouseWheelDelta / 20.0;
            double delta = -Math.Sign(offset) * 20;

            for (int n = 0; n < Math.Abs(offset); n++)
            {
                await TranslateDelta(delta);
                await Task.Delay(10);
            }
        }
        void RadialControl_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if ((!IsOuterDrawing) && (!IsInnerDrawing))
                return;

            ClearOldStrips();

            if (IsOuterDrawing)
            {
                _outerCurrentPoint = e.GetCurrentPoint(this).Position;

                var circleStart = new Point(_startPoint.X, _startPoint.Y - OuterRingRadius);

                //Calculate the angle
                var angle = _mathHelper.AngleBetweenLine(_startPoint, circleStart, _outerCurrentPoint, OuterRingRadius);

                var rawValue = CreateSegment(Name + "OuterRadialStrip", OuterRingRadius, _outerCurrentPoint, OuterRingColor, angle);
                OuterCurrentValue = (int)(rawValue * (OuterRingMaxValue + 1));

                UpdateGripControlPosition(_outerGripControl, angle, OuterRingRadius);
            }
            else
            {
                _innerCurrentPoint = new Point(e.GetCurrentPoint(this).Position.X, e.GetCurrentPoint(this).Position.Y);

                var circleStart = new Point(_startPoint.X, _startPoint.Y - InnerRingRadius);

                //Calculate the angle
                var angle = _mathHelper.AngleBetweenLine(_startPoint, circleStart, _innerCurrentPoint, InnerRingRadius);

                var rawValue = CreateSegment(Name + "InnerRadialStrip", InnerRingRadius, _innerCurrentPoint, InnerRingColor, angle);
                InnerCurrentValue = (int)(rawValue * (InnerRingMaxValue + 1));

                UpdateGripControlPosition(_innerGripControl, angle, InnerRingRadius);
            }
        }
Ejemplo n.º 14
0
        public override void OnPointerMoved(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (isMouseCaptured)
            {
                PointerPoint point = e.GetCurrentPoint(Map);
                double newMouseX = point.Position.X;
                double newMouseY = point.Position.Y;
                double deltaX;
                double deltaY;
                deltaX = newMouseX - oldMouseX;
                deltaY = newMouseY - oldMouseY;

                Map.PanByPixel(-deltaX, -deltaY);

                oldMouseY = point.Position.Y;
                oldMouseX = point.Position.X;
            }
            base.OnPointerMoved(e);
        }
Ejemplo n.º 15
0
 /// <summary>${ui_action_FrawFreeLine_event_OnPointerMoved_D}</summary>
 public override void OnPointerMoved(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     if (isDrawing)
     {
         Point2D item = Map.ScreenToMap(e.GetCurrentPoint(Map).Position);
         points.Add(item);
     }
     base.OnPointerMoved(e);
 }
 private void ChartGrid_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     // we start new action cycle by entering teh state where we first determine which action is starting
     _currentDirection = MoveDirection.Determining;
     _pointerDown = e.GetCurrentPoint(chartGrid).Position;
     e.Handled = true;
 }
Ejemplo n.º 17
0
 /// <summary>${ui_action_FrawFreeLine_event_OnPointerPressed_D}</summary>
 public override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     Point2D item = Map.ScreenToMap(e.GetCurrentPoint(Map).Position);
     if (!isActivated)
     {
         Activate(item);
     }
     e.Handled = true;
     base.OnPointerPressed(e);
 }
        private void ChartGrid_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (_currentDirection == MoveDirection.Done)
            {
                //no down event, since last release, so we do nothing here
                return;
            }
            Point currentPoint = e.GetCurrentPoint(chartGrid).Position;
            double changeX = _pointerDown.X - currentPoint.X;
            double changeY = _pointerDown.Y - currentPoint.Y;
            e.Handled = true;

            // if we have not reached any teshold, we'll wait untill we reach one of them
            if (_currentDirection == MoveDirection.Determining)
            {
                if (changeX > XTRESHOLD_FOR_MOVE
                 || changeX < -XTRESHOLD_FOR_MOVE)
                {
                    _currentDirection = MoveDirection.Horizontal;
                }
                else if (changeY > YTRESHOLD_FOR_ZOOM
                      || changeY < -YTRESHOLD_FOR_ZOOM)
                {
                    _currentDirection = MoveDirection.Vertical;
                }
                //before we get to the treshold, we don't do anything
                // and once we do, we don't want to start the action with huge jumpstart
                //thus we ignore the treshold
                return;
            }

            //handle the action according to the pointer change
            MoveZoom(changeX, changeY);
            //Reset the pointer
            _pointerDown = currentPoint;
        }
Ejemplo n.º 19
0
        private void SetRipplePosition(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var newPosition = e.GetCurrentPoint(null);

            var gtRoot = ((Windows.UI.Xaml.UIElement)_rootParent).TransformToVisual(_root);
            var rootPosition = gtRoot.TransformPoint(new Windows.Foundation.Point(newPosition.Position.X, newPosition.Position.Y));


            UpdatePointer((float)rootPosition.X, (float)rootPosition.Y);

            clock.Restart();

       }
Ejemplo n.º 20
0
 protected override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         if (DefinitionSeriesIsSelectionEnabledHandling)
         {
             // DefinitionSeries-compatible handling
             if (!IsSelectionEnabled)
             {
                 // Prevents clicks from bubbling to background, but necessary
                 // to avoid letting ListBoxItem select the item
                 e.Handled = true;
             }
             base.OnPointerPressed(e);
         }
         else
         {
             // Traditional handling
             base.OnPointerPressed(e);
             if (IsSelectionEnabled)
             {
                 IsSelected = VirtualKeyModifiers.None == (VirtualKeyModifiers.Control & e.KeyModifiers);
                 e.Handled = true;
             }
         }
     }
 }
Ejemplo n.º 21
0
        void root_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var newPosition = e.GetCurrentPoint(null);

            
            var gtRoot = ((Windows.UI.Xaml.UIElement)_rootParent).TransformToVisual(_root);
            var rootPosition = gtRoot.TransformPoint(new Windows.Foundation.Point(newPosition.Position.X, newPosition.Position.Y));


            UpdatePointer((float)rootPosition.X, (float)rootPosition.Y);

        }
Ejemplo n.º 22
0
        private void StartPreviewDragging(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            this.isDraggingPreview = true;
            this.previewPopup = new Popup
            {
                Width = this.parentGrid.ActualWidth,
                Height = this.parentGrid.ActualHeight
            };

            this.previewPopup.IsOpen = true;
            this.previewPopupHostGrid = new Grid
            {
                VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch,
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch
            };

            this.parentGrid.Children.Add(this.previewPopupHostGrid);
            if (this.parentGrid.RowDefinitions.Count > 0)
                Grid.SetRowSpan(this.previewPopupHostGrid, this.parentGrid.RowDefinitions.Count);
            if (this.parentGrid.ColumnDefinitions.Count > 0)
                Grid.SetColumnSpan(this.previewPopupHostGrid, this.parentGrid.ColumnDefinitions.Count);
            this.previewPopupHostGrid.Children.Add(this.previewPopup);

            this.previewGrid = new Grid
            {
                Width = this.parentGrid.ActualWidth,
                Height = this.parentGrid.ActualHeight
            };

            this.previewPopup.Child = this.previewGrid;

            foreach (var definition in this.parentGrid.RowDefinitions)
            {
                var definitionCopy = new RowDefinition
                {
                    Height = definition.Height,
                    MaxHeight = definition.MaxHeight,
                    MinHeight = definition.MinHeight
                };

                this.previewGrid.RowDefinitions.Add(definitionCopy);
            }

            foreach (var definition in this.parentGrid.ColumnDefinitions)
            {
                var w = definition.Width;
                var mxw = definition.MaxWidth;
                var mnw = definition.MinWidth;

                var definitionCopy = new ColumnDefinition();

                definitionCopy.Width = w;
                definition.MinWidth = mnw;
                if (!double.IsInfinity(definition.MaxWidth))
                {
                    definition.MaxWidth = mxw;
                }
                //{
                //    Width = definition.Width,
                //    MaxWidth = definition.MaxWidth,
                //    MinWidth = definition.MinWidth
                //};

                this.previewGrid.ColumnDefinitions.Add(definitionCopy);
            }

            this.previewGridSplitter = new CustomGridSplitter
            {
                Opacity = 0.0,
                ShowsPreview = false,
                Width = this.Width,
                Height = this.Height,
                Margin = this.Margin,
                VerticalAlignment = this.VerticalAlignment,
                HorizontalAlignment = this.HorizontalAlignment,
                ResizeBehavior = this.ResizeBehavior,
                ResizeDirection = this.ResizeDirection,
                KeyboardIncrement = this.KeyboardIncrement
            };

            Grid.SetColumn(this.previewGridSplitter, Grid.GetColumn(this));
            var cs = Grid.GetColumnSpan(this);
            if (cs > 0)
                Grid.SetColumnSpan(this.previewGridSplitter, cs);
            Grid.SetRow(this.previewGridSplitter, Grid.GetRow(this));
            var rs = Grid.GetRowSpan(this);
            if (rs > 0)
                Grid.SetRowSpan(this.previewGridSplitter, rs);
            this.previewGrid.Children.Add(this.previewGridSplitter);

            this.previewControlBorder = new Border
            {
                Width = this.Width,
                Height = this.Height,
                Margin = this.Margin,
                VerticalAlignment = this.VerticalAlignment,
                HorizontalAlignment = this.HorizontalAlignment,
            };

            Grid.SetColumn(this.previewControlBorder, Grid.GetColumn(this));
            if (cs > 0)
                Grid.SetColumnSpan(this.previewControlBorder, cs);
            Grid.SetRow(this.previewControlBorder, Grid.GetRow(this));
            if (rs > 0)
                Grid.SetRowSpan(this.previewControlBorder, rs);
            this.previewGrid.Children.Add(this.previewControlBorder);

            this.previewControl = new GridSplitterPreviewControl();
            if (this.PreviewStyle != null)
                this.previewControl.Style = this.PreviewStyle;
            this.previewControlBorder.Child = this.previewControl;

            this.previewPopup.Child = this.previewGrid;
            //await this.previewGridSplitter.WaitForLoadedAsync();

            //this.previewGridSplitter.OnPointerPressed(e);
            this.previewGridSplitter.dragPointer = e.Pointer.PointerId;
            this.previewGridSplitter.effectiveResizeDirection = this.DetermineEffectiveResizeDirection();
            this.previewGridSplitter.parentGrid = this.previewGrid;
            this.previewGridSplitter.lastPosition = e.GetCurrentPoint(this.previewGrid).Position;
            this.previewGridSplitter.isDragging = true;
            this.previewGridSplitter.StartDirectDragging(e);
            this.previewGridSplitter.DraggingCompleted += previewGridSplitter_DraggingCompleted;
        }
        /*
         * 按下时的事件处理,两个步骤
         * 1、首先判断当前按下去的位置在控件的那个区域(控件共分为9个区域,详见PressPointLocation定义)
         * 2、根据按下去的位置,对控件做不同的效果
         */
        protected override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            // 获得当前区域位置
            PressPointLocation location = GetPointLocation(e.GetCurrentPoint(this).Position);

            // 开始对控件做效果处理

            if (location == (PressPointLocation.Left | PressPointLocation.YCenter))
            {// 左中
                projection.RotationY = angle;
                projection.CenterOfRotationX = 1;
            }
            else if (location == (PressPointLocation.Left | PressPointLocation.Top))
            {// 左上
                projection.RotationX = -angle;
                projection.RotationY = angle;
                projection.CenterOfRotationX = 1;
                projection.CenterOfRotationY = 1;

            }
            else if (location == (PressPointLocation.Top | PressPointLocation.XCenter))
            {// 上中
                projection.RotationX = -angle * 2;
                projection.CenterOfRotationY = 1;
            }
            else if (location == (PressPointLocation.Right | PressPointLocation.Top))
            {// 右上
                projection.RotationY = projection.RotationX = -angle;
                projection.CenterOfRotationX = 0;
                projection.CenterOfRotationY = 1;
            }
            else if (location == (PressPointLocation.Right | PressPointLocation.YCenter))
            {// 右中
                projection.RotationY = -angle;
                projection.CenterOfRotationX = 0;
            }
            else if (location == (PressPointLocation.Right | PressPointLocation.Bottom))
            {// 右下
                projection.RotationX = angle;
                projection.RotationY = -angle;

                projection.CenterOfRotationX = 0;
                projection.CenterOfRotationY = 0;
            }
            else if (location == (PressPointLocation.Bottom | PressPointLocation.XCenter))
            {// 下中
                projection.RotationX = angle * 2;

                projection.CenterOfRotationY = 0;
            }
            else if (location == (PressPointLocation.Left | PressPointLocation.Bottom))
            {// 左下
                projection.RotationY = projection.RotationX = angle;

                projection.CenterOfRotationX = 1;
                projection.CenterOfRotationY = 1;
            }
            else if (location == (PressPointLocation.XCenter | PressPointLocation.YCenter))
            {// 正中
                CompositeTransform transform = RenderTransform as CompositeTransform;

                transform.CenterX = ActualWidth/2;
                transform.CenterY = ActualHeight/2;
                transform.ScaleX = 0.9;
                transform.ScaleY = 0.9;
            }
        }
        void InkingArea_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var pointerPoint = e.GetCurrentPoint(InkingArea);

            if (pointerId == (int)pointerPoint.PointerId)
            {
                switch (inkManager.Mode)
                {
                    case Windows.UI.Input.Inking.InkManipulationMode.Erasing:
                        // Check if something has been erased.
                        // In erase mode InkManager::ProcessPointerUpdate returns an invalidate
                        // rectangle: if it is not degenerate something has been erased
                        // In erase mode we don't bother processing intermediate points
                        var invalidateRect = (Windows.Foundation.Rect)inkManager.ProcessPointerUpdate(e.GetCurrentPoint(InkingArea));
                        if (invalidateRect.Height != 0 && invalidateRect.Width != 0)
                        {
                            // We don't know what has been erased so we clear the render
                            // and add back all the ink saved in the ink manager
                            renderer.Clear();
                            renderer.AddInk(inkManager.GetStrokes());
                        }
                        break;
                    case Windows.UI.Input.Inking.InkManipulationMode.Inking:
                    case Windows.UI.Input.Inking.InkManipulationMode.Selecting:
                        // Process intermediate points
                        var intermediatePoints = e.GetIntermediatePoints(InkingArea);
                        for (int i = intermediatePoints.Count - 1; i >= 0; i--)
                        {
                            inkManager.ProcessPointerUpdate(intermediatePoints[i]);
                        }

                        // Live rendering
                        renderer.UpdateLiveRender(pointerPoint);
                        break;
                }
            }
        }
Ejemplo n.º 25
0
 protected virtual void uiElement_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     moveD3dCanvas = true;
     lastPos = e.GetCurrentPoint(null);
 }
        void InkingArea_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var pointerPoint = e.GetCurrentPoint(InkingArea);

            if (pointerId == (int)pointerPoint.PointerId)
            {
                pointerId = -1; // reset pointerId so that other pointers may enter live rendering mode

                var rect = inkManager.ProcessPointerUp(pointerPoint);
                switch (inkManager.Mode)
                {
                    case Windows.UI.Input.Inking.InkManipulationMode.Inking:
                        renderer.ExitLiveRendering(pointerPoint);
                        renderer.AddInk(inkManager.GetStrokes()[inkManager.GetStrokes().Count - 1]); // Add last stroke that was created to the Bezier render
                        break;

                    case Windows.UI.Input.Inking.InkManipulationMode.Selecting:
                        renderer.ExitLiveRendering(pointerPoint);

                        if (inkManager.AnySelected())
                        {
                            // Something has been selected

                            // Notify the renderer to update the selection
                            renderer.UpdateSelection();

                            // Resize SelectionRect and register event handlers to move the selection
                            Windows.UI.Xaml.Controls.Canvas.SetLeft(SelectionRect, rect.Left);
                            Windows.UI.Xaml.Controls.Canvas.SetTop(SelectionRect, rect.Top);
                            SelectionRect.Width = rect.Width;
                            SelectionRect.Height = rect.Height;
                            SelectionRect.ManipulationMode = Windows.UI.Xaml.Input.ManipulationModes.TranslateX | Windows.UI.Xaml.Input.ManipulationModes.TranslateY;
                        }
                        break;
                }

                rootPage.NotifyUser(" ", SDKTemplate.NotifyType.StatusMessage);
            }
        }
Ejemplo n.º 27
0
        protected override void OnPointerPressed(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (this.dragPointer != null)
                return;

            this.dragPointer = e.Pointer.PointerId;
            this.effectiveResizeDirection = this.DetermineEffectiveResizeDirection();
            this.parentGrid = GetGrid();
            this.previewDraggingStartPosition = e.GetCurrentPoint(this.parentGrid).Position;
            this.lastPosition = this.previewDraggingStartPosition;
            this.isDragging = true;

            if (ShowsPreview)
            {
                //this.Dispatcher.Invoke(
                //    CoreDispatcherPriority.High,
                //    (s, e2) => StartPreviewDragging(e),
                //    this,
                //    null);
                StartPreviewDragging(e);
            }
            else
                StartDirectDragging(e);
        }
        void InkingArea_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            // Make sure no pointer is already inking (we allow only one 'active' pointer at a time)
            if (pointerId == -1)
            {
                var pointerPoint = e.GetCurrentPoint(InkingArea);

                rootPage.NotifyUser(" ", SDKTemplate.NotifyType.StatusMessage);

                // Determine ink manipulation mode
                switch (Helpers.GetPointerEventType(e))
                {
                    case Helpers.PointerEventType.Erase:
                        rootPage.NotifyUser("Erase mode: draw a line across the ink you want to erase.", SDKTemplate.NotifyType.StatusMessage);
                        inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Erasing;
                        break;
                    case Helpers.PointerEventType.Ink:
                        inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Inking;
                        renderer.EnterLiveRendering(pointerPoint, drawingAttributes);
                        break;
                    case Helpers.PointerEventType.Select:
                        rootPage.NotifyUser("Select mode: draw a contour around the ink you want to select.", SDKTemplate.NotifyType.StatusMessage);
                        inkManager.Mode = Windows.UI.Input.Inking.InkManipulationMode.Selecting;
                        renderer.EnterLiveRendering(pointerPoint, lassoAttributes);
                        break;
                    default:
                        return; // pointer is neither inking nor erasing nor selecting: do nothing
                }

                // Clear selection
                inkManager.ClearSelection();
                renderer.UpdateSelection();
                AnchorSelection();

                inkManager.ProcessPointerDown(pointerPoint);              

                pointerId = (int)pointerPoint.PointerId; // save pointer id so that no other pointer can ink until this one is released
            }
        }
Ejemplo n.º 29
0
        protected override void OnPointerMoved(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            if (!this.isDragging ||
                this.dragPointer != e.Pointer.PointerId)
            {
                return;
            }

            var position = e.GetCurrentPoint(this.parentGrid).Position;

            if (isDraggingPreview)
                ContinuePreviewDragging(position);
            else
                ContinueDirectDragging(position);

            this.lastPosition = position;
        }
Ejemplo n.º 30
0
 private void Canvas_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     selectionStartIndex = GetHitIndex(e.GetCurrentPoint(canvas).Position);
     selectionEndIndex = selectionStartIndex;
     canvas.Invalidate();
     e.Handled = true;
 }