效果如图:
因为工作中要用到 类似的代码 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); }
代码写的比较烂, 大家凑合看吧 主要也是想 看看 大家有没有别的更好的方法 能提供一下给我 谢谢了
代码 不清晰的地方 大家可以对比看看 原作者的代码 他的比较清楚
源码: