-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakeIntoTypeForm.cs
69 lines (61 loc) · 2.22 KB
/
MakeIntoTypeForm.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
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace CaravelEditor
{
public partial class MakeIntoTypeForm : Form
{
private string m_sEntityResourceBundle;
private string m_sProjectDirectory;
private string[] m_ExistingTypes;
public MakeIntoTypeForm(string resourceBundle, string projectDirectory, string[] existingTypes)
{
m_sEntityResourceBundle = resourceBundle;
m_ExistingTypes = existingTypes;
m_sProjectDirectory = projectDirectory;
InitializeComponent();
saveButton.Enabled = false;
}
public string GetFileName()
{
return fileTextBox.Text;
}
public string GetTypeName()
{
return typeTextBox.Text;
}
public void textBox_OnTextChanged(object sender, EventArgs eventArgs)
{
if (fileTextBox.Text != "" && typeTextBox.Text != "" && !m_ExistingTypes.Contains(typeTextBox.Text))
{
saveButton.Enabled = true;
}
else
{
saveButton.Enabled = false;
}
}
private void browseButton_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
string bundleLocation = Path.Combine(m_sProjectDirectory, Path.GetFileNameWithoutExtension(m_sEntityResourceBundle));
string entityTypesLocation = Path.Combine(bundleLocation, "entity_types");
saveFile.InitialDirectory = entityTypesLocation;
saveFile.Filter = "Caravel Entity Type | *.cve";
saveFile.ShowDialog();
if (saveFile.FileNames.Length > 0)
{
string fileName = saveFile.FileNames[0];
if (fileName.StartsWith(entityTypesLocation))
{
fileTextBox.Text = fileName.Substring(bundleLocation.Length + 1);
}
else
{
MessageBox.Show("Error - The file must be a part of the same resource bundle as the entity (it must be in " + entityTypesLocation + ").");
}
}
}
}
}