/// <summary>
        ///     This function is the callback used to execute the command when the menu item is clicked.
        ///     See the constructor to see how the menu item is associated with this function using
        ///     OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            IVsSolution solution = _package.GetService <IVsSolution, SVsSolution>();

            // As the "Edit Links" command is added on the Project menu even when no solution is opened, it must
            // be validated that a solution exists (in case it doesn't, GetSolutionInfo() returns 3 nulled strings).
            ErrorHandler.ThrowOnFailure(solution.GetSolutionInfo(out string s1, out string s2, out string s3));
            if (s1 != null && s2 != null && s3 != null)
            {
                try
                {
                    IVsUIShell uiShell = (IVsUIShell)ServiceProvider.GetService(typeof(SVsUIShell));

                    ErrorHandler.ThrowOnFailure(uiShell.GetDialogOwnerHwnd(out IntPtr parentHwnd));
                    IProjectLinkTracker linker = _package.GetService <IProjectLinkTracker, ISProjectLinkTracker>();
                    if (linker == null)
                    {
                        throw new NullReferenceException();
                    }
                    LinksEditorView linksEditor = new LinksEditorView(linker, ServiceProvider);
                    linksEditor.ShowDialog(new WindowHandleAdapter(parentHwnd));
                }
                catch (Exception ex)
                {
                    _package.ShowInformationalMessageBox(Resources.ProjectLinkerCaption, ex.Message, true);
                }
            }
        }
        public LinksEditorPresenter(ILinksEditorView view, IProjectLinkTracker projectLinkTracker, IHierarchyNodeFactory hierarchyNodeFactory)
        {
            this.view = view;
            this.view.ProjectsUnlinking += (s, e) => UnlinkProjects(this.view.SelectedProjectLinkItems);
            this.projectLinkTracker = projectLinkTracker;
            this.hierarchyNodeFactory = hierarchyNodeFactory;

            SetUpProjectLinks();
        }
Beispiel #3
0
        public LinksEditorPresenter(ILinksEditorView view, IProjectLinkTracker projectLinkTracker, IHierarchyNodeFactory hierarchyNodeFactory)
        {
            _view = view;
            _view.ProjectsUnlinking += (s, e) => UnlinkProjects(_view.SelectedProjectLinkItems);
            _projectLinkTracker      = projectLinkTracker;
            _hierarchyNodeFactory    = hierarchyNodeFactory;

            SetUpProjectLinks();
        }
        /// <summary>
        ///     This function is the callback used to execute the command when the menu item is clicked.
        ///     See the constructor to see how the menu item is associated with this function using
        ///     OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            IVsSolution solution = _package.GetService <IVsSolution, SVsSolution>();

            // As the "Edit Links" command is added on the Project menu even when no solution is opened, it must
            // be validated that a solution exists (in case it doesn't, GetSolutionInfo() returns 3 nulled strings).
            ErrorHandler.ThrowOnFailure(solution.GetSolutionInfo(out string s1, out string s2, out string s3));
            if (s1 != null && s2 != null && s3 != null)
            {
                IVsUIShell uiShell = _package.GetService <IVsUIShell, SVsUIShell>();

                ErrorHandler.ThrowOnFailure(uiShell.GetDialogOwnerHwnd(out IntPtr parentHwnd));

                HierarchyNodeFactory hierarchyNodeFactory = new HierarchyNodeFactory(ServiceProvider);
                IHierarchyNode       targetProject        = hierarchyNodeFactory.GetSelectedProject();
                SolutionPickerView   solutionPicker       = new SolutionPickerView(ServiceProvider, targetProject);

                DialogResult result = solutionPicker.ShowDialog(new WindowHandleAdapter(parentHwnd));

                if (result == DialogResult.OK)
                {
                    try
                    {
                        IHierarchyNode sourceProject = solutionPicker.SelectedNode;

                        IProjectLinkTracker linker = _package.GetService <IProjectLinkTracker, ISProjectLinkTracker>();

                        // todo
                        linker.AddProjectLink(sourceProject.ProjectGuid, targetProject.ProjectGuid);
                        if (solutionPicker.CopyProjectItemsByDefault)
                        {
                            linker.LinkAllProjectItems(sourceProject.ProjectGuid, targetProject.ProjectGuid);
                        }
                        _package.ShowInformationalMessageBox(
                            Resources.ProjectLinkerCaption,
                            Resources.ProjectsSuccessfullyLinked,
                            false);
                    }
                    catch (ProjectLinkerException ex)
                    {
                        _package.ShowInformationalMessageBox(Resources.ProjectLinkerCaption, ex.Message, true);
                    }
                }
            }
        }
Beispiel #5
0
 public LinksEditorView(IProjectLinkTracker projectLinkTracker, IServiceProvider provider)
 {
     _projectLinkTracker = projectLinkTracker;
     _provider           = provider;
     InitializeComponent();
 }
 public LinksEditorView(IProjectLinkTracker projectLinkTracker, IServiceProvider provider)
 {
     this.projectLinkTracker = projectLinkTracker;
     this.provider = provider;
     InitializeComponent();
 }