绘制2d表格C#.net的圆圈 [英] Drawing circle for 2d form C#.net

查看:73
本文介绍了绘制2d表格C#.net的圆圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i有一个xml文件,其中包含地面的经度和纬度。



此xml文件是从支持Sony gps的相机生成的。



根据xml,我必须在我的2D屏幕中绘制圆形或矩形..



请尽情提供2d形式的东西



谢谢

Vijay r



i have one xml file which contains the longitude and latitude for the ground.

This xml file was generated from Sony gps enabled camera.

As per the xml i have to draw the circle or rectangle in the my 2d screen..

kindly provide few idea to draw things in the 2d form

Thanks
Vijay r

推荐答案

你需要绘制任何 System.Windows.Forms.Control (包括 System.Windows.Forms.Form )在重写方法 OnPaint 或事件的处理程序 Paint 。对于渲染,使用从事件参数参数中获取的类 System.Drawing.Graphics 的实例。



当您需要更改渲染图像时,只需更改用于渲染的数据并调用 Control.Invalidate 。它将触发发送Windows消息WM _ PAINT 并触发事件。要提高性能,您可以使用带参数的 Control.Invalidate 方法( Rectangle Region )仅触发重新渲染场景的某些部分。



警告:不要重复常见错误 - 不要使用 System.Windows.Forms.PictireBox 。你可以借鉴它,但这绝对没有意义;只是一个额外的间接水平,性能下降,没有额外的好处(除了你在改变大小时遇到​​的麻烦)。



-SA
You need to draw in any System.Windows.Forms.Control (including System.Windows.Forms.Form) in the overridden method OnPaint or in the handler of the event Paint. For rendering, use the instance of the class System.Drawing.Graphics taken from the event arguments parameter.

When you need to change the rendered image, just change the data used for rendering and call Control.Invalidate. It will trigger sending Windows message WM_PAINT and firing the event. To improve performance you can use Control.Invalidate methods with parameter (Rectangle or Region) to trigger re-rendering only some part of the scene.

Warning: do not repeat the common mistake — do not use System.Windows.Forms.PictireBox. You can draw on it, but this is absolutely pointless; just an extra level of indirection with loss of performance and no added benefits (except hassles such as those you face in change of size).

—SA


在表单的paint事件中输入以下代码...



inside the paint event of your form just enter the following code...

e.Graphics.FillEllipse(Brushes.CornflowerBlue, 100, 100, 100, 100);
           e.Graphics.DrawEllipse(Pens.Green, 100, 100, 100, 100);


e.Graphics.FillEllipse(Brushes.CornflowerBlue, 100, 100, 100, 100);
           e.Graphics.DrawEllipse(Pens.Green, 100, 100, 100, 100);


这篇关于绘制2d表格C#.net的圆圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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