当前位置: 首页>>代码示例>>C#>>正文


C# Leap.Controller类代码示例

本文整理汇总了C#中Leap.Controller的典型用法代码示例。如果您正苦于以下问题:C# Controller类的具体用法?C# Controller怎么用?C# Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Controller类属于Leap命名空间,在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecordData

        /// <summary>
        /// Write the data of each frame in the file.
        /// </summary>
        /// <param name="controller">Controller that represent the device.</param>
        /// <param name="path">Path of the file where the data will be write.<br/>
        /// If one already exist it will be deleted and a new empty on is created.</param>
        public void RecordData(Controller controller, String path)
        {
            if (Directory.Exists(path) == true)
            {
                String destination = path + "leapMotion.data";
                try
                {
                    if (File.Exists(destination) == true)
                        File.Delete(destination);
                    file = File.Create(destination);
                }
                catch (ArgumentException e)
                {
                    throw e;
                }
            }
            else
                throw new System.ArgumentException("Destination path doesn't exist", "path");

            BinaryWriter writer = new BinaryWriter(file);
            for (int f = 9; f >= 0; f--)
            {
                Frame frameToSerialize = controller.Frame(f);
                byte[] serialized = frameToSerialize.Serialize;
                Int32 length = serialized.Length;
                writer.Write(length);
                writer.Write(serialized);
            }
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:35,代码来源:RecordAnimation.cs

示例2: LeapListener

 public LeapListener()
 {
     this.LeapInfo = new LeapFrame();
     this.controller = new Controller();
     this.listener = new LeapEventListener(this);
     controller.AddListener(listener);
 }
开发者ID:tbarczyk,项目名称:Lipmon,代码行数:7,代码来源:LeapListener.cs

示例3: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     this.controller = new Controller();
     this.listener = new LeapEventListener(this);
     controller.AddListener(listener);
 }
开发者ID:ArthurFeitosa,项目名称:LeapHand,代码行数:7,代码来源:MainWindow.xaml.cs

示例4: connect

        public void connect()
        {
            if (connected)
            {
                // Remove the listener
                controller.RemoveListener(listener);
                controller.Dispose();
                connected = false;
                connectbutton.Text = "Connect";
                fps_label.Text = "disconnected";
            }
            else
            {
                // Create listener and controller
                listener = new SampleListener();
                listener.form = this;
                controller = new Controller();

                if (controller.IsConnected)
                {
                    controller.AddListener(listener);
                    connectbutton.Text = "Disconnect";
                    connected = true;
                }
            }
        }
开发者ID:Brejlounek,项目名称:Leap-Input,代码行数:26,代码来源:Form1.cs

示例5: Form1

 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.");
 }
开发者ID:harrykeen18,项目名称:InventorIntegration,代码行数:32,代码来源:Form1.cs

示例6: OnConnect

 public override void OnConnect(Controller controller)
 {
     controller.EnableGesture(Gesture.GestureType.TYPE_CIRCLE);
     controller.EnableGesture(Gesture.GestureType.TYPE_KEY_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_SCREEN_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
 }
开发者ID:Zaeran,项目名称:LeapWindowsController,代码行数:7,代码来源:SampleListener.cs

示例7: OnInit

 public override void OnInit(Controller controller)
 {
     /**call the LeapEventNotification method in the eventDelegate interface.
        If the event is activated, the event name can be reported to LeapEventNotification
      */
     this.eventDelegate.LeapEventNotification("onInit");
 }
开发者ID:Fivepoints,项目名称:LeapTutorial1,代码行数:7,代码来源:MainWindow.xaml.cs

示例8: GetBeforeFrame

        // 現在のフレームと、直前の5フレームを取得する
        static void GetBeforeFrame()
        {
            Controller leap = new Controller();
            long previousFrameId = -1;

            while ( true ) {
                // 最新のフレームを取得する(leap.Frame( 0 ) と同じ)
                var currentFrame = leap.Frame();
                if ( previousFrameId == currentFrame.Id ) {
                    continue;
                }

                previousFrameId = currentFrame.Id;

                // 直前の5フレームを取得する
                Console.Write( currentFrame.Id + ", " );
                for ( int i = 1; i <= 5; ++i ) {
                    var previousFrame = leap.Frame( i );
                    Console.Write( previousFrame.Id + ", " );
                }

                Console.WriteLine();
            }

            // 終了処理(onExit()相当)
        }
开发者ID:kaorun55,项目名称:LeapMotionIntroduction2,代码行数:27,代码来源:Program.cs

示例9: Start

 // Use this for initialization
 void Start()
 {
     //enable gestures you need to use here
     controller = new Controller();
     controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
     //controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
 }
开发者ID:AudibleShapes,项目名称:Capstone_Prototype_1,代码行数:8,代码来源:SwipeGestures.cs

示例10: OnFrame

        public override void OnFrame(Controller controller)
        {
            // Get the most recent frame and report some basic information
            Frame frame = controller.Frame();

            // Get gestures
            // Only handles swipe gesture for now...
            GestureList gestures = frame.Gestures();
            for (int i = 0; i < gestures.Count; i++)
            {
                Gesture gesture = gestures[i];

                switch (gesture.Type)
                {
                    case Gesture.GestureType.TYPE_SWIPE:
                        SwipeGesture swipe = new SwipeGesture(gesture);
                        OnGesture("swipe", swipe.Id, swipe.State.ToString(), swipe.Position.ToFloatArray(), swipe.Direction.ToFloatArray());
                        break;
                    case Gesture.GestureType.TYPECIRCLE:
                        CircleGesture circle = new CircleGesture(gesture);
                        OnCircleGesture("circle", circle.Id, circle.State.ToString(), circle.Progress, circle.Normal, circle.Pointable);
                        break;
                }
            }
        }
开发者ID:JakeCowton,项目名称:GestureSpotifyController,代码行数:25,代码来源:Listener.cs

示例11: OnInitial

 public void OnInitial(Controller controller,Cursor palmCursor,Form targetForm)
 {
     
     this.palmCursor = palmCursor;
     this.targetForm = targetForm;
     this.targetForm = targetForm;
 }
开发者ID:craigchang0728,项目名称:LeapMotion,代码行数:7,代码来源:LeapListener.cs

示例12: Start

    private LeapManager manager; //This provides access to leap data

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        manager = Camera.main.GetComponent<LeapManager>();							//This links to some leap data
        listener   = new Leap.Listener ();											//initializes the listener
        controller = new Leap.Controller ();										//Initializes the controler
        controller.AddListener (listener);											//Pipes the listener stream into the controler
    }
开发者ID:Krewn,项目名称:LIOS,代码行数:14,代码来源:GetFrame.cs

示例13: OnConnect

 public override void OnConnect(Controller leapController)
 {
     leapController.Config.SetFloat("Gesture.Swipe.MinLength", 10);
     leapController.Config.SetFloat("Gesture.Swipe.MinVelocity", 100);
     leapController.Config.Save();
     leapController.EnableGesture(Gesture.GestureType.TYPESWIPE);
 }
开发者ID:RyamBaCo,项目名称:StillLife,代码行数:7,代码来源:LeapListener.cs

示例14: OnFrame

        public override void OnFrame(Controller leapController)
        {
            Frame currentFrame = leapController.Frame();

            if (handsLastFrame == 0 && currentFrame.Hands.Count > 0 && LeapRegisterFingers != null)
                LeapRegisterFingers(true);
            else if (handsLastFrame > 0 && currentFrame.Hands.Count == 0 && LeapRegisterFingers != null)
                LeapRegisterFingers(false);
            handsLastFrame = currentFrame.Hands.Count;

            if (currentFrame.Hands.Count > 0 &&
                currentFrame.Hands[0].Fingers.Count > 0 &&
                LeapSwipe != null)
            {
                GestureList gestures = currentFrame.Gestures();
                foreach (Gesture gesture in gestures)
                {
                    SwipeGesture swipe = new SwipeGesture(gesture);
                    if (Math.Abs(swipe.Direction.x) > Math.Abs(swipe.Direction.y)) // Horizontal swipe
                    {
                        if (swipe.Direction.x > 0)
                            LeapSwipe(SwipeDirection.Right);
                        else
                            LeapSwipe(SwipeDirection.Left);
                    }
                    else // Vertical swipe
                    {
                        if (swipe.Direction.y > 0)
                            LeapSwipe(SwipeDirection.Up);
                        else
                            LeapSwipe(SwipeDirection.Down);
                    }
                }
            }
        }
开发者ID:RyamBaCo,项目名称:StillLife,代码行数:35,代码来源:LeapListener.cs

示例15: OnFrame

        public override void OnFrame(Controller controller)
        {
            Pointable pointable = FindPointable(controller);

            // use the pointable movement to move the mouse
            if (null != pointable)
            {
                //SafeWriteLine("pointable: " + pointable.Id + ", " + GetPosition(pointable).ToString());

                if (HasPrevTipPosition)
                {
                    Vector tipMovement = GetPosition(pointable) - PrevTipPosition;
                    //Vector tipMovement = pointable.TipVelocity; // too noisy; need better precision for this

                    Vector mouseMovement = LeapTransform.TransformToScreenSpace(tipMovement);
                    mouseMovement.x *= MouseSensitivityX;
                    mouseMovement.y *= MouseSensitivityY;

                    // there are discontinuities in the data we get back; ignore them and only perform reasonably small movements
                    if (mouseMovement.Magnitude < 300)
                    {
                        MouseWrapper.MoveMouse((int)mouseMovement.x, (int)mouseMovement.y);
                    }
                }

                HasPrevTipPosition = true;
                PrevPointableId = pointable.Id;
                PrevTipPosition = GetPosition(pointable);
            }
            else
            {
                SafeWriteLine("No pointable");

                HasPrevTipPosition = false;
                PrevPointableId = int.MinValue;
                PrevTipPosition = null;
            }

            // convert keyboard presses into mouse clicks. We only want to do this with certain presses,
            // where the key combination would not normally cause anything to happen.  We assume that no
            // one actually presses the right shift key. :)
            if ((KeyboardWrapper.IsKeyDown(Keys.LControlKey)) && (KeyboardWrapper.IsKeyDown(Keys.Space)) && (FrameSinceLastClick > 20))
            {
                MouseWrapper.LeftClick();
                FrameSinceLastClick = 0;
            }
            else if ((KeyboardWrapper.IsKeyDown(Keys.RControlKey)) && (KeyboardWrapper.IsKeyDown(Keys.Space) && (FrameSinceLastClick > 20)))
            {
                MouseWrapper.RightClick();
                FrameSinceLastClick = 0;
            }
            else
            {
                FrameSinceLastClick += 1;
                if (FrameSinceLastClick < 0)
                {
                    FrameSinceLastClick = 20;
                }
            }
        }
开发者ID:rothda,项目名称:UniController2,代码行数:60,代码来源:UniListener.cs


注:本文中的Leap.Controller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。