public override FileTemplateResult Create(FileTemplateOptions options)
		{
			FileTemplateResult result = new FileTemplateResult(options);
			
			StandardHeader.SetHeaders();
			StringParserPropertyContainer.FileCreation["StandardNamespace"] = options.Namespace;
			StringParserPropertyContainer.FileCreation["FullName"]                 = options.FileName;
			StringParserPropertyContainer.FileCreation["FileName"]                 = Path.GetFileName(options.FileName);
			StringParserPropertyContainer.FileCreation["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(options.FileName);
			StringParserPropertyContainer.FileCreation["Extension"]                = Path.GetExtension(options.FileName);
			StringParserPropertyContainer.FileCreation["Path"]                     = Path.GetDirectoryName(options.FileName);
			
			StringParserPropertyContainer.FileCreation["ClassName"] = options.ClassName;
			
			// when adding a file to a project (but not when creating a standalone file while a project is open):
			var project = options.Project;
			if (project != null && !options.IsUntitled) {
				// add required assembly references to the project
				foreach (ReferenceProjectItem reference in RequiredAssemblyReferences) {
					IEnumerable<ProjectItem> refs = project.GetItemsOfType(ItemType.Reference);
					if (!refs.Any(projItem => string.Equals(projItem.Include, reference.Include, StringComparison.OrdinalIgnoreCase))) {
						ReferenceProjectItem projItem = (ReferenceProjectItem)reference.CloneFor(project);
						ProjectService.AddProjectItem(project, projItem);
						ProjectBrowserPad.RefreshViewAsync();
					}
				}
			}
			
			foreach (FileDescriptionTemplate newfile in FileDescriptionTemplates) {
				if (!IsFilenameAvailable(StringParser.Parse(newfile.Name))) {
					MessageService.ShowError(string.Format("Filename {0} is in use.\nChoose another one", StringParser.Parse(newfile.Name))); // TODO : translate
					return null;
				}
			}
			ScriptRunner scriptRunner = new ScriptRunner();
			foreach (FileDescriptionTemplate newFile in FileDescriptionTemplates) {
				FileOperationResult opresult = FileUtility.ObservedSave(
					() => {
						string resultFile;
						if (!String.IsNullOrEmpty(newFile.BinaryFileName)) {
							resultFile = SaveFile(newFile, null, newFile.BinaryFileName, options);
						} else {
							resultFile = SaveFile(newFile, scriptRunner.CompileScript(this, newFile), null, options);
						}
						if (resultFile != null) {
							result.NewFiles.Add(FileName.Create(resultFile));
						}
					}, FileName.Create(StringParser.Parse(newFile.Name))
				);
				if (opresult != FileOperationResult.OK)
					return null;
			}
			
			if (project != null) {
				project.Save();
			}
			
			// raise FileCreated event for the new files.
			foreach (var fileName in result.NewFiles) {
				FileService.FireFileCreated(fileName, false);
			}
			return result;
		}
 public virtual void RunActions(FileTemplateResult result)
 {
 }
		public override void RunActions(FileTemplateResult result)
		{
			if (actions != null)
				actions(result);
		}
		void OpenEvent(object sender, EventArgs e)
		{
			if (categoryTreeView.SelectedNode != null) {
				PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
				PropertyService.Set("Dialogs.NewFileDialog.CategoryViewState", TreeViewHelper.GetViewStateString(categoryTreeView));
				PropertyService.Set("Dialogs.NewFileDialog.LastSelectedCategory", TreeViewHelper.GetPath(categoryTreeView.SelectedNode));
			}
			if (templateListView.SelectedItems.Count == 1) {
				TemplateItem item = (TemplateItem)templateListView.SelectedItems[0];
				
				PropertyService.Set("Dialogs.NewFileDialog.LastSelectedTemplate", item.Template.Name);
				
				string fileName;
				string standardNamespace = "DefaultNamespace";
				if (allowUntitledFiles) {
					fileName = GenerateCurrentFileName();
				} else {
					fileName = ControlDictionary["fileNameTextBox"].Text.Trim();
					if (!FileUtility.IsValidPath(fileName)
					    || fileName.IndexOf(Path.AltDirectorySeparatorChar) >= 0
					    || fileName.IndexOf(Path.DirectorySeparatorChar) >= 0)
					{
						MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new StringTagPair("FileName", fileName)));
						return;
					}
					if (Path.GetExtension(fileName).Length == 0) {
						fileName += Path.GetExtension(item.Template.SuggestFileName(null));
					}
					fileName = Path.Combine(basePath, fileName);
					fileName = FileUtility.NormalizePath(fileName);
					if (project != null) {
						standardNamespace = CustomToolsService.GetDefaultNamespace(project, fileName);
					}
				}
				
				options = new FileTemplateOptions();
				options.ClassName = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false);
				options.FileName = FileName.Create(fileName);
				options.IsUntitled = allowUntitledFiles;
				options.Namespace = standardNamespace;
				options.CustomizationObject = localizedTypeDescriptor;
				options.Project = project;
				
				result = SelectedTemplate.Create(options);
				DialogResult = DialogResult.OK;
				if (result != null)
					SelectedTemplate.RunActions(result);
			}
		}