1. <i id='HwikJ'><tr id='HwikJ'><dt id='HwikJ'><q id='HwikJ'><span id='HwikJ'><b id='HwikJ'><form id='HwikJ'><ins id='HwikJ'></ins><ul id='HwikJ'></ul><sub id='HwikJ'></sub></form><legend id='HwikJ'></legend><bdo id='HwikJ'><pre id='HwikJ'><center id='HwikJ'></center></pre></bdo></b><th id='HwikJ'></th></span></q></dt></tr></i><div id='HwikJ'><tfoot id='HwikJ'></tfoot><dl id='HwikJ'><fieldset id='HwikJ'></fieldset></dl></div>

      <legend id='HwikJ'><style id='HwikJ'><dir id='HwikJ'><q id='HwikJ'></q></dir></style></legend>
    2. <small id='HwikJ'></small><noframes id='HwikJ'>

        <bdo id='HwikJ'></bdo><ul id='HwikJ'></ul>

      <tfoot id='HwikJ'></tfoot>

        Visual Studio 扩展:如何获取调用上下文菜单的行?

        Visual Studio Extension: How to get the line on which Context Menu was called?(Visual Studio 扩展:如何获取调用上下文菜单的行?)
      1. <small id='AunQr'></small><noframes id='AunQr'>

        <i id='AunQr'><tr id='AunQr'><dt id='AunQr'><q id='AunQr'><span id='AunQr'><b id='AunQr'><form id='AunQr'><ins id='AunQr'></ins><ul id='AunQr'></ul><sub id='AunQr'></sub></form><legend id='AunQr'></legend><bdo id='AunQr'><pre id='AunQr'><center id='AunQr'></center></pre></bdo></b><th id='AunQr'></th></span></q></dt></tr></i><div id='AunQr'><tfoot id='AunQr'></tfoot><dl id='AunQr'><fieldset id='AunQr'></fieldset></dl></div>

            <tbody id='AunQr'></tbody>
            <bdo id='AunQr'></bdo><ul id='AunQr'></ul>
                <legend id='AunQr'><style id='AunQr'><dir id='AunQr'><q id='AunQr'></q></dir></style></legend>
                  <tfoot id='AunQr'></tfoot>

                1. 本文介绍了Visual Studio 扩展:如何获取调用上下文菜单的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想创建一个 VS 扩展,我需要知道调用菜单的行号.我找到了一个 VisualBasic 实现,其中的宏似乎 这样做,但我不知道如何在 C# 中启动它.目标是知道调用 ContextMenu 的行的确切编号,以便在其上放置一个占位符图标,就像一个断点一样.感谢有用的链接,因为我在这个主题上找不到太多.

                  I would like to create a VS extension in which I need to know the line number the menu was called on. I found a VisualBasic implementation with a macro that seems to do this, but I don't know how to start this in C#. The goal would be to know the exact number of the line the ContextMenu was called on to put a placeholder icon on it just like a break point. Useful links are appreciated since I couldn't find much on this topic.

                  推荐答案

                  您可以创建一个 VSIX 项目并在您的项目中添加一个 Command 项.然后在 MenuItemCallback() 方法中添加如下代码,获取代码行号.

                  You could create a VSIX project and add a Command item in your project. Then add following code in MenuItemCallback() method to get the code line number.

                      private void MenuItemCallback(object sender, EventArgs e)
                      {
                          EnvDTE.DTE dte = (EnvDTE.DTE)this.ServiceProvider.GetService(typeof(EnvDTE.DTE));
                  
                          EnvDTE.TextSelection ts = dte.ActiveWindow.Selection as EnvDTE.TextSelection;
                          if (ts == null)
                              return;
                          EnvDTE.CodeFunction func = ts.ActivePoint.CodeElement[vsCMElement.vsCMElementFunction]
                                      as EnvDTE.CodeFunction;
                          if (func == null)
                              return;
                  
                          string message = dte.ActiveWindow.Document.FullName + System.Environment.NewLine +
                            "Line " + ts.CurrentLine + System.Environment.NewLine +
                            func.FullName;
                  
                          string title = "GetLineNo";
                  
                          VsShellUtilities.ShowMessageBox(
                              this.ServiceProvider,
                              message,
                              title,
                              OLEMSGICON.OLEMSGICON_INFO,
                              OLEMSGBUTTON.OLEMSGBUTTON_OK,
                              OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                      }
                  

                  这篇关于Visual Studio 扩展:如何获取调用上下文菜单的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                      <legend id='p8ofN'><style id='p8ofN'><dir id='p8ofN'><q id='p8ofN'></q></dir></style></legend>
                      • <small id='p8ofN'></small><noframes id='p8ofN'>

                        <tfoot id='p8ofN'></tfoot>
                          <bdo id='p8ofN'></bdo><ul id='p8ofN'></ul>

                              <tbody id='p8ofN'></tbody>

                            <i id='p8ofN'><tr id='p8ofN'><dt id='p8ofN'><q id='p8ofN'><span id='p8ofN'><b id='p8ofN'><form id='p8ofN'><ins id='p8ofN'></ins><ul id='p8ofN'></ul><sub id='p8ofN'></sub></form><legend id='p8ofN'></legend><bdo id='p8ofN'><pre id='p8ofN'><center id='p8ofN'></center></pre></bdo></b><th id='p8ofN'></th></span></q></dt></tr></i><div id='p8ofN'><tfoot id='p8ofN'></tfoot><dl id='p8ofN'><fieldset id='p8ofN'></fieldset></dl></div>