示例#1
0
文件: Shell.cs 项目: cmrazek/DkTools
        internal static void OpenDocument(string fileName, CodeModel.Span selectSpan)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                try
                {
                    IVsTextView view;
                    IVsWindowFrame windowFrame;
                    OpenDocument(fileName, out view, out windowFrame);
                    ErrorHandler.ThrowOnFailure(windowFrame.Show());

                    if (selectSpan.End > selectSpan.Start)
                    {
                        int startLine, startCol;
                        view.GetLineAndColumn(selectSpan.Start, out startLine, out startCol);

                        int endLine, endCol;
                        view.GetLineAndColumn(selectSpan.End, out endLine, out endCol);

                        view.SetSelection(startLine, startCol, endLine, endCol);
                        view.CenterLines(startLine, 1);
                    }
                    else
                    {
                        int startLine, startCol;
                        view.GetLineAndColumn(selectSpan.Start, out startLine, out startCol);
                        view.SetSelection(startLine, startCol, startLine, startCol);
                        view.CenterLines(startLine, 1);
                    }
                }
                catch (Exception ex)
                {
                    ShowError(ex);
                }
            });
        }
示例#2
0
 public string GetText(CodeModel.Span span)
 {
     return(GetText(span.Start, span.Length));
 }