在PictureBox上绘制一个填充圆圈 [英] draw a fill circle on PictureBox

查看:908
本文介绍了在PictureBox上绘制一个填充圆圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中我必须在点击星标时显示星星的名称。解决方案是在PictureBox上绘制星形,然后绘制这个PictureBox。当我点击星形时,我点击PictureBox(对象)并显示名称。

注意:我必须绘制1000多颗星。对于每个我要显示名称的星星。

in my project i have to when i click on the star show the name of the star. the solution is to draw the star on the PictureBox and them draw this PictureBox .and when i click in the star i click in the PictureBox(object) and show the name.
N.B: i have to draw more than 1000 star. for each star i want to show the name.

推荐答案

绘制实心圆是很简单的:只需从图片框中获取图像控件并使用FillEllipse方法:

Drawing a filled circle is easy: just get the Image control from your picturebox and use the FillEllipse method:
Image i = myPictureBox.Image;
using (Graphics g = Graphics.FromImage(i))
    {
    g.FillEllipse(Brushes.White, new Rectangle(100, 100, 10, 10));
    }



当你绘制它们时,只需调用myPictureBox.Invalidate()来显示它们。

如果我是你,我创建了一个Star类,其中包括它的名称,位置和(显示)大小,这样你就可以在点击图片框时查找它。


When you have drawn them, just call myPictureBox.Invalidate() to display them all.
If I was you, I'd create a Star class which included it's name, location, and (display) size, so you could then look for it when you clicked on the picturebox.



图形g = pictureBox1.CreateGraphics();

or Graphics g = pictureBox1.CreateGraphics();
etc


这篇关于在PictureBox上绘制一个填充圆圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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