Пример #1
0
        public void FormatRange(LineRange range)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Reset();
            int startLine, startLineOffset, endLine, endLineOffset;

            this.GetExtentInfo(range.Start, range.Length, out startLine, out startLineOffset, out endLine, out endLineOffset);

            int oldStartLine, oldStartLineOffset, oldEndLine, oldEndLineOffset;

            _view.GetSelection(out oldStartLine, out oldStartLineOffset, out oldEndLine, out oldEndLineOffset);
            _view.SetSelection(startLine, startLineOffset, endLine, endLineOffset);
            var target = (IOleCommandTarget)ServiceProvider.GlobalProvider.GetService(typeof(SUIHostCommandDispatcher));

            if (null == target)
            {
                return;
            }
            Guid cmdid = VSConstants.VSStd2K;
            int  hr    = _view.SendExplicitFocus();

            hr = target.Exec(ref cmdid, (uint)VSConstants.VSStd2KCmdID.FORMATSELECTION, 0, IntPtr.Zero, IntPtr.Zero);
            _view.SetSelection(oldStartLine, oldStartLineOffset, oldEndLine, oldEndLineOffset);
        }
Пример #2
0
 public void FormatRange(LineRange range)
 {
 }