C#自繪多狀態按鈕
来源:互联网 发布:js添加声音读出软件 编辑:程序博客网 时间:2024/06/01 21:59
C#自繪多狀態按鈕
protected override void OnPaintBackground(PaintEventArgs pea)
{
Graphics grfx = pea.Graphics;
grfx.PageUnit = GraphicsUnit.Pixel;
Graphics offScreenGraphics;
Bitmap offscreenBitmap;
offscreenBitmap = new Bitmap(BackgroundBitmap.Width, BackgroundBitmap.Height);
offScreenGraphics = Graphics.FromImage(offscreenBitmap);
if (BackgroundBitmap != null)
{
offScreenGraphics.DrawImage(BackgroundBitmap, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
}
DrawCloseButton(offScreenGraphics);
DrawText(offScreenGraphics);
grfx.DrawImage(offscreenBitmap, 0, 0);
}
/// <summary>
/// Sets the 3-State Close Button bitmap, its transparency color and its coordinates
/// </summary>
/// <param name="strFilename">Path of the 3-state Close button Bitmap on the disk (width must a multiple of 3)</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// <param name="position">Location of the close button on the popup</param>
/// <returns>Nothing</returns>
public void SetCloseBitmap(string strFilename, Color transparencyColor, Point position)
{
CloseBitmap = new Bitmap(strFilename);
CloseBitmap.MakeTransparent(transparencyColor);
CloseBitmapSize = new Size(CloseBitmap.Width/3, CloseBitmap.Height);
CloseBitmapLocation = position;
}
/// <summary>
/// Sets the 3-State Close Button bitmap, its transparency color and its coordinates
/// </summary>
/// <param name="image">Image/Bitmap object which represents the 3-state Close button Bitmap (width must be a multiple of 3)</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// /// <param name="position">Location of the close button on the popup</param>
/// <returns>Nothing</returns>
public void SetCloseBitmap(Image image, Color transparencyColor, Point position)
{
CloseBitmap = new Bitmap(image);
CloseBitmap.MakeTransparent(transparencyColor);
CloseBitmapSize = new Size(CloseBitmap.Width/3, CloseBitmap.Height);
CloseBitmapLocation = position;
}
protected void DrawCloseButton(Graphics grfx)
{
if (CloseBitmap != null)
{
Rectangle rectDest = new Rectangle(CloseBitmapLocation, CloseBitmapSize);
Rectangle rectSrc;
if (bIsMouseOverClose)
{
if (bIsMouseDown)
rectSrc = new Rectangle(new Point(CloseBitmapSize.Width*2, 0), CloseBitmapSize);
else
rectSrc = new Rectangle(new Point(CloseBitmapSize.Width, 0), CloseBitmapSize);
}
else
rectSrc = new Rectangle(new Point(0, 0), CloseBitmapSize);
grfx.DrawImage(CloseBitmap, rectDest, rectSrc, GraphicsUnit.Pixel);
}
}
- C#自繪多狀態按鈕
- c#程序自启动
- C#自定義直線箭頭大小
- C#开机自启动
- C# 开机自启动
- C#的自开发软件
- C#的自悟
- C# 应用程序自删除
- C#自增和自减
- C#實現自動啟動
- c# 自绘列表框
- C#反射------转自CSDN
- C#获取自增ID
- c# 自带进制转换
- c# 设置开机自启动
- C#自绘控件外形
- C# WinForm 自绘TreeView
- C#自带的事件
- SQL查询表是否存在的两种方法
- java中this的含义?
- SQL查询表是否存在的两种方法
- SQL查询表是否存在的两种方法
- SQL查询表是否存在的两种方法
- C#自繪多狀態按鈕
- WTL.CDC.DrawText参数介绍
- .NET 部署指南(1)
- 文件遍历和过滤
- IDC:全球交付趋势将影响服务外包业
- GridView内按钮Click之后取值
- windows 2003 域控制器降级
- VSS Error: error reading from file 解决方法
- 热炒