本帖最后由 qiaoke_song 于 2018-3-25 22:36 编辑
说明:
开关按钮效果,不要在调试模式下运行,会有些慢,直接点击exe运行就可以
如需新增图像,修改SwitchResource.resx资源文件 添加修改效果,修改Ui3Dflipswitch.cs
另:将InitializeSwitchEffect(this, new Point(100, 50), 1, 0, 2, switch1_Click);换成
InitializeSwitchEffect(this, new Point(100, 50), 1, 0, 2, null);
找两幅大小一样的图像,加到SwitchResource.resx资源文件,或修改代码,指定2副图像
可以当做2副图像3D立体切换的效果
效果截图:
调用代码演示:
[C#] 纯文本查看 复制代码 public partial class Form1 : Form
{
Ui3Dflipswitch us = new Ui3Dflipswitch();
Ui3Dflipswitch us1 = new Ui3Dflipswitch();
Ui3Dflipswitch us2 = new Ui3Dflipswitch();
public Form1()
{
InitializeComponent();
/*
* InitializeSwitchEffect(在哪个控件之内, 位置, 初始开关状态, 动画类型(目前只设定0), 动画速度, 执行的事件);
*/
us.InitializeSwitchEffect(this, new Point(100, 50), 1, 0, 2, switch1_Click);
us1.InitializeSwitchEffect(this, new Point(100, 150), 0, 1, 2, switch2_Click);
us2.InitializeSwitchEffect(this, new Point(100, 250), 0, 2, 2, switch3_Click);
if (us.switch_flag == 0) label1.Text = "打开...";
else label1.Text = "关闭...";
if (us1.switch_flag == 0) label2.Text = "打开...";
else label2.Text = "关闭...";
if (us2.switch_flag == 0) label3.Text = "打开...";
else label3.Text = "关闭...";
}
private void switch1_Click(object sender, EventArgs e)
{
if (us.switch_flag == 0) label1.Text = "打开...";
else label1.Text = "关闭...";
}
private void switch2_Click(object sender, EventArgs e)
{
if (us1.switch_flag == 0) label2.Text = "打开...";
else label2.Text = "关闭...";
}
private void switch3_Click(object sender, EventArgs e)
{
if (us2.switch_flag == 0) label3.Text = "打开...";
else label3.Text = "关闭...";
}
}
|