예제 #1
0
        public void GetGyroscope_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var gyroscopeData = new Vector3F(1, 2, 3);

            var args = new GyroscopeDataEventArgs(
                new Mock<IMyo>().Object,
                DateTime.UtcNow,
                gyroscopeData);

            // Execute
            var result = args.Gyroscope;

            // Assert
            Assert.Equal(gyroscopeData, result);
        }
예제 #2
0
        /// <summary>
        /// Called when gyroscope data has been acquired from the Myo.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnAcquiredGyroscopeData(IntPtr evt, DateTime timestamp)
        {
            var gyroscope = _myoDeviceDriver.GetGyroscope(evt);

            this.Gyroscope = gyroscope;

            var handler = GyroscopeDataAcquired;

            if (handler != null)
            {
                var args = new GyroscopeDataEventArgs(
                    this,
                    timestamp,
                    gyroscope);
                handler.Invoke(this, args);
            }
        }
예제 #3
0
        /// <summary>
        /// Called when gyroscope data has been acquired from the Myo.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnAcquiredGyroscopeData(IntPtr evt, DateTime timestamp)
        {
            // Contract.Requires<ArgumentException>(evt != IntPtr.Zero, "The event handle must be set.");

            var gyroscope = _myoDeviceDriver.GetGyroscope(evt);

            this.Gyroscope = gyroscope;

            var handler = GyroscopeDataAcquired;

            if (handler != null)
            {
                var args = new GyroscopeDataEventArgs(
                    this,
                    timestamp,
                    gyroscope);
                handler.Invoke(this, args);
            }
        }
예제 #4
0
        public void GetMyo_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var myo = new Mock<IMyo>();

            var args = new GyroscopeDataEventArgs(
                myo.Object,
                DateTime.UtcNow,
                new Vector3F());

            // Execute
            var result = args.Myo;

            // Assert
            Assert.Equal(myo.Object, result);
        }
예제 #5
0
        public void GetTimestamp_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var timestamp = DateTime.UtcNow;

            var args = new GyroscopeDataEventArgs(
                new Mock<IMyo>().Object,
                timestamp,
                new Vector3F());

            // Execute
            var result = args.Timestamp;

            // Assert
            Assert.Equal(timestamp, result);
        }
예제 #6
0
        public void Move(object o, GyroscopeDataEventArgs e)
        {
            var myo = (Myo) o;
            if (absoluteTL.ContainsKey(myo))
            {
                var position = GetPixelPosition(myo);

                if (SelectedWindow.ContainsKey(myo))
                {
                    if (rectangles.ContainsKey(myo))
                    {
                        UpdateRect(myo, new Rectangle(position.X - DragOffset[myo].Value.X, position.Y - DragOffset[myo].Value.Y,
                            SelectedWindow[myo].Area.Width, SelectedWindow[myo].Area.Height));
                    }
                    else
                    {
                        AddRect(myo, new Rectangle(position.X - DragOffset[myo].Value.X, position.Y - DragOffset[myo].Value.Y,
                            SelectedWindow[myo].Area.Width, SelectedWindow[myo].Area.Height));
                    }
                    if (blobs.ContainsKey(myo))
                    {
                        DeleteBlob(myo);
                    }
                }
                else {
                    blobs[myo] = position;
                }
                Invalidate();
            }
        }