PageRenderTime 21ms CodeModel.GetById 19ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Kinban.KinectMouseControl/MouseControl/AbsoluteMouseController.cs

#
C# | 46 lines | 38 code | 7 blank | 1 comment | 3 complexity | 43704a502f830aea294c58495decdf5c MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Windows.Media.Media3D;
 6
 7namespace Kinect.KinectMouseControl
 8{
 9    public class AbsoluteMouseController : IMouseController
10    {
11        private AutoItX3Lib.AutoItX3Class _auto;
12
13        public void Initialize()
14        {
15            _auto = new AutoItX3Lib.AutoItX3Class();
16        }
17
18        private bool _lastMouseDownState;
19
20        #region IMouseController Members
21
22        public void SetMousePosition(System.Drawing.Point mousePosition)
23        {
24            _auto.MouseMove(mousePosition.X, mousePosition.Y, 0);
25        }
26
27        public void SetMouseButtonDown(bool mouseButtonDown)
28        {
29            // did the mouse button change state
30            if (_lastMouseDownState != mouseButtonDown)
31            {
32                if (mouseButtonDown)
33                {
34                    _auto.MouseDown();
35                }
36                else
37                {
38                    _auto.MouseUp();
39                }
40                _lastMouseDownState = mouseButtonDown;
41            }
42        }
43
44        #endregion
45    }
46}