用于可视化数学方程式的库(如方程式编辑器) [英] library for visualizing mathematical equations (like an equation editor)

查看:98
本文介绍了用于可视化数学方程式的库(如方程式编辑器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个c#库,它将为我提供方程式编辑器功能.我不是在寻找数学库来评估数学表达式.

I'm looking for a c# library that will provide me with equation editor functionality. I'm not looking for a mathematics library to evaluate mathematical expressions.

有什么建议吗?

推荐答案

存在一些选项:

wpf-math 这是要渲染的API基于数学的TeX转换为WFP,并且有一些有限的代码可以将Expression转换为TeX.

wpf-math this is an API to render math based TeX to WFP, and there some limited code to take an Expression and convert it to TeX.

另一种选择是使用MS Word,它具有一些相当先进的功能,可以将常规的数学公式作为简单的字符串,并以漂亮的格式呈现它们.这是使用该功能的一些代码.

Another option is to use MS Word, which has some quite advanced capabilities to take regular math formulas, as simple strings, and render them in nice formatting. Here's some code to play w/ that feature.

public class FormulaImageConverter: IDisposable
{
    private Guid _guid;

    private Application _wordApp;
    private Document _doc;
    private Range _range;

    private string _saveName;
    private string _extractPath;

    public FormulaImageConverter(Application wordApp)
    {

        _wordApp = wordApp;
        _guid = Guid.NewGuid();
        string guidToString = _guid.ToString("N");
        string saveNameBase = System.IO.Path.Combine(System.IO.Path.GetTempPath(), guidToString);
        _saveName = saveNameBase + ".html";
        _extractPath = saveNameBase + @"_files\image002.gif";

        _wordApp.Visible = false;
        _doc = _wordApp.Documents.Add();
        _range = _doc.Range();
        _range.Text = "5";
        _doc.OMaths.Add(_range);

    }

    public byte[] ConvertFormulaToImage(string eq)
    {
        _range.Text = eq;
        _doc.OMaths.BuildUp();
        _doc.SaveAs(_saveName, WdSaveFormat.wdFormatHTML,Type.Missing,Type.Missing,false,Type.Missing,null,false);

        return System.IO.File.ReadAllBytes(_extractPath);
    }

    public void Dispose()
    {
        _range = null;
        _doc = null;
        _wordApp.Documents.Close(WdSaveOptions.wdDoNotSaveChanges);
        ((_Application)_wordApp).Quit(false);
        _wordApp = null;
        System.IO.File.Delete(_saveName);
        for (int i = 0; i < 2; i++)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
    }
}

这篇关于用于可视化数学方程式的库(如方程式编辑器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆