/// <summary>
        /// Recognizes a <see cref="TangibleObject"/> from given touch points.
        /// </summary>
        /// <param name="points">The collection with touch points.</param>
        /// <returns>an instance of <see cref="TangibleObject"/>.</returns>
        public static TangibleObject Recognize(IEnumerable<TouchPoint> points)
        {
            var pointTuple = RecognizeCore(points);
            if (pointTuple == null)
                return null;

            TangibleObject tangibleObject = new TangibleObject(pointTuple.Item1, pointTuple.Item2, pointTuple.Item3);

            return tangibleObject;
        }
        /// <summary>
        /// Creates a new instance of <see cref="TangibleObjectControl"/> for a given <see cref="TangibleObject"/>.
        /// </summary>
        /// <param name="tangibleObject">The tangible object.</param>
        /// <param name="tangibleCanvas">The tangible canvas that hosts the tangible object.</param>
        internal TangibleObjectController(TangibleObject tangibleObject, TangibleCanvas tangibleCanvas)
        {
            Check.NotNull(tangibleObject, "tangibleObject");
            Check.NotNull(tangibleCanvas, "tangibleCanvas");

            _tangibleObject = tangibleObject;
            _tangibleCanvas = tangibleCanvas;

            //InitializeTopLine();
            InitializePhysicBoundaries();
            //InitializeTangibleObjectData();
        }
Esempio n. 3
0
 internal static double GetTangibleRotation(TangibleObject owner)
 {
     var point1 = owner.LeftPoint;
     var point2 = owner.RightPoint;
     return GetAngleBetween(point1, point2);
 }
 /// <summary>
 /// Creates physic boundary.
 /// </summary>
 /// <param name="tangibleObject">The tangible object.</param>
 /// <returns>a new instance of <see cref="TangibleObjectControl"/>.</returns>
 static TangibleObjectControl CreatePhysicBoundary(TangibleObject tangibleObject)
 {
     var control = new TangibleObjectControl();
     return control;
 }
Esempio n. 5
0
 /// <summary>
 /// Removes an user associated with a tangible object.
 /// </summary>
 /// <param name="tangibleObject">The tangible object.</param>
 void RemoveUser(TangibleObject tangibleObject)
 {
     var associatedUser = _associatedTangibleObjects[tangibleObject];
     //RemoveContacts(associatedUser);
     _associatedTangibleObjects.Remove(tangibleObject);
 }
        /// <summary>
        /// Creates a line.
        /// </summary>
        /// <param name="tangibleObject">The tangible object.</param>
        /// <returns>the line.</returns>
        static Line CreateLine(TangibleObject tangibleObject)
        {
            Check.NotNull(tangibleObject, "tangibleObject");

            Line topLine = new Line();
            topLine.Stroke = new SolidColorBrush(Colors.DarkBlue);
            topLine.StrokeThickness = 5;

            // Bind properties
            Binding x1Binding = new Binding()
            {
                Source = tangibleObject.TopLine.Point1,
                Path = new Windows.UI.Xaml.PropertyPath("X"),
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };
            topLine.SetBinding(Line.X1Property, x1Binding);

            Binding y1Binding = new Binding()
            {
                Source = tangibleObject.TopLine.Point1,
                Path = new Windows.UI.Xaml.PropertyPath("Y"),
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };
            topLine.SetBinding(Line.Y1Property, y1Binding);

            Binding x2Binding = new Binding()
            {
                Source = tangibleObject.TopLine.Point2,
                Path = new Windows.UI.Xaml.PropertyPath("X"),
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };
            topLine.SetBinding(Line.X2Property, x2Binding);

            Binding y2Binding = new Binding()
            {
                Source = tangibleObject.TopLine.Point2,
                Path = new Windows.UI.Xaml.PropertyPath("Y"),
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
            };
            topLine.SetBinding(Line.Y2Property, y2Binding);

            return topLine;
        }
Esempio n. 7
0
        private void OnTangibleObjectDetected(TangibleObject newTangibleObject)
        {
            _tangibleObjects.Add(newTangibleObject);

            UserId freeUser;
            if (HasFreeUser(out freeUser))
                AssociateUser(freeUser, newTangibleObject);

            _controllers.Add(newTangibleObject, new TangibleObjectController(newTangibleObject, this));
        }
Esempio n. 8
0
        void OnTangibleObjectReleased(TangibleObject tangibleObject)
        {
            _tangibleObjects.Remove(tangibleObject);

            // Remove the physic controller
            var physicControler = GetController(tangibleObject);
            physicControler.Dispose();
            _controllers.Remove(tangibleObject);

            RemoveUser(tangibleObject);
        }
Esempio n. 9
0
 /// <summary>
 /// Gets the <see cref="TangibleObjectController"/> of a given <see cref="TangibleObject"/>.
 /// </summary>
 /// <param name="tangibleObject">The tangible object.</param>
 /// <returns>the <see cref="TangibleObjectController"/> of a given <see cref="TangibleObject"/>.</returns>
 TangibleObjectController GetController(TangibleObject tangibleObject)
 {
     return _controllers[tangibleObject];
 }
Esempio n. 10
0
 /// <summary>
 /// Associates a tangible object with user.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="tangibleObject">The tangible object.</param>
 void AssociateUser(UserId user, TangibleObject tangibleObject)
 {
     _associatedTangibleObjects.Add(tangibleObject, user);
     tangibleObject.Data = user;
     //ShowUserContacts(user);
 }
        /// <summary>
        /// Removes a <see cref="TangibleObject"/> from the local collection.
        /// </summary>
        /// <param name="tangibleObject">The tangible object to be removed.</param>
        void RemoveTangibleObject(TangibleObject tangibleObject)
        {
            Check.NotNull(tangibleObject, "tangibleObject");

            tangibleObject.Dispose();
            _detectedObjects.Remove(tangibleObject);

            OnTangibleObjectReleased(tangibleObject);
        }
        /// <summary>
        /// Adds a <see cref="TangibleObject"/> to the local collection.
        /// </summary>
        /// <param name="tangibleObject">The tangible object.</param>
        void AddTangibleObject(TangibleObject tangibleObject)
        {
            Check.NotNull(tangibleObject, "tangibleObject");

            _detectedObjects.Add(tangibleObject);

            OnTangibleObjectDetected(tangibleObject);
        }
        /// <summary>
        /// Raises the <see cref="TangibleObjectReleased"/> event.
        /// </summary>
        /// <param name="tangibleObject">The released tangible object.</param>
        protected virtual void OnTangibleObjectReleased(TangibleObject tangibleObject)
        {
            Check.NotNull(tangibleObject, "tangibleObject");

            var handler = TangibleObjectReleased;
            handler?.Invoke(tangibleObject);
        }