2 using System.Collections.Generic;
5 using System.Windows.Input;
9 using SiliconStudio.Presentation.ViewModel;
11 namespace SiliconStudio.Paradox.ConfigEditor.ViewModels
21 ParadoxPath = Options.ParadoxPath;
22 ParadoxConfigFilename = Options.ParadoxConfigFilename;
25 CheckParadoxConfigFilename();
36 public ICommand CloseCommand {
get;
private set; }
37 public ICommand BrowsePathCommand {
get;
private set; }
38 public ICommand BrowseConfigFileCommand {
get;
private set; }
40 private void BrowsePath()
42 var dialog =
new System.Windows.Forms.FolderBrowserDialog
44 Description =
"Select Paradox base directory",
45 ShowNewFolderButton =
true,
48 if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
49 ParadoxPath = dialog.SelectedPath;
52 private void BrowseConfigFile()
54 var dialog =
new Microsoft.Win32.OpenFileDialog
56 Title =
"Select the Paradox configuration file",
57 Filter =
"Xml Files (*.xml)|*.xml|All Files (*.*)|*.*",
59 CheckFileExists =
true,
62 if (dialog.ShowDialog() ==
true)
63 ParadoxConfigFilename = dialog.FileName;
66 private string paradoxPath;
67 public string ParadoxPath
69 get {
return paradoxPath; }
72 if (SetValue(ref paradoxPath, value,
"ParadoxPath"))
77 private bool isParadoxPathValid;
78 public bool IsParadoxPathValid
80 get {
return isParadoxPathValid; }
81 set { SetValue(ref isParadoxPathValid, value,
"IsParadoxPathValid"); }
84 private void CheckParadoxPath()
86 IsParadoxPathValid = Directory.Exists(ParadoxPath);
89 private string paradoxConfigFilename;
90 public string ParadoxConfigFilename
92 get {
return paradoxConfigFilename; }
95 if (SetValue(ref paradoxConfigFilename, value,
"ParadoxConfigFilename"))
96 CheckParadoxConfigFilename();
100 private bool isParadoxConfigFilenameValid;
101 public bool IsParadoxConfigFilenameValid
103 get {
return isParadoxConfigFilenameValid; }
104 set { SetValue(ref isParadoxConfigFilenameValid, value,
"IsParadoxConfigFilenameValid"); }
107 private void CheckParadoxConfigFilename()
109 if (
string.IsNullOrWhiteSpace(ParadoxConfigFilename))
111 IsParadoxConfigFilenameValid =
true;
115 var tempFilename = ParadoxConfigFilename;
117 if (Path.IsPathRooted(tempFilename) ==
false)
118 tempFilename = Path.Combine(ParadoxPath, ParadoxConfigFilename);
120 IsParadoxConfigFilenameValid = File.Exists(tempFilename);
123 private ICommand acceptCommand;
124 public ICommand AcceptCommand
128 if (acceptCommand == null)
130 return acceptCommand;
134 private void Accept()
136 if (
string.IsNullOrWhiteSpace(ParadoxPath))
138 MessageBox.Show(
"Invalid Paradox Path, this field must not be empty.",
"Paradox Path Error", MessageBoxButton.OK, MessageBoxImage.Error);
142 if (Directory.Exists(ParadoxPath) ==
false)
144 string message = string.Format(
"Invalid Paradox Path, the directory '{0}' does not exit.", ParadoxPath);
145 MessageBox.Show(message,
"Paradox Path Error", MessageBoxButton.OK, MessageBoxImage.Error);
149 Options.ParadoxPath = ParadoxPath;
150 Options.ParadoxConfigFilename = ParadoxConfigFilename;
154 var handler = OptionsChanged;
158 CloseCommand.Execute(null);
An implementation of CommandBase that route Execute calls to a given anonymous method.
This abstract class represents a basic view model, implementing INotifyPropertyChanging and INotifyPr...
void SetOptionsWindow(Window window)