CSkin博客

标题: 【开关按钮重绘】C#开关按钮效果 [打印本页]

作者: qiaoke_song    时间: 2018-1-6 11:42
标题: 【开关按钮重绘】C#开关按钮效果
本帖最后由 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 = "关闭...";
        }

    }

全部代码、说明、Demo全在这里了
https://pan.baidu.com/s/1htebnRu
自行下载,编辑修改


作者: DNAS0310    时间: 2018-1-9 16:14
可以的 不错
作者: 无二    时间: 2018-1-10 01:12
厉害了楼主希望更新
作者: lcj21    时间: 2018-1-14 12:09
谢谢分享,支持一下!
作者: GoodSkin    时间: 2018-1-15 16:07
哇,。感谢楼楼的分享
作者: 沉沦的学弱丶    时间: 2018-1-15 18:45
这个效果就很炫了。谢谢楼主!
作者: JILM    时间: 2018-2-25 16:30
谢谢楼主,感谢分享
作者: ccjgmwz    时间: 2018-3-21 08:44
本帖最后由 ccjgmwz 于 2018-3-21 08:53 编辑

你好,首先感谢你的分享,我在使用的时候遇到了问题,我下载的demo是引用的dll,请问怎么控制按钮的状态,比如在点击ON按钮的时候如果满足条件,就不变成OFF而是继续保持ON状态
作者: qiaoke_song    时间: 2018-3-25 22:32
全部代码、说明、Demo全在这里了
https://pan.baidu.com/s/1htebnRu
自行下载,编辑修改

作者: boxxie    时间: 2018-3-28 09:51
多谢楼主分享哟
作者: 芈锅锅    时间: 2018-3-28 10:27
厉害啊,刚来的,想学这么用就好了

作者: 狂少夜铭哲    时间: 2018-4-2 10:09
嗯 , 可以 可以   这个可以借鉴一下   
作者: vrayshow    时间: 2018-4-17 12:03
谢谢楼主,感谢分享!!!
作者: 王平平平    时间: 2018-7-20 18:50
有病毒有病毒有病毒有病毒
作者: liangyuan    时间: 2018-7-29 19:19
感谢分享!
作者: HaiyuanWu    时间: 2018-8-5 22:59
好是是 的的的的的个个个个有有
作者: snskip    时间: 2018-9-15 08:14
这种资源必须支持,而且是免费的
作者: jacksonwong    时间: 2019-5-18 12:46
多谢楼主分享!
作者: 无醉    时间: 2019-6-15 16:26
感谢分享 下载学习了
作者: SimonZRG    时间: 2019-9-27 09:52
感谢楼楼的分享
作者: 顾倾。    时间: 2019-9-27 14:48
good.mark!
作者: 大瑞R    时间: 2019-10-10 16:19
谢谢分享,支持一下!
作者: 移通小白白    时间: 2019-10-12 08:10
感谢你的分享                     
作者: 移通小白白    时间: 2019-10-14 22:22
        感谢分享,LZ辛苦了~
作者: biglu    时间: 2020-2-2 21:28
感谢楼主的分享~




欢迎光临 CSkin博客 (http://bbs.cskin.net/) Powered by Discuz! X3.2