-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainWindow.xaml.cs
73 lines (65 loc) · 2.47 KB
/
MainWindow.xaml.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
using System.IO;
using System.Windows;
using System.Windows.Input;
namespace XmlValidator
{
public partial class MainWindow : Window
{
private const string SETTINGS_FILE = "XmlValidator.ini";
public MainWindow()
{
InitializeComponent();
ReadSettings();
}
private void btnValidate_Click(object sender, RoutedEventArgs e)
{
Cursor = Cursors.Wait;
ValidateXML();
Cursor = Cursors.Arrow;
}
private void ValidateXML()
{
txtOutput.Text = Xml.Validate(txtXsdPath.Text, chkRecurseXsd.IsChecked.Value, txtXmlPath.Text, chkRecurseXsd.IsChecked.Value, chkIncludeWarnings.IsChecked.Value);
}
private void ReadSettings()
{
Settings settings = SettingsIO.ReadSettings(SETTINGS_FILE);
if (settings != null)
{
txtXsdPath.Text = settings.XsdPath;
chkRecurseXsd.IsChecked = settings.RecurseXsd;
txtXmlPath.Text = settings.XmlPath;
chkRecurseXml.IsChecked = settings.RecurseXml;
chkIncludeWarnings.IsChecked = settings.IncludeWarnings;
if (settings.Height.HasValue) this.Height = settings.Height.Value;
if (settings.Width.HasValue) this.Width = settings.Width.Value;
if (settings.Left.HasValue) this.Left = settings.Left.Value;
if (settings.Top.HasValue) this.Top = settings.Top.Value;
}
}
private void WriteSettings()
{
Settings settings = new Settings
{
XsdPath = txtXsdPath.Text,
RecurseXsd = chkRecurseXsd.IsChecked,
XmlPath = txtXmlPath.Text,
RecurseXml = chkRecurseXml.IsChecked,
IncludeWarnings = chkIncludeWarnings.IsChecked,
Height = this.Height,
Width = this.Width,
Left = this.Left,
Top = this.Top
};
SettingsIO.WriteSettings(SETTINGS_FILE, settings);
}
private void Path_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
btnValidate.IsEnabled = Directory.Exists(txtXsdPath.Text) && Directory.Exists(txtXmlPath.Text);
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
WriteSettings();
}
}
}