电脑培训C# 制作出任意不规则按钮!
来源:百度文库 编辑:神马文学网 时间:2024/04/29 10:28:22
来源:http://www.accp-teem.com.cn/ArticleView/2007-1-9/Article_View_881.Htm
(原理根据背景图绘制button)
using System.Drawing.Drawing2D;
private void button3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{ this.button3.Cursor = Cursors.Hand;
Bitmap bmpBob =(Bitmap)this.button3.Image;
GraphicsPath graphicsPath = CalculateControlGraphicsPath(bmpBob);
this.button3.Region = new Region(graphicsPath);
}
private static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap)
{
GraphicsPath graphicsPath = new GraphicsPath();
Color colorTransparent = bitmap.GetPixel(0, 0);
int colOpaquePixel = 0;
for(int row = 0; row < bitmap.Height; row ++)
{
colOpaquePixel = 0;
for(int col = 0; col < bitmap.Width; col ++)
{
if(bitmap.GetPixel(col, row) != colorTransparent)
{
colOpaquePixel = col;
int colNext = col;
for(colNext=colOpaquePixel; colNextif(bitmap.GetPixel(colNext, row) == colorTransparent)
break;
graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
row, colNext - colOpaquePixel, 1));
col = colNext;
}
}
}
return graphicsPath;
}
(原理根据背景图绘制button)
using System.Drawing.Drawing2D;
private void button3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{ this.button3.Cursor = Cursors.Hand;
Bitmap bmpBob =(Bitmap)this.button3.Image;
GraphicsPath graphicsPath = CalculateControlGraphicsPath(bmpBob);
this.button3.Region = new Region(graphicsPath);
}
private static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap)
{
GraphicsPath graphicsPath = new GraphicsPath();
Color colorTransparent = bitmap.GetPixel(0, 0);
int colOpaquePixel = 0;
for(int row = 0; row < bitmap.Height; row ++)
{
colOpaquePixel = 0;
for(int col = 0; col < bitmap.Width; col ++)
{
if(bitmap.GetPixel(col, row) != colorTransparent)
{
colOpaquePixel = col;
int colNext = col;
for(colNext=colOpaquePixel; colNext
break;
graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
row, colNext - colOpaquePixel, 1));
col = colNext;
}
}
}
return graphicsPath;
}
电脑培训C# 制作出任意不规则按钮!
电脑培训:学员C#学习总结
电脑培训:C#学习总结——向德均
电脑培训:C#学习总结——向德均
PS教程--简单制作不规则边框
C#制作WinForm控件
数学方程式创造出不规则的三维图像
Photoshop制作黑白水晶按钮
教程《双功能按钮制作》
coreldraw制作透明水滴按钮
[求助]怎样创建不规则按钮? - 『 UCGUI源码学习研究 』 - 嵌入式操作系统及图形...
漂亮的玻璃按钮控件C#源码发布(采用GDI+)!
用c#制作pdf文件全攻略
利用C#设计制作端口扫描器
Delphi3中制作快速按钮条
fiash制作第8课<<控制按钮>>
fiash制作第8课<<控制按钮>>
用表格巧妙制作导航条按钮
PS一种按钮的制作[转帖]
10秒钟自制出小程序 与任意
自制出小程序与任意QQ号聊天
用C#制作PDF文件全攻略|c#(csharp)
C#简单游戏外挂制作(以Warcraft Ⅲ为例)
一个简单C#游戏程序制作 - 51CTO.COM