diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
index 7af88ae50c..d73c849d86 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
@@ -33,7 +33,6 @@
-
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/AdvancedBuildOptionsDialog.xfrm b/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/AdvancedBuildOptionsDialog.xfrm
deleted file mode 100644
index ecc4feaf68..0000000000
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/AdvancedBuildOptionsDialog.xfrm
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm b/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm
index 243d8737d9..3fdb8d9013 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Resources/BuildOptions.xfrm
@@ -1,189 +1,298 @@
-
-
+
+
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
+
+
-
+
-
-
+
-
-
-
-
+
+
+
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
+
-
-
-
+
+
-
+
+
-
+
+
-
-
-
-
+
+
+
+
-
+
+
-
-
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs
index 7eccb33a85..f010318e12 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs
@@ -1,180 +1,50 @@
//
// 2002-2005 AlphaSierraPapa
// GNU General Public License
-//
+//
// $Revision$
//
using System;
+using System.Collections.Generic;
using System.Windows.Forms;
-using ICSharpCode.SharpDevelop.Internal.ExternalTool;
+using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
+using ICSharpCode.SharpDevelop.Gui.OptionPanels;
+
+using StringPair = System.Collections.Generic.KeyValuePair;
namespace CSharpBinding.OptionPanels
{
- public class BuildOptions : AbstractOptionPanel
+ public class BuildOptions : AbstractBuildOptions
{
- CSharpProject project;
-
- public BuildOptions()
- {
- }
-
- void ShowAdvancedOptions(object sender, EventArgs e)
- {
- using (AdvancedBuildOptionsDialog advancedBuildOptionsDialog = new AdvancedBuildOptionsDialog(project)) {
- advancedBuildOptionsDialog.ShowDialog(WorkbenchSingleton.MainForm);
- }
- }
- string Config = "Debug";
- string Platform = "AnyCPU";
-
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.BuildOptions.xfrm"));
- this.project = (CSharpProject)((Properties)CustomizationObject).Get("Project");
-
- ConnectBrowseFolder("outputPathBrowseButton", "outputPathTextBox", "${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}");
- Get
-
diff --git a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs
index 1b8e0e75e7..560c6ad9d1 100644
--- a/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs
+++ b/src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerViewContent.cs
@@ -248,6 +248,14 @@ namespace ICSharpCode.FormDesigner
UpdateSelectableObjects();
}
+ public override void Dispose()
+ {
+ if (IsFormDesignerVisible) {
+ Deselected();
+ }
+ base.Dispose();
+ }
+
public override void Deselected()
{
LoggingService.Info("Deselected form designer, unloading...");
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index 720bab0363..209c535adb 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -187,7 +187,6 @@
Form
-
UserControl
@@ -465,10 +464,8 @@
-
-
@@ -613,7 +610,7 @@
-
+
UserControl
@@ -686,6 +683,12 @@
+
+
+
+
+
+
diff --git a/src/Main/Base/Project/Resources/CompileFileProjectOptions.xfrm b/src/Main/Base/Project/Resources/CompileFileProjectOptions.xfrm
deleted file mode 100644
index 717ac7ed9d..0000000000
--- a/src/Main/Base/Project/Resources/CompileFileProjectOptions.xfrm
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Main/Base/Project/Resources/DeployFileOptions.xfrm b/src/Main/Base/Project/Resources/DeployFileOptions.xfrm
deleted file mode 100644
index faaf737fa7..0000000000
--- a/src/Main/Base/Project/Resources/DeployFileOptions.xfrm
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Main/Base/Project/Resources/ProjectOptions/CreateKey.xfrm b/src/Main/Base/Project/Resources/ProjectOptions/CreateKey.xfrm
new file mode 100644
index 0000000000..bce4e5eb40
--- /dev/null
+++ b/src/Main/Base/Project/Resources/ProjectOptions/CreateKey.xfrm
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Main/Base/Project/Resources/ProjectOptions/Publish.xfrm b/src/Main/Base/Project/Resources/ProjectOptions/Publish.xfrm
index d32a0042f6..5dee14a5da 100644
--- a/src/Main/Base/Project/Resources/ProjectOptions/Publish.xfrm
+++ b/src/Main/Base/Project/Resources/ProjectOptions/Publish.xfrm
@@ -1,250 +1,234 @@
-
-
+
-
-
+
+
+
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
-
-
-
-
-
-
-
+
-
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
-
-
+
+
+
-
+
+
+
-
-
-
+
+
-
-
+
+
+
-
+
+
-
-
-
+
+
+
-
+
-
+
+
+
-
-
+
-
-
+
+
-
-
+
-
-
+
+
-
-
+
-
-
+
+
-
-
+
-
-
+
-
\ No newline at end of file
+
diff --git a/src/Main/Base/Project/Resources/ProjectOptions/Signing.xfrm b/src/Main/Base/Project/Resources/ProjectOptions/Signing.xfrm
index a7a77ded2a..fd856684f0 100644
--- a/src/Main/Base/Project/Resources/ProjectOptions/Signing.xfrm
+++ b/src/Main/Base/Project/Resources/ProjectOptions/Signing.xfrm
@@ -1,104 +1,95 @@
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
diff --git a/src/Main/Base/Project/Src/Dom/XmlDoc.cs b/src/Main/Base/Project/Src/Dom/XmlDoc.cs
index b060a9c338..2decfaa575 100644
--- a/src/Main/Base/Project/Src/Dom/XmlDoc.cs
+++ b/src/Main/Base/Project/Src/Dom/XmlDoc.cs
@@ -117,25 +117,39 @@ namespace ICSharpCode.SharpDevelop.Dom
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
int len = (int)fs.Length;
loader = new BinaryReader(fs);
- if (loader.ReadInt64() != magic) {
- LoggingService.Warn("Cannot load XmlDoc: wrong magic");
- return false;
- }
- if (loader.ReadInt16() != version) {
- LoggingService.Warn("Cannot load XmlDoc: wrong version");
- return false;
- }
- if (loader.ReadInt64() != fileDate.Ticks) {
- LoggingService.Info("Not loading XmlDoc: file changed since cache was created");
+ try {
+ if (loader.ReadInt64() != magic) {
+ LoggingService.Warn("Cannot load XmlDoc: wrong magic");
+ return false;
+ }
+ if (loader.ReadInt16() != version) {
+ LoggingService.Warn("Cannot load XmlDoc: wrong version");
+ return false;
+ }
+ if (loader.ReadInt64() != fileDate.Ticks) {
+ LoggingService.Info("Not loading XmlDoc: file changed since cache was created");
+ return false;
+ }
+ int indexStartPosition = loader.ReadInt32(); // go to start of index
+ if (indexStartPosition >= len) {
+ LoggingService.Error("XmlDoc: Cannot find index, cache invalid!");
+ return false;
+ }
+ fs.Position = indexStartPosition;
+ while (fs.Position < len) {
+ string key = loader.ReadString();
+ int pos = loader.ReadInt32();
+ indexDictionary.Add(key, pos);
+ }
+ if (fs.Position > len) {
+ LoggingService.Error("XmlDoc: Jumped over end of file, cache invalid!");
+ return false;
+ }
+ return true;
+ } catch (Exception ex) {
+ LoggingService.Error("Cannot load from cache", ex);
return false;
}
- fs.Position = loader.ReadInt32(); // go to start of index
- while (fs.Position < len) {
- string key = loader.ReadString();
- int pos = loader.ReadInt32();
- indexDictionary.Add(key, pos);
- }
- return true;
}
string LoadDocumentation(string key)
@@ -216,7 +230,12 @@ namespace ICSharpCode.SharpDevelop.Dom
if (doc.xmlDescription.Count > cacheLength * 2) {
LoggingService.Debug("XmlDoc: Creating cache");
DateTime date = File.GetLastWriteTimeUtc(fileName);
- doc.Save(cacheName, date);
+ try {
+ doc.Save(cacheName, date);
+ } catch (Exception ex) {
+ LoggingService.Error("Cannot write to cache file", ex);
+ return doc;
+ }
doc.Dispose();
doc = new XmlDoc();
doc.LoadFromBinary(cacheName, date);
diff --git a/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs b/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
index 216e374a05..dd47575de8 100644
--- a/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
+++ b/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
@@ -61,6 +61,14 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
+ public override void Dispose()
+ {
+ foreach (ISecondaryViewContent svc in secondaryViewContents) {
+ svc.Dispose();
+ }
+ base.Dispose();
+ }
+
public AbstractViewContent()
{
}
diff --git a/src/Main/Base/Project/Src/Gui/ContentInterfaces/ICanBeDirty.cs b/src/Main/Base/Project/Src/Gui/ContentInterfaces/ICanBeDirty.cs
new file mode 100644
index 0000000000..7e4f1e6c43
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/ContentInterfaces/ICanBeDirty.cs
@@ -0,0 +1,32 @@
+/*
+ * Created by SharpDevelop.
+ * User: Daniel Grunwald
+ * Date: 19.08.2005
+ * Time: 18:25
+ */
+
+using System;
+
+namespace ICSharpCode.SharpDevelop.Gui
+{
+ ///
+ /// Description of ICanBeDirty.
+ ///
+ public interface ICanBeDirty
+ {
+ ///
+ /// If this property returns true the content has changed since
+ /// the last load/save operation.
+ ///
+ bool IsDirty {
+ get;
+ set;
+ }
+
+ ///
+ /// Is called when the content is changed after a save/load operation
+ /// and this signals that changes could be saved.
+ ///
+ event EventHandler DirtyChanged;
+ }
+}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
index 51f8fa6907..87db54ccb7 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
@@ -92,6 +92,8 @@ namespace ICSharpCode.SharpDevelop.Gui
return true;
}
+ protected string baseDirectory;
+
protected void ConnectBrowseButton(string browseButton, string target)
{
ConnectBrowseButton(browseButton, target, "${res:SharpDevelop.FileFilter.AllFiles}|*.*");
@@ -113,7 +115,7 @@ namespace ICSharpCode.SharpDevelop.Gui
protected void ConnectBrowseFolder(string browseButton, string target)
{
- // TODO: Translation:
+ // TODO: Translation:
ConnectBrowseFolder(browseButton, target, "Select folder");
}
protected void ConnectBrowseFolder(string browseButton, string target, string description)
@@ -130,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Gui
ControlDictionary[browseButton].Click += new EventHandler(new BrowseFolderEvent(this, target, description).Event);
}
- class BrowseButtonEvent
+ protected class BrowseButtonEvent
{
AbstractOptionPanel panel;
string target;
@@ -150,7 +152,11 @@ namespace ICSharpCode.SharpDevelop.Gui
fdiag.Multiselect = false;
if(fdiag.ShowDialog() == DialogResult.OK) {
- panel.ControlDictionary[target].Text = fdiag.FileName;
+ string file = fdiag.FileName;
+ if (panel.baseDirectory != null) {
+ file = FileUtility.GetRelativePath(panel.baseDirectory, file);
+ }
+ panel.ControlDictionary[target].Text = file;
}
}
}
@@ -171,9 +177,15 @@ namespace ICSharpCode.SharpDevelop.Gui
public void Event(object sender, EventArgs e)
{
- FolderDialog fdiag = new FolderDialog();
+ FolderDialog fdiag = new FolderDialog();
if (fdiag.DisplayDialog(description) == DialogResult.OK) {
- panel.ControlDictionary[target].Text = fdiag.Path;
+ string path = fdiag.Path;
+ if (panel.baseDirectory != null) {
+ path = FileUtility.GetRelativePath(panel.baseDirectory, path);
+ }
+ if (!path.EndsWith("\\") && !path.EndsWith("/"))
+ path += "\\";
+ panel.ControlDictionary[target].Text = path;
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs
index 52463351bf..b70e26e746 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs
@@ -26,24 +26,17 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
- public FolderDialog()
- {
- }
-
- public DialogResult DisplayDialog()
- {
- return DisplayDialog("Select the directory in which the project will be created.");
- }
-
// Alain VIZZINI reminded me to try out the .NET folder browser, because
// the my documents bug seemed to have gone away ...
public DialogResult DisplayDialog(string description)
{
using (FolderBrowser folderBrowser = new FolderBrowser()) {
-
folderBrowser.Description = StringParser.Parse(description);
DialogResult result = folderBrowser.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
path = folderBrowser.DirectoryPath;
+ LoggingService.Info("FolderDialog: user has choosen path " + path);
+ if (path == null || path.Length == 0)
+ return DialogResult.Cancel;
return result;
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
index 792d20a932..1e70823995 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
@@ -348,7 +348,7 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
{
// Changes Shankar
FolderDialog fd = new FolderDialog();
- if (fd.DisplayDialog() == DialogResult.OK) {
+ if (fd.DisplayDialog("Select the directory in which the project will be created.") == DialogResult.OK) {
((TextBox)ControlDictionary["locationTextBox"]).Text = fd.Path;
}
// End
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs
new file mode 100644
index 0000000000..a776ecd8df
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs
@@ -0,0 +1,149 @@
+//
+// 2002-2005 AlphaSierraPapa
+// GNU General Public License
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Gui.XmlForms;
+
+using StringPair = System.Collections.Generic.KeyValuePair;
+
+namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
+{
+ public class AbstractBuildOptions : AbstractProjectOptionPanel
+ {
+ protected void InitOutputPath()
+ {
+ helper.BindString("outputPathTextBox", "OutputPath");
+ ConnectBrowseFolder("outputPathBrowseButton", "outputPathTextBox", "${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}");
+ }
+
+ protected void InitXmlDoc()
+ {
+ helper.BindString("xmlDocumentationTextBox", "DocumentationFile");
+ Get("xmlDocumentation").Checked = Get("xmlDocumentation").Text.Length > 0;
+ Get("xmlDocumentation").CheckedChanged += new EventHandler(UpdateXmlEnabled);
+ Get("xmlDocumentation").Enabled = Get("xmlDocumentation").Checked;
+ }
+
+ void UpdateXmlEnabled(object sender, EventArgs e)
+ {
+ Get("xmlDocumentation").Enabled = Get("xmlDocumentation").Checked;
+ if (Get("xmlDocumentation").Checked && Get("xmlDocumentation").Text.Length == 0) {
+ Get("xmlDocumentation").Text = FileUtility.GetRelativePath(baseDirectory, project.OutputAssemblyFullPath) + ".xml";
+ } else {
+ Get("xmlDocumentation").Text = "";
+ }
+ }
+
+ protected void InitWarnings()
+ {
+ helper.BindStringEnum("warningLevelComboBox", "WarningLevel",
+ "4",
+ new StringPair("0", "0"),
+ new StringPair("1", "1"),
+ new StringPair("2", "2"),
+ new StringPair("3", "3"),
+ new StringPair("4", "4"));
+ helper.BindString("suppressWarningsTextBox", "NoWarn");
+
+ helper.AddBinding("TreatWarningsAsErrors", new WarningsAsErrorsBinding(this));
+ helper.BindString("specificWarningsTextBox", "WarningsAsErrors"); // must be saved AFTER TreatWarningsAsErrors
+
+ Get("specificWarnings").CheckedChanged += new EventHandler(UpdateWarningChecked);
+
+ UpdateWarningChecked(this, EventArgs.Empty);
+ }
+
+ void UpdateWarningChecked(object sender, EventArgs e)
+ {
+ Get("specificWarnings").Enabled = Get("specificWarnings").Checked;
+ }
+
+ protected class WarningsAsErrorsBinding : ConfigurationGuiBinding
+ {
+ RadioButton none, specific, all;
+ Control specificWarningsTextBox;
+
+ public WarningsAsErrorsBinding(AbstractProjectOptionPanel panel)
+ {
+ this.none = panel.Get("none");
+ this.specific = panel.Get("specificWarnings");
+ this.all = panel.Get("all");
+ specificWarningsTextBox = panel.ControlDictionary["specificWarningsTextBox"];
+ }
+
+ public override void Load()
+ {
+ if (bool.Parse(Get("false"))) {
+ all.Checked = true;
+ } else {
+ if (this.Helper.GetProperty("WarningsAsErrors", "").Length > 0) {
+ specific.Checked = true;
+ } else {
+ none.Checked = true;
+ }
+ }
+ }
+
+ public override bool Save()
+ {
+ if (none.Checked) {
+ specificWarningsTextBox.Text = "";
+ }
+ if (all.Checked) {
+ Set("true");
+ } else {
+ Set("false");
+ }
+ return true;
+ }
+ }
+
+ protected void InitAdvanced()
+ {
+ helper.BindEnum("debugInfoComboBox", "DebugType");
+ helper.BindBoolean("registerCOMInteropCheckBox", "RegisterForComInterop", false);
+ helper.BindStringEnum("generateSerializationAssemblyComboBox", "GenerateSerializationAssemblies",
+ "Auto",
+ new StringPair("Off", "Off"),
+ new StringPair("On", "On"),
+ new StringPair("Auto", "Auto"));
+ helper.BindStringEnum("generateSerializationAssemblyComboBox", "GenerateSerializationAssemblies",
+ "Auto",
+ new StringPair("Off", "Off"),
+ new StringPair("On", "On"),
+ new StringPair("Auto", "Auto"));
+ helper.BindHexadecimal(Get("dllBaseAddress"), "BaseAddress", 0x400000);
+ helper.BindStringEnum("targetCpuComboBox", "PlatformTarget",
+ "AnyCPU",
+ new StringPair("AnyCPU", "${res:Dialog.ProjectOptions.Build.TargetCPU.Any}"),
+ new StringPair("x86", "${res:Dialog.ProjectOptions.Build.TargetCPU.x86}"),
+ new StringPair("x64", "${res:Dialog.ProjectOptions.Build.TargetCPU.x64}"),
+ new StringPair("Itanium", "${res:Dialog.ProjectOptions.Build.TargetCPU.Itanium}"));
+ }
+
+ public override bool StorePanelContents()
+ {
+ if (base.StorePanelContents()) {
+ if ((DebugSymbolType)Get("debugInfo").SelectedIndex == DebugSymbolType.Full) {
+ helper.SetProperty("DebugSymbols", "true");
+ } else {
+ helper.SetProperty("DebugSymbols", "false");
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractProjectOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractProjectOptionPanel.cs
new file mode 100644
index 0000000000..cba98212a6
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractProjectOptionPanel.cs
@@ -0,0 +1,48 @@
+//
+// 2002-2005 AlphaSierraPapa
+// GNU General Public License
+//
+// $Revision$
+//
+
+using System;
+using System.Windows.Forms;
+
+using ICSharpCode.SharpDevelop.Internal.ExternalTool;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
+{
+ ///
+ /// Base class for project option panels that are using the .
+ ///
+ public abstract class AbstractProjectOptionPanel : AbstractOptionPanel, ICanBeDirty
+ {
+ protected ConfigurationGuiHelper helper;
+ protected MSBuildProject project;
+
+ protected void InitializeHelper()
+ {
+ project = (MSBuildProject)((Properties)CustomizationObject).Get("Project");
+ baseDirectory = project.Directory;
+ helper = new ConfigurationGuiHelper(project, this.ControlDictionary);
+ }
+
+ public bool IsDirty {
+ get { return helper.IsDirty; }
+ set { helper.IsDirty = value; }
+ }
+
+ public event EventHandler DirtyChanged {
+ add { helper.DirtyChanged += value; }
+ remove { helper.DirtyChanged -= value; }
+ }
+
+ public override bool StorePanelContents()
+ {
+ return helper.Save();
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs
index 5f6ed5af19..cf92649e46 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.cs
@@ -6,6 +6,7 @@
//
using System;
+using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
@@ -14,78 +15,46 @@ using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
-
+
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
- public class ApplicationSettings : AbstractOptionPanel
+ public class ApplicationSettings : AbstractProjectOptionPanel
{
- AdvancedMSBuildProject project;
-
- public ApplicationSettings()
- {
- }
-
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.ApplicationSettings.xfrm"));
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
+ SetupFromXmlResource("ProjectOptions.ApplicationSettings.xfrm");
+
+ InitializeHelper();
ConnectBrowseButton("applicationIconBrowseButton", "applicationIconComboBox", "${res:SharpDevelop.FileFilter.Icons}|*.ico|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
// TODO: Suitable file filter.
ConnectBrowseButton("win32ResourceFileBrowseButton", "win32ResourceFileComboBox");
- Get("assemblyName").Text = project.AssemblyName;
+ helper.BindString("assemblyNameTextBox", "AssemblyName");
Get("assemblyName").TextChanged += new EventHandler(RefreshOutputNameTextBox);
- Get("assemblyName").TextChanged += new EventHandler(Save);
-
- Get("rootNamespace").Text = project.RootNamespace;
- Get("rootNamespace").TextChanged += new EventHandler(Save);
- Get("outputType").Items.Add(StringParser.Parse("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Exe}"));
- Get("outputType").Items.Add(StringParser.Parse("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.WinExe}"));
- Get("outputType").Items.Add(StringParser.Parse("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Library}"));
- Get("outputType").Items.Add(StringParser.Parse("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Module}"));
+ helper.BindString("rootNamespaceTextBox", "RootNamespace");
- Get("outputType").SelectedIndex = (int)project.OutputType;
+ helper.BindEnum("outputTypeComboBox", "OutputType");
Get("outputType").SelectedIndexChanged += new EventHandler(RefreshOutputNameTextBox);
- Get("outputType").SelectedIndexChanged += new EventHandler(Save);
- Get("startupObject").Text = project.StartupObject;
- Get("startupObject").SelectedIndexChanged += new EventHandler(Save);
+ helper.BindString("startupObjectComboBox", "StartupObject");
- Get("applicationIcon").Text = project.ApplicationIcon;
+ helper.BindString("applicationIconComboBox", "ApplicationIcon");
Get("applicationIcon").TextChanged += new EventHandler(ApplicationIconComboBoxTextChanged);
- Get("applicationIcon").TextChanged += new EventHandler(Save);
- Get("win32ResourceFile").Text = project.Win32Resource;
- Get("win32ResourceFile").TextChanged += new EventHandler(Save);
+ helper.BindString("win32ResourceFileComboBox", "Win32Resource");
Get("projectFolder").Text = project.Directory;
Get("projectFile").Text = Path.GetFileName(project.FileName);
- Get("projectFile").TextChanged += new EventHandler(Save);
+
+ // maybe make this writable again? Needs special care when saving!
+ Get("projectFile").ReadOnly = true;
RefreshOutputNameTextBox(null, EventArgs.Empty);
}
- void Save(object sender, EventArgs e)
- {
- StorePanelContents();
- }
-
- public override bool StorePanelContents()
- {
- project.AssemblyName = Get("assemblyName").Text;
- project.RootNamespace = Get("rootNamespace").Text;
- project.OutputType = (OutputType)Get("outputType").SelectedIndex;
- project.StartupObject = Get("startupObject").Text;
- project.ApplicationIcon = Get("applicationIcon").Text;
- project.Win32Resource = Get("win32ResourceFile").Text;
- project.Name = Path.GetFileNameWithoutExtension(Get("projectFile").Text);
- project.Save();
- return true;
- }
-
void RefreshOutputNameTextBox(object sender, EventArgs e)
{
Get("outputName").Text = Get("assemblyName").Text + MSBuildProject.GetExtension((OutputType)Get("outputType").SelectedIndex);
@@ -93,9 +62,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
void ApplicationIconComboBoxTextChanged(object sender, EventArgs e)
{
- string applicationIcon = Get("applicationIcon").Text;
+ string applicationIcon = Path.Combine(baseDirectory, Get("applicationIcon").Text);
if (File.Exists(applicationIcon)) {
- Get("applicationIcon").Image = Image.FromFile(applicationIcon);
+ Get("applicationIcon").Image = Image.FromFile(applicationIcon);
+ } else {
+ Get("applicationIcon").Image = null;
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs
index d924c9af20..bcb4b9e319 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildEvents.cs
@@ -15,13 +15,14 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
- public class BuildEvents : AbstractOptionPanel
+ public class BuildEvents : AbstractProjectOptionPanel
{
- AdvancedMSBuildProject project;
-
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.BuildEvents.xfrm"));
+ SetupFromXmlResource("ProjectOptions.BuildEvents.xfrm");
+
+ InitializeHelper();
+
ConnectBrowseButton("preBuildEventBrowseButton",
"preBuildEventTextBox",
"${res:SharpDevelop.FileFilter.AllFiles}|*.*");
@@ -29,35 +30,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
"postBuildEventTextBox",
"${res:SharpDevelop.FileFilter.AllFiles}|*.*");
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
-
- Get("preBuildEvent").Text = project.PreBuildEvent;
- Get("preBuildEvent").TextChanged += new EventHandler(Save);
-
- Get("postBuildEvent").Text = project.PostBuildEvent;
- Get("postBuildEvent").TextChanged += new EventHandler(Save);
-
- Get("runPostBuildEvent").Items.Add("Always");
- Get("runPostBuildEvent").Items.Add("On successful build");
- Get("runPostBuildEvent").Items.Add("When the build updates the project output");
-
- Get("runPostBuildEvent").SelectedIndex = (int)project.RunPostBuildEvent;
- Get("runPostBuildEvent").SelectedIndexChanged += new EventHandler(Save);
-
- }
-
- void Save(object sender, EventArgs e)
- {
- StorePanelContents();
- }
-
- public override bool StorePanelContents()
- {
- project.PreBuildEvent = Get("preBuildEvent").Text;
- project.PostBuildEvent = Get("postBuildEvent").Text;
- project.RunPostBuildEvent = (RunPostBuildEvent)Get("runPostBuildEvent").SelectedIndex;
- project.Save();
- return true;
+ helper.BindString("preBuildEventTextBox", "PreBuildEvent");
+ helper.BindString("postBuildEventTextBox", "PostBuildEvent");
+ helper.BindEnum("runPostBuildEventComboBox", "RunPostBuildEvent");
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/CreateKey.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/CreateKey.cs
new file mode 100644
index 0000000000..9cff219e6d
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/CreateKey.cs
@@ -0,0 +1,106 @@
+/*
+ * Created by SharpDevelop.
+ * User: Daniel Grunwald
+ * Date: 20.08.2005
+ * Time: 10:47
+ */
+
+using System;
+using System.Drawing;
+using System.Diagnostics;
+using System.IO;
+using System.Windows.Forms;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Gui.XmlForms;
+
+namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
+{
+ public class CreateKeyForm : BaseSharpDevelopForm
+ {
+ string baseDirectory;
+
+ public CreateKeyForm(string baseDirectory)
+ {
+ this.baseDirectory = baseDirectory;
+ SetupFromXmlResource("ProjectOptions.CreateKey.xfrm");
+ Get("usePassword").CheckedChanged += delegate {
+ ControlDictionary["passwordPanel"].Enabled = Get("usePassword").Checked;
+ };
+ ControlDictionary["okButton"].Click += OkButtonClick;
+ }
+
+ void OkButtonClick(object sender, EventArgs e)
+ {
+ KeyFile = KeyFile.Trim();
+ if (KeyFile.Length == 0) {
+ MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.EnterKeyName}");
+ return;
+ }
+ bool usePassword = Get("usePassword").Checked;
+ if (usePassword) {
+ if (!CheckPassword(ControlDictionary["passwordTextBox"],
+ ControlDictionary["confirmPasswordTextBox"]))
+ {
+ return;
+ }
+ MessageService.ShowMessage("Creating a key file with a password is currently not supported.");
+ return;
+ }
+ if (!KeyFile.EndsWith(".snk") && !KeyFile.EndsWith(".pfx"))
+ KeyFile += ".snk";
+ if (CreateKey(Path.Combine(baseDirectory, KeyFile))) {
+ this.DialogResult = DialogResult.OK;
+ Close();
+ }
+ }
+
+ public static bool CreateKey(string keyPath)
+ {
+ if (File.Exists(keyPath)) {
+ string question = "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion}";
+ question = StringParser.Parse(question, new string[,] {{"fileName", keyPath}});
+ if (!MessageService.AskQuestion(question, "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion.InfoName}")) {
+ return false;
+ }
+ }
+ Process p = Process.Start(StrongNameTool, "-k \"" + keyPath + "\"");
+ p.WaitForExit();
+ if (p.ExitCode != 0) {
+ MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.ErrorCreatingKey}");
+ return false;
+ }
+ return true;
+ }
+
+ public string KeyFile {
+ get {
+ return ControlDictionary["keyFileTextBox"].Text;
+ }
+ set {
+ ControlDictionary["keyFileTextBox"].Text = value;
+ }
+ }
+
+ public static bool CheckPassword(Control password, Control confirm)
+ {
+ password.Text = password.Text.Trim();
+ confirm.Text = confirm.Text.Trim();
+ if (password.Text.Length < 6) {
+ MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.PasswordTooShort}");
+ password.Focus();
+ return false;
+ }
+ if (password.Text != confirm.Text) {
+ MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.PasswordsDontMatch}");
+ return false;
+ }
+ return true;
+ }
+
+ public static string StrongNameTool {
+ get {
+ return FileUtility.NetSdkInstallRoot + "bin\\sn.exe";
+ }
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs
index 4d34a6819a..64e4478b3a 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs
@@ -13,83 +13,40 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
+using RadioBinding = System.Collections.Generic.KeyValuePair;
+
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
- public class DebugOptions : AbstractOptionPanel
+ public class DebugOptions : AbstractProjectOptionPanel
{
- AdvancedMSBuildProject project;
-
- string Config = "Debug";
- string Platform = "AnyCPU";
-
- public DebugOptions()
- {
- }
-
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.DebugOptions.xfrm"));
+ SetupFromXmlResource("ProjectOptions.DebugOptions.xfrm");
ConnectBrowseButton("startExternalProgramBrowseButton", "startExternalProgramTextBox", "${res:SharpDevelop.FileFilter.AllFiles}|*.*");
ConnectBrowseFolder("workingDirectoryBrowseButton", "workingDirectoryTextBox");
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
-
- StartAction startAction = project.GetStartAction(Config, Platform);
-
- Get("startProject").Checked = startAction == StartAction.Project;
- Get("startProject").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("startProject").CheckedChanged += new EventHandler(Save);
-
- Get("startExternalProgram").Checked = startAction == StartAction.Program;
- Get("startExternalProgram").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("startExternalProgram").CheckedChanged += new EventHandler(Save);
- Get("startBrowserInURL").Checked = startAction == StartAction.StartURL;
- Get("startBrowserInURL").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("startBrowserInURL").CheckedChanged += new EventHandler(Save);
+ InitializeHelper();
- Get("startExternalProgram").Text = project.GetStartProgram(Config, Platform);
- Get("startExternalProgram").TextChanged += new EventHandler(Save);
+ helper.BindRadioEnum("StartAction",
+ new RadioBinding(StartAction.Project, Get("startProject")),
+ new RadioBinding(StartAction.Program, Get("startExternalProgram")),
+ new RadioBinding(StartAction.StartURL, Get("startBrowserInURL")));
- Get("startBrowserInURL").Text = project.GetStartURL(Config, Platform);
- Get("startBrowserInURL").TextChanged += new EventHandler(Save);
+ Get("startExternalProgram").CheckedChanged += UpdateEnabledStates;
+ Get("startBrowserInURL").CheckedChanged += UpdateEnabledStates;
- Get("commandLineArguments").Text = project.GetStartArguments(Config, Platform);
- Get("commandLineArguments").TextChanged += new EventHandler(Save);
-
- Get("workingDirectory").Text = project.GetStartWorkingDirectory(Config, Platform);
- Get("workingDirectory").TextChanged += new EventHandler(Save);
+ helper.BindString("startExternalProgramTextBox", "StartProgram");
+ helper.BindString("startBrowserInURLTextBox", "StartURL");
+ helper.BindString("commandLineArgumentsTextBox", "StartArguments");
+ helper.BindString("workingDirectoryTextBox", "StartWorkingDirectory");
UpdateEnabledStates(this, EventArgs.Empty);
}
- void Save(object sender, EventArgs e)
- {
- StorePanelContents();
- }
-
void UpdateEnabledStates(object sender, EventArgs e)
{
Get("startExternalProgram").Enabled = Get("startExternalProgramBrowse").Enabled = Get("startExternalProgram").Checked;
Get("startBrowserInURL").Enabled = Get("startBrowserInURL").Checked;
}
-
- public override bool StorePanelContents()
- {
- project.SetStartProgram(Config, Platform, Get("startExternalProgram").Text);
- project.SetStartURL(Config, Platform, Get("startBrowserInURL").Text);
- project.SetStartArguments(Config, Platform, Get("commandLineArguments").Text);
- project.SetStartWorkingDirectory(Config, Platform, Get("workingDirectory").Text);
-
- if (Get("startProject").Checked) {
- project.SetStartAction(Config, Platform, StartAction.Project);
- } else if (Get("startExternalProgram").Checked) {
- project.SetStartAction(Config, Platform, StartAction.Program);
- } else {
- project.SetStartAction(Config, Platform, StartAction.StartURL);
- }
- project.Save();
-
- return true;
- }
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Publish.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Publish.cs
index e598965bed..06a6678619 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Publish.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Publish.cs
@@ -15,21 +15,12 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
- public class Publish : AbstractOptionPanel
+ public class Publish : AbstractProjectOptionPanel
{
- AdvancedMSBuildProject project;
-
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.Publish.xfrm"));
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
- }
-
-
- public override bool StorePanelContents()
- {
- // TODO
- return true;
+ SetupFromXmlResource("ProjectOptions.Publish.xfrm");
+ InitializeHelper();
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePaths.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePaths.cs
index a3feca8df4..a9febd744d 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePaths.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ReferencePaths.cs
@@ -17,12 +17,12 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
public class ReferencePaths : AbstractOptionPanel
{
- AdvancedMSBuildProject project;
+ MSBuildProject project;
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.ReferencePaths.xfrm"));
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
+ SetupFromXmlResource("ProjectOptions.ReferencePaths.xfrm");
+ this.project = (MSBuildProject)((Properties)CustomizationObject).Get("Project");
}
public override bool StorePanelContents()
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.cs
index 2d2e63ac64..30862b5cee 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.cs
@@ -6,86 +6,106 @@
//
using System;
+using System.IO;
using System.Windows.Forms;
-using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
- public class Signing : AbstractOptionPanel
+ public class Signing : AbstractProjectOptionPanel
{
- AdvancedMSBuildProject project;
+ ComboBox keyFile;
+
+ const string KeyFileExtensions = "*.snk;*.pfx;*.key";
public override void LoadPanelContents()
{
- SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ProjectOptions.Signing.xfrm"));
- this.project = (AdvancedMSBuildProject)((Properties)CustomizationObject).Get("Project");
+ SetupFromXmlResource("ProjectOptions.Signing.xfrm");
+ InitializeHelper();
- Get("signAssembly").Checked = project.SignAssembly;
+ helper.BindBoolean("signAssemblyCheckBox", "SignAssembly", false);
Get("signAssembly").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("signAssembly").CheckedChanged += new EventHandler(Save);
-
- Get("useKeyFile").Checked = project.AssemblyOriginatorKeyMode == AssemblyOriginatorKeyMode.File;
- Get("useKeyFile").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("useKeyFile").CheckedChanged += new EventHandler(Save);
-
-
- Get("useKeyProvider").Checked = project.AssemblyOriginatorKeyMode == AssemblyOriginatorKeyMode.Provider;
- Get("useKeyProvider").CheckedChanged += new EventHandler(UpdateEnabledStates);
- Get("useKeyProvider").CheckedChanged += new EventHandler(Save);
-
- Get("keyFile").Text = project.AssemblyOriginatorKeyFile;
- Get("keyFile").TextChanged += new EventHandler(Save);
- Get("providerName").Text = project.AssemblyKeyProviderName;
- Get("providerName").Items.Add("TODO: GetKeyProviders()");
- Get("providerName").TextChanged += new EventHandler(Save);
- Get("container").Text = "TODO";
- Get("container").TextChanged += new EventHandler(Save);
+ keyFile = Get("keyFile");
+ helper.BindString(keyFile, "AssemblyOriginatorKeyFile");
+ if (keyFile.Text.Length > 0) {
+ FindKeys(baseDirectory);
+ if (!keyFile.Items.Contains(keyFile.Text)) {
+ keyFile.Items.Add(keyFile.Text);
+ }
+ }
+ keyFile.Items.Add(StringParser.Parse("<${res:Global.CreateButtonText}...>"));
+ keyFile.Items.Add(StringParser.Parse("<${res:Global.BrowseText}...>"));
+ keyFile.SelectedIndexChanged += delegate {
+ if (keyFile.SelectedIndex == keyFile.Items.Count - 1) {
+ BeginInvoke(new MethodInvoker(BrowseKeyFile));
+ }
+ if (keyFile.SelectedIndex == keyFile.Items.Count - 2) {
+ BeginInvoke(new MethodInvoker(CreateKeyFile));
+ }
+ };
- Get("delaySignOnly").Checked = project.DelaySign;
- Get("delaySignOnly").CheckedChanged += new EventHandler(Save);
+ helper.BindBoolean("delaySignOnlyCheckBox", "DelaySign", false);
UpdateEnabledStates(this, EventArgs.Empty);
}
+ void FindKeys(string directory)
+ {
+ directory = Path.GetFullPath(directory);
+ foreach (string fileName in Directory.GetFiles(directory, "*.snk")) {
+ keyFile.Items.Add(FileUtility.GetRelativePath(baseDirectory, fileName));
+ }
+ foreach (string fileName in Directory.GetFiles(directory, "*.pfx")) {
+ keyFile.Items.Add(FileUtility.GetRelativePath(baseDirectory, fileName));
+ }
+ foreach (string fileName in Directory.GetFiles(directory, "*.key")) {
+ keyFile.Items.Add(FileUtility.GetRelativePath(baseDirectory, fileName));
+ }
+ if (directory.Length > 3) {
+ FindKeys(Path.Combine(directory, ".."));
+ }
+ }
- void Save(object sender, EventArgs e)
+ void BrowseKeyFile()
{
- StorePanelContents();
+ keyFile.SelectedIndex = -1;
+ new BrowseButtonEvent(this, "keyFileComboBox", "${res:SharpDevelop.FileFilter.KeyFiles} (" + KeyFileExtensions + ")|" + KeyFileExtensions + "|${res:SharpDevelop.FileFilter.AllFiles}|*.*").Event(this, EventArgs.Empty);
}
+ void CreateKeyFile()
+ {
+ if (File.Exists(CreateKeyForm.StrongNameTool)) {
+ using (CreateKeyForm createKey = new CreateKeyForm(baseDirectory)) {
+ createKey.KeyFile = project.Name;
+ if (createKey.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK) {
+ keyFile.Text = createKey.KeyFile;
+ return;
+ }
+ }
+ } else {
+ MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.SNnotFound}");
+ }
+ keyFile.Text = "";
+ }
void UpdateEnabledStates(object sender, EventArgs e)
{
- Get("changePassword").Enabled = false;
+ ControlDictionary["strongNameSignPanel"].Enabled = Get("signAssembly").Checked;
- Get("providerName").Enabled = Get("container").Enabled = Get("useKeyProvider").Checked;
- Get("keyFile").Enabled = Get("useKeyFile").Checked;
- Get("signing").Enabled = Get("signAssembly").Checked;
+ Get("changePassword").Enabled = false;
}
public override bool StorePanelContents()
{
- project.SignAssembly = Get("signAssembly").Checked;
- project.DelaySign = Get("delaySignOnly").Checked;
-
- project.AssemblyOriginatorKeyFile = Get("keyFile").Text;
- project.AssemblyKeyProviderName = Get("providerName").Text;
- // TODO : Container ????
-
- if (Get("useKeyFile").Checked) {
- project.AssemblyOriginatorKeyMode = AssemblyOriginatorKeyMode.File;
- } else if (Get("useKeyProvider").Checked) {
- project.AssemblyOriginatorKeyMode = AssemblyOriginatorKeyMode.Provider;
+ if (IsDirty && Get("signAssembly").Checked) {
+ helper.SetProperty("AssemblyOriginatorKeyMode", "File");
}
- project.Save();
-
- return true;
+ return base.StorePanelContents();
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsDialog.cs
deleted file mode 100644
index 1306551667..0000000000
--- a/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsDialog.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-////
-////
-////
-////
-////
-////
-//
-//using System;
-//using System.Drawing;
-//using System.Collections;
-//using System.ComponentModel;
-//using System.Windows.Forms;
-//using System.Xml;
-//
-//using ICSharpCode.Core;
-//using ICSharpCode.Core;
-//using ICSharpCode.Core;
-//using ICSharpCode.Core;
-//using ICSharpCode.SharpDevelop.Project;
-//using ICSharpCode.Core;
-//namespace ICSharpCode.SharpDevelop.Gui {
-// ///
-// /// Dialog for viewing the project options (plain treeview isn't good enough :/)
-// ///
-// public class ProjectOptionsDialog : TreeViewOptions
-// {
-// IProject project;
-// TreeNode configurationTreeNode;
-//
-// AddInTreeNode configurationNode;
-//
-// public ProjectOptionsDialog(IProject project, AddInTreeNode node, AddInTreeNode configurationNode) : base(null, null)
-// {
-// this.project = project;
-// this.configurationNode = configurationNode;
-// this.Text = StringParser.Parse("${res:Dialog.Options.ProjectOptions.DialogName}");
-//
-// ((TreeView)ControlDictionary["optionsTreeView"]).MouseUp += new MouseEventHandler(TreeViewMouseUp);
-// ((TreeView)ControlDictionary["optionsTreeView"]).AfterLabelEdit += new NodeLabelEditEventHandler(AfterLabelEdit);
-//
-// ((TreeView)ControlDictionary["optionsTreeView"]).Font = boldFont;
-//
-// properties = new Properties();
-// properties.Set("Project", project);
-//
-// AddNodes(properties, ((TreeView)ControlDictionary["optionsTreeView"]).Nodes, node.BuildChildItems(this));
-//
-// configurationTreeNode = new TreeNode(StringParser.Parse("${res:Dialog.Options.ProjectOptions.ConfigurationsNodeName}"));
-// configurationTreeNode.NodeFont = plainFont;
-//
-// foreach (IConfiguration config in project.Configurations) {
-// TreeNode newNode = new TreeNode(config.Name);
-// newNode.Tag = config;
-// if (config == project.ActiveConfiguration) {
-// newNode.NodeFont = boldFont;
-// } else {
-// newNode.NodeFont = plainFont;
-// }
-// Properties configNodeProperties = new Properties();
-// configNodeProperties.Set("Project", project);
-// configNodeProperties.Set("Config", config);
-// AddNodes(configNodeProperties, newNode.Nodes, configurationNode.BuildChildItems(this));
-// configurationTreeNode.Nodes.Add(newNode);
-// }
-// ((TreeView)ControlDictionary["optionsTreeView"]).Nodes.Add(configurationTreeNode);
-//
-// }
-//
-// public void AddProjectConfiguration()
-// {
-// int number = -1;
-// string name = "New Configuration"; // don't localize this project configs should have per default an english name
-// string newName = name;
-// bool duplicateNumber;
-// do {
-// duplicateNumber = false;
-// foreach (IConfiguration config in project.Configurations) {
-// newName = number >= 0 ? name + number : name;
-// if (newName == config.Name) {
-// ++number;
-// duplicateNumber = true;
-// break;
-// }
-// }
-// } while (duplicateNumber);
-//
-// TreeNode newNode = new TreeNode(newName);
-// IConfiguration newConfig = project.CloneConfiguration(project.ActiveConfiguration);
-// newConfig.Name = newName;
-//
-// newNode.Tag = newConfig;
-// newNode.NodeFont = plainFont;
-// project.Configurations.Add(newConfig);
-//
-// Properties newProperties = new Properties();
-// newProperties.Set("Project", project);
-// newProperties.Set("Config", newConfig);
-// AddNodes(newProperties, newNode.Nodes, configurationNode.BuildChildItems(newConfig));
-//
-// configurationTreeNode.Nodes.Add(newNode);
-// ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode = newNode;
-// ((TreeView)ControlDictionary["optionsTreeView"]).LabelEdit = true;
-// newNode.BeginEdit();
-// }
-//
-// public void RemoveProjectConfiguration()
-// {
-// IConfiguration config = (IConfiguration)((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode.Tag;
-// if (project.Configurations.Count > 1) {
-// bool newActiveConfig = project.ActiveConfiguration == config;
-// project.Configurations.Remove(config);
-// project.ActiveConfiguration = (IConfiguration)project.Configurations[0];
-// ((TreeView)ControlDictionary["optionsTreeView"]).Nodes.Remove(((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode);
-// UpdateBoldConfigurationNode();
-// configurationTreeNode.Expand();
-// }
-// }
-//
-// void UpdateBoldConfigurationNode()
-// {
-// foreach (TreeNode node in configurationTreeNode.Nodes) {
-// if (node == ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode) {
-// node.NodeFont = boldFont;
-// } else {
-// node.NodeFont = plainFont;
-// }
-// }
-// }
-//
-// public void SetSelectedConfigurationAsStartup()
-// {
-// IConfiguration config = ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode.Tag as IConfiguration;
-// if (config != null) {
-// project.ActiveConfiguration = config;
-// UpdateBoldConfigurationNode();
-// }
-// }
-//
-// public void RenameProjectConfiguration()
-// {
-// ((TreeView)ControlDictionary["optionsTreeView"]).LabelEdit = true;
-// ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode.BeginEdit();
-// }
-//
-// void AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
-// {
-// ((TreeView)ControlDictionary["optionsTreeView"]).LabelEdit = false;
-//
-// // canceled edit (or empty name)
-// if (e.Label == null || e.Label.Length == 0) {
-// return;
-// }
-//
-// bool duplicateLabel = false;
-// foreach (IConfiguration config in project.Configurations) {
-// if (e.Label == config.Name) {
-// duplicateLabel = true;
-// break;
-// }
-// }
-// e.CancelEdit = true;
-//
-// if (!duplicateLabel) {
-// e.Node.Text = e.Label;
-// ((IConfiguration)e.Node.Tag).Name = e.Label;
-// }
-// }
-//
-// static string configNodeMenu = "/SharpDevelop/Workbench/ProjectOptions/ConfigNodeMenu";
-// static string selectConfigNodeMenu = "/SharpDevelop/Workbench/ProjectOptions/SelectedConfigMenu";
-//
-// void TreeViewMouseUp(object sender, MouseEventArgs e)
-// {
-// TreeNode clickedNode = ((TreeView)ControlDictionary["optionsTreeView"]).GetNodeAt(e.X, e.Y);
-//
-// if(clickedNode == null) {
-// return;
-// }
-//
-// if (e.Button == MouseButtons.Right) {
-// MenuService MenuService = (MenuService)ICSharpCode.Core.ServiceManager.Services.GetService(typeof(MenuService));
-// if (clickedNode == configurationTreeNode) {
-// b = false;
-// ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode = clickedNode;
-// b = true;
-// MenuService.ShowContextMenu(this, configNodeMenu, this, e.X, e.Y);
-// }
-// if (clickedNode.Parent == configurationTreeNode) {
-// b = false;
-// ((TreeView)ControlDictionary["optionsTreeView"]).SelectedNode = clickedNode;
-// b = true;
-// MenuService.ShowContextMenu(this, selectConfigNodeMenu, this, e.X, e.Y);
-// }
-// }
-// }
-// }
-//}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsView.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsView.cs
index 5f765fc48c..85b5bab6dc 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsView.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/ProjectOptionsView.cs
@@ -30,16 +30,24 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
}
}
+ public override string FileName {
+ get {
+ return project.FileName;
+ }
+ set {
+ throw new NotSupportedException();
+ }
+ }
+
public override Control Control {
get {
return tabControl;
}
}
- public ProjectOptionsView(AddInTreeNode node, IProject project) : base("a", "a")
+ public ProjectOptionsView(AddInTreeNode node, IProject project)
{
this.project = project;
- base.IsViewOnly = true;
// tabControl.Alignment = TabAlignment.Left;
@@ -76,6 +84,10 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
if (descriptor != null && descriptor.DialogPanel != null && descriptor.DialogPanel.Control != null) { // may be null, if it is only a "path"
descriptor.DialogPanel.CustomizationObject = newProperties;
descriptor.DialogPanel.ReceiveDialogMessage(DialogMessage.Activated);
+ ICanBeDirty dirtyable = descriptor.DialogPanel as ICanBeDirty;
+ if (dirtyable != null) {
+ dirtyable.DirtyChanged += PanelDirtyChanged;
+ }
TabPage page = new TabPage(descriptor.Label);
page.Controls.Add(descriptor.DialogPanel.Control);
@@ -88,12 +100,26 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
}
}
+ void PanelDirtyChanged(object sender, EventArgs e)
+ {
+ bool dirty = false;
+ foreach (IDialogPanelDescriptor descriptor in descriptors) {
+ if (descriptor != null) { // may be null, if it is only a "path"
+ ICanBeDirty dirtyable = descriptor.DialogPanel as ICanBeDirty;
+ if (dirtyable != null) {
+ dirty |= dirtyable.IsDirty;
+ }
+ }
+ }
+ this.IsDirty = dirty;
+ }
+
public override void Save(string fileName)
{
foreach (IDialogPanelDescriptor pane in descriptors) {
pane.DialogPanel.ReceiveDialogMessage(DialogMessage.OK);
}
- ProjectService.SaveSolution();
+ project.Save();
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/IViewContent.cs b/src/Main/Base/Project/Src/Gui/IViewContent.cs
index 4c8e4cd35b..225a4b6a08 100644
--- a/src/Main/Base/Project/Src/Gui/IViewContent.cs
+++ b/src/Main/Base/Project/Src/Gui/IViewContent.cs
@@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// IViewContent is the base interface for all editable data
/// inside SharpDevelop.
///
- public interface IViewContent : IBaseViewContent
+ public interface IViewContent : IBaseViewContent, ICanBeDirty
{
///
/// A generic name for the file, when it does have no file name
@@ -73,15 +73,6 @@ namespace ICSharpCode.SharpDevelop.Gui
get;
}
- ///
- /// If this property returns true the content has changed since
- /// the last load/save operation.
- ///
- bool IsDirty {
- get;
- set;
- }
-
///
/// If this property returns true the content could not be altered.
///
@@ -123,12 +114,6 @@ namespace ICSharpCode.SharpDevelop.Gui
///
event EventHandler TitleNameChanged;
- ///
- /// Is called when the content is changed after a save/load operation
- /// and this signals that changes could be saved.
- ///
- event EventHandler DirtyChanged;
-
event EventHandler Saving;
event SaveEventHandler Saved;
}
diff --git a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlForm.cs b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlForm.cs
index c5733a3c30..467c464c84 100644
--- a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlForm.cs
+++ b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlForm.cs
@@ -14,9 +14,9 @@ using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
-
-namespace ICSharpCode.SharpDevelop.Gui.XmlForms
-{
+
+namespace ICSharpCode.SharpDevelop.Gui.XmlForms
+{
///
/// The basic xml generated form.
///
@@ -53,18 +53,25 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
{
return xmlLoader.Get(name);
}
-//
+//
// protected void SetupFromXml(string fileName)
// {
// if (fileName == null) {
// throw new System.ArgumentNullException("fileName");
// }
-//
+//
// using (Stream stream = File.OpenRead(fileName)) {
// SetupFromXmlStream(stream);
// }
// }
+ protected void SetupFromXmlResource(string resourceName)
+ {
+ Assembly caller = Assembly.GetCallingAssembly();
+ resourceName = "Resources." + resourceName;
+ SetupFromXmlStream(caller.GetManifestResourceStream(resourceName));
+ }
+
protected void SetupFromXmlStream(Stream stream)
{
if (stream == null) {
diff --git a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlUserControl.cs b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlUserControl.cs
index ac13c27b97..d15824985b 100644
--- a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlUserControl.cs
+++ b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlUserControl.cs
@@ -15,7 +15,7 @@ using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
-namespace ICSharpCode.SharpDevelop.Gui.XmlForms
+namespace ICSharpCode.SharpDevelop.Gui.XmlForms
{
///
/// The basic xml generated user control.
@@ -53,18 +53,25 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
{
return xmlLoader.Get(name);
}
-//
+//
// protected void SetupFromXml(string fileName)
// {
// if (fileName == null) {
// throw new System.ArgumentNullException("fileName");
// }
-//
+//
// using (Stream stream = File.OpenRead(fileName)) {
// SetupFromXmlStream(stream);
// }
// }
+ protected void SetupFromXmlResource(string resourceName)
+ {
+ Assembly caller = Assembly.GetCallingAssembly();
+ resourceName = "Resources." + resourceName;
+ SetupFromXmlStream(caller.GetManifestResourceStream(resourceName));
+ }
+
protected void SetupFromXmlStream(Stream stream)
{
if (stream == null) {
diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs
index 1a0a292be0..332a667c7c 100644
--- a/src/Main/Base/Project/Src/Project/AbstractProject.cs
+++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs
@@ -162,6 +162,7 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public string Configuration {
get {
+ // is always stored in BaseConfiguration
return BaseConfiguration["Configuration"];
}
set {
@@ -172,6 +173,7 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public string Platform {
get {
+ // is always stored in BaseConfiguration
return BaseConfiguration["Platform"];
}
set {
@@ -182,17 +184,17 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public virtual OutputType OutputType {
get {
- return BaseConfiguration.Get("OutputType", OutputType.Exe);
+ return GetProperty("OutputType", OutputType.Exe);
}
set {
- BaseConfiguration.Set("OutputType", value);
+ SetProperty("OutputType", value);
}
}
[Browsable(false)]
public string OutputAssemblyFullPath {
get {
- string outputPath = ActiveConfiguration["OutputPath"];
+ string outputPath = GetProperty("OutputPath");
return Path.Combine(Path.Combine(Directory, outputPath), AssemblyName + GetExtension(OutputType));
}
}
@@ -214,6 +216,7 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public Guid Guid {
get {
+ // is always in base config
return new Guid(BaseConfiguration["ProjectGuid"]);
}
}
@@ -221,30 +224,30 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public string RootNamespace {
get {
- return BaseConfiguration["RootNamespace"];
+ return GetProperty("RootNamespace");
}
set {
- BaseConfiguration["RootNamespace"] = value;
+ SetProperty("RootNamespace", value);
}
}
[Browsable(false)]
public string AssemblyName {
get {
- return BaseConfiguration["AssemblyName"];
+ return GetProperty("AssemblyName");
}
set {
- BaseConfiguration["AssemblyName"] = value;
+ SetProperty("AssemblyName", value);
}
}
[Browsable(false)]
public string AppDesignerFolder {
get {
- return BaseConfiguration["AppDesignerFolder"];
+ return GetProperty("AppDesignerFolder");
}
set {
- BaseConfiguration["AppDesignerFolder"] = value;
+ SetProperty("AppDesignerFolder", value);
}
}
@@ -283,6 +286,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
+ /*
public string GetOutputPath(string configurationName, string platform)
{
return GetConfiguration(configurationName, platform)["OutputPath"];
@@ -292,33 +296,108 @@ namespace ICSharpCode.SharpDevelop.Project
{
GetConfiguration(configurationName, platform)["OutputPath"] = val;
}
+ */
- public PropertyGroup GetUserConfiguration(string configurationName)
+ public string GetProperty(string property)
{
- return GetUserConfiguration(configurationName, null);
+ return GetProperty(property, "");
}
- public PropertyGroup GetUserConfiguration(string configurationName, string platform)
+ public T GetProperty(string property, T defaultValue)
+ {
+ return GetProperty(this.Configuration, this.Platform, property, defaultValue);
+ }
+
+ public T GetProperty(string configurationName, string platform, string property, T defaultValue)
{
string configurationKey = platform != null ? configurationName + "|" + platform : configurationName;
- if (!userConfigurations.ContainsKey(configurationKey)) {
- userConfigurations.Add(configurationKey, new PropertyGroup());
+ PropertyGroup pg;
+ if (userConfigurations.TryGetValue(configurationKey, out pg)) {
+ if (pg.IsSet(property)) {
+ return pg.Get(property, defaultValue);
+ }
+ }
+ if (configurations.TryGetValue(configurationKey, out pg)) {
+ if (pg.IsSet(property)) {
+ return pg.Get(property, defaultValue);
+ }
}
- return userConfigurations[configurationKey];
+ if (BaseConfiguration.IsSet(property)) {
+ return BaseConfiguration.Get(property, defaultValue);
+ }
+ return defaultValue;
+ }
+
+ public void SetProperty(string property, T value)
+ {
+ SetProperty(this.Configuration, this.Platform, property, value, PropertyStorageLocation.Unchanged);
}
- public PropertyGroup GetConfiguration(string configurationName)
+ public void SetProperty(string property, T value, PropertyStorageLocation location)
{
- return GetConfiguration(configurationName, null);
+ SetProperty(this.Configuration, this.Platform, property, value, location);
}
- public PropertyGroup GetConfiguration(string configurationName, string platform)
+ public void SetProperty(string configurationName, string platform, string property, T value, PropertyStorageLocation location)
{
string configurationKey = platform != null ? configurationName + "|" + platform : configurationName;
- if (!configurations.ContainsKey(configurationKey)) {
- configurations.Add(configurationKey, new PropertyGroup());
+ PropertyGroup pg;
+ T defaultValue = (typeof(T) == typeof(string)) ? (T)(object)string.Empty : default(T);
+ switch (location) {
+ case PropertyStorageLocation.Unchanged:
+ if (userConfigurations.TryGetValue(configurationKey, out pg)) {
+ if (pg.IsSet(property)) {
+ pg.Set(property, defaultValue, value);
+ return;
+ }
+ }
+ if (configurations.TryGetValue(configurationKey, out pg)) {
+ if (pg.IsSet(property)) {
+ pg.Set(property, defaultValue, value);
+ return;
+ }
+ }
+ BaseConfiguration.Set(property, defaultValue, value);
+ return;
+ case PropertyStorageLocation.BaseConfiguration:
+ if (!BaseConfiguration.IsSet(property)) {
+ RemoveProperty(configurations, property);
+ RemoveProperty(userConfigurations, property);
+ }
+ BaseConfiguration.Set(property, defaultValue, value);
+ return;
+ case PropertyStorageLocation.SpecificConfiguration:
+ if (BaseConfiguration.IsSet(property)) {
+ BaseConfiguration.Remove(property);
+ }
+ RemoveProperty(userConfigurations, property);
+ if (!configurations.TryGetValue(configurationKey, out pg)) {
+ configurations[configurationKey] = pg = new PropertyGroup();
+ }
+ pg.Set(property, defaultValue, value);
+ return;
+ case PropertyStorageLocation.UserSpecificConfiguration:
+ if (BaseConfiguration.IsSet(property)) {
+ BaseConfiguration.Remove(property);
+ }
+ RemoveProperty(configurations, property);
+ if (!userConfigurations.TryGetValue(configurationKey, out pg)) {
+ userConfigurations[configurationKey] = pg = new PropertyGroup();
+ }
+ pg.Set(property, defaultValue, value);
+ return;
+ default:
+ throw new InvalidEnumArgumentException("location", (int)location, typeof(PropertyStorageLocation));
+ }
+ }
+
+ static void RemoveProperty(Dictionary dict, string property)
+ {
+ foreach (PropertyGroup pg in dict.Values) {
+ if (pg.IsSet(property)) {
+ pg.Remove(property);
+ }
}
- return configurations[configurationKey];
}
///
diff --git a/src/Main/Base/Project/Src/Project/AdvancedMSBuildProject.cs b/src/Main/Base/Project/Src/Project/AdvancedMSBuildProject.cs
deleted file mode 100644
index 6e0d6678a8..0000000000
--- a/src/Main/Base/Project/Src/Project/AdvancedMSBuildProject.cs
+++ /dev/null
@@ -1,421 +0,0 @@
-//
-// 2002-2005 AlphaSierraPapa
-// GNU General Public License
-//
-// $Revision$
-//
-
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.IO;
-using ICSharpCode.Core;
-
-namespace ICSharpCode.SharpDevelop.Project
-{
- public enum AssemblyOriginatorKeyMode {
- None,
- File,
- Provider
- }
-
- public enum RunPostBuildEvent {
- Always,
- OnSuccessfulBuild,
- OnOutputUpdated
- }
-
- public enum StartAction {
- Project,
- Program,
- StartURL
- }
-
- ///
- /// Common base of C# and VB.NET projects.
- /// Any AdvancedMSBuildProject can use the common option panels.
- ///
- public class AdvancedMSBuildProject : MSBuildProject
- {
- #region Application
- [Browsable(false)]
- public string ApplicationIcon {
- get {
- return BaseConfiguration["ApplicationIcon"];
- }
- set {
- BaseConfiguration.Set("ApplicationIcon", value);
- }
- }
-
- [Browsable(false)]
- public string StartupObject {
- get {
- return BaseConfiguration["StartupObject"];
- }
- set {
- BaseConfiguration.Set("StartupObject", value);
- }
- }
-
- [Browsable(false)]
- public string Win32Resource {
- get {
- return BaseConfiguration["Win32Resource"];
- }
- set {
- BaseConfiguration.Set("Win32Resource", value);
- }
- }
- #endregion
-
- #region Signing
- [Browsable(false)]
- public bool SignAssembly {
- get {
- return BaseConfiguration.Get("SignAssembly", false);
- }
- set {
- BaseConfiguration.Set("SignAssembly", false, value);
- }
- }
-
- [Browsable(false)]
- public bool DelaySign {
- get {
- return BaseConfiguration.Get("DelaySign", false);
- }
- set {
- BaseConfiguration.Set("DelaySign", false, value);
- }
- }
-
- [Browsable(false)]
- public string AssemblyOriginatorKeyFile {
- get {
- return BaseConfiguration["AssemblyOriginatorKeyFile"];
- }
- set {
- BaseConfiguration.Set("AssemblyOriginatorKeyFile", value);
- }
- }
-
- [Browsable(false)]
- public string AssemblyKeyProviderName {
- get {
- return BaseConfiguration["AssemblyKeyProviderName"];
- }
- set {
- BaseConfiguration.Set("AssemblyKeyProviderName", value);
- }
- }
-
- [Browsable(false)]
- public AssemblyOriginatorKeyMode AssemblyOriginatorKeyMode {
- get {
- return BaseConfiguration.Get("AssemblyOriginatorKeyMode", AssemblyOriginatorKeyMode.None);
- }
- set {
- BaseConfiguration.Set("AssemblyOriginatorKeyMode", AssemblyOriginatorKeyMode.None, value);
- }
- }
- #endregion
-
- #region Build events
- [Browsable(false)]
- public RunPostBuildEvent RunPostBuildEvent {
- get {
- return BaseConfiguration.Get("RunPostBuildEvent", RunPostBuildEvent.OnSuccessfulBuild);
- }
- set {
- BaseConfiguration.Set("RunPostBuildEvent", RunPostBuildEvent.OnSuccessfulBuild, value);
- }
- }
-
- [Browsable(false)]
- public string PreBuildEvent {
- get {
- return BaseConfiguration["PreBuildEvent"];
- }
- set {
- BaseConfiguration.Set("PreBuildEvent", value);
- }
- }
-
- [Browsable(false)]
- public string PostBuildEvent {
- get {
- return BaseConfiguration["PostBuildEvent"];
- }
- set {
- BaseConfiguration.Set("PostBuildEvent", value);
- }
- }
- #endregion
-
- #region Publishing
- [Browsable(false)]
- public string PublishUrl {
- get {
- return BaseConfiguration["PublishUrl"];
- }
- set {
- BaseConfiguration.Set("PublishUrl", value);
- }
- }
-
- [Browsable(false)]
- public bool Install {
- get {
- return BaseConfiguration.Get("Install", false);
- }
- set {
- BaseConfiguration.Set("Install", false, value);
- }
- }
-
- [Browsable(false)]
- public bool UpdateEnabled {
- get {
- return BaseConfiguration.Get("UpdateEnabled", false);
- }
- set {
- BaseConfiguration.Set("UpdateEnabled", false, value);
- }
- }
-
- [Browsable(false)]
- public bool UpdatePeriodically {
- get {
- return BaseConfiguration.Get("UpdatePeriodically", false);
- }
- set {
- BaseConfiguration.Set("UpdatePeriodically", false, value);
- }
- }
-
- [Browsable(false)]
- public bool UpdateRequired {
- get {
- return BaseConfiguration.Get("UpdateRequired", false);
- }
- set {
- BaseConfiguration.Set("UpdateRequired", false, value);
- }
- }
-
- [Browsable(false)]
- public bool UpdateUrlEnabled {
- get {
- return BaseConfiguration.Get("UpdateUrlEnabled", false);
- }
- set {
- BaseConfiguration.Set("UpdateUrlEnabled", value);
- }
- }
-
- [Browsable(false)]
- public bool BootstrapperEnabled {
- get {
- return BaseConfiguration.Get("BootstrapperEnabled", false);
- }
- set {
- BaseConfiguration.Set("BootstrapperEnabled", false, value);
- }
- }
-
- [Browsable(false)]
- public string InstallFrom {
- get {
- return BaseConfiguration["InstallFrom"];
- }
- set {
- BaseConfiguration.Set("InstallFrom", value);
- }
- }
- [Browsable(false)]
- public string FallbackCulture {
- get {
- return BaseConfiguration["FallbackCulture"];
- }
- set {
- BaseConfiguration.Set("FallbackCulture", value);
- }
- }
- [Browsable(false)]
- public string UpdateMode {
- get {
- return BaseConfiguration["UpdateMode"];
- }
- set {
- BaseConfiguration.Set("UpdateMode", value);
- }
- }
- [Browsable(false)]
- public string UpdateIntervalUnits {
- get {
- return BaseConfiguration["UpdateIntervalUnits"];
- }
- set {
- BaseConfiguration.Set("UpdateIntervalUnits", value);
- }
- }
-
- [Browsable(false)]
- public string ApplicationVersion {
- get {
- return BaseConfiguration["ApplicationVersion"];
- }
- set {
- BaseConfiguration.Set("ApplicationVersion", value);
- }
- }
- [Browsable(false)]
- public int UpdateInterval {
- get {
- return BaseConfiguration.Get("UpdateInterval", 0);
- }
- set {
- BaseConfiguration.Set("UpdateInterval", 0, value);
- }
- }
- [Browsable(false)]
- public int ApplicationRevision {
- get {
- return BaseConfiguration.Get("ApplicationRevision", 0);
- }
- set {
- BaseConfiguration.Set("ApplicationRevision", 0, value);
- }
- }
- #endregion
-
- #region Debug Options
- const string runConfiguration = "Debug";
- const string runProcessor = "AnyCPU";
-
- public override bool IsStartable {
- get {
- StartAction action = GetStartAction(runConfiguration, runProcessor);
- switch (action) {
- case StartAction.Project:
- return base.IsStartable;
- case StartAction.Program:
- return GetStartProgram(runConfiguration, runProcessor).Length > 0;
- case StartAction.StartURL:
- return GetStartURL(runConfiguration, runProcessor).Length > 0;
- }
- return false;
- }
- }
-
- void StartProgram(string program, bool withDebugging)
- {
- ProcessStartInfo psi = new ProcessStartInfo();
- psi.FileName = Path.Combine(Directory, program);
- string workingDir = GetStartWorkingDirectory(runConfiguration, runProcessor);
- if (workingDir.Length == 0) {
- psi.WorkingDirectory = Path.GetDirectoryName(psi.FileName);
- } else {
- psi.WorkingDirectory = Path.Combine(Directory, workingDir);
- }
- psi.Arguments = GetStartArguments(runConfiguration, runProcessor);
-
- if (withDebugging) {
- DebuggerService.CurrentDebugger.Start(psi);
- } else {
- DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
- }
- }
-
- public override void Start(bool withDebugging)
- {
- StartAction action = GetStartAction(runConfiguration, runProcessor);
- switch (action) {
- case StartAction.Project:
- StartProgram(this.OutputAssemblyFullPath, withDebugging);
- break;
- case StartAction.Program:
- StartProgram(GetStartProgram(runConfiguration, runProcessor), withDebugging);
- break;
- case StartAction.StartURL:
- FileService.OpenFile("browser://" + GetStartURL(runConfiguration, runProcessor));
- break;
- default:
- throw new ApplicationException("Unknown start action: " + action);
- }
- }
-
- public string GetStartProgram(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform)["StartProgram"];
- }
-
- public void SetStartProgram(string configurationName, string platform, string val)
- {
- GetUserConfiguration(configurationName, platform)["StartProgram"] = val;
- }
-
- public string GetStartURL(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform)["StartURL"];
- }
-
- public void SetStartURL(string configurationName, string platform, string val)
- {
- GetUserConfiguration(configurationName, platform)["StartURL"] = val;
- }
-
- public StartAction GetStartAction(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform).Get("StartAction", StartAction.Project);
- }
-
- public void SetStartAction(string configurationName, string platform, StartAction val)
- {
- GetUserConfiguration(configurationName, platform).Set("StartAction", StartAction.Project, val);
- }
-
- public string GetStartArguments(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform)["StartArguments"];
- }
-
- public void SetStartArguments(string configurationName, string platform, string val)
- {
- GetUserConfiguration(configurationName, platform)["StartArguments"] = val;
- }
-
- public string GetStartWorkingDirectory(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform)["StartWorkingDirectory"];
- }
-
- public void SetStartWorkingDirectory(string configurationName, string platform, string val)
- {
- GetUserConfiguration(configurationName, platform)["StartWorkingDirectory"] = val;
- }
-
-
- public bool GetRemoteDebugEnabled(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform).Get("RemoteDebugEnabled", false);
- }
-
- public void SetRemoteDebugEnabled(string configurationName, string platform, bool val)
- {
- GetUserConfiguration(configurationName, platform).Set("RemoteDebugEnabled", false, val);
- }
-
- public string GetRemoteDebugMachine(string configurationName, string platform)
- {
- return GetUserConfiguration(configurationName, platform)["RemoteDebugMachine"];
- }
-
- public void SetRemoteDebugMachine(string configurationName, string platform, string val)
- {
- GetUserConfiguration(configurationName, platform)["RemoteDebugMachine"] = val;
- }
- #endregion
- }
-}
diff --git a/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs b/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs
new file mode 100644
index 0000000000..4622175121
--- /dev/null
+++ b/src/Main/Base/Project/Src/Project/ConfigurationGuiHelper.cs
@@ -0,0 +1,449 @@
+/*
+ * Created by SharpDevelop.
+ * User: Daniel Grunwald
+ * Date: 19.08.2005
+ * Time: 15:12
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.Windows.Forms;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.SharpDevelop.Project
+{
+ public abstract class ConfigurationGuiBinding
+ {
+ ConfigurationGuiHelper helper;
+ string property;
+
+ public MSBuildProject Project {
+ get {
+ return helper.Project;
+ }
+ }
+
+ public ConfigurationGuiHelper Helper {
+ get {
+ return helper;
+ }
+ internal set {
+ helper = value;
+ }
+ }
+
+ public string Property {
+ get {
+ return property;
+ }
+ internal set {
+ property = value;
+ }
+ }
+
+ public T Get(T defaultValue)
+ {
+ return helper.GetProperty(property, defaultValue);
+ }
+
+ public void Set(T value)
+ {
+ helper.SetProperty(property, value);
+ }
+
+ public abstract void Load();
+ public abstract bool Save();
+ }
+
+ ///
+ /// Class that helps connecting configuration GUI controls to MsBuild properties.
+ ///
+ public class ConfigurationGuiHelper : ICanBeDirty
+ {
+ MSBuildProject project;
+ Dictionary controlDictionary;
+ List bindings = new List();
+
+ public ConfigurationGuiHelper(MSBuildProject project, Dictionary controlDictionary)
+ {
+ this.project = project;
+ this.controlDictionary = controlDictionary;
+ configuration = project.Configuration;
+ platform = project.Platform;
+ }
+
+ public MSBuildProject Project {
+ get {
+ return project;
+ }
+ }
+
+ public T GetProperty(string property, T defaultValue)
+ {
+ return project.GetProperty(configuration, platform, property, defaultValue);
+ }
+
+ public void SetProperty(string property, T value)
+ {
+ project.SetProperty(configuration, platform, property, value, PropertyStorageLocation.Unchanged);
+ }
+
+ ///
+ /// Initializes the Property and Project properties on the binding and calls the load method on it.
+ /// Registers the binding so that Save is called on it when Save is called on the ConfigurationGuiHelper.
+ ///
+ public void AddBinding(string property, ConfigurationGuiBinding binding)
+ {
+ binding.Property = property;
+ binding.Helper = this;
+ binding.Load();
+ bindings.Add(binding);
+ }
+
+ public bool Save()
+ {
+ foreach (ConfigurationGuiBinding binding in bindings) {
+ if (!binding.Save()) {
+ return false;
+ }
+ }
+ IsDirty = false;
+ return true;
+ }
+
+ void ControlValueChanged(object sender, EventArgs e)
+ {
+ IsDirty = true;
+ }
+
+ bool dirty;
+
+ public bool IsDirty {
+ get {
+ return dirty;
+ }
+ set {
+ if (dirty != value) {
+ dirty = value;
+ if (DirtyChanged != null) {
+ DirtyChanged(this, EventArgs.Empty);
+ }
+ }
+ }
+ }
+
+ public event EventHandler DirtyChanged;
+
+ string configuration;
+
+ public string Configuration {
+ get {
+ return configuration;
+ }
+ set {
+ configuration = value;
+ }
+ }
+
+ string platform;
+
+ public string Platform {
+ get {
+ return platform;
+ }
+ set {
+ platform = value;
+ }
+ }
+
+ #region Bind bool to CheckBox
+ public void BindBoolean(string control, string property, bool defaultValue)
+ {
+ BindBoolean(controlDictionary[control], property, defaultValue);
+ }
+
+ public void BindBoolean(Control control, string property, bool defaultValue)
+ {
+ CheckBox checkBox = control as CheckBox;
+ if (checkBox != null) {
+ AddBinding(property, new CheckBoxBinding(checkBox, defaultValue));
+ checkBox.CheckedChanged += ControlValueChanged;
+ } else {
+ throw new ApplicationException("Cannot bind " + control.GetType().Name + " to bool property.");
+ }
+ }
+
+ class CheckBoxBinding : ConfigurationGuiBinding
+ {
+ CheckBox control;
+ bool defaultValue;
+
+ public CheckBoxBinding(CheckBox control, bool defaultValue)
+ {
+ this.control = control;
+ this.defaultValue = defaultValue;
+ }
+
+ public override void Load()
+ {
+ control.Checked = Get(defaultValue);
+ }
+
+ public override bool Save()
+ {
+ Set(control.Checked ? "true" : "false");
+ return true;
+ }
+ }
+ #endregion
+
+ #region Bind string to TextBox or ComboBox
+ public void BindString(string control, string property)
+ {
+ BindString(controlDictionary[control], property);
+ }
+
+ public void BindString(Control control, string property)
+ {
+ if (control is TextBoxBase || control is ComboBox) {
+ AddBinding(property, new SimpleTextBinding(control));
+ control.TextChanged += ControlValueChanged;
+ if (control is ComboBox) {
+ control.KeyDown += ComboBoxKeyDown;
+ }
+ } else {
+ throw new ApplicationException("Cannot bind " + control.GetType().Name + " to string property.");
+ }
+ }
+
+ void ComboBoxKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyData == (Keys.Control | Keys.S)) {
+ e.Handled = true;
+ new ICSharpCode.SharpDevelop.Commands.SaveFile().Run();
+ }
+ }
+
+ class SimpleTextBinding : ConfigurationGuiBinding
+ {
+ Control control;
+
+ public SimpleTextBinding(Control control)
+ {
+ this.control = control;
+ }
+
+ public override void Load()
+ {
+ control.Text = Get("");
+ }
+
+ public override bool Save()
+ {
+ Set(control.Text);
+ return true;
+ }
+ }
+ #endregion
+
+ #region Bind hex number to TextBox
+ public void BindHexadecimal(TextBoxBase textBox, string property, int defaultValue)
+ {
+ AddBinding(property, new HexadecimalBinding(textBox, defaultValue));
+ textBox.TextChanged += ControlValueChanged;
+ }
+
+ class HexadecimalBinding : ConfigurationGuiBinding
+ {
+ TextBoxBase textBox;
+ int defaultValue;
+
+ public HexadecimalBinding(TextBoxBase textBox, int defaultValue)
+ {
+ this.textBox = textBox;
+ this.defaultValue = defaultValue;
+ }
+
+ public override void Load()
+ {
+ int val;
+ if (!int.TryParse(Get(defaultValue.ToString(NumberFormatInfo.InvariantInfo)), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out val)) {
+ val = defaultValue;
+ }
+ textBox.Text = "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo);
+ }
+
+ public override bool Save()
+ {
+ string txt = textBox.Text.Trim();
+ NumberStyles style = NumberStyles.Integer;
+ if (txt.StartsWith("0x")) {
+ txt = txt.Substring(2);
+ style = NumberStyles.HexNumber;
+ }
+ int val;
+ if (!int.TryParse(txt, style, NumberFormatInfo.InvariantInfo, out val)) {
+ textBox.Focus();
+ MessageService.ShowMessage("Please enter a valid number.");
+ return false;
+ }
+ Set(val.ToString(NumberFormatInfo.InvariantInfo));
+ return true;
+ }
+ }
+ #endregion
+
+ #region Bind enum to ComboBox
+ ///
+ /// Bind enum to ComboBox
+ ///
+ public void BindEnum(string control, string property, params T[] values) where T : struct
+ {
+ BindEnum(controlDictionary[control], property, values);
+ }
+
+ ///
+ /// Bind enum to ComboBox
+ ///
+ public void BindEnum(Control control, string property, params T[] values) where T : struct
+ {
+ Type type = typeof(T);
+ if (values == null || values.Length == 0) {
+ values = (T[])Enum.GetValues(type);
+ }
+ ComboBox comboBox = control as ComboBox;
+ if (comboBox != null) {
+ foreach (T element in values) {
+ object[] attr = type.GetField(Enum.GetName(type, element)).GetCustomAttributes(typeof(DescriptionAttribute), false);
+ string description;
+ if (attr.Length > 0) {
+ description = StringParser.Parse((attr[0] as DescriptionAttribute).Description);
+ } else {
+ description = Enum.GetName(type, element);
+ }
+ comboBox.Items.Add(description);
+ }
+ string[] valueNames = new string[values.Length];
+ for (int i = 0; i < values.Length; i++)
+ valueNames[i] = values[i].ToString();
+ AddBinding(property, new ComboBoxBinding(comboBox, valueNames, valueNames[0]));
+ comboBox.SelectedIndexChanged += ControlValueChanged;
+ comboBox.KeyDown += ComboBoxKeyDown;
+ } else {
+ throw new ApplicationException("Cannot bind " + control.GetType().Name + " to enum property.");
+ }
+ }
+
+ ///
+ /// Bind list of strings to ComboBox.
+ /// entries: value -> Description
+ ///
+ public void BindStringEnum(string control, string property, string defaultValue, params KeyValuePair[] entries)
+ {
+ BindStringEnum(controlDictionary[control], property, defaultValue, entries);
+ }
+
+ ///
+ /// Bind list of strings to ComboBox.
+ /// entries: value -> Description
+ ///
+ public void BindStringEnum(Control control, string property, string defaultValue, params KeyValuePair[] entries)
+ {
+ ComboBox comboBox = control as ComboBox;
+ if (comboBox != null) {
+ string[] valueNames = new string[entries.Length];
+ for (int i = 0; i < entries.Length; i++) {
+ valueNames[i] = entries[i].Key;
+ comboBox.Items.Add(StringParser.Parse(entries[i].Value));
+ }
+ AddBinding(property, new ComboBoxBinding(comboBox, valueNames, defaultValue));
+ comboBox.SelectedIndexChanged += ControlValueChanged;
+ comboBox.KeyDown += ComboBoxKeyDown;
+ } else {
+ throw new ApplicationException("Cannot bind " + control.GetType().Name + " to enum property.");
+ }
+ }
+
+ class ComboBoxBinding : ConfigurationGuiBinding
+ {
+ ComboBox control;
+ string[] values;
+ string defaultValue;
+
+ public ComboBoxBinding(ComboBox control, string[] values, string defaultValue)
+ {
+ this.control = control;
+ this.values = values;
+ this.defaultValue = defaultValue;
+ }
+
+ public override void Load()
+ {
+ string val = Get(defaultValue);
+ int i;
+ for (i = 0; i < values.Length; i++) {
+ if (val.Equals(values[i], StringComparison.OrdinalIgnoreCase))
+ break;
+ }
+ if (i == values.Length) i = 0;
+ control.SelectedIndex = i;
+ }
+
+ public override bool Save()
+ {
+ Set(values[control.SelectedIndex]);
+ return true;
+ }
+ }
+ #endregion
+
+ #region Bind enum to RadioButtons
+ ///
+ /// Bind enum to RadioButtons
+ ///
+ public void BindRadioEnum(string property, params KeyValuePair[] values) where T : struct
+ {
+ AddBinding(property, new RadioEnumBinding(values));
+ foreach (KeyValuePair pair in values) {
+ pair.Value.CheckedChanged += ControlValueChanged;
+ }
+ }
+
+ class RadioEnumBinding : ConfigurationGuiBinding where T : struct
+ {
+ KeyValuePair[] values;
+
+ internal RadioEnumBinding(KeyValuePair[] values)
+ {
+ this.values = values;
+ }
+
+ public override void Load()
+ {
+ T val = Get(values[0].Key);
+ int i;
+ for (i = 0; i < values.Length; i++) {
+ if (val.Equals(values[i].Key))
+ break;
+ }
+ if (i == values.Length) i = 0;
+ values[i].Value.Checked = true;
+ }
+
+ public override bool Save()
+ {
+ foreach (KeyValuePair pair in values) {
+ if (pair.Value.Checked) {
+ Set(pair.Key);
+ break;
+ }
+ }
+ return true;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/src/Main/Base/Project/Src/Project/IProject.cs b/src/Main/Base/Project/Src/Project/IProject.cs
index a9e226168e..42dd47d5ad 100644
--- a/src/Main/Base/Project/Src/Project/IProject.cs
+++ b/src/Main/Base/Project/Src/Project/IProject.cs
@@ -6,6 +6,7 @@
//
using System;
+using System.ComponentModel;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using ICSharpCode.Core;
@@ -13,9 +14,13 @@ using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Project
{
public enum OutputType {
- Exe,
- WinExe,
+ [Description("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Exe}")]
+ Exe,
+ [Description("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.WinExe}")]
+ WinExe,
+ [Description("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Library}")]
Library,
+ [Description("${res:Dialog.Options.PrjOptions.Configuration.CompileTarget.Module}")]
Module
};
@@ -82,20 +87,13 @@ namespace ICSharpCode.SharpDevelop.Project
set;
}
- PropertyGroup GetConfiguration(string configurationName);
- PropertyGroup GetConfiguration(string configurationName, string platform);
-
- PropertyGroup GetUserConfiguration(string configurationName);
- PropertyGroup GetUserConfiguration(string configurationName, string platform);
-
-
bool CanCompile(string fileName);
void Save();
void Save(string fileName);
///
- /// Returns true, if a specific file (given by it's name)
+ /// Returns true, if a specific file (given by it's name)
/// is inside this project.
///
bool IsFileInProject(string fileName);
diff --git a/src/Main/Base/Project/Src/Project/MSBuildEnums.cs b/src/Main/Base/Project/Src/Project/MSBuildEnums.cs
new file mode 100644
index 0000000000..27fba2eb5c
--- /dev/null
+++ b/src/Main/Base/Project/Src/Project/MSBuildEnums.cs
@@ -0,0 +1,60 @@
+//
+// 2002-2005 AlphaSierraPapa
+// GNU General Public License
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using ICSharpCode.Core;
+
+namespace ICSharpCode.SharpDevelop.Project
+{
+ public enum RunPostBuildEvent {
+ [Description("${res:Dialog.ProjectOptions.RunPostBuildEvent.Always}")]
+ Always,
+ [Description("${res:Dialog.ProjectOptions.RunPostBuildEvent.OnSuccessfulBuild}")]
+ OnSuccessfulBuild,
+ [Description("${res:Dialog.ProjectOptions.RunPostBuildEvent.OnOutputUpdated}")]
+ OnOutputUpdated
+ }
+
+ public enum DebugSymbolType {
+ None,
+ Full,
+ PdbOnly
+ }
+
+ public enum StartAction {
+ Project,
+ Program,
+ StartURL
+ }
+
+ ///
+ /// Specifies the possible locations where a property can be stored.
+ ///
+ public enum PropertyStorageLocation
+ {
+ Unchanged,
+ ///
+ /// Store the property globally for all configurations in the project file.
+ ///
+ BaseConfiguration,
+ ///
+ /// Store the property in the configuration-specific section(s) in the project file.
+ ///
+ SpecificConfiguration,
+ /////
+ ///// Store the property globally for all configurations in the user file.
+ /////
+ //UserBaseConfiguration,
+ ///
+ /// Store the property in the configuration-specific section(s) in the user file.
+ ///
+ UserSpecificConfiguration,
+ }
+}
diff --git a/src/Main/Base/Project/Src/Project/MSBuildProject.cs b/src/Main/Base/Project/Src/Project/MSBuildProject.cs
index 769d8ddda8..d01e0d353e 100644
--- a/src/Main/Base/Project/Src/Project/MSBuildProject.cs
+++ b/src/Main/Base/Project/Src/Project/MSBuildProject.cs
@@ -253,19 +253,33 @@ namespace ICSharpCode.SharpDevelop.Project
}
#endregion
+ #region Start / Run
public override bool IsStartable {
get {
- return OutputType == OutputType.Exe || OutputType == OutputType.WinExe;
+ switch (this.StartAction) {
+ case StartAction.Project:
+ return OutputType == OutputType.Exe || OutputType == OutputType.WinExe;
+ case StartAction.Program:
+ return this.StartProgram.Length > 0;
+ case StartAction.StartURL:
+ return this.StartUrl.Length > 0;
+ }
+ return false;
}
}
- public override void Start(bool withDebugging)
+ void Start(string program, bool withDebugging)
{
ProcessStartInfo psi = new ProcessStartInfo();
- psi.FileName = OutputAssemblyFullPath;
- psi.WorkingDirectory = Path.GetDirectoryName(OutputAssemblyFullPath);
- psi.Arguments = "";
-
+ psi.FileName = Path.Combine(Directory, program);
+ string workingDir = this.StartWorkingDirectory;
+ if (workingDir.Length == 0) {
+ psi.WorkingDirectory = Path.GetDirectoryName(psi.FileName);
+ } else {
+ psi.WorkingDirectory = Path.Combine(Directory, workingDir);
+ }
+ psi.Arguments = this.StartArguments;
+
if (withDebugging) {
DebuggerService.CurrentDebugger.Start(psi);
} else {
@@ -273,6 +287,69 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
+ public override void Start(bool withDebugging)
+ {
+ switch (this.StartAction) {
+ case StartAction.Project:
+ Start(this.OutputAssemblyFullPath, withDebugging);
+ break;
+ case StartAction.Program:
+ Start(this.StartProgram, withDebugging);
+ break;
+ case StartAction.StartURL:
+ FileService.OpenFile("browser://" + this.StartUrl);
+ break;
+ default:
+ throw new System.ComponentModel.InvalidEnumArgumentException("StartAction", (int)this.StartAction, typeof(StartAction));
+ }
+ }
+
+ public string StartProgram {
+ get {
+ return GetProperty("StartProgram");
+ }
+ set {
+ SetProperty("StartProgram", value);
+ }
+ }
+
+ public string StartUrl {
+ get {
+ return GetProperty("StartURL");
+ }
+ set {
+ SetProperty("StartURL", value);
+ }
+ }
+
+ public StartAction StartAction {
+ get {
+ return GetProperty("StartAction", StartAction.Project);
+ }
+ set {
+ SetProperty("StartAction", value);
+ }
+ }
+
+ public string StartArguments {
+ get {
+ return GetProperty("StartArguments");
+ }
+ set {
+ SetProperty("StartArguments", value);
+ }
+ }
+
+ public string StartWorkingDirectory {
+ get {
+ return GetProperty("StartWorkingDirectory");
+ }
+ set {
+ SetProperty("StartWorkingDirectory", value);
+ }
+ }
+ #endregion
+
// static void BeforeBuild()
// {
// TaskService.NotifyTaskChange();
diff --git a/src/Main/Base/Project/Src/Project/PropertyGroup.cs b/src/Main/Base/Project/Src/Project/PropertyGroup.cs
index c3e0ba4a4a..680f8e244d 100644
--- a/src/Main/Base/Project/Src/Project/PropertyGroup.cs
+++ b/src/Main/Base/Project/Src/Project/PropertyGroup.cs
@@ -18,6 +18,7 @@ namespace ICSharpCode.SharpDevelop.Project
///
public class PropertyGroup
{
+ // TODO: Isn't MSBuild case-insensitive ???
Dictionary isGuardedProperty = new Dictionary();
Dictionary properties = new Dictionary();
@@ -30,14 +31,14 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
- public T Get(string property, T defaultValue)
+ public T Get(string property, T defaultValue)
{
if (!properties.ContainsKey(property)) {
return defaultValue;
}
TypeConverter c = TypeDescriptor.GetConverter(typeof(T));
try {
- return (T)c.ConvertFromInvariantString(properties[property]);
+ return (T)c.ConvertFromInvariantString(properties[property]);
} catch (FormatException ex) {
ICSharpCode.Core.LoggingService.Warn("Cannot get property " + property, ex);
return defaultValue;
@@ -46,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Project
public void Set(string property, T defaultValue, T value)
{
- if (value == null || defaultValue.Equals(value)) {
+ if (value == null || value.Equals(defaultValue)) {
properties.Remove(property);
return;
}
@@ -66,7 +67,7 @@ namespace ICSharpCode.SharpDevelop.Project
public bool IsSet(string property)
{
return properties.ContainsKey(property);
- }
+ }
public bool Remove(string property)
{
diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources
index 329cce2f54..36102d5c4d 100644
Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ