Exemple #1
1
        public void OnCanvasPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            CurrentPointerDevice = e.Pointer.PointerDeviceType;

            if (m_CurrentMode == CanvasMode.Select)
            {
                m_SelectionInitialPoint = e.GetCurrentPoint(m_Canvas).Position;
                if (e.Pointer.PointerDeviceType == PointerDeviceType.Touch)
                {
                    m_TouchId = e.Pointer.PointerId;
                }
                else
                {
                    m_PenId = e.Pointer.PointerId;
                }

                if (m_InkManager.GetStrokes().Any(stroke => stroke.Selected) && m_SelectionRectangle.Contains(m_SelectionInitialPoint))
                {
                    m_IsDragging = true;
                    m_PreviousSelectionRectangle = m_SelectionRectangle;
                }
                else
                {
                    m_IsDragging = false;
                }

                e.Handled = true;
                return;
            }

            // Get information about the pointer location. 
            PointerPoint pt = e.GetCurrentPoint(m_Canvas);
            m_PreviousContactPt = pt.Position;

            // Accept input only from a pen or mouse with the left button pressed.  
            PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
            if (pointerDevType == PointerDeviceType.Pen || (pointerDevType == PointerDeviceType.Mouse &&
                    pt.Properties.IsLeftButtonPressed))
            {
                Log("Pointer Pressed {0}", e.Pointer.PointerId);

                if (m_CurrentMode == CanvasMode.Erase || (pt.Properties.IsEraser && e.Pointer.PointerDeviceType == PointerDeviceType.Pen))
                {
                    Log("Erasing : Pointer Pressed");

                    m_InkManager.ProcessPointerDown(pt);
                    m_HighLightManager.ProcessPointerDown(pt);
                }
                else
                {
                    // Pass the pointer information to the InkManager. 
                    CurrentManager.ProcessPointerDown(pt);
                }

                m_PenId = pt.PointerId;

                e.Handled = true;
            }
            else if (pointerDevType == PointerDeviceType.Touch)
            {
                Log("Pointer Pressed {0}", e.Pointer.PointerId);

                // Process touch input 
                if (m_CurrentMode == CanvasMode.Erase)
                {
                    System.Diagnostics.Debug.WriteLine("Erasing : Pointer Pressed");

                    m_InkManager.ProcessPointerDown(pt);
                    m_HighLightManager.ProcessPointerDown(pt);
                }
                else
                {
                    try
                    {
                        // Pass the pointer information to the InkManager. 
                        CurrentManager.ProcessPointerDown(pt);
                    }
                    catch (System.Exception)
                    {
                        //do nothing
                    }
                }

                m_TouchId = pt.PointerId;

                e.Handled = true;
            }
        }
Exemple #2
0
 internal ManipulationInertiaStartingEventArgs(PointerDeviceType pointerDeviceType, Point position, ManipulationDelta delta, ManipulationDelta cumulative)
 {
     PointerDeviceType = pointerDeviceType;
     Position          = position;
     Delta             = delta;
     Cumulative        = cumulative;
 }
        internal PointerRoutedEventArgs(
            double timestamp,
            uint pointerId,
            PointerDeviceType pointerType,
            Point absolutePosition,
            bool isInContact,
            WindowManagerInterop.HtmlPointerButtonsState buttons,
            WindowManagerInterop.HtmlPointerButtonUpdate buttonUpdate,
            VirtualKeyModifiers keys,
            double pressure,
            UIElement source,
            bool canBubbleNatively)
            : this()
        {
            _timestamp        = timestamp;
            _absolutePosition = absolutePosition;
            _buttons          = buttons;
            _buttonUpdate     = buttonUpdate;
            _pressure         = pressure;

            FrameId           = ToFrameId(timestamp);
            Pointer           = new Pointer(pointerId, pointerType, isInContact, isInRange: true);
            KeyModifiers      = keys;
            OriginalSource    = source;
            CanBubbleNatively = canBubbleNatively;
        }
Exemple #4
0
        private bool HandlePointer(PointerDeviceType pointerDeviceType)
        {
            ResetPlayer();

            InteractionTypes interactionType = InteractionTypes.Mouse;

            switch (pointerDeviceType)
            {
            case PointerDeviceType.Mouse:
                interactionType = InteractionTypes.Mouse;
                break;

            case PointerDeviceType.Pen:
                interactionType = InteractionTypes.Pen;
                break;

            case PointerDeviceType.Touch:
                interactionType = InteractionTypes.Touch;
                break;
            }

            RaiseInteractionEvent(this, interactionType);

            return(true);
        }
Exemple #5
0
 /// <summary>
 /// Executes the necessary animations when the pointer goes over/out of the control.
 /// </summary>
 private void TogglePointerVisualStates(PointerDeviceType pointer, bool on)
 {
     if (pointer == PointerDeviceType.Mouse)
     {
         (on ? ShowHover : HideHover).Begin();
     }
 }
Exemple #6
0
        public static PointerDeviceType GetPointerType(UIElement uiElement)
        {
            PointerDeviceType type = PointerDeviceType.Mouse;

            uiElement.PointerPressed += (sender, e) => type = e.Pointer.PointerDeviceType;
            return(type);
        }
Exemple #7
0
 internal HoldingEventArgs(uint pointerId, PointerDeviceType type, Point position, HoldingState state)
 {
     PointerId         = pointerId;
     PointerDeviceType = type;
     Position          = position;
     HoldingState      = state;
 }
Exemple #8
0
        internal Pointer(uint id, PointerDeviceType type)
        {
            PointerId         = id;
            PointerDeviceType = type;

            UniqueId = new Windows.Devices.Input.PointerIdentifier((Windows.Devices.Input.PointerDeviceType)type, id);
        }
Exemple #9
0
 public Pointer(uint id, PointerDeviceType type, bool isInContact, bool isInRange)
 {
     PointerId         = id;
     PointerDeviceType = type;
     IsInContact       = isInContact;
     IsInRange         = isInRange;
 }
Exemple #10
0
        private bool HandlePointer(PointerDeviceType pointerDeviceType)
        {
            ResetPlayer();

            CoreWindow.GetForCurrentThread().KeyDown -= this.AttractorLoopPlayer_KeyDown;

            InteractionTypes interactionType = InteractionTypes.Mouse;

            switch (pointerDeviceType)
            {
            case PointerDeviceType.Mouse:
                interactionType = InteractionTypes.Mouse;
                break;

            case PointerDeviceType.Pen:
                interactionType = InteractionTypes.Pen;
                break;

            case PointerDeviceType.Touch:
                interactionType = InteractionTypes.Touch;
                break;
            }

            RaiseInteractionEvent(this, interactionType);

            return(true);
        }
Exemple #11
0
        internal Pointer(uint id, PointerDeviceType type)
        {
            PointerId         = id;
            PointerDeviceType = type;

            UniqueId = new PointerIdentifier(type, id);
        }
Exemple #12
0
        public void InkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            // Get information about the pointer location.
            PointerPoint pt = e.GetCurrentPoint(PanelCanvas);

            this.previousContactPt = pt.Position;

            // Accept input only from a pen or mouse with the left button pressed.
            PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;

            if (pointerDevType == PointerDeviceType.Pen ||
                (pointerDevType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed))
            {
                // Pass the pointer information to the InkManager.
                this.inkManager.ProcessPointerDown(pt);
                this.penID = pt.PointerId;

                e.Handled = true;
            }
            else if (pointerDevType == PointerDeviceType.Touch)
            {
                // Process touch input
                this.inkManager.ProcessPointerDown(pt);
                this.penID = pt.PointerId;

                e.Handled = true;
            }
        }
        private void FillPointInformation(ref PointerPoint point,
                                          PointerEventType eventType,
                                          PointerDeviceType deviceType,
                                          PointerUpdateKind updateKind,
                                          System.Windows.Point positionPoint)
        {
            var position = new Vector2((float)(positionPoint.X / element.ActualWidth), (float)(positionPoint.Y / element.ActualHeight));

            position.Saturate();

            point.EventType              = eventType;
            point.DeviceType             = deviceType;
            point.KeyModifiers           = GetPressedKeyModifiers();
            point.PointerId              = 0;
            point.Position               = position;
            point.Timestamp              = (ulong)DateTime.Now.Ticks;
            point.ContactRect            = new RectangleF(position.X, position.Y, 0f, 0f);
            point.IsBarrelButtonPressed  = false;
            point.IsCanceled             = false;
            point.IsEraser               = false;
            point.IsHorizontalMouseWheel = false;
            point.IsInRange              = false;
            point.IsInverted             = false;
            point.IsPrimary              = true;
            point.MouseWheelDelta        = 0;
            point.Orientation            = 0f;
            point.TouchConfidence        = false;
            point.Twist             = 0f;
            point.XTilt             = 0f;
            point.YTilt             = 0f;
            point.PointerUpdateKind = updateKind;
        }
        public void InkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            try
            {
                // Get information about the pointer location.
                PointerPoint pt = e.GetCurrentPoint(InkCanvas);
                _previousContactPt = pt.Position;

                // Accept input only from a pen or mouse with the left button pressed.
                PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
                if (pointerDevType == PointerDeviceType.Pen ||
                    pointerDevType == PointerDeviceType.Mouse &&
                    pt.Properties.IsLeftButtonPressed)
                {
                    // Pass the pointer information to the InkManager.
                    _inkManager.ProcessPointerDown(pt);
                    _penID = pt.PointerId;

                    e.Handled = true;
                }

                else if (pointerDevType == PointerDeviceType.Touch)
                {
                    // Process touch input
                }
            }
            catch (Exception ex)
            {
                MessageDialog msg = new MessageDialog(ex.Message + " Void - InkCanvas_PointerPressed");
                //msg.ShowAsync();
            }
        }
Exemple #15
0
        /// <summary>
        /// Make the current stroke permanent
        /// </summary>
        /// <remarks>Copies the output of the render pipeline from InkBuilder to dry strokes</remarks>
        public override void StoreCurrentStroke(PointerDeviceType deviceType)
        {
            var allData = RasterInkBuilder.SplineInterpolator.AllData;
            var points  = new List <float>();

            if (allData != null)
            {
                for (int i = 0; i < allData.Count; i++)
                {
                    points.Add(allData[i]);
                }

                if (points.Count > 0)
                {
                    var dryStroke = new RasterInkStroke(RasterInkBuilder,
                                                        deviceType,
                                                        points,
                                                        mStartRandomSeed,
                                                        CreateSerializationBrush($"will://examples/brushes/{Guid.NewGuid().ToString()}"),
                                                        mActiveTool.Brush,
                                                        mStrokeConstants.Clone(),
                                                        mSerializer.AddSensorData(deviceType, InkBuilder.GetPointerDataList()));
                    mDryStrokes.Add(dryStroke);
                }
            }
        }
Exemple #16
0
 private void AddRasterBrushToInkDoc(PointerDeviceType deviceType, RasterBrush rasterBrush, Style rasterStyle, StrokeConstants strokeConstants, uint startRandomSeed)
 {
     if (!InkDocument.Brushes.TryGetBrush(rasterBrush.Name, out Brush foundBrush))
     {
         InkDocument.Brushes.AddRasterBrush(rasterBrush);
     }
 }
Exemple #17
0
        private void DisplayBalloon(Slice slice, Point position, PointerDeviceType deviceType)
        {
            int balloonOffset = 10;

            if (deviceType == PointerDeviceType.Touch)
            {
                balloonOffset = 50;
            }
            _balloon.Text       = slice.ToolTipText;
            _balloon.Visibility = Visibility.Visible;
            _balloon.Measure(new Size(_sliceCanvasDecorator.ActualWidth, _sliceCanvasDecorator.ActualHeight));
            double balloonLeft = position.X - _balloon.DesiredSize.Width / 2;

            if (balloonLeft < 0)
            {
                balloonLeft = position.X;
            }
            else if (balloonLeft + _balloon.DesiredSize.Width > _sliceCanvasDecorator.ActualWidth)
            {
                balloonLeft = position.X - _balloon.DesiredSize.Width;
            }
            double balloonTop = position.Y - _balloon.DesiredSize.Height - balloonOffset / 2;

            if (balloonTop < 0)
            {
                balloonTop = position.Y + balloonOffset;
            }
            _balloon.SetValue(Canvas.LeftProperty, balloonLeft);
            _balloon.SetValue(Canvas.TopProperty, balloonTop);
        }
        public RasterInkStroke(RasterInkBuilder inkBuilder,
                               PointerDeviceType pointerDeviceType,
                               List <float> points,
                               uint seed,
                               RasterBrush rasterBrush,
                               ParticleBrush particleBrush,
                               StrokeConstants StrokeParams,
                               Identifier sensorDataId)
        {
            Id = Identifier.FromNewGuid();

            PointerDeviceType = pointerDeviceType;

            uint channelMask = (uint)inkBuilder.SplineInterpolator.InterpolatedSplineLayout.ChannelMask;

            Path = new ParticleList();
            Path.Assign(points, channelMask);

            RandomSeed      = seed;
            StrokeConstants = StrokeParams;
            SensorDataId    = sensorDataId;
            RasterBrush     = rasterBrush;
            ParticleBrush   = particleBrush;

            // Cloning is needed, otherwise the spatial data is corrupted
            Spline = inkBuilder.SplineProducer.AllData.Clone();
            Layout = inkBuilder.Layout;
        }
Exemple #19
0
        private void MyCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            // Get information about the pointer location.
            PointerPoint pt = e.GetCurrentPoint(myCanvas);

            _previousContactPt = pt.Position;

            // Accept input only from a pen or mouse with the left button pressed.
            PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;

            if (pointerDevType == PointerDeviceType.Pen ||
                pointerDevType == PointerDeviceType.Mouse &&
                pt.Properties.IsLeftButtonPressed || pointerDevType == PointerDeviceType.Touch)
            {
                // Pass the pointer information to the InkManager.
                _inkKhaled.ProcessPointerDown(pt);
                _penID = pt.PointerId;

                e.Handled = true;
            }

            //else if (pointerDevType == PointerDeviceType.Touch)
            //{
            //    // Process touch input
            //}
        }
Exemple #20
0
        private void DisplayBalloon(Indicator indicator, PointerDeviceType deviceType)
        {
            int balloonOffset = 10;

            if (deviceType == PointerDeviceType.Touch)
            {
                balloonOffset = 50;
            }
            _balloon.Text       = indicator.Text;
            _balloon.Visibility = Visibility.Visible;
            _balloon.Measure(new Size(_graphCanvasDecorator.ActualWidth, _graphCanvasDecorator.ActualHeight));
            double balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty) - _balloon.DesiredSize.Width / 2 + indicator.ActualWidth / 2;

            if (balloonLeft < 0)
            {
                balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty);
            }
            else if (balloonLeft + _balloon.DesiredSize.Width > _graphCanvasDecorator.ActualWidth)
            {
                balloonLeft = (double)indicator.GetValue(Canvas.LeftProperty) - _balloon.DesiredSize.Width;
            }
            double balloonTop = (double)indicator.GetValue(Canvas.TopProperty) - _balloon.DesiredSize.Height - balloonOffset / 2;

            if (balloonTop < 0)
            {
                balloonTop = (double)indicator.GetValue(Canvas.TopProperty) + balloonOffset;
            }
            _balloon.SetValue(Canvas.LeftProperty, balloonLeft);
            _balloon.SetValue(Canvas.TopProperty, balloonTop);
        }
Exemple #21
0
        public Pointer(uint id, PointerDeviceType type, bool isInContact, bool isInRange)
        {
            PointerId         = id;
            PointerDeviceType = type;
            IsInContact       = isInContact;
            IsInRange         = isInRange;

            UniqueId = (long)PointerDeviceType << 32 | PointerId;
        }
Exemple #22
0
        public Pointer(uint id, PointerDeviceType type, bool isInContact, bool isInRange)
        {
            PointerId         = id;
            PointerDeviceType = type;
            IsInContact       = isInContact;
            IsInRange         = isInRange;

            UniqueId = new PointerIdentifier(type, id);
        }
Exemple #23
0
        public Pointer(uint id, PointerDeviceType type, bool isInContact, bool isInRange)
        {
            PointerId         = id;
            PointerDeviceType = type;
            IsInContact       = isInContact;
            IsInRange         = isInRange;

            UniqueId = new Windows.Devices.Input.PointerIdentifier((Windows.Devices.Input.PointerDeviceType)type, id);
        }
Exemple #24
0
        private void MyCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            PointerPoint pt = e.GetCurrentPoint(MyCanvas);

            _previousContactPt = pt.Position;
            PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;

            e.Handled = true;
        }
        /// <summary>
        /// Make the current stroke permanent
        /// </summary>
        /// <remarks>Copies the output of the render pipeline from InkBuilder to dry strokes</remarks>
        public override void StoreCurrentStroke(PointerDeviceType deviceType)
        {
            var polygons       = VectorInkBuilder.PolygonSimplifier.AllData;
            var mergedPolygons = PolygonUtils.MergePolygons(polygons);

            var stroke = new VectorInkStroke(deviceType, VectorInkBuilder, BrushColor, mergedPolygons, mActiveTool.Shape, mSerializer.AddSensorData(deviceType, VectorInkBuilder.GetPointerDataList()));

            mDryStrokes.Add(stroke);
            mSpatialModel.Add(stroke);
        }
 public PointerData(SharpDX.Direct2D1.DeviceContext context, uint id, PointerDeviceType type, Point p)
 {
     this.PointerId = id;
     this.DeviceType = type;
     this.Pointers = new List<Point>();
     this.Pointers.Add(p);
     Random rnd = new Random();
     // Colors of lines. presents in RGBA (a random value between 0.5 ~ 1.0)
     color = new Color4(rnd.NextFloat(0.5f, 1), rnd.NextFloat(0.5f, 1), rnd.NextFloat(0.5f, 1), 1);
 }
        public PointerData(SharpDX.Direct2D1.DeviceContext context, uint id, PointerDeviceType type, Point p)
        {
            this.PointerId  = id;
            this.DeviceType = type;
            this.Pointers   = new List <Point>();
            this.Pointers.Add(p);
            Random rnd = new Random();

            // Colors of lines. presents in RGBA (a random value between 0.5 ~ 1.0)
            color = new Color4(rnd.NextFloat(0.5f, 1), rnd.NextFloat(0.5f, 1), rnd.NextFloat(0.5f, 1), 1);
        }
Exemple #28
0
 internal ManipulationCompletedEventArgs(
     PointerDeviceType pointerDeviceType,
     Point position,
     ManipulationDelta cumulative,
     bool isInertial)
 {
     PointerDeviceType = pointerDeviceType;
     Position          = position;
     Cumulative        = cumulative;
     IsInertial        = isInertial;
 }
        public override Calculator GetCalculator(PointerDeviceType deviceType)
        {
            switch (deviceType)
            {
            case Windows.Devices.Input.PointerDeviceType.Mouse:
            case Windows.Devices.Input.PointerDeviceType.Touch:
            case Windows.Devices.Input.PointerDeviceType.Pen:
                return(CalculatorForMouseAndTouch);

            default:
                throw new Exception("Unknown input device type");
            }
        }
Exemple #30
0
        public static C1PointerDeviceType GetPointerType(RoutedEventArgs originalArgs)
        {
            PointerDeviceType mouse = Windows.Devices.Input.PointerDeviceType.Mouse;

            if (originalArgs is PointerRoutedEventArgs)
            {
                mouse = ((PointerRoutedEventArgs)originalArgs).Pointer.PointerDeviceType;
            }
            else if (originalArgs is ManipulationStartedRoutedEventArgs)
            {
                mouse = ((ManipulationStartedRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is ManipulationDeltaRoutedEventArgs)
            {
                mouse = ((ManipulationDeltaRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is ManipulationInertiaStartingRoutedEventArgs)
            {
                mouse = ((ManipulationInertiaStartingRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is ManipulationCompletedRoutedEventArgs)
            {
                mouse = ((ManipulationCompletedRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is TappedRoutedEventArgs)
            {
                mouse = ((TappedRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is DoubleTappedRoutedEventArgs)
            {
                mouse = ((DoubleTappedRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is RightTappedRoutedEventArgs)
            {
                mouse = ((RightTappedRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            else if (originalArgs is HoldingRoutedEventArgs)
            {
                mouse = ((HoldingRoutedEventArgs)originalArgs).PointerDeviceType;
            }
            switch (mouse)
            {
            case Windows.Devices.Input.PointerDeviceType.Touch:
                return(C1PointerDeviceType.Touch);

            case Windows.Devices.Input.PointerDeviceType.Pen:
                return(C1PointerDeviceType.Pen);
            }
            return(C1PointerDeviceType.Mouse);
        }
Exemple #31
0
        internal static PointerDevice For(PointerDeviceType type)
        {
            // We cache them as we don't implement any other properties than the PointerDeviceType
            // but this is probably not really valid...
            switch (type)
            {
            case PointerDeviceType.Touch: return(_touch);

            case PointerDeviceType.Mouse: return(_mouse);

            case PointerDeviceType.Pen: return(_pen);

            default: return(new PointerDevice(type));
            }
        }
Exemple #32
0
        private void OnPointerEvent(object sender, PointerRoutedEventArgs args)
        {
            PointerDeviceType pointerDeviceType = args.Pointer.PointerDeviceType;

            // Allows the test app to simulate how the control responds to touch input.
            if (SplitButtonTestHelper.SimulateTouch)
            {
                pointerDeviceType = PointerDeviceType.Touch;
            }

            if (m_lastPointerDeviceType != pointerDeviceType)
            {
                m_lastPointerDeviceType = pointerDeviceType;
                UpdateVisualStates();
            }
        }
Exemple #33
0
 //Handle event to get current values
 private void _targetElement_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     _lastPointerType = e.Pointer.PointerDeviceType;
     UpdateTrigger();
 }
Exemple #34
0
 private void InvokePointerDeviceChanged(PointerDeviceType pointerDeviceType)
 {
     if (PointerDeviceChanged != null)
     {
         PointerDeviceChanged(this, pointerDeviceType);
     }
 }
        private void FillPointInformation(ref PointerPoint point,
                                          PointerEventType eventType,
                                          PointerDeviceType deviceType,
                                          PointerUpdateKind updateKind,
                                          System.Windows.Point positionPoint)
        {
            var position = new Vector2((float)(positionPoint.X / element.ActualWidth), (float)(positionPoint.Y / element.ActualHeight));
            position.Saturate();

            point.EventType = eventType;
            point.DeviceType = deviceType;
            point.KeyModifiers = GetPressedKeyModifiers();
            point.PointerId = 0;
            point.Position = position;
            point.Timestamp = (ulong)DateTime.Now.Ticks;
            point.ContactRect = new RectangleF(position.X, position.Y, 0f, 0f);
            point.IsBarrelButtonPressed = false;
            point.IsCanceled = false;
            point.IsEraser = false;
            point.IsHorizontalMouseWheel = false;
            point.IsInRange = false;
            point.IsInverted = false;
            point.IsPrimary = true;
            point.MouseWheelDelta = 0;
            point.Orientation = 0f;
            point.TouchConfidence = false;
            point.Twist = 0f;
            point.XTilt = 0f;
            point.YTilt = 0f;
            point.PointerUpdateKind = updateKind;
        }
 public void UpdateTrigger(PointerDeviceType type)
 {
     SetActive(_triggerPointerType.Equals(type));
 }