diff --git a/data/templates/file/CSharp/CSharp.Forms.Form.xft b/data/templates/file/CSharp/CSharp.Forms.Form.xft
index 2700fd6777..d9e763dc93 100644
--- a/data/templates/file/CSharp/CSharp.Forms.Form.xft
+++ b/data/templates/file/CSharp/CSharp.Forms.Form.xft
@@ -33,7 +33,7 @@ namespace ${StandardNamespace}
///
/// Description of ${ClassName}.
///
- public class ${ClassName} : System.Windows.Forms.Form
+ public partial class ${ClassName}
{
public ${ClassName}()
{
@@ -46,8 +46,33 @@ namespace ${StandardNamespace}
// TODO: Add constructor code after the InitializeComponent() call.
//
}
+ }
+}
+]]>
+
+ /// Designer variable used to keep track of non-visual components.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Disposes resources used by the form.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) {
+ if (components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Forms Designer generated code
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
@@ -59,11 +84,9 @@ namespace ${StandardNamespace}
// ${ClassName}
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(292, 266);
this.Text = "${ClassName}";
this.Name = "${ClassName}";
}
- #endregion
}
}
]]>
diff --git a/data/templates/file/CSharp/CSharp.Forms.UserControl.xft b/data/templates/file/CSharp/CSharp.Forms.UserControl.xft
index 439628ea8e..b605b1a367 100644
--- a/data/templates/file/CSharp/CSharp.Forms.UserControl.xft
+++ b/data/templates/file/CSharp/CSharp.Forms.UserControl.xft
@@ -34,7 +34,7 @@ namespace ${StandardNamespace}
///
/// Description of ${ClassName}.
///
- public class ${ClassName} : System.Windows.Forms.UserControl
+ public partial class ${ClassName}
{
public ${ClassName}()
{
@@ -47,8 +47,33 @@ namespace ${StandardNamespace}
// TODO: Add constructor code after the InitializeComponent() call.
//
}
+ }
+}
+]]>
+
+ /// Designer variable used to keep track of non-visual components.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Disposes resources used by the form.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) {
+ if (components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Forms Designer generated code
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
@@ -59,10 +84,9 @@ namespace ${StandardNamespace}
//
// ${ClassName}
//
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "${ClassName}";
- this.Size = new System.Drawing.Size(292, 266);
}
- #endregion
}
}
]]>
diff --git a/data/templates/project/CSharp/ControlLibrary.xpt b/data/templates/project/CSharp/ControlLibrary.xpt
index 612e958cea..3397c3f022 100644
--- a/data/templates/project/CSharp/ControlLibrary.xpt
+++ b/data/templates/project/CSharp/ControlLibrary.xpt
@@ -47,7 +47,7 @@ namespace ${StandardNamespace}
///
/// Description of UserControl1.
///
- public class UserControl1 : System.Windows.Forms.UserControl
+ public partial class UserControl1
{
public UserControl1()
{
@@ -60,8 +60,32 @@ namespace ${StandardNamespace}
// TODO: Add constructor code after the InitializeComponent() call.
//
}
+ }
+}]]>
+
+ /// Designer variable used to keep track of non-visual components.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Disposes resources used by the form.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) {
+ if (components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Forms Designer generated code
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
@@ -72,12 +96,12 @@ namespace ${StandardNamespace}
//
// UserControl1
//
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "UserControl1";
- this.Size = new System.Drawing.Size(292, 266);
}
- #endregion
}
-}]]>
+}
+]]>
-
/// Description of MainForm.
///
- public class MainForm : System.Windows.Forms.Form
+ public partial class MainForm
{
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new MainForm());
+ }
+
public MainForm()
{
//
@@ -59,16 +68,33 @@ namespace ${StandardNamespace}
// TODO: Add constructor code after the InitializeComponent() call.
//
}
+ }
+}
+]]>
+
+ /// Designer variable used to keep track of non-visual components.
+ ///
+ private System.ComponentModel.IContainer components = null;
- [STAThread]
- public static void Main(string[] args)
+ ///
+ /// Disposes resources used by the form.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
{
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainForm());
+ if (disposing) {
+ if (components != null) {
+ components.Dispose();
+ }
+ }
+ base.Dispose(disposing);
}
- #region Windows Forms Designer generated code
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
@@ -77,17 +103,16 @@ namespace ${StandardNamespace}
private void InitializeComponent()
{
//
- // Form1
+ // MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(292, 266);
- this.Text = "MainForm";
+ this.Text = "${ProjectName}";
this.Name = "MainForm";
}
- #endregion
}
-}]]>
-
+}
+]]>
+
invisibleNodes = new List();
+ protected List invisibleNodes = new List();
public virtual void UpdateVisibility()
{
for (int i = 0; i < invisibleNodes.Count;) {
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
index 93c946a877..f32dd93cab 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
@@ -32,16 +32,16 @@ namespace ICSharpCode.SharpDevelop.Gui
///
/// This class is for creating a new "empty" file
///
- public class NewFileDialog : BaseSharpDevelopForm, INewFileCreator
+ public class NewFileDialog : BaseSharpDevelopForm
{
ArrayList alltemplates = new ArrayList();
ArrayList categories = new ArrayList();
Hashtable icons = new Hashtable();
bool allowUntitledFiles;
string basePath;
- List createdFiles = new List();
+ List> createdFiles = new List>();
- public List CreatedFiles {
+ public List> CreatedFiles {
get {
return createdFiles;
}
@@ -176,8 +176,8 @@ namespace ICSharpCode.SharpDevelop.Gui
}
if (template.NewFileDialogVisible == true) {
Category cat = GetCategory(StringParser.Parse(titem.Template.Category), StringParser.Parse(titem.Template.Subcategory));
- cat.Templates.Add(titem);
-
+ cat.Templates.Add(titem);
+
if (cat.Selected == false && template.WizardPath == null) {
cat.Selected = true;
}
@@ -235,7 +235,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (localizedTypeDescriptor == null) {
localizedTypeDescriptor = new LocalizedTypeDescriptor();
}
-
+
if (!Controls.Contains(propertyGrid)) {
this.SuspendLayout();
propertyGrid.Location = new Point(Width - GridMargin, GridMargin);
@@ -367,16 +367,21 @@ namespace ICSharpCode.SharpDevelop.Gui
return true;
}
- public void SaveFile(string filename, string content, string languageName, bool showFile)
+ public void SaveFile(FileDescriptionTemplate newfile, string content)
{
- string parsedFileName = StringParser.Parse(filename);
- IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(languageName), StringParser.Parse(content));
- if (window != null) {
- createdFiles.Add(parsedFileName);
+ string parsedFileName = StringParser.Parse(newfile.Name);
+ if (newfile.IsDependentFile && Path.IsPathRooted(parsedFileName)) {
+ File.WriteAllText(parsedFileName, StringParser.Parse(content), ParserService.DefaultFileEncoding);
+ } else {
+ IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(newfile.Language), StringParser.Parse(content));
+ if (window == null) {
+ return;
+ }
if (Path.IsPathRooted(parsedFileName)) {
window.ViewContent.Save(parsedFileName);
}
}
+ createdFiles.Add(new KeyValuePair(parsedFileName, newfile.CreateMSBuildProperties()));
}
string GenerateValidClassName(string className)
@@ -460,7 +465,7 @@ namespace ICSharpCode.SharpDevelop.Gui
ScriptRunner scriptRunner = new ScriptRunner();
foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) {
- SaveFile(newfile.Name, scriptRunner.CompileScript(item.Template, newfile), newfile.Language, true);
+ SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile));
}
DialogResult = DialogResult.OK;
}
@@ -544,7 +549,7 @@ namespace ICSharpCode.SharpDevelop.Gui
imglist.Images.Add(IconService.GetBitmap("Icons.16x16.OpenFolderBitmap"));
imglist.Images.Add(IconService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
((TreeView)ControlDictionary["categoryTreeView"]).ImageList = imglist;
-
+
((TreeView)ControlDictionary["categoryTreeView"]).AfterSelect += new TreeViewEventHandler(CategoryChange);
((TreeView)ControlDictionary["categoryTreeView"]).BeforeSelect += new TreeViewCancelEventHandler(OnBeforeExpand);
((TreeView)ControlDictionary["categoryTreeView"]).BeforeExpand += new TreeViewCancelEventHandler(OnBeforeExpand);
diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs
index 9062c3ab7a..975a16030e 100644
--- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs
+++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs
@@ -16,6 +16,7 @@ using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
+using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
@@ -181,15 +182,14 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public class AddNewItemsToProject : AbstractMenuCommand
{
- FileNode CreateNewFile(DirectoryNode upper, string fileName)
+ FileProjectItem CreateNewFile(DirectoryNode upper, string fileName)
{
upper.Expanding();
FileNode fileNode = new FileNode(fileName, FileNodeStatus.InProject);
fileNode.AddTo(upper);
fileNode.EnsureVisible();
- IncludeFileInProject.IncludeFileNode(fileNode);
- return fileNode;
+ return IncludeFileInProject.IncludeFileNode(fileNode);
}
public override void Run()
@@ -207,8 +207,17 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
using (NewFileDialog nfd = new NewFileDialog(node.Directory)) {
if (nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
- foreach (string createdFile in nfd.CreatedFiles) {
- CreateNewFile(node, createdFile);
+ bool additionalProperties = false;
+ foreach (KeyValuePair createdFile in nfd.CreatedFiles) {
+ FileProjectItem item = CreateNewFile(node, createdFile.Key);
+ if (createdFile.Value.PropertyCount > 0) {
+ additionalProperties = true;
+ item.Properties.Merge(createdFile.Value);
+ }
+ }
+ if (additionalProperties) {
+ node.Project.Save();
+ node.RecreateSubNodes();
}
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs
index 4f7422c442..c9b591c9ba 100644
--- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs
+++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs
@@ -91,7 +91,7 @@ namespace ICSharpCode.SharpDevelop.Project
} else {
node = new DirectoryNode(item.FileName.Trim('\\', '/'), status);
node.ProjectItem = item;
- }
+ }
return node;
}
}
@@ -281,8 +281,9 @@ namespace ICSharpCode.SharpDevelop.Project
return false;
}
- void RecreateSubNodes()
+ public void RecreateSubNodes()
{
+ invisibleNodes.Clear();
if (autoClearNodes) {
Nodes.Clear();
} else {
@@ -296,6 +297,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
Initialize();
+ UpdateVisibility();
}
protected override void Initialize()
diff --git a/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs b/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs
index 8e41459c37..899d6dfcf2 100644
--- a/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs
+++ b/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs
@@ -10,6 +10,8 @@ using System.IO;
using System.Xml;
using System.Collections;
using System.Diagnostics;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Internal.Templates
{
@@ -22,7 +24,13 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
string copyToOutputDirectory;
string dependentUpon;
string subType;
-
+
+ public bool IsDependentFile {
+ get {
+ return !string.IsNullOrEmpty(dependentUpon);
+ }
+ }
+
public FileDescriptionTemplate(XmlElement xml)
{
name = xml.GetAttribute("name");
@@ -34,6 +42,24 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
content = xml.InnerText;
}
+ ///
+ /// Sets MSBuild properties.
+ ///
+ public PropertyGroup CreateMSBuildProperties()
+ {
+ PropertyGroup pg = new PropertyGroup();
+ if (!string.IsNullOrEmpty(copyToOutputDirectory)) {
+ pg.Set("CopyToOutputDirectory", StringParser.Parse(copyToOutputDirectory));
+ }
+ if (!string.IsNullOrEmpty(dependentUpon)) {
+ pg.Set("DependentUpon", StringParser.Parse(dependentUpon));
+ }
+ if (!string.IsNullOrEmpty(subType)) {
+ pg.Set("SubType", StringParser.Parse(subType));
+ }
+ return pg;
+ }
+
public FileDescriptionTemplate(string name, string language, string content)
{
this.name = name;
@@ -67,32 +93,5 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
buildAction = value;
}
}
-
- public string CopyToOutputDirectory {
- get {
- return copyToOutputDirectory ?? "";
- }
- set {
- copyToOutputDirectory = value;
- }
- }
-
- public string DependentUpon {
- get {
- return dependentUpon ?? "";
- }
- set {
- dependentUpon = value;
- }
- }
-
- public string SubType {
- get {
- return subType ?? "";
- }
- set {
- subType = value;
- }
- }
}
}
diff --git a/src/Main/Base/Project/Src/Internal/Templates/File/INewFileCreator.cs b/src/Main/Base/Project/Src/Internal/Templates/File/INewFileCreator.cs
index e7ac353dee..229f99460a 100644
--- a/src/Main/Base/Project/Src/Internal/Templates/File/INewFileCreator.cs
+++ b/src/Main/Base/Project/Src/Internal/Templates/File/INewFileCreator.cs
@@ -13,10 +13,5 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Internal.Templates
{
- public interface INewFileCreator
- {
- bool IsFilenameAvailable(string fileName);
-
- void SaveFile(string filename, string content, string languageName, bool showFile);
- }
+
}
diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
index ba5b6c2d05..e4aedfccb8 100644
--- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
+++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
@@ -157,6 +157,8 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
string fileName = Path.Combine(projectCreateInformation.ProjectBasePath, StringParser.Parse(file.Name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} }));
FileProjectItem projectFile = new FileProjectItem(project, ItemType.Compile);
+ projectFile.Properties.Merge(file.CreateMSBuildProperties());
+
if (file.BuildAction.Length > 0) {
projectFile.BuildAction = (FileProjectItem.FileBuildAction)Enum.Parse(typeof(FileProjectItem.FileBuildAction), file.BuildAction);
} else {
@@ -164,18 +166,8 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
projectFile.BuildAction = FileProjectItem.FileBuildAction.None;
}
}
- if (file.CopyToOutputDirectory.Length > 0) {
- projectFile.CopyToOutputDirectory = (CopyToOutputDirectory)Enum.Parse(typeof(CopyToOutputDirectory), file.CopyToOutputDirectory);
- }
- if (file.DependentUpon.Length > 0) {
- projectFile.DependentUpon = file.DependentUpon;
- }
- if (file.SubType.Length > 0) {
- projectFile.SubType = file.SubType;
- }
projectFile.Include = FileUtility.GetRelativePath(project.Directory, fileName);
-
while (projectFile.Include.Length > 1 && projectFile.Include.StartsWith(".")) {
projectFile.Include = projectFile.Include.Substring(2);
}
diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
index df848c3aad..dd4d6d6940 100644
--- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
+++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
@@ -514,11 +514,17 @@ namespace ICSharpCode.Core
// return res;
// load file
- Properties textEditorProperties = PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties());
- Encoding tmp = Encoding.GetEncoding(textEditorProperties.Get("Encoding", 1252));
+ Encoding tmp = DefaultFileEncoding;
return ICSharpCode.TextEditor.Util.FileReader.ReadFileContent(fileName, ref tmp, tmp);
}
+ public static Encoding DefaultFileEncoding {
+ get {
+ Properties textEditorProperties = PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties());
+ return Encoding.GetEncoding(textEditorProperties.Get("Encoding", 1252));
+ }
+ }
+
public static ParseInformation GetParseInformation(string fileName)
{
if (fileName == null || fileName.Length == 0) {
diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs
index a62cb4606c..d8b20670b9 100644
--- a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs
+++ b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs
@@ -74,8 +74,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (projectItems.Length > 0) {
nextItem = projectItems[0];
}
- Properties textEditorProperties = PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties());
- defaultEncoding = Encoding.GetEncoding(textEditorProperties.Get("Encoding", 1252));
+ defaultEncoding = ParserService.DefaultFileEncoding;
}
string GetParseableFileContent(IProject project, string fileName)