Hug*_*iro 7 vsx vspackage vsix vsct visual-studio-2015
我已经使用VSCT文件中的此设置为Visual Studio 2015的VSIX包中的工具栏定义了动态组合:
<Combo guid="cmdExplorerToolbarSearchGUID" id="cmdExplorerToolbarSearchID" priority="0x0" type="DynamicCombo"
defaultWidth="50" idCommandList="cmdExplorerToolbarSearchGetListID">
<Parent guid="grpExplorerToolbar3GUID" id="grpExplorerToolbar3ID" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>StretchHorizontally</CommandFlag>
<Strings>
<CanonicalName>cmdExplorerToolbarSearch</CanonicalName>
<ButtonText>Search</ButtonText>
<ToolTipText>Search elements in the model explorer</ToolTipText>
</Strings>
</Combo>
</Combos>
Run Code Online (Sandbox Code Playgroud)
相应的DynamicStatusMenuCommand实例定义如下:
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchSelected),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchID));
commands.Add(command);
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchGetList),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchGetListID));
commands.Add(command);
Run Code Online (Sandbox Code Playgroud)
最后OnCmdExplorerToolbarSearchSelected像这样的事件处理程序:
private void OnCmdExplorerToolbarSearchSelected(object sender, EventArgs e)
{
// Process the event arguments
OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;
if (args != null)
{
// Process values
string inValue = args.InValue as string;
IntPtr outValue = args.OutValue;
if (outValue != IntPtr.Zero)
{
// When outValue is not null, the IDE is requesting the current value for the combo
Marshal.GetNativeVariantForObject(this.SearchHandler.CurrentValue, outValue);
}
else if (inValue != null)
{
this.SearchHandler.Search(this.PresentationModel3ExplorerToolWindow.Explorer, inValue);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这导致工具箱中的一个很好的组合:
问题是,如果用户输入"Unit"并按下Enter事件处理程序,则使用inValue!= null调用并执行搜索.但是,如果他输入其他内容(例如:Customer)并按下Tab(否Enter),则组合将恢复为之前的值("Unit"),因为使用args.OutValue!= IntPtr.Zero调用处理程序.
当用户输入内容并将焦点移离组合而不按下时,获取回调的诀窍是什么Enter?并且,鉴于此,如何获得当时组合的值?
| 归档时间: |
|
| 查看次数: |
262 次 |
| 最近记录: |