六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

自定義按鈕(轉(zhuǎn))

[摘要]//這個用戶自定義控件繼承自Button類//實現(xiàn)了在按紐左側(cè)顯示圖片的任務(wù)//和點擊后顯示不同樣式的功能//下面就是人家的了//本人加如了一些注釋using System;using System.Windows.Forms;using System.Drawing;namespace NETT...
//這個用戶自定義控件繼承自Button類
//實現(xiàn)了在按紐左側(cè)顯示圖片的任務(wù)
//和點擊后顯示不同樣式的功能
//下面就是人家的了
//本人加如了一些注釋

using System;
using System.Windows.Forms;
using System.Drawing;

namespace NETToggle
{
/// <summary>
/// Summary description for customFlatButton.
/// </summary>
public class customFlatButton : System.Windows.Forms.Button
{
//used to set the type of image that is displayed with the button
public enum TOGGLE_TYPE{ none, XML_TOGGLE, HTML_TOGGLE };//顯示類型

private bool bSelected = false;//是否被選擇
private System.Windows.Forms.ImageList flatBtnImageList;//從工具欄拖進來的了
//他的一些東西有vs.net工具自動生成
private System.ComponentModel.IContainer components;
private int toggleType = 0;

public int ToggleType
{
get{ return toggleType; }
set{ toggleType = value; }
}

public bool bChangeSelection
{
get{ return bSelected; }
set{ bSelected = value; Invalidate(); }
}

public customFlatButton()
{
InitializeComponent();
}

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(customFlatButton));
this.flatBtnImageList = new System.Windows.Forms.ImageList(this.components);
//
// flatBtnImageList
//
this.flatBtnImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.flatBtnImageList.ImageSize = new System.Drawing.Size(9, 9);
this.flatBtnImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("flatBtnImageList.ImageStream")));
this.flatBtnImageList.TransparentColor = System.Drawing.Color.Transparent;
//
// customFlatButton
//
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Size = new System.Drawing.Size(57, 19);

}

protected override void OnMouseEnter( System.EventArgs e )
{
return;
}

protected override void OnClick( System.EventArgs e)
{
bSelected = true;//觸發(fā)bChangeSelection的寫屬性--調(diào)用this.Invalidate();--引起對OnPaint()的調(diào)用
base.OnClick(e);
}

protected override void OnMouseDown( System.Windows.Forms.MouseEventArgs e)
{
OnClick(e);
}

protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
{
Rectangle rect = e.ClipRectangle;
Graphics g = e.Graphics;

if( bSelected )
{
g.FillRectangle( new SolidBrush(Color.White), rect );
g.DrawString( this.Text, this.Font, new SolidBrush(this.ForeColor), 20, (float)2.5 );

g.DrawRectangle( new Pen(System.Drawing.SystemColors.Highlight, 2), rect );
}
else
{
g.FillRectangle( new SolidBrush(System.Drawing.SystemColors.Control), rect );
g.DrawString( this.Text, this.Font, new SolidBrush(this.ForeColor),20, (float)2.5 );
}

//now draw the correct image if one is specified
if( toggleType == (int)TOGGLE_TYPE.XML_TOGGLE )
g.DrawImage( this.flatBtnImageList.Images[0], 8, 5 );
else if( toggleType == (int)TOGGLE_TYPE.HTML_TOGGLE )
g.DrawImage( this.flatBtnImageList.Images[1], 7, 5 );
}
}
}



相關(guān)文章

主站蜘蛛池模板: 五月婷婷婷 | 亚洲经典在线观看 | 四虎免费在线观看视频 | 亚洲欧美中文日韩v在线观看 | 深爱五月婷婷 | 午夜影院在线观看 | 日韩在线aⅴ免费视频 | 天天碰人人 | 天天干天天操天天插 | 亚洲偷| 性欧美另类 | 欧美视频日韩视频 | 日本最新免费不卡二区在线 | 五月婷婷社区 | 四虎影视库国产精品一区 | 午夜神器成在线人成在线人免费 | 日韩欧美理论片 | 欧美亚洲一级片 | 日本中字 | 日韩黄色a级片 | 欧美无人区码卡二三卡四卡 | 午夜国产福利在线 | 殴美激情| 在线视频一区二区三区在线播放 | 亚洲逼逼 | 亚洲欧洲综合 | 欧美囗交 | 图片区 日韩 欧美 亚洲 | 中文字幕自拍 | 天堂8中文在线最新版在线 天堂8中文在线bt | 中文字幕第一页亚洲 | 日韩风月片 | 色婷婷5月| 日韩欧美一区二区不卡看片 | 日本视频a | 日本五级床片在线观看 | 天天色天天干天天射 | 亚洲欧美综合久久 | 日韩中文欧美 | 亚洲视频一区二区在线观看 | 亚洲韩国日本欧美一区二区三区 |