Beispiel #1
0
        public bool Apply(TransformableItem item)
        {
            var tokenGraph = (TokenGraph)item;

            bool fChanged = false;

            foreach (Vertex v in tokenGraph.Vertexes.Values)
            {
                if ((Token.IsPunctuation(v.Value) == false) && tokenGraph.IsTag(v))
                {
                    continue;
                }

                if (v.Token == null)
                {
                    fChanged = true;

                    Token tk = null;

                    if (Token.IsAlpha(v.Value))
                    {
                        tk = Word.New(v.Value);
                    }
                    else if (Token.IsNumeric(v.Value))
                    {
                        tk = Number.New(v.Value);
                    }
                    else if (Token.IsMathematicalSymbol(v.Value))
                    {
                        tk = MathematicalSymbol.New(v.Value);
                    }
                    else if (Token.IsPunctuation(v.Value))
                    {
                        tk = Punctuation.New(v.Value);
                    }
                    else
                    {
                        throw new ArgumentException($"Token {v.Value} could not be convered to a Token.");
                    }

                    v.Token = tk;
                }
            }

            return(fChanged);
        }
Beispiel #2
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            DSObject item = (DSObject)((Value.Container)args[0]).Item;
            Vector   v    = (Vector)((Value.Container)args[1]).Item;

            DSObject cloned = item.clone();

            _transformableItem = RestoreProperDSType(cloned) as TransformableItem;

            // TODO: throw exception if not transformable item

            _transformableItem.translate(v.x(), v.y(), v.z());

            GraphicItem graphicItem = _transformableItem as GraphicItem;

            if (graphicItem != null)
            {
                GraphicItem.persist(graphicItem);
            }

            return(Value.NewContainer(_transformableItem));
        }
Beispiel #3
0
        public override Value Evaluate(FSharpList<Value> args)
        {
            DSObject item = (DSObject)((Value.Container)args[0]).Item;
            Vector v = (Vector)((Value.Container)args[1]).Item;

            DSObject cloned = item.clone();

            _transformableItem = RestoreProperDSType(cloned) as TransformableItem;

            // TODO: throw exception if not transformable item

            _transformableItem.translate(v.x(), v.y(), v.z());

            GraphicItem graphicItem = _transformableItem as GraphicItem;

            if (graphicItem != null)
            {
                GraphicItem.persist(graphicItem);
            }

            return Value.NewContainer(_transformableItem);
        }