Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 让Visual Studio自定义编辑器响应键输入_C#_Visual Studio_Visual Studio Extensions_Vssdk - Fatal编程技术网

C# 让Visual Studio自定义编辑器响应键输入

C# 让Visual Studio自定义编辑器响应键输入,c#,visual-studio,visual-studio-extensions,vssdk,C#,Visual Studio,Visual Studio Extensions,Vssdk,我正在进行一个项目,需要创建自定义编辑器并为自定义代码文件使用投影缓冲区,我已经按照本文中的步骤创建了一个代码窗口 但是,我无法让代码窗口响应任何键输入,尽管使用拖放操作是有效的 该扩展是为visual studio 2015编写的,他们的代码窗口是否需要执行任何额外的步骤才能正常工作 这是我正在使用的代码: public IWpfTextViewHost CreateEditor(string filePath, int start = 0, int end = 0, bool crea

我正在进行一个项目,需要创建自定义编辑器并为自定义代码文件使用投影缓冲区,我已经按照本文中的步骤创建了一个代码窗口

但是,我无法让代码窗口响应任何键输入,尽管使用拖放操作是有效的

该扩展是为visual studio 2015编写的,他们的代码窗口是否需要执行任何额外的步骤才能正常工作

这是我正在使用的代码:

 public IWpfTextViewHost CreateEditor(string filePath, int start = 0, int end = 0, bool createProjectedEditor = false)
    {
        //IVsInvisibleEditors are in-memory represenations of typical Visual Studio editors.
        //Language services, highlighting and error squiggles are hooked up to these editors
        //for us once we convert them to WpfTextViews. 
        var invisibleEditor = GetInvisibleEditor(filePath);

        var docDataPointer = IntPtr.Zero;
        Guid guidIVsTextLines = typeof(IVsTextLines).GUID;

        ErrorHandler.ThrowOnFailure(invisibleEditor.GetDocData(
            fEnsureWritable: 1
            , riid: ref guidIVsTextLines
            , ppDocData: out docDataPointer));

        IVsTextLines docData = (IVsTextLines)Marshal.GetObjectForIUnknown(docDataPointer);

        //Create a code window adapter
        var codeWindow = _editorAdapter.CreateVsCodeWindowAdapter(VisualStudioServices.OLEServiceProvider);
        ErrorHandler.ThrowOnFailure(codeWindow.SetBuffer(docData));

        //Get a text view for our editor which we will then use to get the WPF control for that editor.
        IVsTextView textView;
        ErrorHandler.ThrowOnFailure(codeWindow.GetPrimaryView(out textView));

        _currentlyFocusedTextView = textView;


        RegisterDocument(filePath);


        var textViewHost = _editorAdapter.GetWpfTextViewHost(textView);

        return textViewHost;
    }