This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFormNew.cs
81 lines (72 loc) · 1.8 KB
/
FormNew.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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace OpenRA.TilesetBuilder
{
public partial class FormNew : Form
{
public bool PaletteFromImage = true;
public string PaletteFile = "";
public string ImageFile = "";
public int TileSize = 24;
public FormNew()
{
InitializeComponent();
}
private void CancelButtonClick(object sender, EventArgs e)
{
Close();
}
private void OkButtonClick(object sender, EventArgs e)
{
if (!PaletteFromImage)
{
if (PaletteFile.Length < 5)
MessageBox.Show("No palette specified", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (ImageFile.Length < 5)
MessageBox.Show("No image selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
DialogResult = DialogResult.OK;
Close();
}
}
private void UsePaletteFromImageCheckedChanged(object sender, EventArgs e)
{
if (chkUsePalFromImage.Checked)
{
btnPalBrowse.Enabled = false;
PaletteFromImage = true;
}
else
{
btnPalBrowse.Enabled = true;
PaletteFromImage = false;
}
}
private void PaletteBrowseClick(object sender, EventArgs e)
{
using (var ofd = new OpenFileDialog { Filter = "C&C Palette (*.pal)|*.pal" })
if (DialogResult.OK == ofd.ShowDialog())
{
PaletteFile = ofd.FileName;
txtPal.Text = PaletteFile;
}
}
private void ImageBrowseClick(object sender, EventArgs e)
{
using (var ofd = new OpenFileDialog { Filter = "8bit Image (*.png,*.pcx,*.bmp)|*.png;*.pcx;*.bmp" })
if (DialogResult.OK == ofd.ShowDialog())
{
ImageFile = ofd.FileName;
imgImage.Image = Image.FromFile(ImageFile);
txtImage.Text = ImageFile;
}
}
private void NumSizeValueChanged(object sender, EventArgs e)
{
TileSize = (int)numSize.Value;
}
}
}