示例#1
0
 public MainWindow()
 {
     CurrentPoint = new GetPoint(10, 20, 0);
     bgThread = new Thread(handle);
     bgThread.Start();
     InitializeComponent();
 }
示例#2
0
        /// <summary>
        /// Gives a textual representation of the object.
        /// </summary>
        /// <returns> A string representing the current state of the packet.</returns>
        public override string ToString()
        {
            switch (Kind)
            {
            case Command.GetPoint: return(GetPoint.ToString());

            case Command.StartCalibration: return(StartCalibration.ToString());

            case Command.EndCalibration: return("EndCalibration()");

            case Command.ClearCalibration: return("ClearCalibration()");

            case Command.AddPoint: return(AddPoint.ToString());

            case Command.Unavailable: return("Unavaliable()");

            case Command.Name: return(Name.ToString());

            case Command.Fps: return(Fps.ToString());

            case Command.KeepAlive: return("KeepAlive()");

            default: return("Unknown(?)");
            }
        }
示例#3
0
        /// <summary>
        /// Returns the hashCode of the message.
        /// The code depends on the content of the message.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            switch (Kind)
            {
            case Command.GetPoint: return(1 + GetPoint.GetHashCode());

            case Command.StartCalibration: return(2 + StartCalibration.GetHashCode());

            case Command.EndCalibration: return(3);

            case Command.ClearCalibration: return(4);

            case Command.AddPoint: return(5 + AddPoint.GetHashCode());

            case Command.Unavailable: return(6);

            case Command.Name: return(7 + Name.GetHashCode());

            case Command.Fps: return(8 + Fps.GetHashCode());

            case Command.KeepAlive: return(9);

            default: return(0);
            }
        }
示例#4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            GetPoint other = obj as GetPoint;

            if ((System.Object)other == null)
            {
                return(false);
            }

            return((Math.Abs(this.X - other.X) < 0.01) &&
                   (Math.Abs(this.Y - other.Y) < 0.01) &&
                   (this.Timestamp == other.Timestamp));
        }
示例#5
0
        /// <summary>
        /// Determines if this object is by value equal to another.
        /// </summary>
        /// <param name="obj">A object to compare with.</param>
        /// <returns>If the two objects are considered equal, true. False otherwise</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            EriverProtocol other = obj as EriverProtocol;

            if ((System.Object)other == null)
            {
                return(false);
            }

            if (this.Kind != other.Kind)
            {
                return(false);
            }

            switch (Kind)
            {
            case Command.GetPoint: return(GetPoint.Equals(other.GetPoint));

            case Command.StartCalibration: return(StartCalibration.Equals(other.StartCalibration));

            case Command.EndCalibration: return(true);

            case Command.ClearCalibration: return(true);

            case Command.AddPoint: return(AddPoint.Equals(other.AddPoint));

            case Command.Unavailable: return(true);

            case Command.Name: return(Name.Equals(other.Name));

            case Command.Fps: return(Fps.Equals(other.Fps));

            case Command.KeepAlive: return(true);

            default: return(false);
            }
        }
示例#6
0
        private GetPoint Henshin(IGazeDataItem gazeDataItem)
        {
            int leftValidity = gazeDataItem.LeftValidity;
            int rightValidity = gazeDataItem.RightValidity;
            Point2D left = gazeDataItem.LeftGazePoint2D;
            Point2D right = gazeDataItem.RightGazePoint2D;
            GetPoint answer = new GetPoint();

            if (leftValidity == BEST_VALIDITY && rightValidity == BEST_VALIDITY)
            {
                eye_distance = new Point2D(right.X - left.X, right.Y - left.Y);
            }
            else if (leftValidity == BEST_VALIDITY)
            {
                right.X = left.X + eye_distance.X;
                right.Y = left.Y + eye_distance.Y;
            }
            else if (rightValidity == BEST_VALIDITY)
            {
                left.X = right.X - eye_distance.X;
                left.Y = right.Y - eye_distance.Y;
            }
            else
            {

            }

            answer.X = (left.X + right.X) / 2;
            answer.Y = (left.Y + right.Y) / 2;
            return answer;
        }
示例#7
0
        public void RegisterOnETEventTest()
        {
            ManualResetEvent recieved = new ManualResetEvent(false);
            GetPoint point = new GetPoint(-1, -1, -1);

            Assert.AreEqual(-1, point.X);
            Assert.AreEqual(-1, point.Y);
            Assert.AreEqual(-1, point.Timestamp);

            tracker.RegisterOnETEvent(delegate(GetPoint p)
            {
                point = p;
                recieved.Set();
            }
            );

            tracker.Enable(null);

            recieved.WaitOne();
            Assert.IsTrue(point.X >= 0);
            Assert.IsTrue(point.X <= 1);

            Assert.IsTrue(point.Y >= 0);
            Assert.IsTrue(point.Y <= 1);

            // Beware of this test. Depending on the implementation,
            // the "zero" point might be in the future.
            // No implementation I know of has this, but the possibility exists.
            // If this is the case, disregard this test.
            Assert.IsTrue(point.Timestamp > 0);
        }