-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormManageCharsets.cs
143 lines (112 loc) · 4.91 KB
/
FormManageCharsets.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using RetroDevStudio.Formats;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ElementEditor
{
public partial class FormManageCharsets : Form
{
FormMain main = null;
public FormManageCharsets( FormMain Main )
{
main = Main;
InitializeComponent();
foreach ( CharsetProjectInfo charset in main.m_Project.CharsetProjects )
{
string shortName = System.IO.Path.GetFileNameWithoutExtension( charset.Filename );
listCharsets.Items.Add( shortName );
}
}
private void listCharsets_SelectedIndexChanged( object sender, EventArgs e )
{
btnRefreshCharset.Enabled = ( listCharsets.SelectedIndex != -1 );
btnChangeCharset.Enabled = ( listCharsets.SelectedIndex != -1 );
btnRemoveCharset.Enabled = ( ( listCharsets.SelectedIndex != -1 ) && ( listCharsets.Items.Count >= 2 ) );
}
private void btnAddCharset_Click( object sender, EventArgs e )
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Title = "Open charset project";
openFile.Filter = "Charset Project Files|*.charsetproject";
if ( openFile.ShowDialog() == DialogResult.OK )
{
CharsetProject charSet = main.OpenCharsetProject( openFile.FileName );
if ( charSet != null )
{
charSet.Name = openFile.FileName;
string shortName = System.IO.Path.GetFileNameWithoutExtension( openFile.FileName );
main.m_Project.Charsets.Add( charSet );
CharsetProjectInfo info = new CharsetProjectInfo();
info.Filename = charSet.Name;
info.Multicolor = true;
main.m_Project.CharsetProjects.Add( info );
main.comboScreenCharset.Items.Add( shortName );
main.comboElementCharset.Items.Add( shortName );
listCharsets.Items.Add( shortName );
}
}
}
private void btnOK_Click( object sender, EventArgs e )
{
DialogResult = DialogResult.OK;
Close();
}
private void btnRefreshCharset_Click( object sender, EventArgs e )
{
int charsetIndex = listCharsets.SelectedIndex;
if ( charsetIndex != -1 )
{
CharsetProject charSet = main.OpenCharsetProject( main.m_Project.CharsetProjects[charsetIndex].Filename );
main.m_Project.Charsets[charsetIndex] = charSet;
main.SetActiveElementCharset( main.m_Project.Charsets[main.comboElementCharset.SelectedIndex],
main.m_Project.Charsets[main.comboElementCharset.SelectedIndex].Colors.MultiColor1,
main.m_Project.Charsets[main.comboElementCharset.SelectedIndex].Colors.MultiColor2,
main.m_Project.CharsetProjects[main.comboElementCharset.SelectedIndex].Multicolor );
}
}
private void btnChangeCharset_Click( object sender, EventArgs e )
{
int charsetIndex = listCharsets.SelectedIndex;
if ( charsetIndex != -1 )
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Title = "Open charset project";
openFile.Filter = "Charset Project Files|*.charsetproject";
if ( openFile.ShowDialog() == DialogResult.OK )
{
CharsetProject charSet = main.OpenCharsetProject( openFile.FileName );
if ( charSet != null )
{
charSet.Name = openFile.FileName;
string shortName = System.IO.Path.GetFileNameWithoutExtension( openFile.FileName );
main.m_Project.Charsets[charsetIndex] = charSet;
main.m_Project.CharsetProjects[charsetIndex].Filename = openFile.FileName;
main.comboElementCharset.Items[charsetIndex] = shortName;
listCharsets.Items[charsetIndex] = shortName;
main.Modified = true;
main.SetActiveElementCharset( main.m_Project.Charsets[main.comboElementCharset.SelectedIndex],
main.m_Project.Charsets[main.comboElementCharset.SelectedIndex].Colors.MultiColor1,
main.m_Project.Charsets[main.comboElementCharset.SelectedIndex].Colors.MultiColor2,
main.m_Project.CharsetProjects[main.comboElementCharset.SelectedIndex].Multicolor );
}
}
}
}
private void btnRemoveCharset_Click( object sender, EventArgs e )
{
int charsetIndex = listCharsets.SelectedIndex;
if ( charsetIndex != -1 )
{
main.m_Project.CharsetProjects.RemoveAt( charsetIndex );
main.m_Project.Charsets.RemoveAt( charsetIndex );
listCharsets.Items.RemoveAt( charsetIndex );
main.Modified = true;
}
}
}
}