【发布时间】:2016-04-27 10:07:51
【问题描述】:
我正在编写我的第一个 VS 扩展。 到目前为止,我有获取选定文本并显示消息框或操作选择的代码:
扩展的 CTOR..
private StringRefactor(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
this.package = package;
OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
commandService.AddCommand(menuItem);
}
}
回调:
private void MenuItemCallback(object sender, EventArgs e)
{
var selection = getSelection();
var selectedText = selection == null ? "No text selected..." : selection.StreamSelectionSpan.GetText();
string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
string title = "StringRefactor";
// Show a message box to prove we were here
VsShellUtilities.ShowMessageBox(
this.ServiceProvider,
selectedText,
title,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
现在我想打开一个提示窗口,而不是VsShellUtilities.ShowMessageBox(...,它显示几个文本框和确定\取消按钮..
我想创建另一个 WPF 应用程序项目并从回调中启动它,但我不确定这是编写打开自定义工具的扩展的正确方法..
那么打开具有 VISIX 功能的自定义窗口的正确方法是什么?
【问题讨论】:
标签: c# wpf visual-studio-extensions