示例#1
0
        public static void checkRules()
        {
            if ((samples == null) || (samples.Count < 1))
            {
                return;
            }
            else if (samples.Count == 1)
            {
                if (solution != null)
                    solution.Clear();
                solution = samples[0];
                return;
            }

            // Always create a new solution based on the gestures
            solution = new SetOfPrimitives();

            // All the samples will be compared to the first as
            // the anti-unification will look for all the elements that
            // are common through all the samples
            SetOfPrimitives firstSample = samples[0];

            foreach (PrimitiveData primitive in firstSample)
            {

                checkProportionforPrimitive(primitive);

                PrimitiveData antiUnifiedString = checkStringListPrimitives(primitive);
                if (antiUnifiedString != null)
                    solution.Add(antiUnifiedString);

               PrimitiveData antiUnifiedComplex =  checkValueComplexPrimitives(primitive);
               if (antiUnifiedComplex != null)
                   solution.Add(antiUnifiedComplex);

            }
        }
示例#2
0
        private static SetOfPrimitives loadPrimitives(List<TouchPoint2> simplegestures, IEnumerable<IPrimitiveConditionData> primitives)
        {
            List<IPrimitiveConditionData> returnList;
            SetOfPrimitives output = new SetOfPrimitives();

            foreach (IPrimitiveConditionData primitive in primitives)
            {
                returnList = null;
                IPrimitiveConditionValidator ruleValidator = GestureLanguageProcessor.GetPrimitiveConditionValidator(primitive);
                returnList = ruleValidator.GenerateRules(simplegestures);
                if (returnList != null)
                {
                    int index = 1;
                    foreach (IPrimitiveConditionData resultData in returnList)
                    {
                        if (resultData != null)
                        {
                            PrimitiveData primitiveData = new PrimitiveData();
                            if (primitive.isComplex())
                            {
                                primitiveData.ID = getIDsFromGDL(resultData.ToGDL());
                            }
                            else
                            {
                                primitiveData.IDadd(index++);
                            }
                            primitiveData.Name = getPrimitiveName(primitive);
                            string strValue = getStrValueFromGDL(resultData.ToGDL());
                            double value;
                            bool isDouble = double.TryParse(strValue, out value);
                            if (isDouble)
                                primitiveData.Value = value;
                            else
                            {
                                int idx = strValue.IndexOf(",");
                                if (idx >= 0)
                                    primitiveData.ListValue = new List<string>(strValue.Split(','));
                                else
                                    primitiveData.ListValue.Add(strValue);
                            }
                            output.Add(primitiveData);

                        }
                        else
                            index++;
                    }
                }
            }
            return output;
        }