コード例 #1
0
        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);
        }
コード例 #2
0
 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);
     }
 }