public void RaiseFingerMove(FingerEventArgs e)
 {
     if (FingerMove != null)
     {
         FingerMove(this, e);
     }
 }
 public void RaiseFingerDown(FingerEventArgs e)
 {
     if (FingerDown != null)
     {
         FingerDown(this, e);
     }
 }
 public void RaiseFingerUp(FingerEventArgs e)
 {
     if (FingerUp != null)
     {
         FingerUp(this, e);
     }
 }
Пример #4
0
 private void OnFinger(string source, int e)
 {
     if (this.onFinger != null)
     {
         FingerEventType fingerEventType = (e == 10) ? FingerEventType.FINGER_UP : FingerEventType.FINGER_DOWN;
         FingerEventArgs fe = new FingerEventArgs(source, fingerEventType);
         this.onFinger(source, fe);
     }
 }
Пример #5
0
 public void RaiseFingerDown(FingerEventArgs e)
 {
     IsChecked = !IsChecked;
     
     if (FingerDown != null)
     {
         FingerDown(this, e);
     }
 }
 private void SpaceCanvas_FingerDown(object sender, FingerEventArgs e)
 {
     if (grabButton.IsChecked)
     {
         if (e.FingerTracker.OnSurfaceFingers.Count() >= 2)
         {
             selectionRect.Opacity = 1.0;
         }
     }
     //Trace.WriteLine("FingerDown: " + e.ID.ToString() + " @ " + e.Position.ToString());
 }
        private void SpaceCanvas_FingerUp(object sender, FingerEventArgs e)
        {
            if (grabButton.IsChecked)
            {
                if (e.FingerTracker.OnSurfaceFingers.Count() == 0)
                {
                    if (lastFingerUpPosition.HasValue)
                    {
                        Point3D center = new Point3D((lastFingerUpPosition.Value.X + e.Position.X) / 2, (lastFingerUpPosition.Value.Y + e.Position.Y) / 2, 0);

                        Canvas.SetLeft(highlightRect, Canvas.GetLeft(selectionRect));
                        Canvas.SetTop(highlightRect, Canvas.GetTop(selectionRect));
                        highlightRect.Width = selectionRect.Width;
                        highlightRect.Height = selectionRect.Height;
                        highlightRect.Opacity = 1.0;

                        SpaceProvider.GrabAt(center, (Action)delegate()
                        {
                            Trace.WriteLine("Grabbed image at " + center.ToString());
                            //move to somewhere else!!!
                            byte[] data;
                            string mime;
                            SpaceProvider.GetLastGrabbedImageData(out data, out mime);

                            Dispatcher.BeginInvoke((Action)delegate()
                            {
                                highlightRect.Opacity = 0;
                                gallery.AddImage(data, mime);
                            }, null);
                        });
                        //grabButton.IsChecked = false;
                    }


                    selectionRect.Opacity = 0;
                    lastFingerUpPosition = null;
                }
                else
                {
                    lastFingerUpPosition = e.Position;
                }
            }
            //Trace.WriteLine("FingerUp: " + e.ID.ToString() + " @ " + e.Position.ToString());
        }
Пример #8
0
        private void handleFingerEvent(FingerEventType type, FingerEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)delegate()
            {
                VisualTreeHelper.HitTest(this,
                    null,
                    (HitTestResultCallback)delegate(HitTestResult result)
                    {
                        //find ISpaceControl parent
                        DependencyObject current = result.VisualHit;
                        while(current != null && !(current is ISpaceControl))
                        {
                            current = VisualTreeHelper.GetParent(current);
                        }

                        if (current != null)
                        {
                            ISpaceControl spaceControl = current as ISpaceControl;
                            switch(type)
                            {
                                case FingerEventType.FingerDown:
                                    spaceControl.RaiseFingerDown(e);
                                    break;

                                case FingerEventType.FingerUp:
                                    spaceControl.RaiseFingerUp(e);
                                    break;

                                case FingerEventType.FingerMove:
                                    spaceControl.RaiseFingerMove(e);
                                    break;
                            }

                            return HitTestResultBehavior.Stop;
                        }
                        else
                        {
                            return HitTestResultBehavior.Continue;
                        }
                    }, 
                    new PointHitTestParameters(new Point(e.Position.X, e.Position.Y)));
            }, null);
        }
 private ScatterRectangle HitTest(ScatterRectangle rectangle, FingerEventArgs args)
 {
     Point global = rectangle.TranslatePoint(args.Position, _canvas), temp;
     ScatterRectangle curr;
     BitmapImage bi;
     byte[] pixel = new byte[4];
     for (int i = 0; i < _canvas.Pieces.Length; ++i)
     {
         curr = _canvas.Pieces[i];
         temp = _canvas.TranslatePoint(global, curr);
         if (temp.X > curr.Width || temp.X < 0 || temp.Y > curr.Height || temp.Y < 0) continue;
         bi = (curr.Background as ImageBrush).ImageSource as BitmapImage;
         bi.CopyPixels(new System.Windows.Int32Rect((int) (temp.X / curr.Width * bi.PixelWidth),
                                                    (int) (temp.Y / curr.Height * bi.PixelHeight), 1, 1), pixel,
                       bi.PixelWidth * 4, 0);
         if (pixel[3] != 0)
             return curr;
     }
     return null;
 }
        private void OnContactRemoved(ScatterRectangle rectangle, FingerEventArgs e)
        {
            int index = (int) rectangle.Category;
            if (!_elementsContacts[index].ContainsKey(e.FingerID))
                return;

            FixedHingeJoint removedJoint;
            if (_contactJoints.TryGetValue(e.FingerID, out removedJoint))
            {
                removedJoint.Lifetime.IsExpired = true;
                _contactBody.Remove(e.FingerID);
                _contactJoints.Remove(e.FingerID);

            }
            _elementsContacts[index].Remove(e.FingerID);
            _fingers.Remove(e.Position);
        }
        private void OnNewContact(ScatterRectangle rectangle, FingerEventArgs e)
        {
            int index = (int)rectangle.Category;
            //not a new contact
            if (_elementsContacts[index].ContainsKey(e.FingerID))
                return;

            //e.Position stands the whole table, get the relative position of Target, i.e. Design Window here
            Point position = rectangle.TranslatePoint(e.Position, _canvas);
            Vector2D contactPoint = new Vector2D((Scalar)position.X, (Scalar)position.Y);
            _fingers.Add(position);

            Body body = _bodies[index];
            if (body.Shape.CanGetIntersection)
            {
                FixedHingeJoint joint = PhysicsHelper.FixedHingeJointFactory(body, contactPoint, new Lifespan());
                _engine.AddJoint(joint);
                _contactJoints[e.FingerID] = joint;
                _contactBody[e.FingerID] = body;
                _elementsContacts[index].Add(e.FingerID, new Contact(e.FingerID, position));
            }
            rectangle.CaptureFinger(e.FingerID);
        }
Пример #12
0
 void fingerTracker_FingerDown(object sender, FingerEventArgs e)
 {
     handleFingerEvent(FingerEventType.FingerDown, e);
 }
Пример #13
0
        private void AddNewPiePiece(FingerEventArgs finger)
        {
            DispatcherTimer startTimer = new DispatcherTimer();
            startTimer.Tick += new EventHandler(startTimer_Elapsed);
            startTimer.Interval = TimeSpan.FromMilliseconds(this._holdTime);
            _holdFingerList.Add(finger.FingerID, startTimer);
            _holdFingerPositionList.Add(finger.FingerID, finger.Position);

            PiePiece pie = new PiePiece();
            pie.Radius = 24;
            pie.InnerRadius = 12;
            pie.Fill = Brushes.Beige;
            pie.Opacity = .8d;
            Canvas.SetLeft(pie, finger.Position.X);
            Canvas.SetTop(pie, finger.Position.Y);
            PopupStage.Children.Add(pie);
            pie.BeginAnimation(PiePiece.WedgeAngleProperty, new DoubleAnimation(360, new Duration(TimeSpan.FromMilliseconds(this._holdTime))));
            startTimer.Tag = pie;
            startTimer.Start();
        }
Пример #14
0
        private void RemovePiePiece(FingerEventArgs finger)
        {
            DispatcherTimer timer = _holdFingerList[finger.FingerID];
            timer.Stop();
            PiePiece pie = timer.Tag as PiePiece;
            pie.BeginAnimation(PiePiece.WedgeAngleProperty, null);
            PopupStage.Children.Remove(pie);

            _holdFingerList.Remove(finger.FingerID);
            _holdFingerPositionList.Remove(finger.FingerID);
        }
Пример #15
0
        void menu_Loaded(object sender, RoutedEventArgs e)
        {
            UElementMenu menu = sender as UElementMenu;
            if (!_menuList.ContainsKey(menu))
            {
                // remove the menu
                PopupStage.Children.Remove(menu);
                return;
            }

            int finger = _menuList[menu];
            // raise the finger down event on that menu so that it can be open when it is shown
            FingerEventArgs args = new FingerEventArgs(FingerEventType.FINGER_DOWN_EVENT, finger, new Point(20, 20));
            Collection<FingerEventArgs> collection = new Collection<FingerEventArgs>();
            collection.Add(args);
            menu.RaiseEvent(new MultiTouchEventArgs(collection, 0));
        }
        private void SpaceCanvas_FingerMove(object sender, FingerEventArgs e)
        {
            if (grabButton.IsChecked)
            {
                //TODO FIXME: This thread is not the same as FingerTracker's thread. How to synchronize? 
                if (e.FingerTracker.OnSurfaceFingers.Count() >= 2)
                {
                    Finger[] fingers = new Finger[2];

                    int count = 0;
                    foreach (Finger f in e.FingerTracker.OnSurfaceFingers)
                    {
                        fingers[count] = f;
                        count++;
                        if (count >= 2)
                        {
                            break;
                        }
                    }

                    Canvas.SetLeft(selectionRect, Math.Min(fingers[0].Position.X, fingers[1].Position.X));
                    Canvas.SetTop(selectionRect, Math.Min(fingers[0].Position.Y, fingers[1].Position.Y));
                    selectionRect.Width = Math.Abs(fingers[0].Position.X - fingers[1].Position.X);
                    selectionRect.Height = Math.Abs(fingers[0].Position.Y - fingers[1].Position.Y);
                }
                else if (e.FingerTracker.OnSurfaceFingers.Count() == 1 && lastFingerUpPosition.HasValue)
                {
                    Finger f = e.FingerTracker.OnSurfaceFingers.First();
                    Canvas.SetLeft(selectionRect, Math.Min(lastFingerUpPosition.Value.X, f.Position.X));
                    Canvas.SetTop(selectionRect, Math.Min(lastFingerUpPosition.Value.Y, f.Position.Y));
                    selectionRect.Width = Math.Abs(lastFingerUpPosition.Value.X - f.Position.X);
                    selectionRect.Height = Math.Abs(lastFingerUpPosition.Value.Y - f.Position.Y);
                }
            }

            //Trace.WriteLine("FingerMove: " + e.ID.ToString() + " @ " + e.Position.ToString());
        }
        private void OnContactMove(ScatterRectangle rectangle, FingerEventArgs e)
        {
            int index = (int)rectangle.Category;
            if (!_elementsContacts[index].ContainsKey(e.FingerID)) return;
            Point position = rectangle.TranslatePoint(e.Position, _canvas);
            _elementsContacts[index][e.FingerID].UpdatePosition(position);

            FixedHingeJoint joint;
            if (_contactJoints.TryGetValue(e.FingerID, out joint))
            {
                // move
                joint.Anchor = new Vector2D((Scalar)position.X, (Scalar)position.Y);
            }
        }
 private void grabButton_FingerDown(object sender, FingerEventArgs e)
 {
     gallery.ClearAllImages();
 }