示例#1
0
        /// <summary>
        /// Retrieves captions and positions of all active tool windows
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<ToolWindowData> GetToolWindowData(IVsUIShell shell) {
            var data = new List<ToolWindowData>();
            try {
                IEnumWindowFrames e;
                shell.GetToolWindowEnum(out e);

                IVsWindowFrame[] frame = new IVsWindowFrame[1];
                uint fetched = 0;
                while (VSConstants.S_OK == e.Next(1, frame, out fetched) && fetched > 0) {
                    object objCaption;
                    frame[0].GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out objCaption);

                    VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1];
                    Guid relative;
                    int x, y, cx, cy;
                    frame[0].GetFramePos(pos, out relative, out x, out y, out cx, out cy);

                    var d = new ToolWindowData() {
                        Caption = objCaption as string,
                        X = x,
                        Y = y,
                        Width = cx,
                        Height = cy
                    };

                    data.Add(d);
                }
            } catch (Exception) { }

            return data;
        }
示例#2
0
        /// <summary>
        /// Retrieves captions and positions of all active tool windows
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <ToolWindowData> GetToolWindowData(IVsUIShell shell)
        {
            var data = new List <ToolWindowData>();

            try {
                IEnumWindowFrames e;
                shell.GetToolWindowEnum(out e);

                IVsWindowFrame[] frame   = new IVsWindowFrame[1];
                uint             fetched = 0;
                while (VSConstants.S_OK == e.Next(1, frame, out fetched) && fetched > 0)
                {
                    object objCaption;
                    frame[0].GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out objCaption);

                    VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1];
                    Guid            relative;
                    int             x, y, cx, cy;
                    frame[0].GetFramePos(pos, out relative, out x, out y, out cx, out cy);

                    var d = new ToolWindowData()
                    {
                        Caption = objCaption as string,
                        X       = x,
                        Y       = y,
                        Width   = cx,
                        Height  = cy
                    };

                    data.Add(d);
                }
            } catch (Exception) { }

            return(data);
        }
示例#3
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the position of the window frame.
        /// </summary>
        /// <param name="position">Window frame coordinates.</param>
        /// <returns>
        /// General position of the frame (docked, tabbed, floating, etc.)
        /// </returns>
        // --------------------------------------------------------------------------------------------
        public FramePosition GetWindowPosition(out Rectangle position)
        {
            int  left;
            int  top;
            int  width;
            int  height;
            var  pdwSFP = new VSSETFRAMEPOS[1];
            Guid guid;

            ErrorHandler.ThrowOnFailure(((IVsWindowFrame)this).
                                        GetFramePos(pdwSFP, out guid,
                                                    out left, out top, out width, out height));
            position = new Rectangle(left, top, width, height);
            switch (pdwSFP[0])
            {
            case VSSETFRAMEPOS.SFP_fDock:
                return(FramePosition.Docked);

            case VSSETFRAMEPOS.SFP_fTab:
                return(FramePosition.Tabbed);

            case VSSETFRAMEPOS.SFP_fFloat:
                return(FramePosition.Float);

            case VSSETFRAMEPOS.SFP_fMdiChild:
                return(FramePosition.MdiChild);
            }
            return(FramePosition.Unknown);
        }
示例#4
0
        public void centerLine(int nNum)
        {
            ///VSAnything 窗口是否为autoHIde
            bool bIsAutoHide = false;

            ToolWindowPane window = VSAnythingPackage.Inst.FindToolWindow(typeof(FastFindToolWindowPane), 0, true);

            if (window != null && window.Frame != null)
            {
                Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame = (Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)window.Frame;
                if (frame != null && frame.IsVisible() == 0) // 0 is visible !!!
                {
                    object currentFrameMode;

                    frame.GetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, out currentFrameMode);
                    if ((VsFrameMode)currentFrameMode == VsFrameMode.AutoHide)
                    {
                        bIsAutoHide = true;
                    }
                }

                IVsTextView textViewCurrent;
                var         txtMngr = (IVsTextManager)VSAnythingPackage.Inst.GetService(typeof(SVsTextManager));
                txtMngr.GetActiveView(1, null, out textViewCurrent);

                /// 如果VSAnything窗口不是autoHide,简单地把改行滚动到Editor中间即可
                /// 但是在autoHide情况下,即使滚动到Editor中间,也可能被挡住。得计算出Editor的可视区域,将line滚到中间
                if (!bIsAutoHide)
                {
                    textViewCurrent.CenterLines(nNum, 1);
                }
                else
                {
                    int nMin;       // 当前页滚动条最小值
                    int nMax;       // 当前页滚动条最大值
                    int nPerPage;   // 当前页的高度等于多少滚动值
                    int nCurPos;    // 当前滚动条所在位置,能展示的区域为 [nCurPos,nCurPos + nPerPage],即一页的内容

                    var scrollInfo = textViewCurrent.GetScrollInfo(1, out nMin, out nMax, out nPerPage, out nCurPos);

                    /// 获取VSAnything窗口大小,还需要加上toolbar高度
                    VSSETFRAMEPOS[] vars = new VSSETFRAMEPOS[20];
                    Guid            guid;
                    int             xToLeft, yToTop, width, height;

                    frame.GetFramePos(vars, out guid, out xToLeft, out yToTop, out width, out height);

                    /// todo ~~~
                    TextDocument text_doc = this.m_DTE.ActiveDocument.Object("") as TextDocument;
                    if (text_doc != null)
                    {
                    }
                    ////// todo ~~~
                    textViewCurrent.CenterLines(nNum, 1);
                    //////
                }
            }
        }
 public int GetFramePos(VSSETFRAMEPOS[] pdwSFP, out Guid pguidRelativeTo, out int px, out int py, out int pcx, out int pcy)
 {
     pguidRelativeTo = Guid.Empty;
     px = 0;
     py = 0;
     pcx = 0;
     pcy = 0;
     return VSConstants.S_OK;
 }
        /// <summary>
        /// Gets the position of the window frame.
        /// </summary>
        /// <param name="position">Window frame coordinates.</param>
        /// <returns>
        /// General position of the frame (docked, tabbed, floating, etc.)
        /// </returns>
        public FramePosition GetWindowPosition(out Rectangle position)
        {
            //TODO: Make this async
            ThreadHelper.ThrowIfNotOnUIThread();

            VSSETFRAMEPOS[] pdwSFP = new VSSETFRAMEPOS[1];
            ErrorHandler.ThrowOnFailure(((IVsWindowFrame)this).GetFramePos(pdwSFP, out _, out int left, out int top, out int width, out int height));
            position = new Rectangle(left, top, width, height);

            return(pdwSFP[0] switch
            {
                VSSETFRAMEPOS.SFP_fDock => FramePosition.Docked,
                VSSETFRAMEPOS.SFP_fTab => FramePosition.Tabbed,
                VSSETFRAMEPOS.SFP_fFloat => FramePosition.Float,
                VSSETFRAMEPOS.SFP_fMdiChild => FramePosition.MdiChild,
                _ => FramePosition.Unknown,
            });
        public WindowStatus(IVsOutputWindowPane outputWindowPane, IVsWindowFrame frame)
        {
            outputPane = outputWindowPane;
            this.frame = frame;

            if (frame != null)
            {
                VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1];
                int x;
                int y;
                int width;
                int height;
                Guid unused;
                frame.GetFramePos(pos, out unused, out x, out y, out width, out height);
                dockable = (pos[0] & VSSETFRAMEPOS.SFP_fFloat) != VSSETFRAMEPOS.SFP_fFloat;
            }
        }
示例#8
0
        public WindowStatus(IVsOutputWindowPane outputWindowPane, IVsWindowFrame frame)
        {
            outputPane = outputWindowPane;
            this.frame = frame;

            if (frame != null)
            {
                VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1];
                int             x;
                int             y;
                int             width;
                int             height;
                Guid            unused;
                frame.GetFramePos(pos, out unused, out x, out y, out width, out height);
                this.dockable = (pos[0] & VSSETFRAMEPOS.SFP_fFloat) != VSSETFRAMEPOS.SFP_fFloat;
            }
        }
示例#9
0
        public int OnSize(int x, int y, int w, int h)
        {
            if (this.frame != null)
            {
                // Beta2: There is a bug with the width and height passed to this notification, so
                // for now we get the width and height directly from the frame
                // This is a workaround that should be removed by RTM
                VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1];
                Guid            unusedGuid;
                int             unusedX;
                int             unusedY;
                frame.GetFramePos(pos, out unusedGuid, out unusedX, out unusedY, out w, out h);
            }

            this.x      = x;
            this.y      = y;
            this.width  = w;
            this.height = h;

            this.GenerateStatusChangeEvent(this, new EventArgs());

            return(Microsoft.VisualStudio.VSConstants.S_OK);
        }
 int IVsWindowFrame.SetFramePos(VSSETFRAMEPOS sfp, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     throw new NotImplementedException();
 }
 int IVsWindowFrame.GetFramePos(VSSETFRAMEPOS[] pdwSFP, out Guid pguidRelativeTo, out int px, out int py, out int pcx, out int pcy)
 {
     throw new NotImplementedException();
 }
示例#12
0
 public int SetFramePos(VSSETFRAMEPOS dwSfp, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     return(VSConstants.E_NOTIMPL);
 }
示例#13
0
 public int SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 /// <summary>
 /// The get frame pos.
 /// </summary>
 /// <param name="pdwSFP">
 /// The pdw sfp.
 /// </param>
 /// <param name="pguidRelativeTo">
 /// The pguid relative to.
 /// </param>
 /// <param name="px">
 /// The px.
 /// </param>
 /// <param name="py">
 /// The py.
 /// </param>
 /// <param name="pcx">
 /// The pcx.
 /// </param>
 /// <param name="pcy">
 /// The pcy.
 /// </param>
 /// <returns>
 /// The get frame pos.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int GetFramePos(VSSETFRAMEPOS[] pdwSFP, out Guid pguidRelativeTo, out int px, out int py, out int pcx, out int pcy)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 /// <summary>
 /// The set frame pos.
 /// </summary>
 /// <param name="dwSFP">
 /// The dw sfp.
 /// </param>
 /// <param name="rguidRelativeTo">
 /// The rguid relative to.
 /// </param>
 /// <param name="x">
 /// The x.
 /// </param>
 /// <param name="y">
 /// The y.
 /// </param>
 /// <param name="cx">
 /// The cx.
 /// </param>
 /// <param name="cy">
 /// The cy.
 /// </param>
 /// <returns>
 /// The set frame pos.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#16
0
 public int SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy) {
     return VSConstants.S_OK;
 }
示例#17
0
 public int SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     return(VSConstants.S_OK);
 }
示例#18
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Sets the position of the window.
 /// </summary>
 /// <param name="dwSFP">
 /// Frame position whose values are taken from the VSSETFRAMEPOS enumeration.
 /// </param>
 /// <param name="rguidRelativeTo">Not used.</param>
 /// <param name="x">Absolute x ordinate.</param>
 /// <param name="y">Absolute y ordinate.</param>
 /// <param name="cx">x ordinate relative to x.</param>
 /// <param name="cy">y ordinate relative to y.</param>
 /// <returns>
 /// If the method succeeds, it returns S_OK. If it fails, it returns an error code.
 /// </returns>
 // --------------------------------------------------------------------------------------------
 int IVsWindowFrame.SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     return(_Frame.SetFramePos(dwSFP, ref rguidRelativeTo, x, y, cx, cy));
 }
示例#19
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Returns the position of the window.
 /// </summary>
 /// <param name="pdwSFP">Pointer to the frame position.</param>
 /// <param name="pguidRelativeTo">Not used.</param>
 /// <param name="px">Pointer to the absolute x ordinate.</param>
 /// <param name="py">Pointer to the absolute y ordinate.</param>
 /// <param name="pcx">Pointer to the x ordinate relative to px.</param>
 /// <param name="pcy">Pointer to the y ordinate relative to py.</param>
 /// <returns>
 /// If the method succeeds, it returns S_OK. If it fails, it returns an error code.
 /// </returns>
 // --------------------------------------------------------------------------------------------
 int IVsWindowFrame.GetFramePos(VSSETFRAMEPOS[] pdwSFP, out Guid pguidRelativeTo, out int px, 
                                out int py, out int pcx, out int pcy)
 {
   return _Frame.GetFramePos(pdwSFP, out pguidRelativeTo, out px, out py, out pcx, out pcy);
 }
示例#20
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Sets the position of the window.
 /// </summary>
 /// <param name="dwSFP">
 /// Frame position whose values are taken from the VSSETFRAMEPOS enumeration.
 /// </param>
 /// <param name="rguidRelativeTo">Not used.</param>
 /// <param name="x">Absolute x ordinate.</param>
 /// <param name="y">Absolute y ordinate.</param>
 /// <param name="cx">x ordinate relative to x.</param>
 /// <param name="cy">y ordinate relative to y.</param>
 /// <returns>
 /// If the method succeeds, it returns S_OK. If it fails, it returns an error code.
 /// </returns>
 // --------------------------------------------------------------------------------------------
 int IVsWindowFrame.SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
   return _Frame.SetFramePos(dwSFP, ref rguidRelativeTo, x, y, cx, cy);
 }
示例#21
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the position of the window frame.
 /// </summary>
 /// <param name="position">Window frame coordinates.</param>
 /// <returns>
 /// General position of the frame (docked, tabbed, floating, etc.)
 /// </returns>
 // --------------------------------------------------------------------------------------------
 public FramePosition GetWindowPosition(out Rectangle position)
 {
   int left;
   int top;
   int width;
   int height;
   var pdwSFP = new VSSETFRAMEPOS[1];
   Guid guid;
   ErrorHandler.ThrowOnFailure(((IVsWindowFrame)this).
                                 GetFramePos(pdwSFP, out guid,
                                             out left, out top, out width, out height));
   position = new Rectangle(left, top, width, height);
   switch (pdwSFP[0])
   {
     case VSSETFRAMEPOS.SFP_fDock:
       return FramePosition.Docked;
     case VSSETFRAMEPOS.SFP_fTab:
       return FramePosition.Tabbed;
     case VSSETFRAMEPOS.SFP_fFloat:
       return FramePosition.Float;
     case VSSETFRAMEPOS.SFP_fMdiChild:
       return FramePosition.MdiChild;
   }
   return FramePosition.Unknown;
 }
 int IVsWindowFrame.SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy)
 {
     throw new NotImplementedException();
 }
示例#23
0
			public int SetFramePos(VSSETFRAMEPOS dwSFP, ref Guid rguidRelativeTo, int x, int y, int cx, int cy) {
				throw new NotImplementedException();
			}