-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaletteForm.cs
94 lines (88 loc) · 2.66 KB
/
PaletteForm.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using MainLibrary;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace AutoPixelArt
{
public partial class PaletteForm : Form
{
public PaletteForm(string lang)
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang == "ru" ? "ru" : "en-US");
InitializeComponent();
}
public void HighlightColorCells(string blockName, bool highlight)
{
if (string.IsNullOrEmpty(blockName))
return;
List<byte> paletteTitleCells = MainLib.PaletteTitles[blockName];
if (highlight)
{
for (byte i = 0; i < paletteTitleCells.Count; i++)
{
Control colorCell = Controls[paletteTitleCells[i]];
Controls[paletteTitleCells[i]].BackgroundImage = colorCell.BackColor.A != 0 ? Properties.Resources.itemBorder_hl : Properties.Resources.itemBorder_bg_hl;
}
}
else
{
for (byte i = 0; i < paletteTitleCells.Count; i++)
{
Control colorCell = Controls[paletteTitleCells[i]];
colorCell.BackgroundImage = colorCell.BackColor.A != 0 ? Properties.Resources.itemBorder : Properties.Resources.itemBorder_bg;
}
}
}
}
public class ColorCell : Panel
{
public ColorCell(Color cellColor, int cellIndex)
{
DoubleBuffered = true;
BackColor = cellColor;
BackgroundImage = (cellColor.A != 0) ? Properties.Resources.itemBorder : Properties.Resources.itemBorder_bg;
Cursor = Cursors.Cross;
Location = new Point(cellIndex % 9 * 100, cellIndex / 9 * 100);
Margin = new Padding(0);
Name = $"colorCell{cellIndex}";
Size = new Size(100, 100);
MouseDown += delegate (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
MainLib.HighlightColor(cellColor, cellIndex, true);
};
MouseUp += delegate (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
MainLib.HighlightColor(cellColor, cellIndex, false);
};
labelPic = new LabelPic(cellIndex, cellColor);
Controls.Add(labelPic);
}
public string ColorName { get; set; }
public LabelPic labelPic;
}
public class LabelPic : PictureBox
{
public LabelPic(int labelIndex, Color color)
{
BackColor = Color.Transparent;
Location = new Point(0, 47);
Margin = new Padding(0);
Name = $"labelPic{labelIndex}";
Size = new Size(100, 44);
SizeMode = PictureBoxSizeMode.CenterImage;
MouseDown += delegate (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
MainLib.HighlightColor(color, labelIndex, true);
};
MouseUp += delegate (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
MainLib.HighlightColor(color, labelIndex, false);
};
}
}
}