示例#1
0
        private bool IsImmediateWindow(IVsUIShell shellService, IVsTextView textView)
        {
            IEnumWindowFrames windowEnum = null;
            IVsTextLines      buffer     = null;

            Marshal.ThrowExceptionForHR(shellService.GetToolWindowEnum(out windowEnum));
            Marshal.ThrowExceptionForHR(textView.GetBuffer(out buffer));

            IVsWindowFrame[] frame = new IVsWindowFrame[1];
            uint             value;

            var immediateWindowGuid = Guid.Parse(ToolWindowGuids80.ImmediateWindow);

            while (windowEnum.Next(1, frame, out value) == VSConstants.S_OK)
            {
                Guid toolWindowGuid;
                Marshal.ThrowExceptionForHR(frame[0].GetGuidProperty((int)__VSFPROPID.VSFPROPID_GuidPersistenceSlot, out toolWindowGuid));
                if (toolWindowGuid == immediateWindowGuid)
                {
                    IntPtr frameTextView;
                    Marshal.ThrowExceptionForHR(frame[0].QueryViewInterface(typeof(IVsTextView).GUID, out frameTextView));
                    try
                    {
                        var immediateWindowTextView = Marshal.GetObjectForIUnknown(frameTextView) as IVsTextView;
                        return(textView == immediateWindowTextView);
                    }
                    finally
                    {
                        Marshal.Release(frameTextView);
                    }
                }
            }

            return(false);
        }
示例#2
0
        internal static bool ContainsImmediateWindow(this IEnumerable <IVsTextView> vsTextViews, IVsUIShell shellService, IVsEditorAdaptersFactoryService _editorAdaptersFactoryService)
        {
            IEnumWindowFrames windowEnum = null;

            Marshal.ThrowExceptionForHR(shellService.GetToolWindowEnum(out windowEnum));

            IVsWindowFrame[] frame = new IVsWindowFrame[1];
            uint             value;

            var immediateWindowGuid = Guid.Parse(ToolWindowGuids80.ImmediateWindow);

            while (windowEnum.Next(1, frame, out value) == VSConstants.S_OK)
            {
                Guid toolWindowGuid;
                Marshal.ThrowExceptionForHR(frame[0].GetGuidProperty((int)__VSFPROPID.VSFPROPID_GuidPersistenceSlot, out toolWindowGuid));
                if (toolWindowGuid == immediateWindowGuid)
                {
                    IntPtr frameTextView;
                    Marshal.ThrowExceptionForHR(frame[0].QueryViewInterface(typeof(IVsTextView).GUID, out frameTextView));
                    try
                    {
                        var immediateWindowTextView    = Marshal.GetObjectForIUnknown(frameTextView) as IVsTextView;
                        var immediateWindowWpfTextView = _editorAdaptersFactoryService.GetWpfTextView(immediateWindowTextView);
                        return(vsTextViews.Any(vsTextView => _editorAdaptersFactoryService.GetWpfTextView(vsTextView) == immediateWindowWpfTextView));
                    }
                    finally
                    {
                        Marshal.Release(frameTextView);
                    }
                }
            }

            return(false);
        }
示例#3
0
        public static Result <List <IVsWindowFrame> > GetContents(this IEnumWindowFrames enumFrames)
        {
            var list  = new List <IVsWindowFrame>();
            var array = new IVsWindowFrame[16];

            while (true)
            {
                uint num;
                var  hr = enumFrames.Next((uint)array.Length, array, out num);
                if (ErrorHandler.Failed(hr))
                {
                    return(Result.CreateError(hr));
                }

                if (0 == num)
                {
                    return(list);
                }

                for (var i = 0; i < num; i++)
                {
                    list.Add(array[i]);
                }
            }
        }
示例#4
0
        public static Mock <IVsUIShell> CreateVsUIShell(MockBehavior behavior = MockBehavior.Strict)
        {
            var mock = new Mock <IVsUIShell>(behavior);

            IEnumWindowFrames enumWindowFrames = null;

            mock.Setup(x => x.GetDocumentWindowEnum(out enumWindowFrames)).Returns(VSConstants.E_FAIL);

            return(mock);
        }
示例#5
0
        /// <summary>
        /// yield tool or document windows to an iterator
        /// </summary>
        /// <param name="frames">this set of tool or document windows</param>
        /// <returns></returns>
        private static IEnumerable <IVsFrameView> ExtractFrames(IEnumWindowFrames frames)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var frame = new IVsWindowFrame[1];
            int ok    = VSConstants.S_OK;

            while (ok == VSConstants.S_OK)
            {
                uint fetched;
                ok = frames.Next(1, frame, out fetched);
                ErrorHandler.ThrowOnFailure(ok);
                if (fetched == 1)
                {
                    yield return(new IVsFrameView(frame[0]));
                }
            }
        }
示例#6
0
 public int GetDocumentWindowEnum(out IEnumWindowFrames ppenum)
 {
     ppenum = new EnumWindowFrames(this);
     return(VSConstants.S_OK);
 }
 public int Clone(out IEnumWindowFrames ppenum) {
     throw new NotImplementedException();
 }
 int IVsUIShell.GetDocumentWindowEnum(out IEnumWindowFrames ppenum)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// The get web browser enum.
 /// </summary>
 /// <param name="rguidPersistenceSlot">
 /// The rguid persistence slot.
 /// </param>
 /// <param name="ppenum">
 /// The ppenum.
 /// </param>
 /// <returns>
 /// The get web browser enum.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int GetWebBrowserEnum(ref Guid rguidPersistenceSlot, out IEnumWindowFrames ppenum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#10
0
 /// <summary>
 /// The get web browser enum.
 /// </summary>
 /// <param name="rguidPersistenceSlot">
 /// The rguid persistence slot.
 /// </param>
 /// <param name="ppenum">
 /// The ppenum.
 /// </param>
 /// <returns>
 /// The get web browser enum.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int GetWebBrowserEnum(ref Guid rguidPersistenceSlot, out IEnumWindowFrames ppenum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 int IVsUIShell.GetToolWindowEnum(out IEnumWindowFrames ppenum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#12
0
 public int GetToolWindowEnum(out IEnumWindowFrames ppenum) {
     ppenum = new EnumWindowFramesMock(new List<IVsWindowFrame>(_frames.Values));
     return VSConstants.S_OK;
 }
示例#13
0
 public int GetDocumentWindowEnum(out IEnumWindowFrames ppenum) {
     throw new NotImplementedException();
 }
示例#14
0
 public int GetDocumentWindowEnum(out IEnumWindowFrames ppenum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#15
0
 public int Clone(out IEnumWindowFrames ppenum)
 {
     throw new NotImplementedException();
 }
示例#16
0
 int IVsUIShell.GetDocumentWindowEnum(out IEnumWindowFrames ppenum)
 {
     throw new NotImplementedException();
 }
示例#17
0
 public int GetToolWindowEnum(out IEnumWindowFrames ppenum)
 {
     throw new NotImplementedException();
 }
示例#18
0
 public int GetToolWindowEnum(out IEnumWindowFrames ppenum)
 {
     ppenum = new EnumWindowFramesMock(new List <IVsWindowFrame>(_frames.Values));
     return(VSConstants.S_OK);
 }