Exemple #1
0
        public override void RetrieveRenderKnowledge()
        {
            var symbols = _shapeSymbol.RetrieveConcreteShapes();
            var shapes  = new ObservableCollection <IKnowledge>();

            RenderKnowledge = null;
            if (symbols != null)
            {
                var shapeSymbol = symbols as ShapeSymbol;
                var ssLst       = symbols as IEnumerable <ShapeSymbol>;

                if (shapeSymbol != null)
                {
                    starPadSDK.MathExpr.Expr expr = ExprG.Generate(shapeSymbol);
                    var agShape = new AGShapeExpr(expr, shapeSymbol);
                    shapes.Add(agShape);
                }

                if (ssLst != null)
                {
                    foreach (ShapeSymbol ss in ssLst.ToList())
                    {
                        var expr   = ExprG.Generate(ss);
                        var agExpr = new AGShapeExpr(expr, ss);
                        shapes.Add(agExpr);
                    }
                }
                RenderKnowledge = shapes;
                RenderKnowledge.CollectionChanged += RenderKnowledge_CollectionChanged;
            }
        }
Exemple #2
0
        public override void RetrieveRenderKnowledge()
        {
            if (_query.CachedEntities.Count == 0)
            {
                return;
            }
            var lst = new ObservableCollection <IKnowledge>();

            foreach (var cacheObj in _query.CachedEntities)
            {
                var cacheShapeSymbol = cacheObj as ShapeSymbol;
                var cacheGoal        = cacheObj as EqGoal;
                var cacheEq          = cacheObj as Equation;
                if (cacheShapeSymbol != null)
                {
                    starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheShapeSymbol);
                    var agShape = new AGShapeExpr(expr, cacheShapeSymbol);
                    lst.Add(agShape);
                }
                else if (cacheGoal != null)
                {
                    starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheGoal);
                    var agGoal = new AGPropertyExpr(expr, cacheGoal);
                    lst.Add(agGoal);
                }
                else if (cacheEq != null)
                {
                    starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheEq);
                    var agEq = new AGEquationExpr(expr, cacheEq);
                    lst.Add(agEq);
                }
            }
            RenderKnowledge = lst;
        }
Exemple #3
0
        /// <summary>
        /// ShapeSymbol Input Pattern Match
        /// </summary>
        /// <param name="expr"></param>
        /// <param name="ss"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        private bool EvalExprPatterns(Expr expr, ShapeSymbol ss, out object output, bool userInput = false)
        {
            if (!userInput)
            {
                RelationGraph.AddNode(ss);
            }

            //expr = ExprG.Generate(ss);
            output = new AGShapeExpr(expr, ss);
            return(true);
        }
        /// <summary>
        /// ShapeSymbol Input Pattern Match
        /// </summary>
        /// <param name="expr"></param>
        /// <param name="ss"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        private bool EvalExprPatterns(Expr expr, ShapeSymbol ss, out object output, bool userInput = false)
        {
            if (!userInput) RelationGraph.AddNode(ss);

            //expr = ExprG.Generate(ss);
            output = new AGShapeExpr(expr, ss);
            return true;
        }
        private bool ShapeVerify(IKnowledge obj, ShapeSymbol shape, out string msg, out object output)
        {
            msg = AGTutorMessage.VerifyWrong;
            output = null;

            List<Tuple<object, object>> trace = null;

            var agShapeExpr = new AGShapeExpr(obj.Expr, shape);
            agShapeExpr.IsSelected = true;
            agShapeExpr.GenerateSolvingTrace();
            trace = agShapeExpr.AutoTrace;

            if (trace == null || trace.Count == 0) return false;

         /*   var lastTuple = trace[trace.Count - 1] as Tuple<object, object>;
            var lastLst = lastTuple.Item2 as List<object>;
            Debug.Assert(lastLst != null);
            Debug.Assert(lastLst.Count != 0);
            var lastTs = lastLst[lastLst.Count - 1] as TraceStepExpr;*/
            bool matchResult = UserGraph.Match(trace); //match and update
            if (!matchResult) return false;

            //insert nodes
            UserGraph.Insert(trace);
            CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode;
            //var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode);
          /*  if (nextTuple1 == null) // query-end
            {
                msg = AGTutorMessage.SolvedProblem;
                return true;
            }*/
            msg = AGTutorMessage.VerifyCorrect;
            return true;
        }
Exemple #6
0
        public override void RetrieveRenderKnowledge()
        {
            var symbols = _shapeSymbol.RetrieveConcreteShapes();
            var shapes = new ObservableCollection<IKnowledge>();
            RenderKnowledge = null;
            if (symbols != null)
            {
                var shapeSymbol = symbols as ShapeSymbol;
                var ssLst = symbols as IEnumerable<ShapeSymbol>;

                if (shapeSymbol != null)
                {
                    starPadSDK.MathExpr.Expr expr = ExprG.Generate(shapeSymbol);
                    var agShape = new AGShapeExpr(expr, shapeSymbol);
                    shapes.Add(agShape);
                }

                if (ssLst != null)
                {
                    foreach (ShapeSymbol ss in ssLst.ToList())
                    {
                        var expr = ExprG.Generate(ss);
                        var agExpr = new AGShapeExpr(expr, ss);
                        shapes.Add(agExpr);
                    }
                }
                RenderKnowledge = shapes;
                RenderKnowledge.CollectionChanged += RenderKnowledge_CollectionChanged;
            }
        }