-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathColorPicker.cs
65 lines (57 loc) · 4.11 KB
/
ColorPicker.cs
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
// Copyright 2009-2013 Matvei Stefarov <[email protected]>
using System.Collections.Generic;
using System.Windows.Forms;
namespace fCraft.ConfigGUI {
internal sealed partial class ColorPicker : Form {
public static readonly Dictionary<int, ColorPair> ColorPairs = new Dictionary<int, ColorPair>();
public int ColorIndex;
static ColorPicker() {
ColorPairs.Add( 0, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Black ) );
ColorPairs.Add( 8, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.DimGray ) );
ColorPairs.Add( 1, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Navy ) );
ColorPairs.Add( 9, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.RoyalBlue ) );
ColorPairs.Add( 2, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Green ) );
ColorPairs.Add( 10, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.Lime ) );
ColorPairs.Add( 3, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Teal ) );
ColorPairs.Add( 11, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.Aqua ) );
ColorPairs.Add( 4, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Maroon ) );
ColorPairs.Add( 12, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Red ) );
ColorPairs.Add( 5, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Purple ) );
ColorPairs.Add( 13, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.Magenta ) );
ColorPairs.Add( 6, new ColorPair( System.Drawing.Color.White, System.Drawing.Color.Olive ) );
ColorPairs.Add( 14, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.Yellow ) );
ColorPairs.Add( 7, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.Silver ) );
ColorPairs.Add( 15, new ColorPair( System.Drawing.Color.Black, System.Drawing.Color.White ) );
}
public ColorPicker( string title, int oldColorIndex ) {
InitializeComponent();
Text = title;
ColorIndex = oldColorIndex;
StartPosition = FormStartPosition.CenterParent;
b0.Click += delegate { ColorIndex = 0; DialogResult = DialogResult.OK; Close(); };
b1.Click += delegate { ColorIndex = 1; DialogResult = DialogResult.OK; Close(); };
b2.Click += delegate { ColorIndex = 2; DialogResult = DialogResult.OK; Close(); };
b3.Click += delegate { ColorIndex = 3; DialogResult = DialogResult.OK; Close(); };
b4.Click += delegate { ColorIndex = 4; DialogResult = DialogResult.OK; Close(); };
b5.Click += delegate { ColorIndex = 5; DialogResult = DialogResult.OK; Close(); };
b6.Click += delegate { ColorIndex = 6; DialogResult = DialogResult.OK; Close(); };
b7.Click += delegate { ColorIndex = 7; DialogResult = DialogResult.OK; Close(); };
b8.Click += delegate { ColorIndex = 8; DialogResult = DialogResult.OK; Close(); };
b9.Click += delegate { ColorIndex = 9; DialogResult = DialogResult.OK; Close(); };
ba.Click += delegate { ColorIndex = 10; DialogResult = DialogResult.OK; Close(); };
bb.Click += delegate { ColorIndex = 11; DialogResult = DialogResult.OK; Close(); };
bc.Click += delegate { ColorIndex = 12; DialogResult = DialogResult.OK; Close(); };
bd.Click += delegate { ColorIndex = 13; DialogResult = DialogResult.OK; Close(); };
be.Click += delegate { ColorIndex = 14; DialogResult = DialogResult.OK; Close(); };
bf.Click += delegate { ColorIndex = 15; DialogResult = DialogResult.OK; Close(); };
}
internal struct ColorPair {
public ColorPair( System.Drawing.Color foreground, System.Drawing.Color background ) {
Foreground = foreground;
Background = background;
}
public System.Drawing.Color Foreground;
public System.Drawing.Color Background;
}
}
}