• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Leap.Controller类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: OnFrame

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

            try
            {
                // Update all registered items
                lock (_FrameUpdateItems)
                {
                    var item = _FrameUpdateItems.First;
                    while (item != null)
                    {
                        var next = item.Next;
                        if (!item.Value.Update(frame))
                            _FrameUpdateItems.Remove(item);
                        item = next;
                    }
                }
            }
            catch (Exception e)
            {
                _LogAction("Exception: " + e.GetType().FullName + "\n" + e.Message + "\n" + e.StackTrace);
            }
        }
开发者ID:RossDay,项目名称:Leap,代码行数:25,代码来源:MainListener.cs


示例17: DetectLeapGesture

        protected void DetectLeapGesture(Controller leap, Leap.Frame frame)
        {
            GestureList gestures = frame.Gestures();

            foreach (Gesture gesture in gestures)
            {
                if (gesture.State != Gesture.GestureState.STATESTOP)
                {
                    continue;
                }

                switch (gesture.Type)
                {
                    case Gesture.GestureType.TYPESWIPE:
                        SwipeGesture swipe = new SwipeGesture(gesture);

                        if (swipe.StartPosition.x < 0 && swipe.Direction.x > 0)
                        {
                            TurnSlide(-1);
                        }
                        else if (swipe.StartPosition.x > 0 && swipe.Direction.x < 0)
                        {
                            TurnSlide(+1);
                        }
                        break;
                    default: break;
                }
            }
        }
开发者ID:MaxMEllon,项目名称:LeaPresen,代码行数:29,代码来源:MainWindow.xaml.cs


示例18: Awake

 void Awake() {
   leap_controller_ = new Controller();
   if (leap_controller_.IsConnected) {
     InitializeFlags();
   }
   leap_controller_.Device += HandleControllerConnect;
 }
开发者ID:CMPUT302-W2016,项目名称:HCI-Gestures,代码行数:7,代码来源:LeapProvider.cs


示例19: StillLife

        public StillLife()
        {
            InitializeComponent();

            ConfigFile config = new ConfigFile(@"config.ini");
            speedUpDown = config.SettingGroups["Movement"].Settings["SpeedUpDown"].GetValueAsFloat();
            speedLeftRight = config.SettingGroups["Movement"].Settings["SpeedLeftRight"].GetValueAsFloat();
            idleTexturePosition.Width = config.SettingGroups["Idle"].Settings["IdleX"].GetValueAsInt();
            idleTexturePosition.Height = config.SettingGroups["Idle"].Settings["IdleY"].GetValueAsInt();
            timeTillIdle = config.SettingGroups["Idle"].Settings["IdleAfter"].GetValueAsFloat();
            idleSpeed = config.SettingGroups["Idle"].Settings["IdleSpeed"].GetValueAsFloat();

            leapController = new Controller();
            leapListener = new LeapListener();
            leapController.AddListener(leapListener);
            leapListener.LeapSwipe += new LeapListener.SwipeEvent(OnSwipe);
            leapListener.LeapRegisterFingers += new LeapListener.RegisterFingers(OnRegisterFingers);

            CalculateColumnsRows();
            InitializeIdleValues();

            stopWatch.Start();
            updateThread = new Thread(UpdateThread);
            updateThread.Start();
        }
开发者ID:RyamBaCo,项目名称:StillLife,代码行数:25,代码来源:StillLife.cs


示例20: Program

 private Program(string fileName)
 {
     _c = new Controller();
     _serializer = new LeapFrameSerializer();
     _file = new FileStream(fileName, FileMode.OpenOrCreate);
     _c.FrameReady += WriteFrames;
 }
开发者ID:i2e-haw-hamburg,项目名称:gesture-recognition,代码行数:7,代码来源:Program.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Leap.Vector类代码示例发布时间:2022-05-26
下一篇:
C# TransferObjects.Card类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap