如何在Web应用程序中的运行时绘制形状和控件 [英] How do I draw shapes and controls at run time in a web application

查看:72
本文介绍了如何在Web应用程序中的运行时绘制形状和控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用工具提示功能在图片上绘制一个形状来标记像FB一样的人。

如何在某个特定位置绘制一个控件(带有1个图片和3个文本框的面板)网页。我没有要求代码,我要求在.NET中使用工具或示例。欢迎任何帮助。

解决方案

首先,您应该了解ASP.NET允许您动态生成任何内容,以响应HTTP请求。特别是,您可以生成任何可思考的控件作为HTML的一部分。这应该可以解决控制问题;所有的ASP.NET都是为了提供这样的东西。



有了图形,问题就更复杂了;可以有不同的方法。首先,您可以使用 System.Drawing 根据请求创建位图,在其上绘制任何图形并将其包含在页面上。您可以通过在HTTP响应的标头中指定适当的内容类型来实时创建(不将任何图像文件存储在服务器主机的文件系统中,这将是非常明显的)。这些类型是标准化的,并在此支持: http://www.iana.org/assignments/ media-types / media-types.xhtml#image [ ^ ]。

(另请参阅: http:// en.wikipedia.org/wiki/Content_type [ ^ ]。)



另一种方法是使用HTML5 Canvas功能。它会为您提供更多的灵活性和更好的性能。有关详细信息,请参阅我之前的回答:如何在asp.net中制作绘图区域 [ ^ ]。



-SA

How draw a shape over a picture to tag a person like in FB, with tooltip function.
And how draw a control (panel with 1 picture and 3 textboxes) in some specific location in the web page. I don´t ask for code, I´am asking for a tool or example in .NET. Any help is welcome.

解决方案

First of all, you should understand that ASP.NET allows you to generate any content on the fly, in response to HTTP request. In particular, you can generate any thinkable controls as a part of HTML. That should close the problem of controls; all ASP.NET is designed to serve up such things.

With graphics, the problem is more complex; there can be different approaches. First, you can use System.Drawing to create bitmaps on request, draw any graphics on them and include them on the page. You can make it on the fly (without storing any image files in the file system of the server's host, which would be quite obvious) by prescribing appropriate content type in the header of an HTTP response. Those types are standardized and supported here: http://www.iana.org/assignments/media-types/media-types.xhtml#image[^].
(See also: http://en.wikipedia.org/wiki/Content_type[^].)

Another approach would be using HTML5 Canvas feature. It would give you a lot more of flexibility and better performance. For further detail, please see my past answer: how to make a drawing area in asp.net[^].

—SA


这篇关于如何在Web应用程序中的运行时绘制形状和控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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