blob: 91b6b76eb11801452711e794a198f86da001002b (
plain) (
blame)
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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace love2dToAPK.Controls {
public partial class minimalButton : System.Windows.Forms.Label {
public Color BackgroundColor {
get { return colorStates[0]; }
set { generateColors(value); }
}
public Color ForegroundColor {
get { return this.ForeColor; }
set { this.ForeColor = value; }
}
private Color[] colorStates;
public minimalButton() {
InitializeComponent();
// Bind eventHandlers
this.MouseEnter += onMouseEnter;
this.MouseLeave += onMouseLeave;
this.MouseDown += onMouseDown;
this.MouseUp += onMouseUp;
// Generate colors
ForegroundColor = this.ForeColor;
BackgroundColor = this.BackColor;
}
protected override void OnPaint(PaintEventArgs pe) {
base.OnPaint(pe);
}
private void onMouseEnter(object sender, System.EventArgs e) {
this.BackColor = colorStates[1];
}
private void onMouseLeave(object sender, System.EventArgs e) {
this.BackColor = colorStates[0];
}
private void onMouseDown(object sender, System.EventArgs e) {
this.BackColor = colorStates[2];
}
private void onMouseUp(object sender, System.EventArgs e) {
this.BackColor = colorStates[1];
}
private void generateColors(Color buttonColor) {
colorStates = new Color[3];
colorStates[0] = buttonColor;
colorStates[1] = Color.FromArgb(buttonColor.R + 10, buttonColor.G + 10, buttonColor.B + 10);
colorStates[2] = Color.FromArgb(buttonColor.R - 10, buttonColor.G - 10, buttonColor.B - 10);
//colorStates[1] = buttonColor;
//colorStates[2] = buttonColor;
this.BackColor = buttonColor;
}
}
}
|