如何在单击圆形图像上设置Dialoge Box [英] How Can I Set Dialoge Box On Clicking Circular Image

查看:86
本文介绍了如何在单击圆形图像上设置Dialoge Box的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在点击圆形图像上设置拨号框

解决方案

假设您正在绘制面板或类似物,请处理Paint事件。

首先,创建一个循环区域:

  private 图片myImage = Image.FromFile( @  D:\ Temp \ AAMyPic.jpg); 
private GraphicsPath path = new GraphicsPath();
private 区域reg = new Region();
...
path.AddEllipse( 0 0 ,MyPanel.Width ,MyPanel.Height);
reg = new 区域(路径);



然后,将您的图像绘制到油漆事件:

<前lang =c#> e.Graphics.SetClip(路径);
e.Graphics.DrawImage(myImage, 0 0 );



然后,处理面板MouseClick事件:

  private   void  MyPanel_MouseClick( object  sender,MouseEventArgs e)
{
if (reg.IsVisible(e.Location))
{
Debug.WriteLine( IN!);
}
}


how can i set dialoge box on clicking circular image

解决方案

Assuming you are drawing on a panel or similar, handle the Paint event.
First, create a circular Region:

        private Image myImage = Image.FromFile(@"D:\Temp\AAMyPic.jpg");
        private GraphicsPath path = new GraphicsPath();
        private Region reg = new Region();
...
            path.AddEllipse(0, 0, MyPanel.Width, MyPanel.Height);
            reg = new Region(path);


Then, draw your image into the region in the Paint Event:

e.Graphics.SetClip(path);
e.Graphics.DrawImage(myImage, 0, 0);


Then, handle the panel MouseClick event:

private void MyPanel_MouseClick(object sender, MouseEventArgs e)
    {
    if (reg.IsVisible(e.Location))
        {
        Debug.WriteLine("IN!");
        }
    }


这篇关于如何在单击圆形图像上设置Dialoge Box的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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