Visual studio extensions 实施;导航栏“;用于自定义编辑器
注册自定义语言服务扩展时,Visual Studio会在Visual studio extensions 实施;导航栏“;用于自定义编辑器,visual-studio-extensions,vsx,vs-extensibility,vspackage,visual-studio-sdk,Visual Studio Extensions,Vsx,Vs Extensibility,Vspackage,Visual Studio Sdk,注册自定义语言服务扩展时,Visual Studio会在文本编辑器节点(在Visual Studio选项对话框中)中为该语言创建一个新的选项条目。在该节点下,创建了两个名为General和Tabs的默认节点,General选项卡包含语句完成和显示设置 在Dispay组中有三个选项;其中之一是导航栏复选框(显示/隐藏编辑器的导航栏)。对于我的自定义语言服务,此选项已禁用。当然,它还没有实现 我想知道,我必须做什么,为我的自定义编辑器提供一个导航栏。。。我想我必须在编辑器的工厂中实现某个接口,或者
文本编辑器
节点(在Visual Studio选项对话框中)中为该语言创建一个新的选项条目。在该节点下,创建了两个名为General
和Tabs
的默认节点,General
选项卡包含语句完成和显示设置
在Dispay
组中有三个选项;其中之一是导航栏
复选框(显示/隐藏编辑器的导航栏)。对于我的自定义语言服务,此选项已禁用。当然,它还没有实现
我想知道,我必须做什么,为我的自定义编辑器提供一个导航栏。。。我想我必须在编辑器的工厂中实现某个接口,或者语言服务包必须导出某个MEF组件,或者,…我认为以下步骤应该是您所需要的:
包
类中,在ProvideLanguageService
属性中将showdropdownpoptions
属性设置为trueTypeAndMemberDropdownBars
LanguageService
类中,实现CreateDropDownHelper
函数,并让它返回TypeAndMemberDropdownBars
我相信以下步骤应该是您所需要的:
包
类中,在ProvideLanguageService
属性中将showdropdownpoptions
属性设置为trueTypeAndMemberDropdownBars
LanguageService
类中,实现CreateDropDownHelper
函数,并让它返回TypeAndMemberDropdownBars
我相信以下步骤应该是您所需要的:
包
类中,在ProvideLanguageService
属性中将showdropdownpoptions
属性设置为trueTypeAndMemberDropdownBars
LanguageService
类中,实现CreateDropDownHelper
函数,并让它返回TypeAndMemberDropdownBars
我相信以下步骤应该是您所需要的:
包
类中,在ProvideLanguageService
属性中将showdropdownpoptions
属性设置为trueTypeAndMemberDropdownBars
LanguageService
类中,实现CreateDropDownHelper
函数,并让它返回TypeAndMemberDropdownBars
乔恩·森奇纳的回答引导我走向正确的方向。从不调用
OnSynchronizeDropdowns
方法(在这种情况下SDK文档是错误的)。最后一个技巧是至少覆盖GetComboAttributes
、GetEntryAttributes
和GetEntryText
以获取两个组合框的纯文本项
[ComVisible(true)]
public sealed class CustomTypeAndMemberDropdownBars : TypeAndMemberDropdownBars
{
private readonly IList<string> declarations;
private readonly IList<string> members;
public CustomTypeAndMemberDropdownBars(
LanguageService languageService,
IVsTextView view)
: base(languageService)
{
// TODO: initialize declarations and members from the given text view...
this.declarations = ...
this.members = ...
}
private enum ComboIndex
{
Types = 0,
Members = 1
}
public override int GetComboAttributes(
int combo,
out uint entries,
out uint entryType,
out IntPtr imageList)
{
entries = 0;
imageList = IntPtr.Zero;
entryType = (uint)DROPDOWNENTRYTYPE.ENTRY_TEXT;
var comboType = (ComboIndex)combo;
switch (comboType)
{
case ComboIndex.Types:
entries = (uint)this.declarations.Count();
break;
case ComboIndex.Members:
entries = (uint)this.members.Count();
break;
}
return VSConstants.S_OK;
}
public override int GetEntryAttributes(
int combo,
int entry,
out uint fontAttrs)
{
fontAttrs = (uint)DROPDOWNFONTATTR.FONTATTR_PLAIN;
return VSConstants.S_OK;
}
public override int GetEntryText(
int combo,
int entry,
out string text)
{
text = null;
var comboType = (ComboIndex)combo;
switch (comboType)
{
case ComboIndex.Types:
text = this.declarations[entry];
break;
case ComboIndex.Members:
text = this.members[entry];
break;
}
return VSConstants.S_OK;
}
public override bool OnSynchronizeDropdowns(
LanguageService languageService,
IVsTextView textView,
int line,
int col,
ArrayList dropDownTypes,
ArrayList dropDownMembers,
ref int selectedType,
ref int selectedMember)
{
return false;
}
}
[ComVisible(true)]
公共密封类CustomTypeAndMemberDropdownBars:TypeAndMemberDropdownBars
{
私有只读IList声明;
私人只读IList成员;
公共自定义类型和成员下拉栏(
语言服务语言服务,
IVsTextView(视图)
:base(语言服务)
{
//TODO:初始化给定文本视图中的声明和成员。。。
this.declarations=。。。
this.members=。。。
}
私有枚举组合索引
{
类型=0,
成员=1
}
公共覆盖int-GetComboAttributes(
整数组合,
输出uint条目,
out uint入口类型,
输出IntPtr图像列表)
{
条目=0;
imageList=IntPtr.Zero;
entryType=(uint)DROPDOWNENTRYTYPE.ENTRY\u文本;
var comboType=(ComboIndex)combo;
开关(组合式)
{
大小写组合索引。类型:
entries=(uint)this.declarations.Count();
打破
案例索引。成员:
entries=(uint)this.members.Count();
打破
}
返回VSConstants.S_OK;
}
公共覆盖int GetEntryAttributes(
整数组合,
整数输入,
out uint fontAttrs)
{
fontAttrs=(uint)DROPDOWNFONTATTR.FONTATTR\u平原;
返回VSConstants.S_OK;
}
公共覆盖int GetEntryText(
整数组合,
整数输入,
输出字符串(文本)
{
text=null;
var comboType=(ComboIndex)combo;
开关(组合式)
{
大小写组合索引。类型:
text=this.declarations[entry];
打破
案例索引。成员:
text=this.members[条目];
打破
}
返回VSConstants.S_OK;
}
公共覆盖bool OnSynchronizeDropdowns(
语言服务语言服务,
IVsTextView textView,
内线,
int col,
ArrayList下拉列表类型,
ArrayList下拉列表成员,
ref int selectedType,
ref int selectedMember)
{
返回false;
}
}
乔恩·森奇纳的回答引导我走向正确的方向。从不调用OnSynchronizeDropdowns
方法(在这种情况下SDK文档是错误的)。最后一个技巧是至少覆盖GetComboAttributes
、GetEntryAttributes
和GetEntryText
以获取两个组合框的纯文本项
[ComVisible(true)]
public sealed class CustomTypeAndMemberDropdownBars : TypeAndMemberDropdownBars
{
private readonly IList<string> declarations;
private readonly IList<string> members;
public CustomTypeAndMemberDropdownBars(
LanguageService languageService,
IVsTextView view)
: base(languageService)
{
// TODO: initialize declarations and members from the given text view...
this.declarations = ...
this.members = ...
}
private enum ComboIndex
{
Types = 0,
Members = 1
}
public override int GetComboAttributes(
int combo,
out uint entries,
out uint entryType,
out IntPtr imageList)
{
entries = 0;
imageList = IntPtr.Zero;
entryType = (uint)DROPDOWNENTRYTYPE.ENTRY_TEXT;
var comboType = (ComboIndex)combo;
switch (comboType)
{
case ComboIndex.Types:
entries = (uint)this.declarations.Count();
break;
case ComboIndex.Members:
entries = (uint)this.members.Count();
break;
}
return VSConstants.S_OK;
}
public override int GetEntryAttributes(
int combo,
int entry,
out uint fontAttrs)
{
fontAttrs = (uint)DROPDOWNFONTATTR.FONTATTR_PLAIN;
return VSConstants.S_OK;
}
public override int GetEntryText(
int combo,
int entry,
out string text)
{
text = null;
var comboType = (ComboIndex)combo;
switch (comboType)
{
case ComboIndex.Types:
text = this.declarations[entry];
break;
case ComboIndex.Members:
text = this.members[entry];
break;
}
return VSConstants.S_OK;
}
public override bool OnSynchronizeDropdowns(
LanguageService languageService,
IVsTextView textView,
int line,
int col,
ArrayList dropDownTypes,
ArrayList dropDownMembers,
ref int selectedType,
ref int selectedMember)
{
return false;
}
}
[ComVisible(true)]
公共密封类CustomTypeAndMemberDropdownBars:TypeAndMemberDropdownBars
{
普里瓦特