Exemplo n.º 1
0
        public static void WriteEvalToTypesetExpression(IMathLink ml, object obj, int pageWidth, string graphicsFmt, bool useStdForm)
        {
            ml.PutFunction("EvaluatePacket", 1);
            int numArgs = 2 + (useStdForm ? 0 : 1) + (pageWidth > 0 ? 1 : 0);

            ml.PutFunction("EvaluateToTypeset", numArgs);
            ml.Put(obj);
            if (!useStdForm)
            {
                ml.PutSymbol("TraditionalForm");
            }
            if (pageWidth > 0)
            {
                ml.Put(pageWidth);
            }
            ml.Put(graphicsFmt);
            ml.EndPacket();
        }
Exemplo n.º 2
0
        public static void WriteEvalToImageExpression(IMathLink ml, object obj, int width, int height, string graphicsFmt, int dpi, bool useFE)
        {
            ml.PutFunction("EvaluatePacket", 1);
            int numArgs = 2 + (useFE ? 1 : 0) + (dpi > 0 ? 1 : 0) + (width > 0 || height > 0 ? 1 : 0);

            ml.PutFunction("EvaluateToImage", numArgs);
            ml.Put(obj);
            if (useFE)
            {
                ml.Put(true);
            }
            ml.Put(graphicsFmt);
            if (dpi > 0)
            {
                ml.PutFunction("Rule", 2);
                ml.PutSymbol("ImageResolution");
                ml.Put(dpi);
            }
            if (width > 0 || height > 0)
            {
                ml.PutFunction("Rule", 2);
                ml.PutSymbol("ImageSize");
                ml.PutFunction("List", 2);
                if (width > 0)
                {
                    ml.Put(width);
                }
                else
                {
                    ml.PutSymbol("Automatic");
                }
                if (height > 0)
                {
                    ml.Put(height);
                }
                else
                {
                    ml.PutSymbol("Automatic");
                }
            }
            ml.EndPacket();
        }
Exemplo n.º 3
0
        // These next methods are called by implementors of the KernelLink "evaluateTo" methods. It is useful to separate the
        // code to create the appropriate expression to send (which is what these methods do) and the code that runs the
        // reading loop. In these methods, obj must be a string or Expr.

        // This is ready to accommodate an evaluateToMathML() function, but I have not added such a function to KernelLink yet.
        public static void WriteEvalToStringExpression(IMathLink ml, Object obj, int pageWidth, string format)
        {
            ml.PutFunction("EvaluatePacket", 1);
            ml.PutFunction("ToString", 3);
            if (obj is string)
            {
                ml.PutFunction("ToExpression", 1);
            }
            ml.Put(obj);
            ml.PutFunction("Rule", 2);
            ml.PutSymbol("FormatType");
            ml.PutSymbol(format);
            ml.PutFunction("Rule", 2);
            ml.PutSymbol("PageWidth");
            if (pageWidth > 0)
            {
                ml.Put(pageWidth);
            }
            else
            {
                ml.PutSymbol("Infinity");
            }
            ml.EndPacket();
        }
Exemplo n.º 4
0
 public override void EndPacket()
 {
     impl.EndPacket();
 }