Xpbutton. CS Code
Using system;
Using system. windows;
Using system. drawing;
Using system. Drawing. drawing2d;
Using system. Windows. forms;
Namespace xpctrl
{
/// <Summary>
/// Summary of xpbutton.
/// </Summary>
Public class xpbutton: system. Windows. Forms. Button
{
Private bool Mouseover = false;
Public xpbutton ()
{
//
// Todo: add the constructor logic here
//
This. cursor = system. Windows. Forms. cursors. hand;
}
Protected override void onpaint (system. Windows. Forms. painteventargs E)
{
// Base. onpaint (E );
// System. Drawing. Graphics pp = This. creategraphics ();
// E. Graphics. Clear (color. Transparent );
// E. Graphics. drawellipse (new system. Drawing. Pen (system. Drawing. color. whitesmoke, 5), 0, 0, this. Width, this. Height );
// System. Drawing. solidbrush dd = new solidbrush (system. Drawing. color. whitesmoke );
// E. Graphics. fillellipse (DD, 0, 0, this. Width, this. Height );
// (This. backcolor. tostring ())
Color C5 = color. fromargb
(255,255,255 );
Color C2 = color. fromargb
(192,192,192 );
If (Mouseover)
{
C5 = color. fromargb (245,245,245 );
// C2 = color. fromargb (192,192,192 );
C2 = color. fromargb (180,175,190 );
}
Brush B = new system. Drawing. drawing2d. lineargradientbrush
(Clientrectangle, C5, C2, lineargradientmode. Vertical );
// System. Drawing. region = new region (
Int offsetwidth = This. width/50;
Point [] points = new point [8];
Points [0]. x = offsetwidth;
Points [0]. Y = 0;
Points [1]. x = This. Width-offsetwidth;
Points [1]. Y = 0;
Points [2]. x = This. width;
Points [2]. Y = offsetwidth;
Points [3]. x = This. width;
Points [3]. Y = This. Height-offsetwidth;
Points [4]. x = This. Width-offsetwidth;
Points [4]. Y = This. height;
Points [5]. x = offsetwidth;
Points [5]. Y = This. height;
Points [6]. x = 0;
Points [6]. Y = This. Height-offsetwidth;
Points [7]. x = 0;
Points [7]. Y = offsetwidth;
// E. Graphics. fillrectangle (B, clientrectangle );
E. Graphics. fillpolygon (B, points, fillmode. Winding );
If (this. Focused)
{
Int offsetwidth1 = (this. Width-5)/50 + 2;
Point [] points1 = new point [8];
Points1 [0]. x = offsetwidth1;
Points1 [0]. Y = 2;
Points1 [1]. x = This. Width-offsetwidth1;
Points1 [1]. Y = 2;
Points1 [2]. x = This. Width-1;
Points1 [2]. Y = offsetwidth1;
Points1 [3]. x = This. Width-1;
Points1 [3]. Y = This. Height-offsetwidth1;
Points1 [4]. x = This. Width-offsetwidth1;
Points1 [4]. Y = This. Height-1;
Points1 [5]. x = 1;
Points1 [5]. Y = This. Height-1;
Points1 [6]. x = 2;
Points1 [6]. Y = This. Height-offsetwidth1;
Points1 [7]. x = 2;
Points1 [7]. Y = offsetwidth1;
// E. Graphics. drawpolygon (new pen (color. Yellow, 2), points1 );
Pen P = new pen (color. Orange, 2 );
Pen p1 = new pen (color. Wheat, 2 );
// P. dashstyle = dashstyle. dashdot;
E. Graphics. drawline (P1, points1 [0], points1 [1]);
E. Graphics. drawline (p, points1 [1], points1 [2]);
E. Graphics. drawline (p, points1 [2], points1 [3]);
E. Graphics. drawline (p, points1 [3], points1 [4]);
E. Graphics. drawline (p, points1 [4], points1 [5]);
E. Graphics. drawline (p, points1 [5], points1 [6]);
E. Graphics. drawline (P1, points1 [6], points1 [7]);
E. Graphics. drawline (P1, points1 [7], points1 [0]);
}
E. Graphics. drawpolygon (new pen (color. darkblue, 2), points );
// E. Graphics. drawline (new pen (color. darkblue, 2), new point (0, 0), new point (this. Width, 0 ));
// E. Graphics. drawline (new pen (color. darkblue, 2), new point (0, 0), new point (0, this. Height ));
// E. graphics. drawline (new pen (color. darkblue, 2), new point (this. width, this. height), new point (this. width, 0 ));
// E. graphics. drawline (new pen (color. darkblue, 2), new point (this. width, this. height), new point (0, this. height ));
Stringformat drawformat = new stringformat ();
Drawformat. formatflags = stringformatflags. displayformatcontrol;
Drawformat. linealignment = stringalignment. Center;
Drawformat. Alignment = system. Drawing. stringalignment. Center;
E. graphics. drawstring (this. text, this. font, new lineargradientbrush (this. clientrectangle, color. black, color. black, lineargradientmode. vertical), this. clientrectangle, drawformat );
B. Dispose ();
}
Protected override void onleave (eventargs E)
{
Base. onleave (E );
}
// Protected override void onmousehover (eventargs E)
//{
//
// Mouseover = true;
// This. invalidate (false );
// Base. onmousehover (E );
//}
Protected override void onmouseenter (eventargs E)
{
Mouseover = true;
This. invalidate (false );
Base. onmouseenter (E );
}
Protected override void onnotifymessage (system. Windows. Forms. Message m)
{
Base. onpolicymessage (m );
}
Protected override void onmouseleave (eventargs E)
{
Mouseover = false;
This. invalidate (false );
Base. onmouseleave (E );
}
Private void drawbutton (system. Drawing. Graphics g)
{
}
Protected override void onpaintbackground (system. Windows. Forms. painteventargs pevent)
{
// Color C5 = color. fromargb
// (255,255,255 );
// Color C2 = color. fromargb
// (192,192,192 );
// If (Mouseover)
//{
// C5 = color. fromargb (245,245,245 );
/// C2 = color. fromargb (192,192,192 );
// C2 = color. fromargb (180,175,190 );
//}
// Brush B = new system. Drawing. drawing2d. lineargradientbrush
// (Clientrectangle, C5, C2, lineargradientmode. Vertical );
// Pevent. Graphics. drawrectangle (new pen (color. Transparent, 2), this. clientrectangle );
Pevent. Graphics. Clear (color. Wheat );
// Base. onpaintbackground (pevent );
}
}
}