Exemplo n.º 1
0
        private void PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            PointerPoint pp = e.GetCurrentPoint(renderer);

            if (pp.IsInContact)
            {
                bool found = false;
                foreach (Touch touch in touches)
                {
                    if (touch.Id == pp.PointerId && !touch.IsEnded)
                    {
                        touch.X = (int)pp.Position.X;
                        touch.Y = (int)pp.Position.Y;
                        found   = true;
                        break;
                    }
                }

                if (!found)
                {
                    touches.Add(new Touch(pp.PointerId, (int)pp.Position.X, (int)pp.Position.Y));
                }
            }
        }
        private async void AllView_ItemPress(object sender, PointerRoutedEventArgs e)
        {
            var ctrlPressed  = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
            var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);

            var cp = e.GetCurrentPoint((UIElement)sender);

            if (cp.Position.Y <= AllView.ColumnHeaderHeight || // Return if click is on the header
                cp.Properties.IsLeftButtonPressed || // Return if dragging an item
                cp.Properties.IsRightButtonPressed || // Return if the user right clicks an item
                ctrlPressed || shiftPressed)    // Allow for Ctrl+Shift selection
            {
                return;
            }

            // Check if the setting to open items with a single click is turned on
            if (AppSettings.OpenItemsWithOneclick)
            {
                tapDebounceTimer.Stop();
                await Task.Delay(200); // The delay gives time for the item to be selected

                ParentShellPageInstance.InteractionOperations.OpenItem_Click(null, null);
            }
        }
Exemplo n.º 3
0
        void VendFinderApp_PointerPressedOverride(object sender, PointerRoutedEventArgs e)
        {
            Bing.Maps.Location loc = new Bing.Maps.Location();
            this.VendFinderApp.TryPixelToLocation(e.GetCurrentPoint(this.VendFinderApp).Position, out loc);
            Bing.Maps.Pushpin pushPin = new Bing.Maps.Pushpin();
            pushPin.SetValue(Bing.Maps.MapLayer.PositionProperty, loc);
            this.VendFinderApp.Children.Add(pushPin);



            // Add code to prompt user to enter VendMachine metadata...
            inputPrompt        = new TextBox();
            inputPrompt.Height = (1 / 4) * Height;
            inputPrompt.Width  = Width;
            inputPrompt.SetValue(Bing.Maps.MapLayer.PositionProperty, loc);
            inputPrompt.PlaceholderText = "Enter location of Vending Machine...";
            inputPrompt.IsEnabled       = true;
            inputPrompt.UpdateLayout();
            inputPrompt.Opacity    = 1;
            inputPrompt.Visibility = Visibility.Visible;
            VendFinderApp.Children.Add(inputPrompt);

            // Generic file name for file which stores user-prescribed location info.
            //string name = "database.txt";

            // Package the info file and save it to the user's system.
            //StorageFile storeFile =
            //  await storageFolder.CreateFileAsync(name, CreationCollisionOption.GenerateUniqueName);

            mLoc = loc.Latitude.ToString() + "|" + loc.Longitude.ToString();

            //storeFile = await storageFolder.GetFileAsync("dataBase.txt");
            //await FileIO.WriteTextAsync(storeFile, loc.Latitude.ToString() + " " + loc.Longitude.ToString());

            pinBeingPlaced = true;
        }
Exemplo n.º 4
0
 void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (IsItemLeftEdgeTapEnabled)
     {
         // This conditional was commented to enable this on non-Mobile devices.
         // var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;
         // if (qualifiers.ContainsKey("DeviceFamily") && qualifiers["DeviceFamily"] == "Mobile")
         {
             if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
             {
                 UIElement element = (sender as UIElement);
                 if (null != element)
                 {
                     PointerPoint pointerPoint = e.GetCurrentPoint(element);
                     if (pointerPoint.Position.X <= HIT_TARGET)
                     {
                         listViewItemHighlighted = VisualTreeHelper.GetParent(element) as ListViewItem;
                         ShowVisual();
                     }
                 }
             }
         }
     }
 }
        private void MainCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (!IsSelectable)
            {
                return;
            }
            if (!_draggingState.IsDragging || _innerScore == null)
            {
                return;
            }

            Point currentPosition = e.GetCurrentPoint(MainCanvas).Position;
            var   strategy        = DraggingStrategy.For(SelectedElement);

            if (strategy != null)
            {
                strategy.Drag(Renderer, SelectedElement, _draggingState, CanvasScoreRenderer.ConvertPoint(currentPosition));
            }

            if (InvalidatingMode == InvalidatingModes.RedrawAllScore)
            {
                RenderOnCanvas(_innerScore);
            }
        }
        private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var pointerId = e.Pointer.PointerId;

            if (IndexOfPointerWithId(pointerId) != -1)
            {
                throw new InvalidOperationException("A pointer with this ID already exists.");
            }

            var originalSource = e.OriginalSource as DependencyObject;
            var rootPoint      = e.GetCurrentPoint(_view);
            var reactView      = GetReactViewTarget(e) as UIElement;

            if (reactView != null && _view.CapturePointer(e.Pointer))
            {
                // Pointer pressing updates the enter/leave state
                UpdatePointersInViews(reactView, rootPoint, e);

                var pointer      = CreateReactPointer(reactView, rootPoint, e, true);
                var pointerIndex = _pointers.Count;
                _pointers.Add(pointer);
                DispatchTouchEvent(TouchEventType.Start, _pointers, pointerIndex);
            }
        }
Exemplo n.º 7
0
 private void LayoutRoot_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
 {
     if (_bitmap != null && e.KeyModifiers == Windows.System.VirtualKeyModifiers.Control)
     {
         if (e.GetCurrentPoint(sender as UIElement).Properties.MouseWheelDelta > 0)
         {
             // Zoom in
             if (PhotoTransform.ScaleX < 4.0)
             {
                 PhotoTransform.ScaleX += 0.1;
                 PhotoTransform.ScaleY += 0.1;
             }
         }
         else
         {
             // Zoom out
             if (PhotoTransform.ScaleX > 1.0)
             {
                 PhotoTransform.ScaleX -= 0.1;
                 PhotoTransform.ScaleY -= 0.1;
             }
         }
     }
 }
Exemplo n.º 8
0
        private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (!IsEnabled)
            {
                return;
            }

            if (_recogniser.IsActive)
            {
                _recogniser.CompleteGesture();
                if (_capturedElement != null && _capturedPointer != null)
                {
                    _capturedElement.ReleasePointerCapture(_capturedPointer);
                }

                _capturedElement = null;
                _capturedPointer = null;
            }

            _capturedElement = (sender as UIElement);
            _capturedPointer = e.Pointer;
            _capturedElement.CapturePointer(_capturedPointer);
            _recogniser.ProcessDownEvent(e.GetCurrentPoint(_reference));
        }
Exemplo n.º 9
0
        // This captures when a mousewheel interaction occurs. We will then take the "delta" from the mousewheel and
        // funnel that into an animation and animate the position of InteractionTracker. Tracker's position ultimately defines position of the scrubber
        private void PointerWheel_Changed(object sender, PointerRoutedEventArgs e)
        {
            // Calling OnDragStart() so we can change the position of the scrubber
            OnDragStart();

            // Grab the delta of the mousewheel from the event handler
            var wheelDelta = e.GetCurrentPoint(trackCanvas).Properties.MouseWheelDelta;

            propSet.InsertVector3("wheelDelta", new System.Numerics.Vector3(wheelDelta, 0f, 0f));

            // Create the animation that we will use to animate the position of InteractionTracker
            var wheelKFA = this.compositor.CreateVector3KeyFrameAnimation();

            wheelKFA.Duration = TimeSpan.FromSeconds(1);

            // We are using strings here instead of ExpressionBuilder. We need an extension method added to ExpressionBuilder for TryUpdatePositionWithAnimation to take in
            // an ExpressionNode. Then we can use ExpressionNodes in the ExpressionKeyFrame instead of strings
            wheelKFA.InsertExpressionKeyFrame(1f, "this.CurrentValue + props.wheelDelta");
            wheelKFA.SetReferenceParameter("tracker", this.tracker);
            wheelKFA.SetReferenceParameter("props", propSet);

            // Update the position of InteractionTracker with the animation based on the scroll wheel delta
            this.tracker.TryUpdatePositionWithAnimation(wheelKFA);
        }
Exemplo n.º 10
0
        void HtmlCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
#endif
        {
            // Get the cursor position relative to this HtmlCanvas
#if MIGRATION
            Point pos = e.GetPosition(this);
#else
            Point pos = e.GetCurrentPoint(this).Position;
#endif

            // Get a stack of the HtmlCanvasElement directly under the cursor and all his parents
            // (Parent1, Parent2, ..., ElementDirectlyUnderTheCursor)
            Stack <HtmlCanvasElement> elements = GetPointedElements(this, pos.X, pos.Y);

            HtmlCanvasPointerRoutedEventArgs e2 = new HtmlCanvasPointerRoutedEventArgs(e, this);

            // Loop backward on every element of the stack
            while (!e.Handled && elements.Count > 0)
            {
                // Remove the last element of the stack and call its OnPointerMoved() method
                var el = elements.Pop();
                el.OnPointerPressed(e2);
            }
        }
        private void Slider_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (!pointerCaptured)
            {
                return;
            }

            Point  newPos = e.GetCurrentPoint(Base).Position;
            double delta  = newPos.Y - startPosition.Y;

            if (delta == 0)
            {
                return;                              //shortcut
            }
            int distance = (int)(delta / 185 * 100); //mapping distance to 0-100 range

            if (Math.Abs(distance) > 100)
            {
                distance = 100 * Math.Sign(distance);
                delta    = distance * 185 / 100;
            }
            Distance = distance;

            sliderPosition.Y = delta;

            if (Math.Abs(previousDistance - distance) < DistanceChangeThreshold)
            {
                return;
            }

            Moved?.Invoke(this, new SliderEventArgs {
                Distance = Distance
            });

            previousDistance = Distance;
        }
Exemplo n.º 12
0
        public async void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e, Canvas InkCanvas, TextBox RecognizedTextBox)
        {
            if (e.Pointer.PointerId != _currentPointerId)
            {
                return;
            }
            if (e.GetCurrentPoint(null).Properties.PointerUpdateKind == PointerUpdateKind.RightButtonReleased)
            {
                return;
            }
            var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_CUT | WritePadAPI.GEST_RETURN, _currentStroke.Points);

            switch (gesture)
            {
            case WritePadAPI.GEST_RETURN:
                InkCanvas.Children.Remove(_currentStroke);
                _currentStroke.Points.Clear();
                var strokes = (from object child in InkCanvas.Children select child as UIElement).ToList();
                var result  = RecognizeStrokes(strokes, true);
                if (string.IsNullOrEmpty(result))
                {
                    var messageBox = new MessageDialog("Text could not be recognized.");
                    messageBox.Commands.Add(new UICommand("Close"));
                    await messageBox.ShowAsync();

                    result = "";
                }
                RecognizedTextBox.Text = result;
                return;

            case WritePadAPI.GEST_CUT:
                ClearInk(InkCanvas);
                return;
            }
            FinishStrokeDraw(InkCanvas);
        }
        private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
        {
            var pointerIndex = IndexOfPointerWithId(e.Pointer.PointerId);

            if (pointerIndex != -1)
            {
                // Touch/Dragging case
                var pointer = _pointers[pointerIndex];
                UpdatePointerForEvent(pointer, e);
                DispatchTouchEvent(TouchEventType.Move, _pointers, pointerIndex);
            }
            else
            {
                // Moving case (with no buttons pressed)
                var originalSource = e.OriginalSource as DependencyObject;
                var rootPoint      = e.GetCurrentPoint(_view);
                var reactView      = GetReactViewTarget(e) as UIElement;
                if (reactView != null)
                {
                    // Moving a non captured pointer updates the enter/leave state
                    UpdatePointersInViews(reactView, rootPoint, e);
                    if (ShouldSendPointerMoveEvent(reactView))
                    {
                        var pointer = CreateReactPointer(reactView, rootPoint, e, true);
                        pointerIndex = _pointers.Count;
                        _pointers.Add(pointer);
                        DispatchTouchEvent(TouchEventType.PointerMove, _pointers, pointerIndex);
                        _pointers.Remove(pointer);
                        if (_pointers.Count == 0)
                        {
                            _pointerIDs = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Picker area pointer pressed event handler
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event aruments</param>
        private void OnPickerPressed(object sender, PointerRoutedEventArgs e)
        {
            this.PickColor(e.GetCurrentPoint(this.pickerCanvas).Position);
            this.pickerCanvas.CapturePointer(e.Pointer);

            PointerEventHandler moved = null;

            moved = (s, args) =>
            {
                this.PickColor(args.GetCurrentPoint(this.pickerCanvas).Position);
            };
            PointerEventHandler released = null;

            released = (s, args) =>
            {
                this.pickerCanvas.ReleasePointerCapture(args.Pointer);
                this.PickColor(args.GetCurrentPoint(this.pickerCanvas).Position);
                this.pickerCanvas.PointerMoved    -= moved;
                this.pickerCanvas.PointerReleased -= released;
            };

            this.pickerCanvas.PointerMoved    += moved;
            this.pickerCanvas.PointerReleased += released;
        }
 private void targetContainer_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(targetContainer);
     // Update event sequence.
     eventLog.Text += "\nOver: " + pt.PointerId;
     if (contacts.Count == 0)
     {
         // Change background color of target when pointer contact detected.
         targetContainer.Fill = new SolidColorBrush(Windows.UI.Colors.Blue);
     }
     // Check if pointer already exists (if enter occurred prior to down).
     if (contacts.ContainsKey(pt.PointerId))
     {
         return;
     }
     // Push new pointer Id onto expando target pointers array.
     contacts[pt.PointerId]      = pt;
     startLocation[pt.PointerId] = pt.Position;
     pointSwiped[pt.PointerId]   = false;
     ++numActiveContacts;
     e.Handled = true;
     // Display pointer details.
     createInfoPop(e);
 }
Exemplo n.º 16
0
        private void ViewControl_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if ((e.OriginalSource as FrameworkElement)?.DataContext is FileSystemStorageItemBase Item)
            {
                PointerPoint PointerInfo = e.GetCurrentPoint(null);

                if ((e.OriginalSource as FrameworkElement).FindParentOfType <SelectorItem>() != null)
                {
                    if (e.KeyModifiers == VirtualKeyModifiers.None && SearchResultList.SelectionMode != ListViewSelectionMode.Multiple)
                    {
                        if (SearchResultList.SelectedItems.Contains(Item))
                        {
                            SelectionExtention.Disable();
                        }
                        else
                        {
                            if (PointerInfo.Properties.IsLeftButtonPressed)
                            {
                                SearchResultList.SelectedItem = Item;
                            }

                            if (e.OriginalSource is ListViewItemPresenter || (e.OriginalSource is TextBlock Block && Block.Name == "EmptyTextblock"))
                            {
                                SelectionExtention.Enable();
                            }
                            else
                            {
                                SelectionExtention.Disable();
                            }
                        }
                    }
                    else
                    {
                        SelectionExtention.Disable();
                    }
                }
Exemplo n.º 17
0
        void OnPointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (this.dragging)
            {
                PointerPoint pointerPointRelativeToInnerRadius = e.GetCurrentPoint(this.innerRadius);

                Point positionRelativeToInnerRadiusCenter = new Point(
                    pointerPointRelativeToInnerRadius.Position.X - this.RadialLength,
                    pointerPointRelativeToInnerRadius.Position.Y - this.RadialLength);

                positionRelativeToInnerRadiusCenter.Y = 0 - positionRelativeToInnerRadiusCenter.Y;

                double angleRadians = Math.Atan(
                    positionRelativeToInnerRadiusCenter.X / positionRelativeToInnerRadiusCenter.Y);

                double angleDegrees = RadiansToDegrees(angleRadians);
                double increment    = 0.0d;

                if (positionRelativeToInnerRadiusCenter.Y <= 0.0d)
                {
                    increment = 180.0d;
                }
                else if ((positionRelativeToInnerRadiusCenter.Y >= 0.0d) &&
                         (positionRelativeToInnerRadiusCenter.X <= 0.0d))
                {
                    increment = 360.0d;
                }
                angleDegrees += increment;

                if ((angleDegrees >= this.MinAngle) &&
                    (angleDegrees <= this.MaxAngle))
                {
                    this.Value = this.GetValueFromAngle(angleDegrees);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Called before the PointerMoved event occurs.
        /// </summary>
        /// <param name="e">Event data for the event.</param>
        protected override void OnPointerMoved(PointerRoutedEventArgs e)
        {
            base.OnPointerMoved(e);

            if (e == null || !this.currentlyRepeating)
            {
                return;
            }

            var point = e.GetCurrentPoint(this);
            var rect  = new Rect(0, 0, this.ActualWidth, this.ActualHeight);

            if (rect.Contains(point.Position))
            {
                if (!this.repeatTimer.IsEnabled)
                {
                    this.repeatTimer.Start();
                }
            }
            else
            {
                this.repeatTimer.Stop();
            }
        }
Exemplo n.º 19
0
        public static string MouseClicked(PointerRoutedEventArgs e, UIElement uIElement)
        {
            string objectDescription = "null";

            if (GameEngine.currentGameState == GameState.PlayerPlaying && Dice.DiceSave > 0)
            {
                object returned = GameEngine.HitDetection(new Vector2((float)e.GetCurrentPoint(uIElement).Position.X, (float)e.GetCurrentPoint(uIElement).Position.Y));

                if (returned is GamePiece)
                {
                    GameEngine.player.MovePiece((GamePiece)returned);
                }

                if (returned is GamePiece)
                {
                    objectDescription = "GamePiece";
                }
                else if (returned is GameTile)
                {
                    objectDescription = "GameTile";
                }
            }
            return(objectDescription);
        }
Exemplo n.º 20
0
        /// <summary>
        /// The pointer canceled event handler.
        /// Fires for for various reasons, including:
        ///    - Touch contact canceled by pen coming into range of the surface.
        ///    - The device doesn't report an active contact for more than 100ms.
        ///    - The desktop is locked or the user logged off.
        ///    - The number of simultaneous contacts exceeded the number supported by the device.
        /// </summary>
        /// <param name="sender">Source of the pointer event.</param>
        /// <param name="e">Event args for the pointer routed event.</param>
        private void Target_PointerCanceled(object sender, PointerRoutedEventArgs e)
        {
            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            PointerPoint ptrPt = e.GetCurrentPoint(Target);

            // Update event log.
            UpdateEventLog("Pointer canceled: " + ptrPt.PointerId);

            // Remove contact from dictionary.
            if (pointers.ContainsKey(ptrPt.PointerId))
            {
                pointers[ptrPt.PointerId] = null;
                pointers.Remove(ptrPt.PointerId);
            }

            if (pointers.Count == 0)
            {
                Target.Fill = new SolidColorBrush(Windows.UI.Colors.Black);
            }

            DestroyInfoPop(ptrPt);
        }
Exemplo n.º 21
0
        private void LabelingArea_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            if (!spray)
            {
                // Process position
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(LabelingArea);
                int x = (int)(ptrPt.Position.X / 20);
                int y = (int)(ptrPt.Position.Y / 20);

                var selected = LabelingArea.Children[20 * x + y + 1];

                // Set color
                if (selected is Rectangle)
                {
                    Rectangle rect = (Rectangle)selected;
                    if ((rect.Fill as SolidColorBrush).Equals(background))
                    {
                        rect.Fill = bee;
                    }
                    else
                    {
                        if ((rect.Fill as SolidColorBrush).Equals(bee))
                        {
                            rect.Fill = mite;
                        }
                        else
                        {
                            rect.Fill = background;
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
        private void Page_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
        {
            if (!PanelToggle.IsChecked.GetValueOrDefault())
            {
                if (Flip.ContainerFromIndex(Flip.SelectedIndex).FindChildOfName <ScrollViewer>("ScrollViewerMain") is ScrollViewer Viewer)
                {
                    if (Viewer.ZoomFactor > 1f)
                    {
                        int Delta = e.GetCurrentPoint(null).Properties.MouseWheelDelta;

                        if (Delta > 0)
                        {
                            if (Viewer.VerticalOffset == 0 && Flip.SelectedIndex > 0)
                            {
                                if (++DelaySelectionChangeCount > 1)
                                {
                                    DelaySelectionChangeCount = 0;
                                    Flip.SelectedIndex--;
                                }
                            }
                        }
                        else
                        {
                            if (Viewer.VerticalOffset == Viewer.ScrollableHeight && Flip.SelectedIndex < PdfCollection.Count - 1)
                            {
                                if (++DelaySelectionChangeCount > 1)
                                {
                                    DelaySelectionChangeCount = 0;
                                    Flip.SelectedIndex++;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
 private void mouseMove(object sender, PointerRoutedEventArgs e)
 {
     //If the move tool is selected, this makes it possible to drag a selection
     if (tool == "Move" && dragStart != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         timeindex--;;
         Update(false);
         var p2 = e.GetCurrentPoint(paintSurface);
         foreach (int tag in selected)
         {
             Composite tmp           = group.FindID(tag).Copy();
             Move      moveAction    = new Move(tmp, p2.Position.X - dragStart.Position.X, p2.Position.Y - dragStart.Position.Y);
             Replace   replaceAction = new Replace(group, tmp, tag);
             actionmanager.takeAction(moveAction);
             actionmanager.takeAction(replaceAction);
         }
         actionmanager.executeActions();
         Update(true);
         Update(false);
     }
     //If the rectangle or ellipse tool is selected, then this creates the shape
     else if ((tool == "Rectangle" || tool == "Ellipse") && dragStart != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         Undo_Click(sender, e);
         itemcount++;
         Composite newshape = new Composite(itemcount, tool);
         newshape.height = Math.Abs(dragStart.Position.Y - e.GetCurrentPoint(paintSurface).Position.Y);
         newshape.width  = Math.Abs(dragStart.Position.X - e.GetCurrentPoint(paintSurface).Position.X);
         newshape.x      = ReturnSmallest(dragStart.Position.X, e.GetCurrentPoint(paintSurface).Position.X);
         newshape.y      = ReturnSmallest(dragStart.Position.Y, e.GetCurrentPoint(paintSurface).Position.Y);
         Add addAction = new Add(group, newshape);
         actionmanager.takeAction(addAction);
         actionmanager.executeActions();
         Update(true);
         Update(false);
     }
 }
Exemplo n.º 24
0
        public virtual void MoveArea_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            //FrameworkElement item = sender as FrameworkElement;
            //item = (sender as Panel).Parent as FrameworkElement;

            //if (item == null) { return; }
            if (!(_EnableH || _EnableV))
            {
                return;
            }
            //if (!isMouseCaptured) { return; }

            if (IsMove)
            {
                double deltaV = 0, deltaH = 0;
                Canvas p = po.Parent as Canvas;

                if (_EnableV)
                {
                    deltaV = e.GetCurrentPoint(p).Position.Y - mouseVerticalPosition;
                    double startTop = Convert.ToDouble(po.GetValue(Canvas.TopProperty));
                    double newTop   = deltaV + startTop;
                    if ((newTop > _MinTop) && (newTop < _MaxTop))
                    {
                        po.SetValue(Canvas.TopProperty, newTop);
                        foreach (FrameworkElement fe in MoveObjectList)
                        {
                            fe.SetValue(Canvas.TopProperty, newTop);
                            //fe.SetValue(Canvas.LeftProperty, newLeft);
                        }
                        foreach (LynxAnchorPoint lp in AnchorPointList)
                        {
                            lp.MoveLines(0, deltaV);
                        }
                        mouseVerticalPosition = mouseVerticalPosition + deltaV;
                        //if (lynxMoved != null) { lynxMoved(); }//移动完成以后回调
                    }
                }
                if (_EnableH)
                {
                    deltaH = e.GetCurrentPoint(p).Position.X - mouseHorizontalPosition;
                    double startLeft = Convert.ToDouble(po.GetValue(Canvas.LeftProperty));
                    double newLeft   = deltaH + startLeft;
                    if ((newLeft > _MinLeft) && (newLeft < _MaxLeft))
                    {
                        po.SetValue(Canvas.LeftProperty, newLeft);
                        foreach (FrameworkElement fe in MoveObjectList)
                        {
                            //fe.SetValue(Canvas.TopProperty, newTop);
                            fe.SetValue(Canvas.LeftProperty, newLeft);
                        }
                        foreach (LynxAnchorPoint lp in AnchorPointList)
                        {
                            lp.MoveLines(deltaH, 0);
                        }
                        mouseHorizontalPosition = mouseHorizontalPosition + deltaH;
                    }
                }
                po.SetValue(Canvas.ZIndexProperty, MaxZIndex++);
                if (lynxMoved != null)
                {
                    lynxMoved(deltaH, deltaV);
                }                                                   //移动完成以后回调
            }
        }
Exemplo n.º 25
0
 private void img2_pressed2(object sender, PointerRoutedEventArgs e)
 {
     holding     = sender as Image;
     imageOffset = e.GetCurrentPoint(holding).Position;
 }
 private void ScrollViewer_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
 {
     //ScrollMaster.Scroll
     ScrollMaster.ChangeView(ScrollMaster.HorizontalOffset + (e.GetCurrentPoint(ScrollMaster).Properties.MouseWheelDelta * 2), ScrollMaster.VerticalOffset, ScrollMaster.ZoomFactor);
     //ScrollMaster.ScrollToHorizontalOffset(ScrollMaster.HorizontalOffset + e.GetCurrentPoint(ScrollMaster).Properties.MouseWheelDelta);
 }
Exemplo n.º 27
0
        private void cgReleased(object sender, PointerRoutedEventArgs e)
        {
            dbg("Release - enter");

            if (dragging)
            {
                centerGrid.ReleasePointerCapture(e.Pointer);
                e.Handled = true;
                dragging  = false;
                dbg("Release - dragging handled");
            }
            else
            {
                dbg("Release - not dragging - return");
                return;
            }

            if (centerGridAnimating)
            {
                dbg("Release - return: move = " + cgMoving + " / animate = " + centerGridAnimating);
                return;
            }
            PointerPoint pp = e.GetCurrentPoint(this);

            cgTargetRotation = 0;
            dbg("Release - is move || animate");

            if (startX == pp.Position.X && startY == pp.Position.Y)
            {
                dbg("Release - toggle and return");
                toggleCenterGrid();
                return;
            }

            CompositeTransform ct  = centerGrid.RenderTransform as CompositeTransform;
            double             toX = -App.Width * xShift;
            double             toY = -App.Height * yShift;

            centerGridAnimating = true;
            cgMoving            = true;
            dbg("Release - compare = " + centerGridShowCompare);
            if (centerGridShowCompare)
            {
                Storyboards.MoveXY(subscriptionVsOneTimeGrid, CenterGridSplitTime, -toX * xShiftCompareFactor, toY, 0, toY, null);
                Storyboards.FadeOut(subscriptionVsOneTimeGrid, CenterGridSplitTime, finishCenterGridAnimation);
                dbg("Release - cgTargetX = " + cgTargetX);

                /*if (cgTransform != null && Math.Abs(cgTargetX) < 5) {
                 *  dbg("Release Point - set TranslateX" + toX);
                 *  cgTransform.TranslateX = toX;
                 *  cgTransform.TranslateY = toY;
                 * }*/
                cgTargetX             = 0;
                cgTargetY             = toY;
                centerGridShowCompare = false;
                dbg("Release - hide compare");
            }
            else
            {
                Storyboards.MoveXY(subscriptionVsOneTimeGrid, CenterGridSplitTime, 0, toY, -toX * xShiftCompareFactor, toY, null);
                Storyboards.FadeIn(subscriptionVsOneTimeGrid, CenterGridSplitTime, finishCenterGridAnimation);
                dbg("Release - cgTargetX = " + cgTargetX);

                /*if (cgTransform != null && Math.Abs(cgTargetX) < 5) {
                 *  dbg("Release Point - set TranslateX = 0");
                 *  cgTransform.TranslateX = 0;
                 *  cgTransform.TranslateY = toY;
                 * }*/
                cgTargetX             = toX;
                cgTargetY             = toY;
                centerGridShowCompare = true;
                dbg("Release - show compare");
            }
        }
        private void HandlePointerEventFrameworkElement(FrameworkElement uiElement, PointerRoutedEventArgs pointerRoutedEventArgs, PointerState pointerState)
        {
            HandlePointerEvent(pointerRoutedEventArgs.GetCurrentPoint(uiElement), pointerState);

            pointerRoutedEventArgs.Handled = true;
        }
Exemplo n.º 29
0
 /// <summary>
 ///     Hack for pivot not to consume mouse wheel.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PinPivotItem_OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
 {
     ScrollView.ChangeView(null, ScrollView.VerticalOffset -
                           e.GetCurrentPoint(ScrollView).Properties.MouseWheelDelta, null);
 }
Exemplo n.º 30
0
        private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (scrollViewer == null)
            {
                return;
            }

            var currentPoint   = e.GetCurrentPoint(uiElement);
            var verticalOffset = scrollViewer.VerticalOffset;

            if (selectionState == SelectionState.Starting)
            {
                if (!HasMovedMinimalDelta(originDragPoint.X, originDragPoint.Y - verticalOffset, currentPoint.Position.X, currentPoint.Position.Y))
                {
                    return;
                }

                // Clear selected items once if the pointer is pressed and moved
                selectionStrategy.StartSelection();
                OnSelectionStarted();
                selectionState = SelectionState.Active;
            }
            if (currentPoint.Properties.IsLeftButtonPressed)
            {
                var originDragPointShifted = new Point(originDragPoint.X, originDragPoint.Y - verticalOffset); // Initial drag point relative to the topleft corner
                base.DrawRectangle(currentPoint, originDragPointShifted, uiElement);
                // Selected area considering scrolled offset
                var rect = new System.Drawing.Rectangle((int)Canvas.GetLeft(selectionRectangle), (int)Math.Min(originDragPoint.Y, currentPoint.Position.Y + verticalOffset), (int)selectionRectangle.Width, (int)Math.Abs(originDragPoint.Y - (currentPoint.Position.Y + verticalOffset)));
                foreach (var item in uiElement.Items.ToList().Except(itemsPosition.Keys))
                {
                    var listViewItem = (FrameworkElement)uiElement.ContainerFromItem(item); // Get ListViewItem
                    if (listViewItem == null)
                    {
                        continue; // Element is not loaded (virtualized list)
                    }

                    var gt             = listViewItem.TransformToVisual(uiElement);
                    var itemStartPoint = gt.TransformPoint(new Point(0, verticalOffset)); // Get item position relative to the top of the list (considering scrolled offset)
                    var itemRect       = new System.Drawing.Rectangle((int)itemStartPoint.X, (int)itemStartPoint.Y, (int)listViewItem.ActualWidth, (int)listViewItem.ActualHeight);
                    itemsPosition[item] = itemRect;
                }

                foreach (var item in itemsPosition.ToList())
                {
                    try
                    {
                        if (rect.IntersectsWith(item.Value))
                        {
                            selectionStrategy.HandleIntersectionWithItem(item.Key);
                        }
                        else
                        {
                            selectionStrategy.HandleNoIntersectionWithItem(item.Key);
                        }
                    }
                    catch (ArgumentException)
                    {
                        // Item is not present in the ItemsSource
                        itemsPosition.Remove(item);
                    }
                }
                if (currentPoint.Position.Y > uiElement.ActualHeight - 20)
                {
                    // Scroll down the list if pointer is at the bottom
                    var scrollIncrement = Math.Min(currentPoint.Position.Y - (uiElement.ActualHeight - 20), 40);
                    scrollViewer.ChangeView(null, verticalOffset + scrollIncrement, null, false);
                }
                else if (currentPoint.Position.Y < 20)
                {
                    // Scroll up the list if pointer is at the top
                    var scrollIncrement = Math.Min(20 - currentPoint.Position.Y, 40);
                    scrollViewer.ChangeView(null, verticalOffset - scrollIncrement, null, false);
                }
            }
        }