Exemplo n.º 1
0
        void listener_onGesture(GestureLib.Gesture gesture)
        {
            string gestures = "";

            foreach (GestureLib.Gesture.Direction direction in gesture.directions)
            {
                if (Application.SlideShowWindows.Count != 1)
                {
                    return;
                }
                if (Application.ActivePresentation.SlideShowWindow == null)
                {
                    return;
                }
                if (DateTime.Now - LastGesture <= new TimeSpan(0, 0, 1))
                {
                    return;
                }

                if (direction.ToString() == "Right")
                {
                    Application.ActivePresentation.SlideShowWindow.View.Next();
                    LastGesture = DateTime.Now;
                }
                if (direction.ToString() == "Left")
                {
                    Application.ActivePresentation.SlideShowWindow.View.Previous();
                    LastGesture = DateTime.Now;
                }
            }
            Console.WriteLine("gestured " + gestures + " with " + gesture.fingers + " fingers.");
        }
Exemplo n.º 2
0
        void listener_onGesture(GestureLib.Gesture gesture)
        {
            //string gestures = "";
            foreach (GestureLib.Gesture.Direction direction in gesture.directions)
            {
                //     gestures += direction.ToString() + ", ";

                if (DateTime.Now - LastGesture <= new TimeSpan(0, 0, 1))
                {
                    return;
                }

                if (direction.ToString() == "Right")
                {
                    var next = Application.ActivePage.Index + 1;
                    if (Application.ActiveDocument.Pages.Count >= next)
                    {
                        Application.ActiveWindow.Page = Application.ActiveDocument.Pages[next];
                        LastGesture = DateTime.Now;
                    }
                }
                if (direction.ToString() == "Left")
                {
                    if (Application.ActivePage.Index > 1)
                    {
                        Application.ActiveWindow.Page = Application.ActiveDocument.Pages[Application.ActivePage.Index - 1];
                        LastGesture = DateTime.Now;
                    }
                }
            }
            //Console.WriteLine("gestured " + gestures + " with " + gesture.fingers + " fingers.");
        }
Exemplo n.º 3
0
 void listener_onGesture(GestureLib.Gesture gesture)
 {
     //string gestures = "";
     foreach (GestureLib.Gesture.Direction direction in gesture.directions)
     {
         if (DateTime.Now - LastGesture <= new TimeSpan(0, 0, 1))
         {
             return;                                                       //Max once every second
         }
         if (direction.ToString() == "Right")
         {
             Application.ActiveWindow.PageScroll(1, 0);
             LastGesture = DateTime.Now;
         }
         if (direction.ToString() == "Left")
         {
             Application.ActiveWindow.PageScroll(0, 1);
             LastGesture = DateTime.Now;
         }
     }
     //Console.WriteLine("gestured " + gestures + " with " + gesture.fingers + " fingers.");
 }
Exemplo n.º 4
0
        void listener_onGesture(GestureLib.Gesture gesture)
        {
            string gestures = "";

            foreach (GestureLib.Gesture.Direction direction in gesture.directions)
            {
                gestures += direction.ToString() + ", ";

                if ((DateTime.Now - LastGesture) <= new TimeSpan(0, 0, 0, 1, 0))
                {
                    return;
                }
                if (gesture.fingers >= 1)
                {
                    var             excelWorksheet = (Excel.Worksheet)Application.ActiveSheet;
                    Excel.Worksheet newsheet       = null;
                    switch (direction.ToString())
                    {
                    case "Right":
                    case "Left":
                        Excel.Worksheet sheet = Application.ActiveSheet;
                        if (sheet != null)
                        {
                            int i = sheet.Shapes.Count;
                            if (i > 0)
                            {
                                Excel.Shape s = sheet.Shapes.Item(1);
                                if (s.HasChart == Office.MsoTriState.msoTrue && s.Chart.ChartArea.Format.ThreeD != null)
                                {
                                    float z = s.Chart.ChartArea.Format.ThreeD.RotationX;
                                    Application.ActiveSheet.Shapes.Item(1).Chart.ChartArea.Format.ThreeD.RotationX = z + 10;
                                }
                            }
                        }
                        break;

                    case "Up":
                        if (Application.ActiveWindow != null)
                        {
                            Application.ActiveWindow.Zoom = Application.ActiveWindow.Zoom + 5;
                        }
                        break;

                    case "Down":
                        if (Application.ActiveWindow != null)
                        {
                            Application.ActiveWindow.Zoom = Application.ActiveWindow.Zoom - 5;
                        }
                        break;
                    }
                    if (newsheet != null)
                    {
                        LastGesture = DateTime.Now;
                        newsheet.Activate();
                    }
                    return;
                }
                if (gesture.fingers == 1 || gesture.fingers == 2)
                {
                    ColumnStep = 3;
                    RowStep    = 5;
                    switch (direction.ToString())
                    {
                    case "Right": Application.ActiveWindow.SmallScroll(null, null, ColumnStep, null);
                        continue;

                    case "Left": Application.ActiveWindow.SmallScroll(null, null, null, ColumnStep);
                        continue;

                    case "Up": Application.ActiveWindow.SmallScroll(null, RowStep, null, null);
                        continue;

                    case "Down": Application.ActiveWindow.SmallScroll(RowStep, null, null, null);
                        continue;
                    }
                    LastGesture = DateTime.Now;
                }
                else if (gesture.fingers >= 3)
                {
                    switch (direction.ToString())
                    {
                    case "Right": Application.ActiveWindow.LargeScroll(0, 0, 1, 0);
                        continue;

                    case "Left": Application.ActiveWindow.LargeScroll(0, 0, 0, 1);
                        continue;

                    case "Up": Application.ActiveWindow.LargeScroll(0, 1, 0, 0);
                        continue;

                    case "Down": Application.ActiveWindow.LargeScroll(1, 0, 0, 0);
                        continue;
                    }
                    LastGesture = DateTime.Now;
                }
            }
            Console.WriteLine("gestured " + gestures + " with " + gesture.fingers + " fingers.");
        }
        public override void OnFrame(Controller controller)
        {
            Frame frame = controller.Frame();
            // Get the first hand
            Hand hand = frame.Hands[0];

            // Check if the hand has any fingers
            FingerList fingers = hand.Fingers;
            if (!fingers.Empty)
            {
                // Calculate the hand's average finger tip position
                Vector avgPos = Vector.Zero;
                Vector avgVelocity = Vector.Zero;
                foreach (Finger finger in fingers)
                {
                    avgPos += finger.TipPosition;
                    avgVelocity += finger.TipVelocity;
                }
                avgPos /= fingers.Count;
                avgVelocity /= fingers.Count;
                List<Gesture.Direction> directions = new List<Gesture.Direction>();

                if (avgVelocity.y > 1500)
                {
                    directions.Add(Gesture.Direction.Up);
                }
                else if (avgVelocity.y < -1500)
                {
                    directions.Add(Gesture.Direction.Down);
                }

                if (avgVelocity.x > 1500)
                {
                    directions.Add(Gesture.Direction.Left);
                }
                else if (avgVelocity.x < -1500)
                {
                    directions.Add(Gesture.Direction.Right);
                }

                if (avgVelocity.z > 1500)
                {
                    directions.Add(Gesture.Direction.Forward);
                }
                else if (avgVelocity.z < -1500)
                {
                    directions.Add(Gesture.Direction.Backward);
                }

                if (directions.Count > 0)
                {
                    Gesture gesture = new Gesture(directions.ToArray(), fingers.Count);
                    onGesture(gesture);
                }

                //Console.WriteLine("Hand has " + fingers.Count
                //            + " fingers, average finger tip Velocity: " + avgVelocity);
            }
        }