diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
index 1fda004b99..ab2cf92f50 100755
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
@@ -1245,7 +1245,7 @@
+ class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.ExternalToolPanel"/>
OpenWithDialog.cs
-
- ExternalToolPanelXaml.xaml
+
+ ExternalToolPanel.xaml
Code
@@ -768,7 +768,7 @@
-
+
@@ -934,7 +934,7 @@
-
+
diff --git a/src/Main/Base/Project/Resources/ExternalToolOptions.xfrm b/src/Main/Base/Project/Resources/old_ExternalToolOptions.xfrm
similarity index 100%
rename from src/Main/Base/Project/Resources/ExternalToolOptions.xfrm
rename to src/Main/Base/Project/Resources/old_ExternalToolOptions.xfrm
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.cs
index e75c4e746d..1b3fb4d9b5 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.cs
@@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void BrowseForProgramButtonClick(object sender, EventArgs e)
{
using (OpenFileDialog dlg = new OpenFileDialog()) {
- dlg.Filter = StringParser.Parse(OptionPanels.ExternalToolPanelXaml.ExecutableFilesFilter);
+ dlg.Filter = StringParser.Parse(OptionPanels.ExternalToolPanel.ExecutableFilesFilter);
if (dlg.ShowDialog(this) == DialogResult.OK) {
programNameTextBox.Text = "\"" + dlg.FileName + "\"";
if (!userEditedDisplayName) {
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanelXaml.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml
similarity index 97%
rename from src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanelXaml.xaml
rename to src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml
index 1a4b31c12e..8a9861938a 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanelXaml.xaml
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml
@@ -1,4 +1,4 @@
-
@@ -107,7 +106,6 @@
-
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml.cs
new file mode 100644
index 0000000000..e73d6f9561
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ExternalToolPanel.xaml.cs
@@ -0,0 +1,296 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 28.10.2012
+ * Time: 18:35
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+
+using ICSharpCode.Core;
+using ICSharpCode.Core.WinForms;
+using ICSharpCode.SharpDevelop.Internal.ExternalTool;
+using Microsoft.Win32;
+
+namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
+{
+ ///
+ /// Interaction logic for ExternalToolPanelXaml.xaml
+ ///
+ public partial class ExternalToolPanel : OptionPanel
+ {
+ internal const string ExecutableFilesFilter = "${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe;*.com;*.pif;*.bat;*.cmd|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
+
+ static string[,] argumentQuickInsertMenu = new string[,] {
+
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.FullItemPath}", "${ItemPath}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.FullItemDirectory}", "${ItemDir}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.ItemFileName}", "${ItemFileName}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.ItemExtension}", "${ItemExt}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CurrentLine}", "${CurLine}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CurrentColumn}", "${CurCol}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CurrentText}", "${CurText}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.FullTargetPath}", "${TargetPath}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.TargetDirectory}", "${TargetDir}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.TargetName}", "${TargetName}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.TargetExtension}", "${TargetExt}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.ProjectDirectory}", "${ProjectDir}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.ProjectFileName}", "${ProjectFileName}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CombineDirectory}", "${SolutionDir}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CombineFileName}", "${SolutionFileName}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.SharpDevelopStartupPath}", "${StartupPath}"},
+ };
+
+ static string[,] workingDirInsertMenu = new string[,] {
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.FullItemDirectory}", "${ItemDir}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.TargetDirectory}", "${TargetDir}"},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.TargetName}", "${TargetName}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.ProjectDirectory}", "${ProjectDir}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.CombineDirectory}", "${SolutionDir}"},
+ {"-", ""},
+ {"${res:Dialog.Options.ExternalTool.QuickInsertMenu.SharpDevelopStartupPath}", "${StartupPath}"},
+ };
+
+
+ public ExternalToolPanel()
+ {
+ InitializeComponent();
+ EnableFields(false);
+ ButtonsEnable = false;
+ ArgumentContextMenu = FillArgumentContextMenu(argumentQuickInsertMenu);
+ WorkingDirContextMenu = FillArgumentContextMenu(workingDirInsertMenu);
+ this.DataContext = this;
+ }
+
+ private List FillArgumentContextMenu(string[,] menuArray)
+ {
+ var list = new List();
+ for (int i = 0; i < menuArray.GetLength(0); i++) {
+ if (menuArray[i,0].StartsWith("${") && (!String.IsNullOrEmpty(menuArray[i,1]))) {
+ list.Add(new MenuItem()
+ {
+ Header = StringParser.Parse(menuArray[i,0]),
+ Tag = argumentQuickInsertMenu[i,1],
+ });
+ }
+ else {
+ list.Add(new Separator());
+ }
+ }
+ return list;
+ }
+
+
+ #region overrides
+
+ public override void LoadOptions()
+ {
+ base.LoadOptions();
+ foreach (ExternalTool o in ToolLoader.Tool) {
+ listBox.Items.Add(o);
+ }
+ SelectedTool = null;
+ }
+
+ public override bool SaveOptions()
+ {
+ List newlist = new List();
+ foreach (ExternalTool tool in listBox.Items) {
+ if (!FileUtility.IsValidPath(StringParser.Parse(tool.Command))) {
+ if (!Regex.IsMatch(tool.Command, @"^\$\{SdkToolPath:[\w\d]+\.exe\}$")) {
+ // Always treat SdkToolPath entries as valid - this allows saving the tool options
+ // with the default entries even when the .NET SDK is not installed.
+ MessageService.ShowError(String.Format("The command of tool \"{0}\" is invalid.", tool.MenuCommand));
+ return false;
+ }
+ }
+ if ((tool.InitialDirectory != String.Empty) && (!FileUtility.IsValidPath(tool.InitialDirectory))) {
+ MessageService.ShowError(String.Format("The working directory of tool \"{0}\" is invalid.", tool.MenuCommand));
+ return false;
+ }
+ newlist.Add(tool);
+ }
+
+ ToolLoader.Tool = newlist;
+ ToolLoader.SaveTools();
+
+ return true;
+ }
+
+
+ #endregion
+
+ #region properties
+
+ private ExternalTool selectedTool;
+
+ public ExternalTool SelectedTool {
+ get { return selectedTool; }
+ set { selectedTool = value;
+ Console.WriteLine("selected {0}",listBox.SelectedItems.Count.ToString());
+ base.RaisePropertyChanged(() => SelectedTool); }
+ }
+
+
+ private bool editEnable;
+
+ public bool EditEnable {
+ get { return editEnable;}
+ set {editEnable = value;
+ base.RaisePropertyChanged(() => EditEnable);}
+ }
+
+ private bool buttonsEnable;
+
+ public bool ButtonsEnable {
+ get { return buttonsEnable; }
+ set { buttonsEnable = value;
+ base.RaisePropertyChanged(() => ButtonsEnable); }
+ }
+
+ public List ArgumentContextMenu {get; private set;}
+
+ public List WorkingDirContextMenu {get; private set;}
+
+ #endregion
+
+
+ private void AddButton_Click(object sender, RoutedEventArgs e)
+ {
+ EditEnable = true;
+ ButtonsEnable = true;
+ var newTool = new ExternalTool();
+ listBox.Items.Add(newTool);
+ SelectedTool = newTool;
+ var i = listBox.SelectedIndex;
+ listBox.SelectedIndex = listBox.Items.Count -1;
+ }
+
+
+ private void RemoveButton_Click(object sender, RoutedEventArgs e)
+ {
+ for (int i =listBox.SelectedItems.Count -1 ; i >= 0; i--) {
+ listBox.Items.Remove(listBox.SelectedItems[i]);
+ }
+
+ if (listBox.Items.Count == 0) {
+ EditEnable = false;
+ ButtonsEnable = false;
+ } else {
+ listBox.SelectedIndex = 0;
+ }
+ listBox.SelectedItems.Clear();
+ }
+
+
+ private void UpButton_Click(object sender, RoutedEventArgs e)
+ {
+ int index = listBox.SelectedItems.Count;
+ object tmp = listBox.Items[index];
+ listBox.Items[index] = listBox.Items[index - 1];
+ listBox.Items[index - 1] = tmp;
+ listBox.SelectedIndex = index - 1;
+ listBox.SelectedItems.Clear();
+ base.RaisePropertyChanged(null);
+ }
+
+
+ private void DownButton_Click(object sender, RoutedEventArgs e)
+ {
+ int index = listBox.SelectedIndex;
+ if (index < listBox.Items.Count -1) {
+ object tmp = listBox.Items[index];
+ listBox.Items[index] = listBox.Items[index + 1];
+ listBox.Items[index + 1] = tmp;
+ listBox.SelectedIndex = index + 1;
+ base.RaisePropertyChanged(null);
+ }
+ listBox.SelectedItems.Clear();
+ }
+
+
+ private void ArgumentQuickInsertButton_Click(object sender, RoutedEventArgs e)
+ {
+ argumentTextBox.ContextMenu.PlacementTarget = argumentTextBox;
+ argumentTextBox.ContextMenu.IsOpen = true;
+ }
+
+
+ private void ArgumentTextBoxMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var menuItem = e.OriginalSource as MenuItem;
+ if (menuItem != null) {
+ argumentTextBox.Text = menuItem.Tag.ToString() + argumentTextBox.Text;
+ }
+ }
+
+
+ private void WorkingDirQuickInsertButton_Click(object sender, RoutedEventArgs e)
+ {
+ workingDirTextBox.ContextMenu.PlacementTarget = argumentTextBox;
+ workingDirTextBox.ContextMenu.IsOpen = true;
+ }
+
+
+ private void WorkingDirTextBoxMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var menuItem = e.OriginalSource as MenuItem;
+ if (menuItem != null) {
+ workingDirTextBox.Text = menuItem.Tag.ToString() + workingDirTextBox.Text;
+ }
+ }
+
+
+ private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+
+ if (listBox.SelectedItems.Count == 0 ) {
+ EnableFields(false);
+ ButtonsEnable = false;
+ } else {
+ if (listBox.SelectedItems.Count > 1) {
+ EnableFields(false);
+ } else{
+ ButtonsEnable = false;
+ EnableFields(true);
+ }
+ ButtonsEnable = true;
+ }
+ }
+
+
+ private void EnableFields (bool enable)
+ {
+ EditEnable = enable;
+ this.upButton.IsEnabled = enable;
+ this.downButton.IsEnabled = enable;
+ }
+
+ private void BrowseButton_Click(object sender, RoutedEventArgs e)
+ {
+ var dialog = new OpenFileDialog();
+ dialog.CheckFileExists = true;
+ dialog.Filter = StringParser.Parse(ExecutableFilesFilter);
+ if (dialog.ShowDialog() == true) {
+ commandTextBox.Text = dialog.FileName;
+ }
+ }
+ }
+}
\ No newline at end of file