private void Refresh(IEnumerable <string> files = null) { //Because refreshing removes all components, we need to store the current selection, // so we can correctly reset it once the files are imported from the repository. var selection = _project.VBE.ActiveCodePane.GetSelection(); string name = null; if (selection.QualifiedName.Component != null) { name = selection.QualifiedName.Component.Name; } if (files == null) { _project.RemoveAllComponents(); _project.ImportSourceFiles(_repo.Info.WorkingDirectory); } else { foreach (var file in files) { if (File.Exists(file)) { string component = Path.GetFileNameWithoutExtension(file); if (_project.RemoveComponent(component)) { _project.ImportSourceFile(file); } } } } _project.VBE.SetSelection(selection.QualifiedName.Project, selection.Selection, name); }
private void ReloadVBComponent(VBProject project, string name, string filePath) { try { project.RemoveComponent(name); project.ImportSourceFile(filePath); } catch (Exception ex) { ExceptionMessageBox.Show(new IntPtr(_vbe.MainWindow.HWnd), ex); } }
/// <summary> /// Imports all source code files from target directory into project. /// </summary> /// <remarks> /// Only files with extensions "cls", "bas, "frm" are imported. /// It is the callers responsibility to remove any existing components prior to importing. /// </remarks> /// <param name="project"></param> /// <param name="path">Directory path containing the source files.</param> public static void ImportSourceFiles(this VBProject project, string path) { var dirInfo = new DirectoryInfo(path); var files = dirInfo.EnumerateFiles() .Where(f => f.Extension == VBComponentExtensions.StandardExtension || f.Extension == VBComponentExtensions.ClassExtesnion || f.Extension == VBComponentExtensions.DocClassExtension || f.Extension == VBComponentExtensions.FormExtension ); files.ToList().ForEach(file => project.ImportSourceFile(file.FullName)); }