private void Canvas_PointerMoved_1(object sender, PointerRoutedEventArgs e)
        {
            Canvas canvas = (sender as Canvas);

            if (canvas == null)
            {
                return;
            }
            Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(canvas);
            uint ptrId = pt.PointerId;

            if (contacts.ContainsKey(ptrId) && contacts[ptrId].HasValue)
            {
                Point currentContact  = pt.Position;
                Point previousContact = contacts[ptrId].Value;
                if (Distance(currentContact, previousContact) > 4)
                {
                    Line l = new Line()
                    {
                        X1 = previousContact.X,
                        Y1 = previousContact.Y,
                        X2 = currentContact.X,
                        Y2 = currentContact.Y,
                        StrokeThickness  = STROKETHICKNESS,
                        Stroke           = new SolidColorBrush(Colors.Red),
                        StrokeEndLineCap = PenLineCap.Round
                    };

                    contacts[ptrId] = currentContact;
                    canvas.Children.Add(l);
                }
            }
        }
 void targetContainer_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     foreach (TextBlock tb in pointerInfo.Children)
     {
         if (tb.Name == e.Pointer.PointerId.ToString())
         {
             pointerInfo.Children.Remove(tb);
         }
     }
     Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(targetContainer);
     // Update event sequence.
     eventLog.Text += "\nUp: " + pt.PointerId;
     // Change background color of target when pointer contact detected.
     targetContainer.Fill = new SolidColorBrush(Windows.UI.Colors.Red);
     if (contacts.ContainsKey(pt.PointerId))
     {
         checkSwipe();
         contacts[pt.PointerId] = null;
         contacts.Remove(pt.PointerId);
         startLocation.Remove(pt.PointerId);
         if (pointSwiped.ContainsKey(pt.PointerId))
         {
             pointSwiped.Remove(pt.PointerId);
         }
         --numActiveContacts;
     }
     e.Handled = true;
 }
 // PointerPressed and PointerReleased events do not always occur in pairs.
 // Your app should listen for and handle any event that might conclude a pointer down action
 // (such as PointerExited, PointerCanceled, and PointerCaptureLost).
 void targetContainer_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (Convert.ToBoolean(SupportedContacts.TouchPresent) && (numActiveContacts > SupportedContacts.Contacts))
     {
         // cannot support more contacts
         eventLog.Text += "\nNumber of contacts exceeds the number supported by the device.";
         return;
     }
     Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(targetContainer);
     // Update event sequence.
     eventLog.Text += "\nDown: " + pt.PointerId;
     // Change background color of target when pointer contact detected.
     targetContainer.Fill = new SolidColorBrush(Windows.UI.Colors.Green);
     // Check if pointer already exists (if enter occurred prior to down).
     if (contacts.ContainsKey(pt.PointerId))
     {
         return;
     }
     contacts[pt.PointerId]      = pt;
     startLocation[pt.PointerId] = pt.Position;
     pointSwiped[pt.PointerId]   = false;
     ++numActiveContacts;
     e.Handled = true;
     // Display pointer details.
     createInfoPop(e);
 }
 private void targetContainer_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(targetContainer);
     // Update event sequence.
     eventLog.Text += "\nPointer exited: " + pt.PointerId;
     if (contacts.ContainsKey(pt.PointerId))
     {
         checkSwipe();
         contacts[pt.PointerId] = null;
         contacts.Remove(pt.PointerId);
         startLocation.Remove(pt.PointerId);
         if (pointSwiped.ContainsKey(pt.PointerId))
         {
             pointSwiped.Remove(pt.PointerId);
         }
         --numActiveContacts;
     }
     // Update the UI and pointer details.
     foreach (TextBlock tb in pointerInfo.Children)
     {
         if (tb.Name == e.Pointer.PointerId.ToString())
         {
             pointerInfo.Children.Remove(tb);
         }
     }
     if (contacts.Count == 0)
     {
         targetContainer.Fill = new SolidColorBrush(Windows.UI.Colors.Gray);
     }
     e.Handled = true;
 }
예제 #5
0
        private void SlidePanel_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptr = e.GetCurrentPoint(sender as UIElement);
            Point pt = ptr.Position;

            if (pt.X <= _panelLeft.Width)
            {
                _panelRight.Visibility = Visibility.Collapsed;
                if (_child.Margin.Left < 0)
                {
                    _panelLeft.Visibility = Visibility.Visible;
                }
            }
            else if (pt.X >= this.Width - _panelRight.Width)
            {
                _panelLeft.Visibility = Visibility.Collapsed;
                if (_child.Margin.Right < 0)
                {
                    _panelRight.Visibility = Visibility.Visible;
                }
            }
            else
            {
                _panelRight.Visibility = _panelLeft.Visibility = Visibility.Collapsed;
            }
        }
예제 #6
0
        private void viewPane_MouseUp(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            CalcPoint   mousePos = new CalcPoint(ptrPt.Position);
            MouseButton mB       = MouseButton.NONE;

            MouseObject mousePoint;

            if (leftpointer != null)
            {
                if (leftpointer.PointerId.Equals(e.Pointer.PointerId))
                {
                    leftpointer = null;
                    mB          = MouseButton.LEFT;
                }
            }

            if (rightpointer != null)
            {
                if (rightpointer.PointerId.Equals(e.Pointer.PointerId))
                {
                    rightpointer = null;
                    mB           = MouseButton.RIGHT;
                }
            }

            mousePoint = new MouseObject(mB, mousePos);

            mouse.viewPane_Released(mousePoint);
        }
예제 #7
0
 private void scrollViewer_PointerInit(PointerRoutedEventArgs e)
 {
     _initialHorizontalOffset = scrollViewer.HorizontalOffset;
     _initialVerticalOffset   = scrollViewer.VerticalOffset;
     _initialPoint            = e.GetCurrentPoint(scrollViewer);
     _lastClickedTime         = DateTime.Now;
 }
예제 #8
0
파일: MainPage.xaml.cs 프로젝트: Yup746/DP
 //Anything on the paint surface gets pressed, even the drawings already there
 private void mouseDown(object sender, PointerRoutedEventArgs e)
 {
     //If the move tool is selected, this part (initializes and) moves the selected shapes or group
     if (tool == "Move" && ((FrameworkElement)sender).Name == paintSurface.Name)
     {
         dragStart = e.GetCurrentPoint(paintSurface);
         Update(true);
     }
     //If the select tool is selected, this part will select or unselect any shape or group
     else if (tool == "Select" && ((FrameworkElement)sender).Name != paintSurface.Name)
     {
         lptag = Convert.ToInt32((e.OriginalSource as FrameworkElement).Tag);
         bool lptagselected  = false;
         int  actualselected = lptag;
         foreach (int c in selected)
         {
             if (selected.Contains(lptag) || group.FindID(c).FindID(lptag).type != "Placeholder")
             {
                 lptagselected  = true;
                 actualselected = c;
             }
         }
         if (!lptagselected)
         {
             selected.Add(lptag);
         }
         else
         {
             if (selected.Contains(lptag))
             {
                 selected.Remove(lptag);
             }
             else
             {
                 selected.Remove(actualselected);
             }
         }
         if (selected.Count == 1)
         {
             anchor = selected[0];
         }
         Update(false);
     }
     //This part initiates the drawing of a shape
     else if (tool == "Rectangle" || tool == "Ellipse")
     {
         itemcount++;
         dragStart = e.GetCurrentPoint(paintSurface);
         Composite newshape = new Composite(itemcount, tool);
         newshape.height = 1;
         newshape.width  = 1;
         newshape.x      = e.GetCurrentPoint(paintSurface).Position.X;
         newshape.y      = e.GetCurrentPoint(paintSurface).Position.Y;
         Add addAction = new Add(group, newshape);
         actionmanager.takeAction(addAction);
         actionmanager.executeActions();
         Update(true);
         Update(false);
     }
 }
예제 #9
0
        void Pointer_Clicked(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint           currentPoint      = e.GetCurrentPoint(GridMain);
            Windows.UI.Input.PointerPointProperties pointerProperties = currentPoint.Properties;

            string temp = "none";

            if (pointerProperties.IsLeftButtonPressed)
            {
                temp = "Left";
            }
            if (pointerProperties.IsMiddleButtonPressed)
            {
                temp = "Scroll";
            }
            if (pointerProperties.IsRightButtonPressed)
            {
                temp = "Right";
            }

            spKeyboard.Children.Insert(0, (new TextBlock()
            {
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = Convert.ToString($"{temp} Mouse Button Clicked at " + DateTime.Now.ToString("h:mm:ss fffffff"))
            }));
        }
예제 #10
0
        public bool DrawBegin(Vector2 position, Windows.UI.Input.PointerPoint pointerPoint, out List <Vector2Int> _coveredTiles, out TileRect _tileRect)
        {
            _coveredTiles = null;
            _tileRect     = new TileRect();
            if (CurrentLayout == null || currentBrush == null)
            {
                return(false);
            }
            //PaintingTexture.CopyTo(PaintingTextureBackup);
            UpdateBrushPropertyButDontUpload();
            UpdateBrushData(position, pointerPoint);
            brushData.FillPointerData();
            brushDataBuffer.UpdateResource(brushData);
            CurrentLayout.saved = false;
            List <Vector2Int> tilesCovered = GetPaintingTiles(position, position, out TileRect coveredRect);

            if (tilesCovered.Count != 0)
            {
                ComputeBrush(currentBrush.cBegin, tilesCovered);
                _coveredTiles = tilesCovered;
                _tileRect     = coveredRect;
            }
            drawPrevPos = position;
            return(true);
        }
예제 #11
0
        private void GameBoard_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint pointer = e.GetCurrentPoint(gameBoard);
            Point pointerPosition = GetGridPosition(pointer);

            lock (hoverLock)
            {
                GetHoveredShip(pointerPosition);
            }
            lock (clickedLock)
            {
                if (clickedShip != null && pointerPosition.X > -1)
                {
                    Point newMainPoint;
                    if (clickedShip.Vertical)
                    {
                        newMainPoint = new Point(pointerPosition.X, pointerPosition.Y - clickedShipTile);
                    }
                    else
                    {
                        newMainPoint = new Point(pointerPosition.X - clickedShipTile, pointerPosition.Y);
                    }
                    int result = clickedShip.Move(newMainPoint);
                    if (result == 1)
                    {
                        moveError = new Tuple <Point, int>(newMainPoint, 5);
                    }
                    else
                    {
                        moveError = null;
                    }
                }
            }
        }
예제 #12
0
        private Point GetGridPosition(Windows.UI.Input.PointerPoint pointerPosition)
        {
            double x = pointerPosition.Position.X;
            double y = pointerPosition.Position.Y;

            if (x >= Globals.Adjust(40) && x <= Globals.Adjust(670) && y >= Globals.Adjust(30) && y <= Globals.Adjust(660))
            {
                x = x - Globals.Adjust(40);
                y = y - Globals.Adjust(30);
                bool xSet = false;
                bool ySet = false;
                for (int i = 0; i < 9; i++)
                {
                    if (x <= Globals.Adjust(70 * (i + 1)) && !xSet)
                    {
                        x    = i;
                        xSet = true;
                    }
                    if (y <= Globals.Adjust(70 * (i + 1)) && !ySet)
                    {
                        y    = i;
                        ySet = true;
                    }
                    if (xSet && ySet)
                    {
                        break;
                    }
                }
                return(new Point(x, y));
            }
            return(new Point(-1, -1));
        }
예제 #13
0
        private void Control_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Pointer ptr = e.Pointer;

            if (ptr.PointerDeviceType == PointerDeviceType.Mouse)
            {
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(this);
                if (ptrPt.Properties.IsLeftButtonPressed)
                {
                }
                if (ptrPt.Properties.IsMiddleButtonPressed)
                {
                }
                if (ptrPt.Properties.IsRightButtonPressed)
                {
                    // Right Mouse click
                    numActiveContacts = 2;
                }
            }
            else if (ptr.PointerDeviceType == PointerDeviceType.Touch)
            {
                numActiveContacts++;
            }

            e.Handled = true;
        }
예제 #14
0
        // throws ArgumentException if pointerPoint.pointerId is already in live rendering mode
        public void EnterLiveRendering(Windows.UI.Input.PointerPoint pointerPoint, Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes)
        {
            uint pointerId = pointerPoint.PointerId;

            // Create and initialize the data structures necessary to render a polyline in XAML.
            var stroke = new Windows.UI.Xaml.Media.PolyLineSegment();

            stroke.Points.Add(pointerPoint.Position);
            var figure = new Windows.UI.Xaml.Media.PathFigure();

            figure.StartPoint = pointerPoint.Position;
            figure.Segments.Add(stroke);
            var geometry = new Windows.UI.Xaml.Media.PathGeometry();

            geometry.Figures.Add(figure);
            var path = new Windows.UI.Xaml.Shapes.Path();

            path.Data = geometry;

            // Set the stroke's graphical properties, which are controlled by the Path object
            path.Stroke             = new Windows.UI.Xaml.Media.SolidColorBrush(drawingAttributes.Color);
            path.StrokeThickness    = drawingAttributes.Size.Width;
            path.StrokeLineJoin     = Windows.UI.Xaml.Media.PenLineJoin.Round;
            path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round;

            // Update dictionaries
            liveStrokes.Add(pointerId, stroke); // throws ArgumentException if pointerId is already in the dictionary
            livePaths.Add(pointerId, path);     // throws ArgumentException if pointerId is already in the dictionary

            // Add path to render so that it is rendered (on top of all the elements with same ZIndex).
            // We want the live render to be on top of the Bezier render, so we set the ZIndex of the elements of the
            // live render to 2 and that of the elements of the Bezier render to 1.
            render.Children.Add(path);
            Windows.UI.Xaml.Controls.Canvas.SetZIndex(path, 2);
        }
예제 #15
0
        private void LabelingArea_PointerMoved(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;
                    }
                }
            }
        }
예제 #16
0
        private void CanvasPointerPressed(
            Object sender,
            PointerRoutedEventArgs e)
        {
            Debug.WriteLine("Mouse clicked on canvas");
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                Windows.UI.Input.PointerPoint pointerPoint = e.GetCurrentPoint(this.MainCanvas);
                Point  pointerPosition = pointerPoint.Position;
                String mouseButton     = "";

                if (pointerPoint.Properties.IsLeftButtonPressed)
                {
                    mouseButton = "Left";
                }
                else if (pointerPoint.Properties.IsRightButtonPressed)
                {
                    mouseButton = "Right";
                }
                else if (pointerPoint.Properties.IsMiddleButtonPressed)
                {
                    mouseButton = "Center";
                }

                Boolean shapeFound = false;
                foreach (KeyValuePair <UInt32, GraphVertex> kvp in this.currentGraph.Vertices)
                {
                    Rect bounds = kvp.Value.Circle.ComputeBounds();
                    if (bounds.Contains(pointerPosition) == true)
                    {
                        Debug.WriteLine("vertex clicked!");
                        this.StatusTextBlock.Text = "Vertex clicked";
                        ToggleSelectVertex(kvp.Value);
                        shapeFound = true;
                        break;
                    }
                }

                if (shapeFound == false)
                {
                    foreach (KeyValuePair <UInt32, GraphEdge> kvp in this.currentGraph.Edges)
                    {
                        Rect bounds = kvp.Value.Line.ComputeBounds();
                        if (bounds.Contains(pointerPosition) == true)
                        {
                            Debug.WriteLine("edge clicked!");
                            this.StatusTextBlock.Text = "Edge clicked";
                            ToggleSelectEdge(kvp.Value);
                            break;
                        }
                    }
                }

                if (shapeFound == true)
                {
                    //this.MainCanvas.Invalidate();
                }
            }
        }
예제 #17
0
        private void viewPane_MouseDown(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            CalcPoint   mousePos = new CalcPoint(ptrPt.Position);
            MouseButton mB       = MouseButton.NONE;
            MouseObject mousePoint;

            //status2 += "Mouse Down" + "\n";

            if (ptrPt.Properties.IsRightButtonPressed)
            {
                rightpointer = e.Pointer;
                mB           = MouseButton.RIGHT;
            }

            if (ptrPt.Properties.IsLeftButtonPressed)
            {
                leftpointer = e.Pointer;
                mB          = MouseButton.LEFT;
            }

            if (ptrPt.Properties.IsMiddleButtonPressed)
            {
                leftpointer = e.Pointer;
                mB          = MouseButton.MIDDLE;
            }

            mousePoint = new MouseObject(mB, mousePos);

            mouse.viewPane_Pressed(mousePoint);
        }
예제 #18
0
        private void DroneClickPress(object sender, PointerRoutedEventArgs e)
        {
            if (e.GetCurrentPoint(null).Properties.IsLeftButtonPressed)
            {
                ContentControl c = sender as ContentControl;
                c.Focus(FocusState.Pointer);

                Image i = c.Content as Image;
                Windows.UI.Input.PointerPoint ptr = e.GetCurrentPoint(Map);

                c.SetValue(Canvas.LeftProperty, ptr.Position.X - i.Width / 2);
                c.SetValue(Canvas.TopProperty, ptr.Position.Y - i.Height / 2);

                if (ptr.Position.X < i.Width / 2)
                {
                    c.SetValue(Canvas.LeftProperty, 0);
                }
                else if (ptr.Position.X > Map.Width - i.Width / 2)
                {
                    c.SetValue(Canvas.LeftProperty, Map.Width - i.Width);
                }

                if (ptr.Position.Y < i.Height / 2)
                {
                    c.SetValue(Canvas.TopProperty, 0);
                }
                else if (ptr.Position.Y > Map.Height - i.Height / 2)
                {
                    c.SetValue(Canvas.TopProperty, Map.Height - i.Height);
                }
            }
        }
        void Scenario1OutputRoot_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(Scenario1OutputRoot);
            uint ptrId = pt.PointerId;

            if (pt.Properties.PointerUpdateKind != Windows.UI.Input.PointerUpdateKind.Other)
            {
                this.buttonPress.Text = pt.Properties.PointerUpdateKind.ToString();
            }
            if (contacts.ContainsKey(ptrId) && contacts[ptrId].HasValue)
            {
                Point currentContact  = pt.Position;
                Point previousContact = contacts[ptrId].Value;
                if (Distance(currentContact, previousContact) > 4)
                {
                    Line l = new Line()
                    {
                        X1 = previousContact.X,
                        Y1 = previousContact.Y,
                        X2 = currentContact.X,
                        Y2 = currentContact.Y,
                        StrokeThickness  = STROKETHICKNESS,
                        Stroke           = new SolidColorBrush(Colors.Red),
                        StrokeEndLineCap = PenLineCap.Round
                    };

                    contacts[ptrId] = currentContact;
                    ((System.Collections.Generic.IList <UIElement>)Scenario1OutputRoot.Children).Add(l);
                }
            }

            e.Handled = true;
        }
예제 #20
0
파일: MainPage.xaml.cs 프로젝트: Yup746/DP
 //If the mouse button is released and a move action was being executed, then this cleans up after itself
 private void mouseUp(object sender, PointerRoutedEventArgs e)
 {
     if (tool == "Move")
     {
         dragStart = null;
     }
 }
예제 #21
0
        private void Grid_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint pointer = e.GetCurrentPoint(gameBoard);
            Tuple <Point, string>         result  = GetGridPosition(pointer);
            Point  pointerPosition = result.Item1;
            string pointerGrid     = result.Item2;

            if (pointerGrid.Equals("home"))
            {
                lock (hoverLock)
                {
                    if (hoveredShip != null)
                    {
                        lock (clickedLock)
                        {
                            clickedShip = hoveredShip;
                            DisplayError("");
                        }
                    }
                }
            }
            else if (pointerGrid.Equals("target"))
            {
                //TODO
                if (clickedShip == null && Globals.player.HasTurn)
                {
                    DisplayError("Must Select Ship First!");
                }
                else
                {
                    DisplayError("");
                }
            }
        }
예제 #22
0
 // If the pointer is moved and you are collecting data,
 // convert the pixel coordinates to "Unity" coordinates (a 30x30 grid with the origin in the lower left hand corner),
 // and save the data to a string
 void Pointer_Moved(object sender, PointerRoutedEventArgs e)
 {
     if (collectdata == true)
     {
         // Retrieve the point associated with the current event
         Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(mainCanvas);
         // translate the coordinates so that the person is at (0,0)
         double tempx = currentPoint.Position.X - x_person_tablet;
         double tempy = currentPoint.Position.Y - y_person_tablet;
         // NOTE THE REST OF THE CONVERSION HAS BEEN REMOVES AND PERFORMED AFTER SENDING OVER TCP SOCKET
         int x_unity = Convert.ToInt32(Math.Round(tempx));
         int y_unity = Convert.ToInt32(Math.Round(tempy));
         if (string_of_coordinates == "")
         {
             string_of_coordinates = string_of_coordinates + "5,";
         }
         if ((x_unity_prev == x_unity) && (y_unity_prev == y_unity))
         {
             //System.Diagnostics.Debug.WriteLine("Repeat Coordinate- skipped");
         }
         else
         {
             string_of_coordinates = string_of_coordinates + x_unity.ToString() + ',' + y_unity.ToString() + ',';
             System.Diagnostics.Debug.WriteLine("Position: X- {0} Y- {1}", x_unity, y_unity);
         }
         x_unity_prev = x_unity;
         y_unity_prev = y_unity;
     }
 }
예제 #23
0
        private void viewPane_UpdateMousePos(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            lastMousePosition = new CalcPoint(ptrPt.Position);

            //status += "Posx:" + mousePos.X + "/ " + mousePos.Y + "\n";
        }
        void Pointer_Released(object sender, PointerRoutedEventArgs e)
        {
            // Retrieve the point associated with the current event
            Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(mainCanvas);

            // Remove the popup corresponding to the pointer
            HidePropertyPopUp(currentPoint);
        }
예제 #25
0
 private void MainWindow_PointerMoved(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Input.PointerPoint ptr = e.GetCurrentPoint(sender as UIElement);
     if (ptr.Position.X > menuPanel.Width)
     {
         menuPanel.Visibility = Visibility.Collapsed;
     }
 }
예제 #26
0
 void Pointer_Entered(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(MainCanvas);
     if (currentPoint.IsInContact)
     {
         handlePointerEntered(currentPoint.Position);
     }
 }
예제 #27
0
 void Pointer_Moved(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(GridMain);
     spMouse.Children.Insert(0, (new TextBlock()
     {
         Text = Convert.ToString($"Cursor on X={Math.Round(currentPoint.Position.X, 0)} Y={Math.Round(currentPoint.Position.Y, 0)} at " + DateTime.Now.ToString("h:mm:ss fffffff"))
     }));
 }
        void Pointer_Pressed(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint currentPoint = e.GetCurrentPoint(mainCanvas);

            // Retrieve the properties for the curret PointerPoint and display
            // them alongside the pointer's location on screen
            CreateOrUpdatePropertyPopUp(currentPoint);
        }
 void HidePropertyPopUp(Windows.UI.Input.PointerPoint currentPoint)
 {
     if (popups.ContainsKey(currentPoint.PointerId))
     {
         mainCanvas.Children.Remove(popups[currentPoint.PointerId]);
         popups[currentPoint.PointerId] = null;
         popups.Remove(currentPoint.PointerId);
     }
 }
예제 #30
0
 //! @brief  handle the user calibrating
 private void OnPointerMoved(object sender, PointerRoutedEventArgs args)
 {
     m_rotation.Angle = 0;
     Windows.UI.Input.PointerPoint pointer = args.GetCurrentPoint(m_calibrateRotationRoot);
     if (pointer.Properties.IsLeftButtonPressed)
     {
         CalibrateFromPoint(pointer.Position);
     }
 }
예제 #31
0
        /// <summary>
        /// Raises corresponding events to update mouse state
        /// </summary>
        /// <param name="p"><see cref="PointerPoint"/> instance that contains all needed information</param>
        private void UpdateMouse(WinRTPointerPoint p)
        {
            // adjust mouse position from Device-Independent-Pixels to physical pixels
            pointerPosition = new Vector2((float)p.Position.X / windowSize.Width, (float)p.Position.Y / windowSize.Height);

            // update mouse wheel delta
            OnMouseWheel(p.Properties.MouseWheelDelta);

            var properties = p.Properties;

            // update mouse buttons state
            RaiseButtonChange(properties.IsLeftButtonPressed, MouseButton.Left);
            RaiseButtonChange(properties.IsMiddleButtonPressed, MouseButton.Middle);
            RaiseButtonChange(properties.IsRightButtonPressed, MouseButton.Right);
            RaiseButtonChange(properties.IsXButton1Pressed, MouseButton.XButton1);
            RaiseButtonChange(properties.IsXButton2Pressed, MouseButton.XButton2);
        }
예제 #32
0
        /// <summary>
        /// Raises corresponding events to update mouse state
        /// </summary>
        /// <param name="p"><see cref="PointerPoint"/> instance that contains all needed information</param>
        private void UpdateMouse(WinRTPointerPoint p)
        {
            // adjust mouse position from Device-Independent-Pixels to physical pixels
            var dipFactor = DisplayProperties.LogicalDpi / 96.0f;
            pointerX = (int)(p.Position.X * dipFactor);
            pointerY = (int)(p.Position.Y * dipFactor);

            // update mouse wheel delta
            OnMouseWheel(p.Properties.MouseWheelDelta);

            var properties = p.Properties;

            // update mouse buttons state
            RaiseButtonChange(properties.IsLeftButtonPressed, MouseButton.Left);
            RaiseButtonChange(properties.IsMiddleButtonPressed, MouseButton.Middle);
            RaiseButtonChange(properties.IsRightButtonPressed, MouseButton.Right);
            RaiseButtonChange(properties.IsXButton1Pressed, MouseButton.XButton1);
            RaiseButtonChange(properties.IsXButton2Pressed, MouseButton.XButton2);
        }
 private void CanvasControl_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     _pp = e.GetCurrentPoint(ccCanvas);
     ccCanvas.Invalidate();
 }