Button | The program makes a control so you can say goodbye to the picture button:
Effect:
Program Source code:
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Drawing;
Using System.Data;
Using System.Windows.Forms;
Using System.Drawing.Drawing2D;
Using System.Drawing.Text;
Namespace WindowsControlLibrary1
{
<summary>
Summary description of the UserControl1.
</summary>
public class Usercontrol1:button
{
<summary>
The required designer variable.
</summary>
Private System.ComponentModel.Container components = null;
private bool Xiacen=false;
private bool Mousemove=false;
Private Color BackColor;
Public UserControl1 ()
{
This call is required for the Windows.Forms form designer.
InitializeComponent ();
TODO: Add any initialization after the initcomponent call
Backcolor=this.backcolor;
This. Text=this. Showfocuscues.tostring ();
}
<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
Components. Dispose ();
}
Base. Dispose (disposing);
}
Code generated #region Component Designer
<summary>
Designer supports the desired method-do not use the Code Editor
Modify the contents of this method.
</summary>
private void InitializeComponent ()
{
//
UserControl1
//
This. MouseUp + = new System.Windows.Forms.MouseEventHandler (this. Usercontrol1_mouseup);
This. Paint + = new System.Windows.Forms.PaintEventHandler (this. Usercontrol1_paint);
This. MouseEnter + = new System.EventHandler (this. Usercontrol1_mouseenter);
This. KeyUp + = new System.Windows.Forms.KeyEventHandler (this. Usercontrol1_keyup);
This. KeyDown + = new System.Windows.Forms.KeyEventHandler (this. Usercontrol1_keydown);
This. Backcolorchanged + = new System.EventHandler (this. usercontrol1_backcolorchanged);
This. MouseLeave + = new System.EventHandler (this. Usercontrol1_mouseleave);
This. MouseDown + = new System.Windows.Forms.MouseEventHandler (this. Usercontrol1_mousedown);
}
#endregion
Protected GraphicsPath Getgraphicspath (Rectangle rect)
{
GraphicsPath Clientpath = new System.Drawing.Drawing2D.GraphicsPath ();
if (rect. width<=0)
{
Rect. width=1;
}
if (rect. height<=0)
{
Rect. Height=1;
}
int R=BACKCOLOR.R;
int g=backcolor.g;
int b=backcolor.b;
R=r+3*a;
G=g+3*a;
B=b+3*a;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
Gr. FillPath (New SolidBrush (Color.FromArgb (r,g,b)), path);
}
}
if (this. Focused)
{
E.graphics.drawpath (New Pen (Color.FromArgb (0x22,0xff,0xff,0xff), 3), Clientpath);
}
}
private void Usercontrol1_backcolorchanged (object sender, System.EventArgs e)
{
int R=BACKCOLOR.R;
int g=backcolor.g;
int b=backcolor.b;
r=r+0x22;
g=g+0x22;
b=b+0x22;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
Backcolor=color.fromargb (R,G,B);
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.