Inheritance: IPointer
示例#1
0
        private void pointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            PointerPoint ptrPt     = e.GetCurrentPoint(img);
            uint         pointerId = ptrPt.PointerId;

            textbox1.Text += "P id:" + ptrPt.PointerId + "\tX:\t" + ptrPt.Position.X + "\tY:\t" + ptrPt.Position.Y + "\n";

            int   frecuencia = (int)(ptrPt.Position.X * 2048.0f / 640.0f);
            float vol        = (float)(ptrPt.Position.Y / 1280.0f);

            if (!dictSonidos.ContainsKey(ptrPt.PointerId))
            {
                dictSonidos.Add(ptrPt.PointerId, new sonido(vol, frecuencia, ptrPt.PointerId, xaudio2, syntActual, envoActual, envolventeFreq));

                dictSonidos[pointerId].play();
            }
            else
            {
                //dictSonidos[ptrPt.PointerId]= new sonido(vol,frecuencia, ptrPt.PointerId, xaudio2);
                dictSonidos[pointerId].play();
            }

            e.Handled = true;
        }
        // </SnippetPointerMoved>

// <SnippetPointerEntered>
        private void Target_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Update event sequence.
            eventLog.Text += "\nOver: " + ptr.PointerId;

            if (contacts.Count == 0)
            {
                // Change background color of target when pointer contact detected.
                Target.Fill = new SolidColorBrush(Windows.UI.Colors.Blue);
            }

            // Check if pointer already exists (if enter occurred prior to down).
            if (contacts.ContainsKey(ptr.PointerId))
            {
                return;
            }

            // Add contact to dictionary.
            contacts[ptr.PointerId] = ptr;
            ++numActiveContacts;

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            // Display pointer details.
            createInfoPop(e);
        }
示例#3
0
        private void MainCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            PointerPoint pt = e.GetCurrentPoint(MainCanvas);


            Stick.Visibility            = Visibility.Visible;
            Stick.RenderTransformOrigin = new Point(0, 0);

            ScaleTransform myScaleTransform = new ScaleTransform();

            myScaleTransform.ScaleX = MainCanvas.ActualWidth / 500;
            myScaleTransform.ScaleY = MainCanvas.ActualWidth / 500;

            TranslateTransform myTranslateTransfrom = new TranslateTransform();

            myTranslateTransfrom.X = pt.Position.X - (170 * myScaleTransform.ScaleX);
            myTranslateTransfrom.Y = pt.Position.Y - (170 * myScaleTransform.ScaleY);

            TransformGroup myTransformGroup = new TransformGroup();

            myTransformGroup.Children.Add(myScaleTransform);
            myTransformGroup.Children.Add(myTranslateTransfrom);

            Stick.RenderTransform = myTransformGroup;
            Stick.Base_PointerPressed(sender, e);
        }
        private void MapCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Multiple, simultaneous mouse button inputs are processed here.
            // Mouse input is associated with a single pointer assigned when
            // mouse input is first detected.
            // Clicking additional mouse buttons (left, wheel, or right) during
            // the interaction creates secondary associations between those buttons
            // and the pointer through the pointer pressed event.
            // The pointer released event is fired only when the last mouse button
            // associated with the interaction (not necessarily the initial button)
            // is released.
            // Because of this exclusive association, other mouse button clicks are
            // routed through the pointer move event.
            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // To get mouse state, we need extended pointer details.
                // We get the pointer info through the getCurrentPoint method
                // of the event argument.
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(MapCanvas);
                if (ptrPt.Properties.IsLeftButtonPressed)
                {
                }
                if (ptrPt.Properties.IsMiddleButtonPressed)
                {
                }
                if (ptrPt.Properties.IsRightButtonPressed)
                {
                }
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
// </SnippetInitialize>

// <SnippetPointerPressed>
        // 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).
        // For this example, we track the number of contacts in case the
        // number of contacts has reached the maximum supported by the device.
        // Depending on the device, additional contacts might be ignored
        // (PointerPressed not fired).
        void Target_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (Convert.ToBoolean(touchCapabilities.TouchPresent) && (numActiveContacts > touchCapabilities.Contacts))
            {
                // Number of supported contacts exceeded.
                return;
            }

            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Update event sequence.
            eventLog.Text += "\nDown: " + ptr.PointerId;

            // Change background color of target when pointer contact detected.
            Target.Fill = new SolidColorBrush(Windows.UI.Colors.Green);

            // Check if pointer already exists (for example, enter occurred prior to press).
            if (contacts.ContainsKey(ptr.PointerId))
            {
                return;
            }
            // Add contact to dictionary.
            contacts[ptr.PointerId] = ptr;
            ++numActiveContacts;

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            // Display pointer details.
            createInfoPop(e);
        }
        void MapCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // If event source is mouse or touchpad and the pointer is still
            // over the MapCanvas, retain pointer and pointer details.
            // Return without removing pointer from pointers dictionary.
            // For this example, we assume a maximum of one mouse pointer.
            if (ptr.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // Update MapCanvas UI.


                // Remove contact from dictionary.
                if (contacts.ContainsKey(ptr.PointerId))
                {
                    contacts[ptr.PointerId] = null;
                    contacts.Remove(ptr.PointerId);
                    --numActiveContacts;
                }

                // Release the pointer from the MapCanvas.
                MapCanvas.ReleasePointerCapture(e.Pointer);


                // Prevent most handlers along the event route from handling the same event again.
                e.Handled = true;
            }
            else
            {
            }
        }
// </SnippetPointerPressed>

        // <SnippetPointerReleased>
        void Target_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Update event sequence.
            eventLog.Text += "\nUp: " + ptr.PointerId;

            // If event source is mouse pointer and the pointer is still
            // over the target, retain pointer and pointer details.
            // Return without removing pointer from pointers dictionary.
            // For this example, we assume a maximum of one mouse pointer.
            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                Target.Fill = new SolidColorBrush(Windows.UI.Colors.Blue);
                return;
            }

            // Update target UI.
            Target.Fill = new SolidColorBrush(Windows.UI.Colors.Red);


            destroyInfoPop(ptr);

            // Remove contact from dictionary.
            if (contacts.ContainsKey(ptr.PointerId))
            {
                contacts[ptr.PointerId] = null;
                contacts.Remove(ptr.PointerId);
                --numActiveContacts;
            }
            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
        //https://docs.microsoft.com/de-de/windows/uwp/input-and-devices/handle-pointer-input
        // 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).
        // For this example, we track the number of contacts in case the
        // number of contacts has reached the maximum supported by the device.
        // Depending on the device, additional contacts might be ignored
        // (PointerPressed not fired).
        void MapCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            // Lock the pointer to the MapCanvas.
            MapCanvas.CapturePointer(e.Pointer);

            if ((MapModeEnum)MapMode == MapModeEnum.Set)
            {
                SetTree(e.GetCurrentPoint(mapImage), e.GetCurrentPoint(MapCanvas));
            }

            if ((MapModeEnum)MapMode == MapModeEnum.Move)
            {
                MoveTree(e.GetCurrentPoint(mapImage), e.GetCurrentPoint(MapCanvas));
            }
            // Check if pointer already exists (for example, enter occurred prior to press).
            if (contacts.ContainsKey(ptr.PointerId))
            {
                return;
            }
            // Add contact to dictionary.
            contacts[ptr.PointerId] = ptr;
            ++numActiveContacts;
        }
        // </SnippetPointerCanceled>

        // <SnippetPointerExited>
        private void Target_PointerExited(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Update event sequence.
            eventLog.Text += "\nPointer exited: " + ptr.PointerId;

            // Remove contact from dictionary.
            if (contacts.ContainsKey(ptr.PointerId))
            {
                contacts[ptr.PointerId] = null;
                contacts.Remove(ptr.PointerId);
                --numActiveContacts;
            }

            // Update the UI and pointer details.
            destroyInfoPop(ptr);

            if (contacts.Count == 0)
            {
                Target.Fill = new SolidColorBrush(Windows.UI.Colors.Red);
            }
            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
示例#10
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();
                }
            }
        }
示例#11
0
        public void Base_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if ((_PointerId == e.Pointer.PointerId) || (isExited == true))
            {
                Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
                PointerPoint pt = e.GetCurrentPoint(Base);

                NormalizeKnopPosition(pt);
            }
        }
示例#12
0
        private void pointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            PointerPoint ptrPt     = e.GetCurrentPoint(img);
            uint         pointerId = ptrPt.PointerId;

            if (dictSonidos.ContainsKey(pointerId))
            {
                dictSonidos.Remove(pointerId);
            }
            e.Handled = true;
        }
示例#13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CanvasPointerPressed(
            Object sender,
            PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // To get mouse state, we need extended pointer details.
                // We get the pointer info through the getCurrentPoint method
                // of the event argument.
                //Windows.UI.Input.PointerPoint ptrPt =
                //    e.GetCurrentPoint(this.MainDrawingCanvas);
                //Point ptrPos = ptrPt.Position;
                //String mouseBtn = "";
                //if (ptrPt.Properties.IsLeftButtonPressed)
                //{
                //    mouseBtn = "Left";

                //    bool shapeFound = false;
                //    foreach (KeyValuePair<Guid, DrawableVertex> kvp in this.appCtx.DrawableVertices)
                //    {
                //        Rect bounds = kvp.Value.Circle.ComputeBounds();
                //        if (bounds.Contains(ptrPos) == true) {
                //            Debug.WriteLine("vertex clicked!");
                //            shapeFound = true;
                //            break;
                //        }
                //    }

                //    if (shapeFound == false)
                //    {
                //        foreach(KeyValuePair<Guid, DrawableEdge> kvp in this.appCtx.DrawableEdges)
                //        {
                //            Rect bounds = kvp.Value.Line.ComputeBounds();
                //            if (bounds.Contains(ptrPos) == true)
                //            {
                //                Debug.WriteLine("edge clicked!");
                //                break;
                //            }
                //        }
                //    }
                //}
                //else if (ptrPt.Properties.IsRightButtonPressed)
                //{
                //    mouseBtn = "Right";
                //}
                //else if (ptrPt.Properties.IsMiddleButtonPressed)
                //{
                //    mouseBtn = "Middle";
                //}
                //Debug.WriteLine(String.Format("{2} mouse btn id {0} pressed at {1}", ptr.PointerId, ptrPos, mouseBtn));
            }
        }
示例#14
0
 private void Page_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
     if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
     {
         Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(this);
         if (ptrPt.Properties.IsXButton1Pressed)
         {
             //On_BackRequested();
         }
     }
 }
示例#15
0
        private void DriveButtonOnPointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            var btn = sender as Button;

            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                this.commandQueue.Enqueue(Tuple.Create(MoveVehicle, StopVehicle, 10));
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
示例#16
0
        private bool TestLeftMouseClick(PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(this);
                if (ptrPt.Properties.IsLeftButtonPressed)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#17
0
        private void CameraButtonOnPointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            var btn = sender as Button;

            if (this.camButtonToken != null &&
                ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                this.camButtonToken.Cancel();
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
        // </SnippetCreateInfoPop>

        // <SnippetDestroyInfoPop>
        void destroyInfoPop(Windows.UI.Xaml.Input.Pointer ptr)
        {
            foreach (var pointerDetails in Container.Children)
            {
                if (pointerDetails.GetType().ToString() == "Windows.UI.Xaml.Controls.TextBlock")
                {
                    TextBlock _TextBlock = (TextBlock)pointerDetails;
                    if (_TextBlock.Name == ptr.PointerId.ToString())
                    {
                        Container.Children.Remove(pointerDetails);
                    }
                }
            }
        }
示例#19
0
        private void SwapChainPanel_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // To get mouse state, we need extended pointer details.
                // We get the pointer info through the getCurrentPoint method
                // of the event argument.
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(swapChainPanel);
                r.SetPointerPoint(ptrPt);
            }

            e.Handled = true;
        }
示例#20
0
        public void Base_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;


            if (_PointerId == 0)
            {
                isExited   = false;
                isInRange  = true;
                _PointerId = e.Pointer.PointerId;
                PointerPoint pt = e.GetCurrentPoint(Base);

                NormalizeKnopPosition(pt);
            }
        }
示例#21
0
        /// <summary>
        /// Rimuove l'effetto tilt ad un FrameworkElement
        /// </summary>
        public void RemoveTilt()
        {
            if(_isOn)
            {
                element.PointerPressed -= TiltDown;
                element.PointerReleased -= TiltUp;
                element.PointerExited -= TiltUp;
                element.PointerCaptureLost -= TiltUp;

                tilt_down = null;
                tilt_up = null;
                element = null;
                point = null;

                _isOn = false;
            }
        }
示例#22
0
        private void FacePhoto_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            // Start here:
            // https://docs.microsoft.com/en-us/azure/cognitive-services/Face/Tutorials/FaceAPIinCSharpTutorial

            //todo: change to an event instead oif DI
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(FacePhoto);

                //txtBoxCaptureStatus.Text = MainPageViewModel.TempDetectedFaceData ?? string.Empty;
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
        // Fires for for various reasons, including:
        //    - User interactions
        //    - Programmatic capture of another pointer
        //    - Captured pointer was deliberately released
        // PointerCaptureLost can fire instead of PointerReleased.
        private void MapCanvas_PointerCaptureLost(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Remove contact from dictionary.
            if (contacts.ContainsKey(ptr.PointerId))
            {
                contacts[ptr.PointerId] = null;
                contacts.Remove(ptr.PointerId);
                --numActiveContacts;
            }

            if (contacts.Count == 0)
            {
            }
            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
        private void MapCanvas_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;



            // Check if pointer already exists (for example, enter occurred prior to wheel).
            if (contacts.ContainsKey(ptr.PointerId))
            {
                return;
            }

            // Add contact to dictionary.
            contacts[ptr.PointerId] = ptr;
            ++numActiveContacts;

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
示例#25
0
 private void CanvasPointerMoved(
     Object sender,
     PointerRoutedEventArgs e)
 {
     Debug.WriteLine("Canvas pointer moved");
     Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
     if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
     {
         // get extended pointer details
         //Windows.UI.Input.PointerPoint ptrPoint = e.GetCurrentPoint(MainCanvas);
         //Point ptrPos = ptrPoint.Position;
         //if (ptrPoint.Properties.IsLeftButtonPressed)
         //{
         //    Debug.WriteLine(String.Format("left mouse button: {0}", ptrPoint.PointerId));
         //    foreach (KeyValuePair<Guid, DrawableVertex> kvp in this.drawableGraph.DrawableVertices)
         //    {
         //        Rect bounds = kvp.Value.Circle.ComputeBounds();
         //    }
         //}
     }
 }
示例#26
0
        private void pointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            PointerPoint ptrPt     = e.GetCurrentPoint(img);
            uint         pointerId = ptrPt.PointerId;

            int   frecuenciaN = (int)(ptrPt.Position.X * 2048.0f / 640.0f);
            float volN        = (float)(ptrPt.Position.Y / 1280.0f);

            if (dictSonidos.ContainsKey(pointerId))
            {
                dictSonidos[pointerId].cambioFrec(frecuenciaN, envolventeFreq);
                dictSonidos[pointerId].cambioVol(volN);
                dictSonidos[pointerId].play();
            }

            /*
             * Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
             * PointerPoint ptrPt = e.GetCurrentPoint(img);
             * textbox1.Text += "M:id:" + ptrPt.PointerId + "\tX:\t" + ptrPt.Position.X + "\tY:\t" + ptrPt.Position.Y + "\n";
             * */
            e.Handled = true;
        }
// </SnippetPointerEntered>

        // <SnippetPointerWheel>
        private void Target_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Update event sequence.
            eventLog.Text += "\nMouse wheel: " + ptr.PointerId;

            // Check if pointer already exists (for example, enter occurred prior to wheel).
            if (contacts.ContainsKey(ptr.PointerId))
            {
                return;
            }

            // Add contact to dictionary.
            contacts[ptr.PointerId] = ptr;
            ++numActiveContacts;

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;

            // Display pointer details.
            createInfoPop(e);
        }
示例#28
0
        private void CameraButtonOnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
            var btn = sender as Button;

            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                this.camButtonToken = new CancellationTokenSource();
                Action loop = async() =>
                {
                    while (!this.camButtonToken.IsCancellationRequested)
                    {
                        this.commandQueue.Enqueue(Tuple.Create(MoveCamera, btn.Name.Replace("CAM", string.Empty, StringComparison.OrdinalIgnoreCase), 10));

                        await Task.Delay(TimeSpan.FromMilliseconds(2000));
                    }
                };

                loop.Invoke();
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
        private void Btn_ClickDireito(object sender, PointerRoutedEventArgs e)
        {
            Button btn = (Button)sender;

            Windows.UI.Xaml.Input.Pointer ptr   = e.Pointer;
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(btn);
            var properties = e.GetCurrentPoint(this).Properties;

            if (ptrPt.Properties.IsRightButtonPressed)
            {
                btn.Click          -= Btn_ClickEsquerdo;
                btn.PointerPressed -= Btn_ClickDireito;
                btn.Visibility      = Visibility.Collapsed;

                //desequipar
                if (ListItems.ElementAt <Item>(int.Parse(btn.Name)).GetType() == typeof(Equipamento) &&
                    jogador.EquipamentosEquipados.Contains(ListItems.ElementAt <Item>(int.Parse(btn.Name))))
                {
                    jogador.DesequiparEquipamento(ListItems.ElementAt <Item>(int.Parse(btn.Name)) as Equipamento);
                }

                RemoverItem(jogador.inventario, ListItems.ElementAt <Item>(int.Parse(btn.Name)));
            }
        }
示例#30
0
        public void HandleMoved(Point _position,Pointer _pointer)
        {
            FlagFactory factory = control.factory;
            Pointer pointer = _pointer;
            if (factory.CannotDraw())
                return;

            Point IllusionPoint = _position;
            Point point = new Point();
            point.X = IllusionPoint.X - control.Painter.Margin.Left;
            point.Y = IllusionPoint.Y - control.Painter.Margin.Top;

            if (!IsOnPainter(IllusionPoint))
            {

                if (!factory.MoveOut)
                {
                    factory.MoveOut = true;
                    uint id = pointer.PointerId;

                    if (factory.pointerDictionary.ContainsKey(id))
                        factory.pointerDictionary.Remove(id);
                }

                return;
            }

            if (factory.MoveOut)
            {
                factory.MoveOut = false;
                if (factory.Pressed && !factory.ReleaseAtOut)
                   HandlePressed(_position,_pointer);
                return;
            }

            if (factory.IsWaterbrushOrEraser())
            {
                uint id = pointer.PointerId;

                if (factory.pointerDictionary.ContainsKey(id))
                    factory.pointerDictionary[id].Points.Add(point);
            }

            else if (factory.CurrentPenStyle == 1 && factory.Pressed)
            {
                DrawOilPastel(point);
            }
        }
示例#31
0
文件: TiltEffect.cs 项目: liquidboy/X
        /// <summary>
        /// Begins the tilt effect by preparing the control and doing the 
        /// initial animation.
        /// </summary>
        /// <param name="element">The element to tilt.</param>
        /// <param name="touchPoint">The touch point, in element coordinates.</param>
        /// <param name="centerPoint">The center point of the element in element
        /// coordinates.</param>
        /// <param name="centerDelta">The delta between the 
        /// <paramref name="element"/>'s center and the container's center.</param>
        private static void BeginTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint, Point centerDelta, Pointer p)
        {
            if (tiltReturnStoryboard != null)
            {
                StopTiltReturnStoryboardAndCleanup();
            }

            if (PrepareControlForTilt(element, centerDelta, p) == false)
            {
                return;
            }

            currentTiltElement = element;
            currentTiltElementCenter = centerPoint;
            PrepareTiltReturnStoryboard(element);

            ApplyTiltEffect(currentTiltElement, touchPoint, currentTiltElementCenter);
        }
示例#32
0
        private void Target_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;

            // Multiple, simultaneous mouse button inputs are processed here.
            // Mouse input is associated with a single pointer assigned when
            // mouse input is first detected.
            // Clicking additional mouse buttons (left, wheel, or right) during
            // the interaction creates secondary associations between those buttons
            // and the pointer through the pointer pressed event.
            // The pointer released event is fired only when the last mouse button
            // associated with the interaction (not necessarily the initial button)
            // is released.
            // Because of this exclusive association, other mouse button clicks are
            // routed through the pointer move event.

            //Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint();
            if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                FrameworkElement element = (FrameworkElement)sender;
                int col = Grid.GetColumn(element);

                Layer layer = network.Layers[col];

                if (layer.IsLast == false) // show connections
                {
                    Layer nextLayer   = network.Layers[col + 1];
                    int   nodesInNext = nextLayer.Nodes.Count;

                    // generates lines for every node in next layer

                    for (int i = 0; i < nodesInNext; i++)
                    {
                        // TODO MAKE LINES
                    }
                }

                // gets stack

                StackPanel stack = (StackPanel)NetworkLayout.Children[col];

                // gets ellipse index

                int ellipseIndex = -1;
                for (int i = 0; i < stack.Children.Count; i++)
                {
                    if (stack.Children[i] == (UIElement)element)
                    {
                        ellipseIndex = i;
                    }
                }

                Node node = network.Layers[col].Nodes[ellipseIndex];

                ToolTip toolTip = new ToolTip();
                toolTip.Content = node.A.ToString();

                ToolTipService.SetToolTip(element, toolTip);
            }

            // Prevent most handlers along the event route from handling the same event again.
            e.Handled = true;
        }
示例#33
0
 private Boolean weCareAbout(Pointer pointer)
 {
     switch (pointer.PointerDeviceType) {
         case Windows.Devices.Input.PointerDeviceType.Mouse:
             return settings.EnableMouse;
         case Windows.Devices.Input.PointerDeviceType.Pen:
             return settings.EnablePen;
         case Windows.Devices.Input.PointerDeviceType.Touch:
             return settings.EnableTouch;
         default:
             return true;
     }
 }
示例#34
0
        private void TiltDown(object sender, PointerRoutedEventArgs e)
        {
            point = e.Pointer;
            element.CapturePointer(point);
            element.Projection = new PlaneProjection();

            tilt_down.Stop();
            tilt_down.Begin();

        }
        /// <summary>
        /// Handler for the event when the user starts dragging the dragElement.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position in the child where the user clicked</param>
        /// <param name="pointer">Pointer</param>
        internal void BeginFluidDrag(UIElement child, Point position, Pointer pointer)
        {
            if ((child == null) || (!IsComposing))
                return;

            child.SetValue(Canvas.ZIndexProperty, ZIndexDrag);
            // Capture further pointer events
            child.CapturePointer(pointer);
            _dragElement = child;

            var visual = _fluidVisuals[_dragElement];
            visual.Opacity = (float)DragOpacity;
            visual.CenterPoint = new Vector3((float)position.X, (float)position.Y, 0);
            visual.Scale = new Vector3((float)DragScale, (float)DragScale, 1);
            visual.ImplicitAnimations = _implicitDragAnimationCollection;

            // Set the starting position of the drag
            _dragStartPoint = new Point(position.X, position.Y);
        }
示例#36
0
        private void PointerPressed(PointerPoint pointerPoint, UIElement target, Pointer pointer)
        {
            // To convert from DIPs (device independent pixels) to screen resolution pixels.
            var dipFactor = DisplayProperties.LogicalDpi / 96.0f;
            var pos = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) * dipFactor;

            var isTouch = pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch;

            TouchPanel.AddEvent((int)pointerPoint.PointerId, TouchLocationState.Pressed, pos, !isTouch);
            
            if (!isTouch)
            {
                // Mouse or stylus event.
                UpdateMouse(pointerPoint);

                // Capture future pointer events until a release.		
                if (target != null)
                    target.CapturePointer(pointer);
            }
        }
示例#37
0
        /// <summary>
        /// Handler for the event when the user stops dragging the dragElement and releases it.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position where the user clicked w.r.t. the UIElement being dragged</param>
        /// <param name="positionInParent">Position where the user clicked w.r.t. the FluidWrapPanel (the parentFWPanel of the UIElement being dragged</param>
        internal async Task EndFluidDragAsync(UIElement child, Point position, Point positionInParent, Pointer pointer)
        {
            if ((child == null) || (!IsComposing) || (_dragElement == null))
                return;

            // Call the event handler core on the Dispatcher. (Improves efficiency!)
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                _dragElement.RenderTransform = CreateTransform(positionInParent.X - _dragStartPoint.X,
                                                               positionInParent.Y - _dragStartPoint.Y,
                                                               DragScale,
                                                               DragScale);

                child.Opacity = NORMAL_OPACITY;
                // Z-Index is set to 1 so that during the animation it does not go below other elements.
                child.SetValue(Canvas.ZIndexProperty, Z_INDEX_INTERMEDIATE);
                // Release the mouse capture
                child.ReleasePointerCapture(pointer);

                // Reference used to set the Z-Index to 0 during the UpdateFluidLayout
                _lastDragElement = _dragElement;

                _dragElement = null;
                _lastExchangeElement = null;

                InvalidateMeasure();
            });
        }
示例#38
0
        private void PointerReleased(PointerPoint pointerPoint, UIElement target, Pointer pointer)
        {
            // To convert from DIPs (device independent pixels) to screen resolution pixels.
            var dipFactor = DisplayProperties.LogicalDpi / 96.0f;
            var pos = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) * dipFactor;

            var isTouch = pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch;

            _touchQueue.Enqueue((int)pointerPoint.PointerId, TouchLocationState.Released, pos, !isTouch);

            if (!isTouch)
            {
                // Mouse or stylus event.
                UpdateMouse(pointerPoint);

                // Release the captured pointer.
                if (target != null)
                    target.ReleasePointerCapture(pointer);
            }
        }
        /// <summary>
        /// Handler for the event when the user stops dragging the dragElement and releases it.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position where the user clicked w.r.t. the UIElement being dragged</param>
        /// <param name="positionInParent">Position where the user clicked w.r.t. the FluidWrapPanel</param>
        /// <param name="pointer">Pointer</param>
        internal void EndFluidDrag(UIElement child, Point position, Point positionInParent, Pointer pointer)
        {
            if ((child == null) || (!IsComposing) || (_dragElement == null))
                return;

            // Set the offset of the _dragElement's visual
            var visual = _fluidVisuals[_dragElement];
            visual.ImplicitAnimations = _implicitAnimationCollection;
            visual.Opacity = 1f;
            visual.Scale = Vector3.One;
            visual.Offset = new Vector3((float)(positionInParent.X - _dragStartPoint.X),
                                                            (float)(positionInParent.Y - _dragStartPoint.Y),
                                                            0);
            //visual.CenterPoint = new Vector3((float)(ItemWidth / 2), (float)(ItemHeight / 2), 0);

            // Z-Index is set to 1 so that during the animation it does not go below other elements.
            child.SetValue(Canvas.ZIndexProperty, ZIndexIntermediate);
            // Release the pointer capture
            child.ReleasePointerCapture(pointer);

            _dragElement = null;
            _lastExchangedElement = null;

            InvalidateArrange();
        }
示例#40
0
        public void HandlePressed(Point _position, Pointer _pointer)
        {
            FlagFactory factory = control.factory;
            Point IllusionPoint = _position;
            if (!IsOnPainter(IllusionPoint))
                return;

            if (factory.CanPutStamp())
            {
                Image image = new Image();
                image.Source = factory.DragPic.Source;
                image.VerticalAlignment = VerticalAlignment.Top;
                image.HorizontalAlignment = HorizontalAlignment.Left;
                image.Stretch = Stretch.None;
                image.Margin = new Thickness(IllusionPoint.X - control.Painter.Margin.Left, IllusionPoint.Y - control.Painter.Margin.Top, 0, 0);
                control.Painter.Children.Add(image);
            }

            if (factory.CurrentPenColor.Equals(""))
                return;

            Point point = new Point();
            point.X = IllusionPoint.X - control.Painter.Margin.Left;
            point.Y = IllusionPoint.Y - control.Painter.Margin.Top;
            if (factory.IsWaterbrushOrEraser())
            {
                uint id = _pointer.PointerId;
                if (!factory.pointerDictionary.ContainsKey(id))
                {
                    Color color = factory.GetCurrentColor();

                    SolidColorBrush brush = new SolidColorBrush(color);
                    brush.Opacity = factory.CurrentOpacity;

                    Polyline polyline = new Polyline
                    {
                        Stroke = brush,
                        StrokeThickness = 20,
                    };
                    polyline.Points.Add(point);
                    control.Painter.Children.Add(polyline);
                    factory.pointerDictionary.Add(id, polyline);
                }
            }

            else if (factory.IsOilpastel())
            {
                DrawOilPastel(point);
            }

            factory.Pressed = true;
        }
		/// <summary>
		/// Begins the tilt effect by preparing the control and doing the 
		/// initial animation.
		/// </summary>
		/// <param name="element">The element to tilt.</param>
		/// <param name="touchPoint">The touch point, in element coordinates.</param>
		/// <param name="centerPoint">The center point of the element in element
		/// coordinates.</param>
		/// <param name="centerDelta">The delta between the 
		/// <paramref name="element"/>'s center and the container's center.</param>
#if WINDOWS_STORE
			static void BeginTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint, Point centerDelta, Pointer p)
示例#42
0
        public void HandleReleased(Point position,Pointer pointer)
        {
            FlagFactory factory = control.factory;
            if (factory.IsWaterbrushOrEraser())
            {
                uint id = pointer.PointerId;

                if (factory.pointerDictionary.ContainsKey(id))
                    factory.pointerDictionary.Remove(id);
            }

            if (!IsOnPainter(position))
                factory.ReleaseAtOut = true;
            else
                factory.ReleaseAtOut = false;

            factory.Pressed = false;
        }
示例#43
0
        /// <summary>
        /// Handler for the event when the user starts dragging the dragElement.
        /// </summary>
        /// <param name="child">UIElement being dragged</param>
        /// <param name="position">Position in the child where the user clicked</param>
        /// <param name="pointer">Pointer</param>
        internal async Task BeginFluidDragAsync(UIElement child, Point position, Pointer pointer)
        {
            if ((child == null) || (!IsComposing))
                return;

            // Call the event handler core on the Dispatcher. (Improves efficiency!)
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                child.Opacity = DragOpacity;
                child.SetValue(Canvas.ZIndexProperty, Z_INDEX_DRAG);
                // Capture further mouse events
                child.CapturePointer(pointer);
                _dragElement = child;
                _lastDragElement = null;

                // Since we are scaling the dragElement by DragScale, the clickPoint also shifts
                _dragStartPoint = new Point(position.X * DragScale, position.Y * DragScale);
            });
        }
示例#44
0
文件: TiltEffect.cs 项目: liquidboy/X
        /// <summary>
        /// Prepares a control to be tilted by setting up a plane projection and
        /// some event handlers.
        /// </summary>
        /// <param name="element">The control that is to be tilted.</param>
        /// <param name="centerDelta">Delta between the element's center and the
        /// tilt container's.</param>
        /// <returns>true if successful; false otherwise.</returns>
        /// <remarks>
        /// This method is conservative; it will fail any attempt to tilt a 
        /// control that already has a projection on it.
        /// </remarks>
        private static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta, Pointer p)
        {
            // Prevents interference with any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
            {
                return false;
            }

            _originalCacheMode[element] = element.CacheMode;
            element.CacheMode = new BitmapCache();

            TranslateTransform transform = new TranslateTransform();
            transform.X = centerDelta.X;
            transform.Y = centerDelta.Y;
            element.RenderTransform = transform;

            PlaneProjection projection = new PlaneProjection();
            projection.GlobalOffsetX = -1 * centerDelta.X;
            projection.GlobalOffsetY = -1 * centerDelta.Y;
            element.Projection = projection;

            element.PointerMoved += TiltEffect_PointerMoved;
            element.PointerReleased += TiltEffect_PointerReleased;
            element.CapturePointer(p);
            return true;
        }
		/// <summary>
		/// Prepares a control to be tilted by setting up a plane projection and
		/// some event handlers.
		/// </summary>
		/// <param name="element">The control that is to be tilted.</param>
		/// <param name="centerDelta">Delta between the element's center and the
		/// tilt container's.</param>
		/// <returns>true if successful; false otherwise.</returns>
		/// <remarks>
		/// This method is conservative; it will fail any attempt to tilt a 
		/// control that already has a projection on it.
		/// </remarks>
#if WINDOWS_STORE
			static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta, Pointer p)