public Form1()
 {
     InitializeComponent();
     oCamera = new InventorCamera();
     controller = new Controller();
     InitializeTexBox();
     AddToLog("Component initialization.");
     Thread.Sleep(100); // wait for connection
     if (controller.Devices.IsEmpty)
     {
         AddToLog("ERROR: No connection to Leap Motion service.");
         AddToLog("ERROR: Connect device and restart application.");
         return;
     }
     else
     {
         AddToLog("Connected to Leap Motion service.");
         controller.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
         controller.EnableGesture(Gesture.GestureType.TYPE_CIRCLE);
         listener = new LeapEventListener(this);
         controller.SetPolicyFlags(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);
         controller.AddListener(listener);
     }
     if (!oCamera.IsStarted())
         AddToLog("ERROR: Inventor instance not found.");
     else
         AddToLog("Iventor instance found. ");
     if (!oCamera.IsOpened())
         AddToLog("ERROR: Assembly, part or presentation document not found.");
     else
         AddToLog(oCamera.GetDocType() + " document found.");
 }
        public LeapInterface()
        {
            listener = new LeapListener();
            controller = new Controller();
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            Start();
        }
 public override void OnInit(Controller controller)
 {
     controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
     controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
     controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
     controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
     controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
 }
 public override void OnConnect(Controller controller)
 {
     controller.SetPolicyFlags(Controller.PolicyFlag.POLICY_IMAGES);
     //enable all four types of gestures
     controller.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
     controller.EnableGesture(Gesture.GestureType.TYPE_KEY_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_SCREEN_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_CIRCLE);
     this.eventDelegate.LeapEventNotification("onConnect");
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.Title = "Leap Mousion v2.0";
            Console.WriteLine("Leap Mousion v2.0 by TangoChen    :)\r\n------------------------------------\r\nBlog: TangoChen.com\r\nYoutube Channel: www.youtube.com/tan9ochen\r\n--------------------\r\nTwitter:\ttwitter.com/tangochen\t@TangoChen\r\n微博(Weibo):\tweibo.com/tangochen\t@TangoChen\r\n--------------------\r\nPress any key to exit...\r\n--------------------");

            // Create a sample listener and controller
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();

            foreach (string arg in args)
            {
                switch (arg.Substring(0, 1).ToLower())
                {
                    case "l": // L = Set isLeftHanded = true;
                        listener.isLeftHanded = true;
                        break;
                    case "s": // Scale
                        float.TryParse(arg.Substring(1), out listener.moveScale);
                        break;
                    case "r": // Reverse Orientation
                        /*
                         * It won't just reverse the horizontal axes but also change the fingerIndex...
                         * So this is used when the device get reversed horizontal axes
                         * and you don't want to click the [Reverse Orientation] inside the [Leap Motion Controller Settings] or
                         * rotate the device...
                         */
                        listener.isReversed = true;
                        break;
                    case "c": // Click-Only
                        listener.isClickOnly = true;
                        break;
                }
            }

            Console.WriteLine(
                "Speed: " + listener.moveScale.ToString() +
                "\r\nClick-Only: " + listener.isClickOnly.ToString() +
                "\r\nReversed: " + listener.isReversed.ToString() +
                "\r\nLeft Handed Mode: " + (listener.isLeftHanded ? "Enabled" : "Disabled") +
                "\r\n--------------------"
                );

            // Receive frames of tracking data while in the background
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until any key is pressed
            Console.ReadKey(true); //System.Diagnostics.Process.Start("pause"); Won't work...

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
        /// <summary>
        /// Constructor for LeapInterface class
        /// </summary>
        public LeapInterface()
        {
            // Create a listener and controller
            this.listener = new LeapListener();
            this.controller = new Controller();

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);

            // Register event handler
            listener.GestureMade += new EventHandler<GestureEvent>(ProcessGesture);
        }
Beispiel #7
0
        public static void Main()
        {
            using (UniListener listener = new UniListener())
            {
                using (Controller controller = new Controller())
                {
                    controller.SetPolicyFlags(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);

                    // Have the listener receive events from the controller
                    controller.AddListener(listener);

                    // Keep this process running until Enter is pressed
                    Console.WriteLine("Press Enter to quit...");
                    string result = Console.ReadLine();

                    // Remove the listener when done
                    controller.RemoveListener(listener);
                }
            }
        }
Beispiel #8
0
 public override void OnInit(Controller controller)
 {
     _LogAction("Initialized");
     controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
 }
Beispiel #9
0
 public void Init()
 {
     _leapController = new Controller();
     _leapController.SetPolicyFlags(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);
 }
        public override void OnConnect(Controller controller)
        {
            SafeWriteLine("Connected");

            // enable gesture recognition for screen locking
            controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
            //controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
            //controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
            //controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
        }
Beispiel #11
0
 public override void OnInit(Controller controller)
 {
     SafeWriteLine("Initialized");
     stopWatch = new Stopwatch();
     stopWatch.Start();
     controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
 }
Beispiel #12
0
 public override void OnInit(Controller controller)
 {
     SafeWriteLine("Initialized");
     controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
 }
Beispiel #13
0
        // Enables/Disables the controller based on the visibility of the overlay
        public void HandleController(object sender, DependencyPropertyChangedEventArgs e)
        {
            Window overlay = sender as Window;

            if (overlay.Visibility == Visibility.Hidden)
            {
                leap.RemoveListener(listener);
                leap.Dispose();
            }
            else if (overlay.Visibility == Visibility.Visible)
            {
                leap = new Controller();

                // Runs the leap constantly so it can be used when the window loses focus
                if (leap.PolicyFlags != Controller.PolicyFlag.POLICYBACKGROUNDFRAMES)
                {
                    leap.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);
                }

                leap.AddListener(listener);
            }
        }