zoukankan      html  css  js  c++  java
  • 类似iPhone的 按钮 上带数字 winform 按钮

    效果如图:

    因为工作中要用到  类似的代码       google 了 半天也没找到,  最后  还是 找到了   园中的  这一篇

    C# 模仿360安全卫士玻璃按钮(源码)

    因为本人水平有限, 但又急着用   所以  胡乱加了一点 代码  勉强实现了  类似的效果          另外 感谢 原作者(阿东东)提供的 源码 

    其它部分基本都没有修改  主要是在   void DrawImage(Graphics g) 这个 代码中添加了  画圆角矩形和数字 效果

                  if (BitmapNum > 0)
                    {
                        int x = this.Width - 26;
                        int x1 = this.Width - 21;
                        int width = 20;
    
                        switch (BitmapNum.ToString().Length)
                        {
    
                            case 2:
                                x = x + 2;
                                width = width + 4;
                                break;
    
                            case 3:
                                x = x - 4;
                                x1 = x + 3;
                                width = width + 10;
                                break;
    
                            case 4:
                                x = x - 8;
                                x1 = x + 1;
                                width = width + 16;
                                break;
                        }
    
                        FillRoundRectangle(g, new Rectangle(x, 2, width, 20), BitmapColor, 6);
    
                        g.DrawString(BitmapNum.ToString(), new Font("Arial", 9, FontStyle.Bold),
                            new SolidBrush(Color.White), x1, 4);
                    }
    

    代码写的比较烂,  大家凑合看吧    主要也是想  看看  大家有没有别的更好的方法  能提供一下给我    谢谢了

    代码 不清晰的地方  大家可以对比看看  原作者的代码  他的比较清楚    

    源码: 

     /Files/hpze2000/GlassButton.zip

  • 相关阅读:
    c++ struct 使用
    c++数组、字符串操作
    c++ List、Vector、Stack、Queue使用
    十三、哈希表
    十二、234树
    十一、红黑树
    十、哈夫曼编码
    九、二叉树
    八、高级排序
    七、递归
  • 原文地址:https://www.cnblogs.com/hpze2000/p/2521678.html
Copyright © 2011-2022 走看看