Example #1
0
 public static SemaphoreGesture AddSemaphoreTouchGesture(this User user)
 {
     var gesture = new SemaphoreGesture();
     var fpsFilter = new FramesFilter(6);
     user.AttachPipeline(fpsFilter);
     fpsFilter.AttachPipeline(gesture);
     return gesture;
 }
Example #2
0
 public static AccelerationGesture AddAccelerationGesture(this User user)
 {
     var gesture = new AccelerationGesture();
     var fpsFilter = new FramesFilter(6);
     user.AttachPipeline(fpsFilter);
     fpsFilter.AttachPipeline(gesture);
     return gesture;
 }
Example #3
0
        public static SelfTouchGesture AddSelfTouchGesture(this User user, Point3D correction, params JointID[] joints)
        {
            if (joints.Length < 2)
            {
                throw new ArgumentException("At least 2 joints are expected for a SelfTouchGesture", "joints");
            }

            XDocument xmlDoc = XDocument.Load(GestureXmlFiles.GesturesXmlFile);
            IEnumerable<XElement> selfTouchGestureNodes = xmlDoc.Root.Descendants("SelfTouchGesture");

            var selfTouchGestures = new List<SelfTouchGesture>(selfTouchGestureNodes.Count());
            SelfTouchGesture selfTouchGesture = null;
            List<Filter<IUserChangedEvent>> filters;

            foreach (XElement node in selfTouchGestureNodes)
            {
                if (!Convert.ToBoolean(node.Attribute(XName.Get("Active")).Value))
                {
                    continue;
                }

                if (!AreJointsMatching(node.Element(XName.Get("PointsToCheck")), joints))
                {
                    continue;
                }

                filters = GetFilters(node.Element(XName.Get("Filters")), joints);
                if (filters == null || filters.Count == 0)
                {
                    filters = GetStandardSelfTouchFilters(joints);
                }

                for (int i = 0; i < filters.Count; i++)
                {
                    if (i == 0)
                    {
                        user.AttachPipeline(filters[i]);
                    }
                    else
                    {
                        filters[i - 1].AttachPipeline(filters[i]);
                    }

                    var correctionFilter = filters[i] as CorrectionFilter;
                    if (correctionFilter != null && joints[1].Equals(correctionFilter.JointToCorrect))
                    {
                        correctionFilter.Correction = correction;
                    }
                }

                int historyCount = 10;
                string history = node.Attribute(XName.Get("History")).Value;
                int.TryParse(history, out historyCount);
                selfTouchGesture = new SelfTouchGesture
                                       {
                                           HistoryCount = historyCount,
                                           Joints = joints
                                       };

                filters[filters.Count - 1].AttachPipeline(selfTouchGesture);
            }

            if (selfTouchGesture == null)
            {
                var sb = new StringBuilder();
                sb.Append("No SelfTouch configuration in \"");
                sb.Append(GestureXmlFiles.GesturesXmlFile);
                sb.Append("\" found for joints: ");

                for (int i = 0; i < joints.Length; i++)
                {
                    sb.Append("{"+i+"}");
                }
                _log.IfErrorFormat(sb.ToString(), joints);
                throw new NullReferenceException(string.Format(sb.ToString(), joints));
            }

            return selfTouchGesture;
        }
Example #4
0
        public static List<SelfTouchGesture> AddSelfTouchGestures(this User user)
        {
            XDocument xmlDoc = XDocument.Load(GestureXmlFiles.GesturesXmlFile);
            IEnumerable<XElement> selfTouchGestureNodes = xmlDoc.Root.Descendants("SelfTouchGesture");

            var selfTouchGestures = new List<SelfTouchGesture>(selfTouchGestureNodes.Count());
            foreach (XElement node in selfTouchGestureNodes)
            {
                if (!Convert.ToBoolean(node.Attribute(XName.Get("Active")).Value))
                {
                    continue;
                }

                JointID[] joints = null;
                joints = GetJoints(node.Element(XName.Get("PointsToCheck"))).ToArray();

                if (joints != null)
                {
                    List<Filter<IUserChangedEvent>> filters;
                    filters = GetFilters(node.Element(XName.Get("Filters")), joints);

                    for (int i = 0; i < filters.Count; i++)
                    {
                        if (i == 0)
                        {
                            user.AttachPipeline(filters[i]);
                        }
                        else
                        {
                            filters[i - 1].AttachPipeline(filters[i]);
                        }
                    }

                    SelfTouchGesture gesture = null;
                    int historyCount;
                    string history = node.Attribute(XName.Get("History")).Value;

                    if (int.TryParse(history, out historyCount))
                    {
                        gesture = new SelfTouchGesture {HistoryCount = historyCount, Joints = joints};
                    }
                    else
                    {
                        gesture = new SelfTouchGesture {HistoryCount = 10, Joints = joints};
                    }

                    filters[filters.Count - 1].AttachPipeline(gesture);
                    selfTouchGestures.Add(gesture);
                }
            }

            return selfTouchGestures;
        }