创建自定义形状的按钮 [英] Create custom shape for button

查看:172
本文介绍了创建自定义形状的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想作一个地图,显示每个状态下,将鼠标悬停在某个状态,各自的形状会改变颜色和一些关于它的信息将会出现。

I would like to make a map that shows each state, when hovering over a certain state, the respective shape would change color and some information about it would appear.

下面是类似一个基于网络的例子 kartograph.org/showcase/usa-projection

Here is a web-based example of something similar kartograph.org/showcase/usa-projection

使用.NET 4.5,C#和WinForms是否有可能用一个按钮实现这一点,并处理鼠标事件?

Using .NET 4.5, C#, and WinForms is it possible to achieve this with a Button and handling mouse events?

推荐答案

这是不是一个完整的答案,但可能把你在正确的道路上。

This isn't a complete answer, but might put you on the right path.

的WinForms不会让你使用按钮对象以这种方式;的WinForms按钮都相当有限,以定制自己的能力 - WPF可能会借给自己这一点,如果它是一个选项

WinForms won't let you use the Button object in this way; WinForms buttons are quite limited in their ability to be customized--WPF would likely lend itself to this, if it's an option.

要做到这一点的WinForms很可能是你需要使用GDI和加载每个国家到它自己的图形对象,并编写自己的管道的点击事件和这样的。虽然我不能提供一个具体的例子应该是可行的,但它也可能是工作了相当多的(特别的东西,如图像的透明部分)。

To do this in WinForms it's likely that you'll need to use GDI and load each state into it's own Graphics object and write your own plumbing for click events and such. While I can't offer a specific example it should be feasible, but it's also likely to be a fair amount of work (especially for things such as transparent parts of the image).

然而,如果你要不是看在WPF或与GDI交互对象,你就应该能够取得进展。

However, if you either look into WPF or into interacting with GDI objects you should be able to make progress.

这篇关于创建自定义形状的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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