/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the Client class. /// </summary> public Client() { // Will attempt to load "GazeTrackerSettings.xml" from execution dir. or set default this.settings = new Settings(); this.socketUdpReceive = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.commands = new Commands(); this.stream = new Stream(this); this.streamformat = new StreamFormat { TimeStampMilliseconds = true, GazePosition = true, EyetrackingType = StreamFormat.EyeTrackingType.Left }; this.stream.StreamFormat = this.streamformat; this.tracker = new Tracker(); this.camera = new Camera(this); this.calibration = new Calibration(this); this.uiControl = new UIControl(this); this.log = new Log(this); // Not fully implemented yet.. this.MouseControl = new MouseControl(); // On new gaze data this.gazeData = new GazeData(); this.gazeData.OnSmoothedGazeData += this.MouseControl.Move; }
/// <summary> /// This function moves the cursor to a specific point at the screen. /// </summary> /// <param name="x">X coordinate of the posotion as pixel</param> /// <param name="y">Y coordinate of the posotion as pixel</param> /// <returns>Returns 0 if there was an error otherwise 1.</returns> /// public void Move(GazeData gData) { if (isEnabled) { double ScreenWidth = Screen.PrimaryScreen.Bounds.Width; double ScreenHeight = Screen.PrimaryScreen.Bounds.Height; var input_move = new INPUT(); input_move.mi.dx = (int)Math.Round(gData.GazePositionX * (65535 / ScreenWidth), 0); input_move.mi.dy = (int)Math.Round(gData.GazePositionY * (65535 / ScreenHeight), 0); input_move.mi.mouseData = 0; input_move.mi.dwFlags = (int)(MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE); INPUT[] input = { input_move }; } //return SendInput(1, input, Marshal.SizeOf(input_move)); }
/// <summary> /// This function moves the cursor to a specific point at the screen. /// </summary> /// <param name="x">X coordinate of the posotion as pixel</param> /// <param name="y">Y coordinate of the posotion as pixel</param> /// <returns>Returns 0 if there was an error otherwise 1.</returns> /// public void Move(GazeData gData) { if (isEnabled) { double ScreenWidth = Screen.PrimaryScreen.Bounds.Width; double ScreenHeight = Screen.PrimaryScreen.Bounds.Height; var input_move = new INPUT(); input_move.mi.dx = (int) Math.Round(gData.GazePositionX*(65535/ScreenWidth), 0); input_move.mi.dy = (int) Math.Round(gData.GazePositionY*(65535/ScreenHeight), 0); input_move.mi.mouseData = 0; input_move.mi.dwFlags = (int) (MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE); INPUT[] input = {input_move}; } //return SendInput(1, input, Marshal.SizeOf(input_move)); }