本文介绍了确定在鼠标单击上的惠点位于定义的椭圆内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我已经在图片框上创建了一个椭圆,现在我想当我单击图片框时应该告诉天气我单击了内部" 定义的椭圆或外部" . br/>
请朋友帮我..

我想在PictureBox_MouseClick()事件上执行此操作.....

我的绘画事件代码如下.

Dear friends,

I have created an ellipse over picture box , now I want when I click on picture box it should tell weather I have clicked "Inside" defined ellipse or "Outside".

Please friends help me..

I want to do this on PictureBox_MouseClick() event.....

My paint event code is below.

private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Color c1 = Color.FromArgb(50, Color.Green);
            foreach (Rectangle rect in listRect)
            {
                using (Pen pen = new Pen(Color.Red, 2))
                {
                    e.Graphics.DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
                    e.Graphics.FillEllipse(new SolidBrush(c1), rect.X, rect.Y, rect.Width, rect.Height);
                   
                }
            }           
        }

推荐答案

PictureBox_MouseClick(object j,eve.... e){

Color colorAtPoint = img.GetPixel(e.x, e.y);
 // check if color == green 
}



问候...



Regards...


Region r = new Region(myPictureBox.Size);
GraphicsPath elipse = new GraphicsPath();
elipse.AddEllipse(rect);
r.Union(elipse);
if (r.IsVisible(point))
    {
    ...
    }


这篇关于确定在鼠标单击上的惠点位于定义的椭圆内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 08:14