Ejemplo n.º 1
0
        public static void Add(string gestureName, int blockNo, ValidSetOfPointsCollection data, string blockName)
        {
            List<ValidateBlockResult> previous = Get(gestureName, blockNo);

            if (previous.Count >= 1)
            {
                Remove(previous[0]);
            }

            var item = new ValidateBlockResult()
            {
                Data = data,
                GestureName = gestureName,
                ValidateBlockNo = blockNo,
                ValidateBlockName = blockName
            };
            _cache.Add(item);
        }
Ejemplo n.º 2
0
        private bool Validate(ValidateBlockResult firstBlockResult, ValidateBlockResult secBlockResult)
        {
            foreach (var firstTouches in firstBlockResult.Data)
            {
                foreach (var firstTouch in firstTouches)
                {
                    foreach (var secTouches in secBlockResult.Data)
                    {
                        foreach (var secTouch in secTouches)
                        {
                            var stylusPoints1 = firstTouch.Stroke.StylusPoints;
                            var stylusPoints2 = secTouch.Stroke.StylusPoints;

                            // Calculate slope of each line represented by the two sets of touch points
                            double set1Angle = TrigonometricCalculationHelper.GetSlopeBetweenPoints(stylusPoints1[0], stylusPoints1[stylusPoints1.Count - 1]);
                            double set2Angle = TrigonometricCalculationHelper.GetSlopeBetweenPoints(stylusPoints2[0], stylusPoints2[stylusPoints2.Count - 1]);

                            double angularDiff = (set1Angle - set2Angle) * 180 / 3.14;
                            if (Math.Abs(angularDiff) > 70 && Math.Abs(angularDiff) < 110)
                            {
                                return true;
                            }
                            else
                            {
                                angularDiff = Math.Abs(angularDiff) - 180;
                                if (Math.Abs(angularDiff) > 70 && Math.Abs(angularDiff) < 110)
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }
            }

            return false;
        }
Ejemplo n.º 3
0
        public static ValidateBlockResult[] GetAll()
        {
            ValidateBlockResult[] list = new ValidateBlockResult[_cache.Count];
            _cache.CopyTo(list);

            return list;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes the item and any other results listed in item.AssociatedResults
        /// </summary>
        /// <param name="item"></param>
        public static void Remove(ValidateBlockResult item)
        {
            /*    foreach (var id in item.AssociatedResults)
            {
                var relatedResult = _cache.SingleOrDefault(x => x.Id == id);

                if (relatedResult != null) {
                    _cache.Remove(relatedResult);
                    Remove(relatedResult);

               } */

            _cache.Remove(item);

              //  _cache.Remove(item);

            //TODO: Should follow the above logic. The following code is only for testing another feature
            /*    var itemsToRemove = _cache.Where(x => x.GestureName == item.GestureName);
            foreach (var g in itemsToRemove)
                _cache.Remove(g);*/
        }