1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Drawing; |
5 |
using System.Data; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Windows.Forms; |
9 |
|
10 |
namespace NexusPowerControl |
11 |
{ |
12 |
public delegate void Click(EventArgs e); |
13 |
[DefaultEvent("Click")] |
14 |
public partial class ThemeButton : UserControl |
15 |
{ |
16 |
[Browsable(true)] |
17 |
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] |
18 |
public EventHandler OnClickEvent; |
19 |
public ThemeButton() |
20 |
{ |
21 |
InitializeComponent(); |
22 |
this.OnClickEvent = null; |
23 |
this.Image = NexusPowerControl.Properties.Resources.missing; |
24 |
this.Text = "template"; |
25 |
this.ToolTip = new ToolTip(); |
26 |
} |
27 |
[Browsable(true)] |
28 |
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] |
29 |
public Image Image |
30 |
{ |
31 |
get { return picImage.Image; } |
32 |
set { picImage.Image = value; } |
33 |
} |
34 |
[Browsable(true)] |
35 |
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] |
36 |
public override string Text |
37 |
{ |
38 |
get { return lblText.Text; } |
39 |
set { lblText.Text = value; } |
40 |
} |
41 |
[Browsable(true)] |
42 |
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] |
43 |
public ToolTip ToolTip |
44 |
{ |
45 |
get { return toolTip1; } |
46 |
protected set { toolTip1 = value; } |
47 |
} |
48 |
[Browsable(true)] |
49 |
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] |
50 |
public string ToolTipText |
51 |
{ |
52 |
get { return this.ToolTip.GetToolTip(this); } |
53 |
set { this.ToolTip.SetToolTip(this, value); } |
54 |
} |
55 |
|
56 |
|
57 |
private void ThemeButton_Click(object sender, EventArgs e) |
58 |
{ |
59 |
if (this.OnClickEvent != null) |
60 |
{ |
61 |
this.OnClickEvent(this, e); |
62 |
} |
63 |
else |
64 |
{ |
65 |
base.OnClick(e); |
66 |
} |
67 |
} |
68 |
|
69 |
private void picImage_Click(object sender, EventArgs e) |
70 |
{ |
71 |
ThemeButton_Click(sender, e); |
72 |
} |
73 |
|
74 |
private void lblText_Click(object sender, EventArgs e) |
75 |
{ |
76 |
ThemeButton_Click(sender, e); |
77 |
} |
78 |
} |
79 |
} |