Пример #1
0
        /// <summary>
        /// This function is called when the user clicks the menu item that shows the
        /// tool window. See the Initialize method to see how the menu item is associated to
        /// this function using the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void ShowMergeToolWindow(object sender, EventArgs e)
        {
            IVsUIShell4 uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell4;

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = this.FindToolWindow(typeof(vMergeMergeToolWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            SetMergeToolWindowIsVisible();

            var windowEvents = new ToolWindowEvents(windowFrame);

            windowEvents.OnClose = (options) =>
            {
                MergeToolWindowIsVisible = false;
                if (_mergeToolWindowVisibilityChanged != null)
                {
                    _mergeToolWindowVisibilityChanged(this, new EventArgs());
                }
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, null);
                windowEvents.Dispose();
                return(VSConstants.S_OK);
            };
            windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, windowEvents);

            vMergeMergeToolWindow mergeToolWindow = (vMergeMergeToolWindow)window;
        }
Пример #2
0
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();
            var handler = new ToolWindowEvents((TeamNotificationPackage)this.Package, Container.GetInstance<IHandleToolWindowEvents>());
            ((IVsWindowFrame)this.Frame).SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, handler);
//
//            var pdwSFP = new VSSETFRAMEPOS[1];
//            Guid guid;
//            int px;
//            int py;
//            int pcx;
//            int pcy;
//            ((IVsWindowFrame)this.Frame).GetFramePos(pdwSFP, out guid, out px, out py, out pcx, out pcy);
//
//            object res0;
//            ((IVsWindowFrame) this.Frame).GetProperty((int) __VSFPROPID.VSFPROPID_FrameMode, out res0);
//
//            object res2;
//            ((IVsWindowFrame)this.Frame).GetProperty((int)__VSFPROPID.VSFPROPID_SPFrame, out res2);
//            
//            object res3;
//            ((IVsWindowFrame)this.Frame).GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out res3);
//            
//
//            object res;
//            ((IVsWindowFrame) this.Frame).GetProperty((int) __VSFPROPID.VSFPROPID_WindowState, out res);
//
//            object res1;
//            ((IVsWindowFrame)this.Frame).GetProperty((int)__VSFPROPID.VSFPROPID_IsWindowTabbed, out res1);
//
//            int a = 0;
        }
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();

            var handler = new ToolWindowEvents(
                (AppMobiCloudServiceExtensionPackage)this.Package);
            ((IVsWindowFrame)this.Frame).SetProperty(
                (int)__VSFPROPID.VSFPROPID_ViewHelper, handler);
        }
        private void SetMergeDiffWindowsToFloatOnly()
        {
            if (vMergePackage.MergeToolWindowIsVisible)
            {
                return;
            }

            IVsWindowFrame[]  frames = new IVsWindowFrame[1];
            uint              numFrames;
            IEnumWindowFrames ppenum;

            UIShell.GetDocumentWindowEnum(out ppenum);

            while (ppenum.Next(1, frames, out numFrames) == VSConstants.S_OK && numFrames == 1)
            {
                var    frame = frames[0] as IVsWindowFrame;
                object title;
                frame.GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out title);
                var window = VsShellUtilities.GetWindowObject(frame);

                if (window.Caption.StartsWith("Merge - ") || window.Caption.StartsWith("Diff - "))
                {
                    if (!_attachedFrames.ContainsKey(frame))
                    {
                        window.IsFloating = true;
                        var windowEvents = new ToolWindowEvents(frame);
                        windowEvents.OnDockableChange = (fDockable, x, y, w, h) =>
                        {
                            if (_attachedFrames.ContainsKey(frame) && !_attachedFrames[frame])
                            {
                                try
                                {
                                    _attachedFrames[frame] = true;
                                    if (fDockable)
                                    {
                                        window.IsFloating = true;
                                    }
                                }
                                catch (Exception)
                                {
                                }
                                finally
                                {
                                    _attachedFrames[frame] = false;
                                }
                            }
                            return(VSConstants.S_OK);
                        };
                        windowEvents.OnClose = (options) =>
                        {
                            windowEvents.OnDockableChange = null;
                            windowEvents.OnClose          = null;
                            _attachedFrames.Remove(frame);
                            windowEvents.Dispose();
                            return(VSConstants.S_OK);
                        };
                        try
                        {
                            frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, windowEvents);
                            _attachedFrames[frame] = false;
                        }
                        catch (Exception ex)
                        {
                            SimpleLogger.Log(ex, true);
                        }
                    }
                }
            }
        }