2017-08-09 77 views
0

我有一个当前正在工作的基于窗口的工具。我需要在Visual Studio中将此工具添加为插件/扩展。所以如果用户安装了visual studio,那么这个工具可以从visual studio菜单打开。当从视觉工作室打开时,它应该作为模型对话框在Visual Studio 中打开,而不是一个单独的应用程序(因为我们用process.start打开)。请为相同的建议。 谢谢。创建Visual Studio插件以在Visual Studio中启动窗体应用程序(不是独立的)

+0

所以,我说的对,使用工具/外部工具是不适合你的选择,正确吗?它应该集成到VS. – Fildor

+0

只需通过Google搜索,我发现:https://msdn.microsoft.com/de-de/library/dd885119(v=vs.110).aspx,https://msdn.microsoft.com/en-us/library/ bb166030.aspx,只是为了命名顶级命中。 – Fildor

+0

是的,它只需要在VS中集成,但不能作为工具/外部工具选项。我需要使用插件/扩展来打开我的winform应用程序,用户不需要指定应用程序打开的路径。 – Gerry

回答

0

根据你的描述,我认为你可以使用自定义的toolwindow来实现它。有关更多信息,请参见: https://msdn.microsoft.com/en-us/library/cc138567.aspx

从Visual Studio 2010中,工具窗口本身是基于WPF技术的开始,虽然他们仍然提供的WinForms组件的托管向后兼容性。

如果您使用Winform控件,请参考以下代码。

namespace TWToolbar 
{ 
    using System; 
    using System.Runtime.InteropServices; 
    using Microsoft.VisualStudio.Shell; 
    using System.ComponentModel.Design; 
    using System.Collections.Generic; 


    /// <summary> 
    /// This class implements the tool window exposed by this package and hosts a user control. 
    /// </summary> 
    /// <remarks> 
    /// In Visual Studio tool windows are composed of a frame (implemented by the shell) and a pane, 
    /// usually implemented by the package implementer. 
    /// <para> 
    /// This class derives from the ToolWindowPane class provided from the MPF in order to use its 
    /// implementation of the IVsUIElementPane interface. 
    /// </para> 
    /// </remarks> 
    [Guid("1a24c96c-30bd-466b-8315-14bf54e4f17a")] 
    public class TestToolWindow : ToolWindowPane 
    { 
     /// <summary> 
     /// Initializes a new instance of the <see cref="TestToolWindow"/> class. 
     /// </summary> 
     /// 
     public UserControl1 control; 
     public TestToolWindow() : base(null) 
     { 
      this.Caption = "TestToolWindow"; 
     // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, 
      // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on 
      // the object returned by the Content property. 
      this.control = new UserControl1();//new TestToolWindowControl(users); 
     } 

     override public System.Windows.Forms.IWin32Window Window 
     { 
      get 
      { 
       return (System.Windows.Forms.IWin32Window)control; 
      } 
     } 
    } 
} 

enter image description here

示例项目:https://1drv.ms/u/s!AlvaNEnglADDgRMFqXKjdb63OeeK

相关问题