using ;
using .Collections;
using .ComponentModel;
using .Drawing;
using .Data;
using .Windows.Forms;
using .Diagnostics;
EastSpider
{
/// <summary>
/// Summary description for VSNetButton.
/// </summary>
public XPButton : .Windows.Forms.Button
{
bool gotFocus = false;
bool mouseDown = false;
bool mouseEnter = false;
bool useDisableImage = true;
public XPButton
{
SetStyle(ControlStyles.AllPaingInWmPa|ControlStyles.UserPa|ControlStyles.Opaque, true);
}
public bool UseDisableImage
{
get
{
useDisableImage;
}
{
useDisableImage = value;
}
}
protected override void _disibledevent=>
( mouseDown )
{
DrawSelectedState(g, ColorUtil.VSNetPressedColor);
;
}
(mouseEnter)
{
DrawSelectedState(g, ColorUtil.VSNetSelectionColor);
;
}
( Enabled )
DrawNormalState(pe.Graphics);
DrawDisableState(pe.Graphics);
}
protected override void _disibledevent=>base.OnMouseEnter(e);
Invalidate;
}
protected override void _disibledevent=>base.OnMouseLeave(e);
Invalidate;
}
protected override void _disibledevent=>
{
// Don\'t call base
// it makes the paing to screw up
base.OnMouseDown(e);
mouseDown = true;
Invalidate;
}
protected override void _disibledevent=>Invalidate;
}
protected override void _disibledevent=>Invalidate;
}
protected override void _disibledevent=>Invalidate;
}
protected void DrawNormalState(Graphics g)
{
Rectangle rc = ClientRectangle;
// Draw background
g.FillRectangle( SolidBrush(Colors.Control), rc);
( Image != null )
{
SizeF sizeF = Image.PhysicalDimension;
imageWidth = ()sizeF.Width;
imageHeight = ()sizeF.Height;
// We are assuming that the button image is smaller than
// the button itself
( imageWidth > rc.Width || imageHeight > rc.Height)
{
Debug.WriteLine(\"Image dimensions need to be smaller that button\'s dimension...\");
;
}
x = (Width - imageWidth)/2;
y = (Height - imageHeight)/2;
g.DrawImage(Image, x, y, imageWidth, imageHeight);
}
}
protected void DrawDisableState(Graphics g)
{
// Draw disable image
Rectangle rc = ClientRectangle;
// Erase whaterver that was there before
g.FillRectangle( SolidBrush(Colors.Control), rc);
// Draw border rectangle
g.DrawRectangle( Pen( SolidBrush(Colors.ControlDark)),
rc.Left, rc.Top, rc.Width-1, rc.Height-1);
// Draw disable image
( Image != null )
{
SizeF sizeF = Image.PhysicalDimension;
imageWidth = ()sizeF.Width;
imageHeight = ()sizeF.Height;
// We are assuming that the button image is smaller than
// the button itself
( imageWidth > rc.Width || imageHeight > rc.Height)
{
Debug.WriteLine(\"Image dimensions need to be smaller that button\'s dimension...\");
;
}
x = (Width - imageWidth)/2;
y = (Height - imageHeight)/2;
ControlPa.DrawImageDisabled(g, Image, x, y, Colors.Control);
}
}
protected void DrawSelectedState(Graphics g, Color selColor)
{
Rectangle rc = ClientRectangle;
// Erase whaterver that was there before
g.FillRectangle( SolidBrush(selColor), rc);
// Draw border rectangle
g.DrawRectangle( Pen( SolidBrush(Colors.Highlight)),
rc.Left, rc.Top, rc.Width-1, rc.Height-1);
// Draw image
( Image != null )
{
SizeF sizeF = Image.PhysicalDimension;
imageWidth = ()sizeF.Width;
imageHeight = ()sizeF.Height;
// We are assuming that the button image is smaller than
// the button itself
( imageWidth > rc.Width || imageHeight > rc.Height)
{
Debug.WriteLine(\"Image dimensions need to be smaller that button\'s dimension...\");
;
}
x = (Width - imageWidth)/2;
y = (Height - imageHeight)/2;
gap = 1;
( selColor != ColorUtil.VSNetPressedColor )
{
// Draw disable image first to produce the popping image effect
( useDisableImage )
{
ControlPa.DrawImageDisabled(g, Image, x, y, Colors.Control);
}
gap = 0;
}
{
gap = 0;
}
g.DrawImage(Image, x-gap, y-gap, imageWidth, imageHeight);
}
}
}
}
最新评论