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

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

自定義按鈕(轉)

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

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;//觸發bChangeSelection的寫屬性--調用this.Invalidate();--引起對OnPaint()的調用
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 );
}
}
}



主站蜘蛛池模板: 日本视频不卡 | 日本视频在线观看播放免费 | 四虎在线观看一区二区 | 午夜亚洲福利 | 亚洲图片综合区另类图片 | 天天干天天草天天 | 天天天夜夜夜 | 羞羞漫画在线阅读页面漫画入口页面弹窗无限 | 青草全福视在线 | 伊人久久综合影院首页 | 性生活视频欧美 | 午夜影院在线观看视频 | 中文字幕不卡视频 | 日本色资源 | 亚洲天堂高清 | 天啪天天久久天天综合啪 | 天天综合天天干 | 日本在线观看一级高清片 | 亚洲一二三四区 | 影音先锋男人资源站 | 婷婷丁香综合 | 欧美性高清极品猛交 | 日日摸夜夜添夜夜添成人 | 网址在线观看 | 日韩高清在线观看 | 伊人手机在线视频 | 午夜小视频网站 | 色综合五月婷婷 | 日韩亚洲综合精品国产 | 天天躁夜夜 | 亚洲综合色在线观看 | 青青青线在线观看 | 性天堂网| 午夜三级成人三级 | 日本mv精品中文字幕 | 亚欧精品在线观看 | 欧美一级淫片免费播放口 | 亚洲视频免费在线 | 四虎免费永久在线播放 | 亚洲高清一区二区三区四区 | 午夜影视在线观看免费完整高清大全 |