/// <summary> /// Load circuit templates stored in an external file</summary> /// <param name="uri">Document URI, or null to present file open dialog to user</param> /// <returns>Returns the file path used to load the external templates. /// An empty string indicates no templates were loaded</returns> protected override ImportedContent LoadExternalTemplateLibrary(Uri uri) { string filePath = string.Empty; if (uri == null) { var dlg = new OpenFileDialog(); dlg.Filter = "Script Template File (*.vscript)|*.vscript".Localize(); dlg.CheckFileExists = true; if (dlg.ShowDialog() == DialogResult.OK) { uri = new Uri(dlg.FileName, UriKind.RelativeOrAbsolute); filePath = dlg.FileName; } } else { filePath = uri.LocalPath; } if (File.Exists(filePath)) { if (TemplatingContext.ValidateNewFolderUri(uri)) { // read existing document using standard XML reader using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var reader = new ScriptReader(m_nodeDefinitionManager.NodeTypeManager); var root = reader.Read(stream, uri); var toFolder = CreateTemplateFolder(); reader.ImportTemplates(toFolder.DomNode, root, uri); return(new ImportedContent(toFolder.DomNode, uri)); } } } return(new ImportedContent(null, null)); }