-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFlatButton.cs
More file actions
86 lines (75 loc) · 1.78 KB
/
Copy pathFlatButton.cs
File metadata and controls
86 lines (75 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Spirograph
{
public class FlatButton : Button
{
/// <summary>
/// Required designer variable.
/// </summary>
private Container components = null;
private bool hover;
public FlatButton()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter (e);
hover=true;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave (e);
hover=false;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
if ( this.ImageList != null )
this.ImageList.Draw(e.Graphics, ImageIndex, 0, 0);
else
{
e.Graphics.FillRectangle(Brushes.White, ClientRectangle);
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(ForeColor), 0, 0);
}
if ( hover )
e.Graphics.DrawRectangle(Pens.Black, 0, 0, Width-1, Height-1);
if ( Focused )
{
Rectangle rc=ClientRectangle;
rc.Inflate(-1, -1);
ControlPaint.DrawFocusRectangle(e.Graphics, rc);
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}