|
@@ -19,10 +19,13 @@
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
-public partial class OptionalYesNoExecutablePanel : StackPanel
|
|
|
+public partial class OptionalYesNoExecutablePanel : StackPanel, SettingPanel
|
|
|
{
|
|
|
private Setting setting;
|
|
|
|
|
@@ -33,6 +36,61 @@ public partial class OptionalYesNoExecutablePanel : StackPanel
|
|
|
this.setting = setting;
|
|
|
SettingCheckBox.Content = setting.name + ":";
|
|
|
SettingUsage.Text = setting.usage + ":";
|
|
|
+
|
|
|
+ Regex regex = new Regex(@"^(?:/|--?)" + setting.option.Substring(1) + @"(?:[:=](?<executable>.*))?$");
|
|
|
+
|
|
|
+ foreach (string option in options)
|
|
|
+ {
|
|
|
+ Match match = regex.Match(option);
|
|
|
+ if (match.Success)
|
|
|
+ {
|
|
|
+ Group group = match.Groups["executable"];
|
|
|
+ if (group.Success)
|
|
|
+ switch (group.Value)
|
|
|
+ {
|
|
|
+ case "yes":
|
|
|
+ SettingYes.IsChecked = true;
|
|
|
+ break;
|
|
|
+ case "no":
|
|
|
+ SettingNo.IsChecked = true;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ SettingExecutable.IsChecked = true;
|
|
|
+ SettingExecutableBox.Text = group.Value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingCheckBox.IsChecked = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsSelected
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return SettingCheckBox.IsChecked.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string Option
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (SettingYes.IsChecked.Value)
|
|
|
+ return setting.option + ":yes";
|
|
|
+ else if (SettingNo.IsChecked.Value)
|
|
|
+ return setting.option + ":no";
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string executable = SettingExecutableBox.Text;
|
|
|
+
|
|
|
+ if (File.GetAttributes(executable).HasFlag(FileAttributes.Directory))
|
|
|
+ throw new Exception("'" + executable + "' is not a file.");
|
|
|
+
|
|
|
+ return setting.option + ":" + executable;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void SettingCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
|