///-------------------------------------------------------------------------------- /// <summary>This method loads templates from a directory into the view model.</summary> /// /// <param name="directory">The directory to load.</param> /// <param name="refresh">Flag whether to refresh view.</param> ///-------------------------------------------------------------------------------- public void LoadTemplateDirectory(string directory, bool refresh = true) { if (!String.IsNullOrEmpty(directory) && Directory.Exists(directory)) { foreach (string file in Directory.GetFiles(directory, "*.mpt")) { CodeTemplate template = new CodeTemplate(); template.TemplateID = Guid.NewGuid(); template.Solution = Solution; template.FilePath = file; template.LoadTemplateFileData(); Solution.CodeTemplates[template.TemplateKey] = template; AddTemplate(new CodeTemplateViewModel(template, Solution), refresh); } foreach (string subDirectory in Directory.GetDirectories(directory)) { LoadTemplateDirectory(subDirectory, refresh); } } if (refresh == true) { Refresh(true); } }