在dotNET中的文本框中编写数学函数/表达式 [英] Writing mathematical functions/expression in a textbox in dotNET

查看:90
本文介绍了在dotNET中的文本框中编写数学函数/表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对文本框控件中的数学函数或表达式进行纠正或复制粘贴.如果可以使用用户定义的控件,那么还要知道如何?此外,我想将该数学方程式/函数存储在数据库中.
非常感谢

I want to right or copy-paste mathematical function or expression in a text box control. If user defined control can be used then also tell of how? Moreover i want to store that mathematical equations/function in database.
Thanx a lot

推荐答案

文本框控件,无论它是什么,都不能用于显示纯文本.

您可以选择仅使用传统的高级编程语言符号来以纯文本形式编写表达式(例如:"sqrt(sin(x))").如果您想要求客户能够学习和使用这种表示法,那就没问题了,但是如果您认为客户不必对编程风格感到满意,而是熟悉呈现的传统数学表示法,就可以了.在书中,您将需要解决更困难的问题.

向前迈出的第一步是使用带有添加的下标/上标表达式的简化符号,而不是所有这些整数,水平线分隔符号,基本符号等,您可以使用HTML.然后,您可以通过两种方式来表示它们:WebBrowser控件(由于您未指定要使用的UI库,所以我没有给您完整的类型名)或某些结构化文本控件,例如(在WPF中,有更多选项).此类数据的输入是一个单独的问题,非常困难,但仅出于演示目的,我可以建议在这些CodeProject文章中提供的基于HTML的出色控件:
您将使用的专业HTML渲染器 [ ^ ],
WPF HTML支持的TextBlock [ http://en.wikipedia.org/wiki/MathML [ http://en.wikipedia.org/wiki/Framework_Class_Library [ http://en.wikipedia.org/wiki/Gecko_%28layout_engine%29 [ ^ ].

请查看主要现有布局引擎当前支持的内容:
http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28HTML5%29 [ ^ ].

我什至不讨论如何实现公式的输入.这将需要认真的设计和开发工作,对于真正合格的开发人员而言,这确实是非常昂贵的.

最后,您可以直接基于Control类使用自己的呈现和输入来开发自己的自定义控件(请参阅关于要使用的未知UI库的注释).自己考虑是否可行.

—SA
The text box control, whatever it is, is not designed for presenting anything but plain text.

You may choose to use only the notation traditional for high-level programming language, to write expressions in the plain text form (example: "sqrt(sin(x))"). If you want require your customer to be able to learn and use such notation, it can be fine, but if you assume that the customer does not have to be comfortable with programming style of writing but is familiar with traditional mathematical notations as they are presented in books, you will need to solve much more difficult problem.

One step forward would be using simplified notation with added subscript/superscript expressions not not all those integrals, horizontal-line division notation, radical signs, etc., you can use HTML. Then, you have two ways to represent them: WebBrowser control (I''m not giving you the full type name because you did not specify the UI library you want to use) or some structured-text control, such as RichTextBox (in WPF, there are more options). The input of such data is the separate problem, pretty difficult, but just for presentation, I could advice wonderful HTML-based controls presented in these CodeProject articles:
A Professional HTML Renderer You Will Use[^],
WPF HTML Supported TextBlock[^].

A full-fledged option would be the support of MathML. See also how the problem of embedding of MathML looks like:
http://en.wikipedia.org/wiki/MathML[^].

Using it would be even more difficult problem, even for just presentation. One option would be using MathML directly embedded in HTML, but this is a feature of HTML5 not yet supported by all browsers. Importantly, at the moment of writing, to best of my knowledge, it is not supported by IE which control will actually be used it you use the WebBrowser control provided in the GAC as a part of .NET FCL (Framework Class Library, http://en.wikipedia.org/wiki/Framework_Class_Library[^]). Hence, you would probably need to use some third-party library for .NET, such as Mozilla Gecko:
http://en.wikipedia.org/wiki/Gecko_%28layout_engine%29[^].

Please see what''s currently supported by major existing layout engines:
http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28HTML5%29[^].

I don''t even discuss how can you implement the input of the formulas. It will need serious design and development work, really costly in terms of working hours of really qualified developers.

Finally, you can develop your own custom control with your own rendering and input, based directly on the Control class (please see my note on the unknown UI library to be used). Think by yourself if it seems feasible or not.

—SA


这篇关于在dotNET中的文本框中编写数学函数/表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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