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

明輝手游網(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)文章

主站蜘蛛池模板: 亚洲人成网站在线观看播放 | 一级aa免费视频毛片 | 色五婷婷 | 午夜视频hd | 亚洲欧美综合色区小说 | 天美视频在线观看 | 天堂在线最新版www中文 | 亚洲人成亚洲精品 | 亚洲欧美激情在线 | 日韩乱码视频 | 青青青青草原国产免费 | 在线观看 一区二区 麻豆 | 色五月在线视频 | 日韩欧美国产综合 | 日韩视频一| 青青青青青视频免费播放 | 欧美视频综合 | 天天操天天射天天色 | 青青福利| 中文字幕乱码一二三四区 | 日韩大片免费看 | 亚洲整片 | 日韩免费精品一级毛片 | 中文字幕亚洲一区婷婷 | 婷婷色综合成人成人网小说 | 欧洲精品视频完整版在线 | 日本三级理论 | 欧美在线天堂 | 色.www| 青娱在线| 亚洲一个色| 天天弄天天操 | 伊人色综合7777 | 四虎精品久久久久影院 | 四虎影视国产在线观看精品 | 日本草草视频在线观看 | 日韩香蕉网| 欧美在线区 | 欧美一级黄色带 | 三级在线免费观看 | 午夜激情在线 |