- 浏览: 276259 次
- 性别:
- 来自: 南京
文章分类
最新评论
-
Java_zhou:
...
Oracle自定义函数 -
wmj007:
SELECT USER_TAB_COLS.TABLE_NAME ...
Oracle 查询字段详细信息 -
avi9111:
怎么可以个人有一个MQ? 咁威的
使用c#操作IBM WebSphere MQ -
chouchouzzj:
8个小时。。。让我想起了世界时和北京时之间的差距,MQ存在时区 ...
使用c#操作IBM WebSphere MQ
vista风格的按钮 vistabutton
下载
Code
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing.Drawing2D;
namespace VistaButton
{
/// <summary>
/// 重写Windows系统按钮空间 A replacement for the Windows Button Control.
/// 技术支持 http://www.softbk.com http://wuyisky.cnblogs.com
/// wuyisky1@163.com
/// </summary>
[DefaultEvent("Click")]
public class VistaButton : System.Windows.Forms.UserControl
{
#region - Designer -
private System.ComponentModel.Container components = null;
/// <summary>
/// Initialize the component with it's
/// default settings.
/// </summary>
public VistaButton()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.BackColor = Color.Transparent;
mFadeIn.Interval = 30;
mFadeOut.Interval = 30;
}
/// <summary>
/// Release resources used by the control.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region - Component Designer generated code -
private void InitializeComponent()
{
//
// VistaButton
//
this.Name = "VistaButton";
this.Size = new System.Drawing.Size(100, 32);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VistaButton_Paint);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.VistaButton_KeyUp);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VistaButton_KeyDown);
this.MouseEnter += new System.EventHandler(this.VistaButton_MouseEnter);
this.MouseLeave += new System.EventHandler(this.VistaButton_MouseLeave);
this.MouseUp += new MouseEventHandler(VistaButton_MouseUp);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.VistaButton_MouseDown);
//this.GotFocus += new EventHandler(VistaButton_MouseEnter);
//this.LostFocus += new EventHandler(VistaButton_MouseLeave);
this.mFadeIn.Tick += new EventHandler(mFadeIn_Tick);
this.mFadeOut.Tick += new EventHandler(mFadeOut_Tick);
this.Resize += new EventHandler(VistaButton_Resize);
}
#endregion
#endregion
#region - Enums -
/// <summary>
/// A private enumeration that determines
/// the mouse state in relation to the
/// current instance of the control.
/// </summary>
enum State { None, Hover, Pressed };
/// <summary>
/// A public enumeration that determines whether
/// the button background is painted when the
/// mouse is not inside the ClientArea.
/// </summary>
public enum Style
{
/// <summary>
/// Draw the button as normal
/// </summary>
Default,
/// <summary>
/// Only draw the background on mouse over.
/// </summary>
Flat
};
#endregion
#region - Properties -
#region - Private Variables -
private bool calledbykey = false;
private State mButtonState = State.None;
private Timer mFadeIn = new Timer();
private Timer mFadeOut = new Timer();
private int mGlowAlpha = 0;
#endregion
#region - Text -
private string mText;
/// <summary>
/// The text that is displayed on the button.
/// </summary>
[Category("Text"),
Description("The text that is displayed on the button.")]
public string ButtonText
{
get { return mText; }
set { mText = value; this.Invalidate(); }
}
private Color mForeColor = Color.White;
/// <summary>
/// The color with which the text is drawn.
/// </summary>
[Category("Text"),
Browsable(true),
DefaultValue(typeof(Color), "White"),
Description("The color with which the text is drawn.")]
public override Color ForeColor
{
get { return mForeColor; }
set { mForeColor = value; this.Invalidate(); }
}
private ContentAlignment mTextAlign = ContentAlignment.MiddleCenter;
/// <summary>
/// The alignment of the button text
/// that is displayed on the control.
/// </summary>
[Category("Text"),
DefaultValue(typeof(ContentAlignment), "MiddleCenter"),
Description("The alignment of the button text " +
"that is displayed on the control.")]
public ContentAlignment TextAlign
{
get { return mTextAlign; }
set { mTextAlign = value; this.Invalidate(); }
}
#endregion
#region - Image -
private Image mImage;
/// <summary>
/// The image displayed on the button that
/// is used to help the user identify
/// it's function if the text is ambiguous.
/// </summary>
[Category("Image"),
DefaultValue(null),
Description("The image displayed on the button that " +
"is used to help the user identify" +
"it's function if the text is ambiguous.")]
public Image Image
{
get { return mImage; }
set { mImage = value; this.Invalidate(); }
}
private ContentAlignment mImageAlign = ContentAlignment.MiddleLeft;
/// <summary>
/// The alignment of the image
/// in relation to the button.
/// </summary>
[Category("Image"),
DefaultValue(typeof(ContentAlignment), "MiddleLeft"),
Description("The alignment of the image " +
"in relation to the button.")]
public ContentAlignment ImageAlign
{
get { return mImageAlign; }
set { mImageAlign = value; this.Invalidate(); }
}
private Size mImageSize = new Size(24, 24);
/// <summary>
/// The size of the image to be displayed on the
/// button. This property defaults to 24x24.
/// </summary>
[Category("Image"),
DefaultValue(typeof(Size), "24, 24"),
Description("The size of the image to be displayed on the" +
"button. This property defaults to 24x24.")]
public Size ImageSize
{
get { return mImageSize; }
set { mImageSize = value; this.Invalidate(); }
}
#endregion
#region - Appearance -
private Style mButtonStyle = Style.Default;
/// <summary>
/// Sets whether the button background is drawn
/// while the mouse is outside of the client area.
/// </summary>
[Category("Appearance"),
DefaultValue(typeof(Style), "Default"),
Description("Sets whether the button background is drawn " +
"while the mouse is outside of the client area.")]
public Style ButtonStyle
{
get { return mButtonStyle; }
set { mButtonStyle = value; this.Invalidate(); }
}
private int mCornerRadius = 8;
/// <summary>
/// The radius for the button corners. The
/// greater this value is, the more 'smooth'
/// the corners are. This property should
/// not be greater than half of the
/// controls height.
/// </summary>
[Category("Appearance"),
DefaultValue(8),
Description("The radius for the button corners. The " +
"greater this value is, the more 'smooth' " +
"the corners are. This property should " +
"not be greater than half of the " +
"controls height.")]
public int CornerRadius
{
get { return mCornerRadius; }
set { mCornerRadius = value; this.Invalidate(); }
}
private Color mHighlightColor = Color.White;
/// <summary>
/// The colour of the highlight on the top of the button.
/// </summary>
[Category("Appearance"),
DefaultValue(typeof(Color), "White"),
Description("The colour of the highlight on the top of the button.")]
public Color HighlightColor
{
get { return mHighlightColor; }
set { mHighlightColor = value; this.Invalidate(); }
}
private Color mButtonColor = Color.Black;
/// <summary>
/// The bottom color of the button that
/// will be drawn over the base color.
/// </summary>
[Category("Appearance"),
DefaultValue(typeof(Color), "Black"),
Description("The bottom color of the button that " +
"will be drawn over the base color.")]
public Color ButtonColor
{
get { return mButtonColor; }
set { mButtonColor = value; this.Invalidate(); }
}
private Color mGlowColor = Color.FromArgb(141, 189, 255);
/// <summary>
/// The colour that the button glows when
/// the mouse is inside the client area.
/// </summary>
[Category("Appearance"),
DefaultValue(typeof(Color), "141,189,255"),
Description("The colour that the button glows when " +
"the mouse is inside the client area.")]
public Color GlowColor
{
get { return mGlowColor; }
set { mGlowColor = value; this.Invalidate(); }
}
private Image mBackImage;
/// <summary>
/// The background image for the button,
/// this image is drawn over the base
/// color of the button.
/// </summary>
[Category("Appearance"),
DefaultValue(null),
Description("The background image for the button, " +
"this image is drawn over the base " +
"color of the button.")]
public Image BackImage
{
get { return mBackImage; }
set { mBackImage = value; this.Invalidate(); }
}
private Color mBaseColor = Color.Black;
/// <summary>
/// The backing color that the rest of
/// the button is drawn. For a glassier
/// effect set this property to Transparent.
/// </summary>
[Category("Appearance"),
DefaultValue(typeof(Color), "Black"),
Description("The backing color that the rest of" +
"the button is drawn. For a glassier " +
"effect set this property to Transparent.")]
public Color BaseColor
{
get { return mBaseColor; }
set { mBaseColor = value; this.Invalidate(); }
}
#endregion
#endregion
#region - Functions -
private GraphicsPath RoundRect(RectangleF r, float r1, float r2, float r3, float r4)
{
float x = r.X, y = r.Y, w = r.Width, h = r.Height;
GraphicsPath rr = new GraphicsPath();
rr.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y);
rr.AddLine(x + r1, y, x + w - r2, y);
rr.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2);
rr.AddLine(x + w, y + r2, x + w, y + h - r3);
rr.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h);
rr.AddLine(x + w - r3, y + h, x + r4, y + h);
rr.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4);
rr.AddLine(x, y + h - r4, x, y + r1);
return rr;
}
#endregion
#region - Drawing -
/// <summary>
/// Draws the outer border for the control
/// using the ButtonColor property.
/// </summary>
/// <param name="g">The graphics object used in the paint event.</param>
private void DrawOuterStroke(Graphics g)
{
if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
Rectangle r = this.ClientRectangle;
r.Width -= 1; r.Height -= 1;
using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
{
using (Pen p = new Pen(this.ButtonColor))
{
g.DrawPath(p, rr);
}
}
}
/// <summary>
/// Draws the inner border for the control
/// using the HighlightColor property.
/// </summary>
/// <param name="g"><span s
发表评论
-
想做一个wiki网站
2007-06-16 01:01 799很想做一个wiki网站,用来收集一些资源,不知道好不好 -
.net 编译器csc的用法大全
2007-07-03 13:08 14381. 配置环境变量:在path 变量中加上csc.exe的路径 ... -
ASP日期和时间函数
2007-07-04 11:37 1194<%=year(now)%>年<%=mo ... -
C# ini文件读写 类
2007-08-05 14:00 1553一个C# ini文件读写类,从网上收集的,很全,就是没有对se ... -
C# 接口
2007-08-13 16:18 792目录 接口的定义 ... -
c#索引器
2007-08-13 17:13 1307经常见有这样的类:如aClass a = new Class ... -
为sql server 表数据生成创建的储存过程(生成insert 脚本)
2007-08-14 13:35 1165使用SQL Server 2000自带的“生成SQL脚本”工具 ... -
学习MemberShip
2007-08-15 21:38 878这几天没时间,先收集一些资料(没有msdn就是不爽,上网速度有 ... -
sql server的随机函数newID()和RAND()
2007-08-16 20:15 1718sql server的随机函数newID( ... -
用The Regulator 学习正则表达式
2007-08-17 17:12 1067前几天发现一个好的学习正则表达式的工具 The Regulat ... -
C# float 与零比较(南京某公司面试题)
2007-09-01 02:48 2184写出float类型与零比较的判断语句 <script t ... -
我的.net学习资料
2007-09-11 00:55 1126我的.net学习资料 -
javascript 给text赋值
2007-09-25 12:27 2786javascript 给text赋值 方法一: <!D ... -
javascript权威指南例子(自己写的)
2007-10-03 14:17 900javascript权威指南例子(自己边看边写的) 前面几章的 ... -
msdn的javascript文章转载
2007-10-08 10:18 1073JavaScript 使用面向对象的技术创建高级 Web 应用 ... -
vs2005 调试时出现“无法附加。绑定句柄无效”的解决办法
2007-10-08 17:34 1232vs2005启动调试程序时,出现 无法附加,绑定句柄无效 ... -
vs 2005 启动设备仿真器管理器出错(wm5)解决方案
2007-10-10 12:14 1184vs 2005 启动设备仿真器管理器出错(wm5)解决方案,问 ... -
C#(.net) 线程和最小化到托盘的例子
2007-10-13 15:55 1058自己写的一个使用线程和最小化到托盘的例子。 例子下载当你看这个 ... -
ORACLE函数介绍
2007-10-17 12:22 820ORACLE函数介绍 第一篇 著名函数之单值函数 ... -
sqlserver 查询字段的详细信息
2007-11-29 19:54 892sqlserver 查询字段的详细信息 http://www. ...
相关推荐
总的来说,创建一个C#的Vista风格按钮控件涉及到多个方面的知识,包括图形绘制、事件处理、动画实现和性能优化。虽然这个过程可能较为复杂,但一旦掌握,你将能够为你的应用程序增添独特的视觉吸引力和用户体验。...
Vista风格的日历控件是其中一种,它提供了美观的界面和便捷的日历功能。本篇将详细讲解如何利用标题中提及的"C# Vista风格日历控件DLL"进行开发。 首先,这个控件是一个动态链接库(DLL)文件,名为`VistaCalendar....
在Windows Forms中,虽然没有直接的Vista风格按钮控件,但我们可以通过自定义控件来模拟这种效果。这通常涉及到重绘按钮的背景和边框,使用GDI+图形库来实现半透明和动态效果。我们可以覆盖`OnPaint`事件,并在其中...
如果源码没有直接使用Aero Glass,那么可能是通过绘制自定义的背景、边框和按钮来模拟Vista风格。 3. **事件处理**:C#中的事件处理机制是控件交互的核心。日历控件会包含多种事件,如日期选择、月份切换等。开发者...
接下来,通过重绘控件来实现Vista风格的视觉效果,这通常涉及到绘制背景、边框、按钮等元素。使用Graphics类和Pen、Brush对象进行绘制,并利用Windows API调用来获取系统主题颜色,以保持与Vista风格的一致性。 2. ...
漂亮的Vista风格按钮源码全用函数画出,没用图片,是自定义控件最好的范例。 效果图和代码说明:http://www.our-code.com/news/2010920/n4649132.html C#Vista风格按钮源码 C#下自定义控件的范例
"C# Vista风格日历控件2021.rar"是一个包含C#实现的,模仿Windows Vista界面设计的日历和日期选择组件的压缩包。这个控件不仅提供了基本的日历展示功能,还可能具备了Vista风格的美观界面和增强的用户体验。 Vista...
标题中的“VB仿Vista风格真彩色图标按钮控件”是指在Visual Basic(VB)环境中开发的一种用户界面组件,它模仿了微软Windows Vista操作系统中的视觉样式。这种控件允许开发者在他们的应用程序中创建具有真实色彩、高...
总的来说,"用户自定义控件Vista风格按钮"项目展示了C#中自定义控件的创建过程,包括继承已有控件、重绘控件外观、处理用户交互事件以及封装和分发自定义控件。这个项目不仅有助于提升应用程序的视觉效果,也是深入...
"逼真的仿Vista效果的按钮控件"再次强调了这个控件的主要特性,即其能够高度模拟Vista风格的按钮,包括色彩、阴影、高光等细节,以提供更吸引人的用户界面。 标签“.net”指示了该控件是基于.NET Framework的,这是...
【标题】:“控件类库Vista风格日历控件C#版”是针对Windows操作系统Vista界面设计的一款日历控件,它采用C#编程语言实现,为开发者提供了更现代、美观的用户界面元素。 【描述】:这个控件库的C#源代码为开发者...
首先,`VistaButton.cs`文件是C#源代码文件,其中包含了实现Vista风格按钮的核心逻辑。这个类通常会继承自`System.Windows.Forms.Button`基类,并重写或扩展一些方法和属性,以便提供Vista样式的效果。开发者可能会...
它是动态链接库,封装了所有与Vista风格按钮相关的功能和样式。开发人员在项目中引用这个DLL后,就可以在代码中实例化VistaButton控件,并可以通过属性设置来调整按钮的外观和行为,例如颜色、大小、文本、图标等。...
这个"VB仿Vista风格窗体控件源码.7z"压缩包提供了模仿Windows Vista操作系统界面风格的控件集,对于开发者来说,可以方便地在VB项目中创建具有Vista视觉效果的应用程序。 Vista风格的界面设计注重用户体验,引入了...
在压缩包文件"Vista风格按钮"中,可能包含了一些示例代码或库文件,用于展示如何在C#项目中创建和使用这些风格的按钮。如果能够查看这些文件,将有助于深入理解并实践上述知识。在实际操作时,记得根据项目需求选择...
能实现java、mac、vista等多种风格的按钮,可自定义添加PNG透明图片,实现不规则图形按钮。
"C# 漂亮vista按钮"这个项目是利用Visual Studio 2008(简称VS2008)来创建一个具有Vista风格的按钮控件。Vista是微软在2007年发布的一款操作系统,它引入了全新的用户界面和设计元素,其中就包括更加现代化和美观的...
4. **主题兼容性**:虽然这些控件模仿XP风格,但也要考虑程序在不同操作系统上的表现,确保在Windows XP、Vista、Win7甚至更高版本上都能正常工作。 5. **性能优化**:由于XP风格控件可能增加了额外的图形渲染,...
在本文中,我们将深入探讨MFC(Microsoft Foundation Classes)中各种控件的使用与布局,特别是在实现透明Vista风格界面的技巧。MFC是微软提供的一套C++库,用于构建Windows应用程序,它极大地简化了Windows API的...