/// <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
        private IVsWindowFrame CreateChildEditorFrame(Guid guidEditorFactory, SplitterPanel panel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsUIShellOpenDocument vsUISHOD = GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            IVsWindowFrame      childFrame = null;
            IVsUIHierarchy      vsUIHier;
            uint                itemid;
            int                 fOpen;
            Guid                guidLogEditorView = Guid.Empty;
            IOleServiceProvider oleServiceProvider;

            int hr = vsUISHOD.IsSpecificDocumentViewOpen((IVsUIHierarchy)this.vsHierarchy, this.itemid, this.fileName, ref guidEditorFactory, null, 0, out vsUIHier, out itemid, out childFrame, out fOpen);

            if (ErrorHandler.Succeeded(hr) && fOpen != 0)
            {
                // if already open, create a copy
                hr = vsUISHOD.OpenCopyOfStandardEditor(childFrame, ref guidLogEditorView, out childFrame);
            }
            else
            {
                hr = vsUISHOD.OpenDocumentViaProjectWithSpecific(fileName,
                                                                 (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor | (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen,
                                                                 ref guidEditorFactory, null, ref guidLogEditorView, out oleServiceProvider, out vsUIHier, out itemid, out childFrame);
            }

            if (ErrorHandler.Failed(hr))
            {
                Debug.Fail("Failed to create/open editor!!!");
                Marshal.ThrowExceptionForHR(hr);
            }

            IVsWindowFrame parentFrame = GetService(typeof(SVsWindowFrame)) as IVsWindowFrame;

            if (parentFrame == null)
            {
                throw new System.InvalidOperationException("could not retrieve the parent Window Frame");
            }

            childFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentFrame, parentFrame);
            childFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this);
            childFrame.SetProperty((int)__VSFPROPID3.VSFPROPID_NotifyOnActivate, true);
            childFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_DontAutoOpen, true);
            childFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentHwnd, panel.Handle);

            Guid cmdUITextEditorGuid = VSConstants.GUID_TextEditorFactory;

            childFrame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref cmdUITextEditorGuid);

            return(childFrame);
        }
示例#3
0
 private void HostCSharpEditor()
 {
     if (_TextViewHost == null)
     {
         InitializeEditor(_CurrentScriptName);
     }
     if (_childWindowFrame != null)
     {
         //because VsShellUtilities.OpenDocumentWithSpecificEditor call Show, i should cause hide, before changing parent
         _childWindowFrame.Hide();
         var window = VsShellUtilities.GetWindowObject(parentWindowFrame);
         _childWindowFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentHwnd, window.HWnd);
         _childWindowFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_ParentFrame, parentWindowFrame);
     }
 }
示例#4
0
        public static WinForms.Panel    create_WinForms_Window(this string title, VSFRAMEMODE frameMode)
        {
            var visualStudio = new VisualStudio_2010();
            var _panel       = visualStudio.invokeOnThread(
                () =>
            {
                var type   = typeof(O2.FluentSharp.VisualStudio.WindowPane_WinForms);
                var window = (ToolWindowPane)visualStudio.package().invoke("CreateToolWindow", type, 64000.random());

                window.Caption             = title;
                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                //if(floating)
                //    windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Float);
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, frameMode);
                windowFrame.Show();
                var content         = (Control_WinForms)window.Content;
                var windowsFormHost = (System.Windows.Forms.Integration.WindowsFormsHost)content.Content;
                var panel           = new WinForms.Panel();
                panel.backColor("Control");
                windowsFormHost.Child = panel;
                return(panel);
            });

            return(_panel);
        }
        /// <summary>
        /// Creates a new instance from the specified frame
        /// </summary>
        /// <param name="frame"></param>
        public WindowFrame(IVsWindowFrame frame)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            _frame = frame ?? throw new ArgumentNullException("frame");

            ErrorHandler.ThrowOnFailure(_frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this));
        }
 private static void DockWindow(IVsWindowFrame windowFrame)
 {
     if (windowFrame == null)
     {
         return;
     }
     windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock);
 }
示例#7
0
        public override void Execute()
        {
            rm = new ResourceManager(typeof(Resources));

            CodeFile codeFile;
            IList <ISyntaxEntity> contextHierarchy;

            //Getting the code text from the active document
            var path     = TalkCodePackage.vsOperations.GetActiveDocumentPath();
            var codeText = TalkCodePackage.vsOperations.GetActiveDocumentCode();

            //Creating a language service
            var lService = new Language(path);

            try
            {
                //Parsing the code
                codeFile = lService.Parse(codeText, System.IO.Path.GetFileName(path));
            }
            catch (CodeTalkLanguageServiceException)
            {
                MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                int currentLineNumber = 0;

                currentLineNumber = TalkCodePackage.vsOperations.GetCurrentCursorPosition().lineNumber;
                contextHierarchy  = codeFile.GetContextAtLine(currentLineNumber) as IList <ISyntaxEntity>;

                if (0 == contextHierarchy.Count)
                {
                    MessageBox.Show(rm.GetString("NoContextString", CultureInfo.CurrentCulture) + " " + currentLineNumber.ToString(), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
                    return;
                }

                var entities = contextHierarchy.Reverse().ToList().ConvertAll(x => (ISyntaxEntity)x);

                ToolWindowPane listFunctionsWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(AccessibilityToolWindow), 0, true);

                if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
                {
                    MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
                }

                IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture));

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

                (listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(entities, rm.GetString("GetContextTitle", CultureInfo.CurrentCulture), false);
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("The cursor does not seem to be in code. please move the cursor and try again.", "CodeTalk", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#8
0
        public static void RenameDocument(ServiceProvider site, string oldName, string newName)
        {
            IVsRunningDocumentTable pRDT = (IVsRunningDocumentTable)site.QueryService(VsConstants.SID_SVsRunningDocumentTable, typeof(IVsRunningDocumentTable));
            IVsUIShellOpenDocument  doc  = (IVsUIShellOpenDocument)site.QueryService(VsConstants.SID_VsUIShellOpenDocument, typeof(IVsUIShellOpenDocument));
            IVsUIShell uiShell           = (IVsUIShell)site.QueryService(VsConstants.guidShellIID, typeof(IVsUIShell));

            if (pRDT == null || doc == null)
            {
                return;
            }

            IVsHierarchy pIVsHierarchy;
            uint         itemId;
            IntPtr       docData;
            uint         uiVsDocCookie;

            pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock,
                                     oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie);

            if (docData != IntPtr.Zero)
            {
                IntPtr pUnk = Marshal.GetIUnknownForObject(pIVsHierarchy);
                Guid   iid  = typeof(IVsHierarchy).GUID;
                IntPtr pHier;
                Marshal.QueryInterface(pUnk, ref iid, out pHier);
                try
                {
                    pRDT.RenameDocument(oldName, newName, pHier, itemId);
                }
                finally
                {
                    Marshal.Release(pHier);
                    Marshal.Release(pUnk);
                }

                string newCaption = Path.GetFileName(newName);

                // now we need to tell the windows to update their captions.
                IEnumWindowFrames ppenum;
                uiShell.GetDocumentWindowEnum(out ppenum);
                IVsWindowFrame[] rgelt = new IVsWindowFrame[1];
                uint             fetched;
                while (ppenum.Next(1, rgelt, out fetched) == 0 && fetched == 1)
                {
                    IVsWindowFrame windowFrame = rgelt[0];
                    object         data;
                    windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out data);
                    IntPtr ptr = Marshal.GetIUnknownForObject(data);
                    if (ptr == docData)
                    {
                        windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, newCaption);
                    }
                    Marshal.Release(ptr);
                }
                Marshal.Release(docData);
            }
        }
示例#9
0
 public static ToolWindowPane    as_Dock(this ToolWindowPane toolWindow)
 {
     if (toolWindow.notNull())
     {
         IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame;
         windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock);
     }
     return(toolWindow);
 }
示例#10
0
        // i wish we could simply do th:is:
        //VsShellUtilities.GetWindowObject(wf).Caption = some caption;
        // but its impossible. Exception is thrown  - invalid operation, bla bla.

        public static void SetDocumentWindowFrameCaptionWithLabel(this IVsWindowFrame wf,
                                                                  string vanillaTabCaption, string jumpLabel)
        {
            //TODO: (check for length (what if vanilla caption is shorter than label & decor ???!!!)
            var newCaption = PeasyMotionEdAdornment.getDocumentTabCaptionWithLabel(vanillaTabCaption, jumpLabel);

            wf.SetProperty((int)VsFramePropID.OverrideCaption, newCaption);
            //Debug.WriteLine($"WindowFrame oldCaption={vanillaTabCaption} => newCaption={newCaption}");
        }
示例#11
0
        /// <summary>
        /// Sets ToolWindowEvents instance as a listener for the VS events
        /// </summary>
        public void AddEventsListener()
        {
            IVsWindowFrame frame = (IVsWindowFrame)Frame;

            if (frame != null)
            {
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, windowEvents);
            }
        }
示例#12
0
        /// <summary>
        /// Updates all of the open windows that are editing this node's files to update their captions.
        /// </summary>
        /// <param name="newCaption">The new caption.</param>
        protected void UpdateOpenWindowCaptions(string newCaption)
        {
            // Get the environment's UI shell in preparation for enumerating the window frames.
            IVsUIShell        uiShell = this.ServiceProvider.GetVsUIShell(classType, "UpdateOpenWindowCaptions");
            IEnumWindowFrames enumerator;

            NativeMethods.ThrowOnFailure(uiShell.GetDocumentWindowEnum(out enumerator));
            IVsWindowFrame[] windowFrames = new IVsWindowFrame[1];
            uint             fetchCount;

            // Get the document data for this node (don't find by cookie because the document cookie
            // could have changed on a rename).
            DocumentInfo docInfo = Package.Instance.Context.RunningDocumentTable.FindByPath(this.AbsolutePath);

            if (docInfo == null)
            {
                // There's no need to rename any captions if the document isn't open.
                return;
            }

            IntPtr docData = Marshal.GetIUnknownForObject(docInfo.DocumentData);

            try
            {
                // Tell all of the windows to update their caption to the new file name.
                while (enumerator.Next(1, windowFrames, out fetchCount) == NativeMethods.S_OK && fetchCount == 1)
                {
                    IVsWindowFrame windowFrame = windowFrames[0];
                    object         documentDataObject;
                    NativeMethods.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out documentDataObject));
                    IntPtr pUnknownDocData = Marshal.GetIUnknownForObject(documentDataObject);
                    try
                    {
                        // We found a window frame that contains the document to rename.
                        if (pUnknownDocData == docData)
                        {
                            NativeMethods.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, newCaption));
                        }
                    }
                    finally
                    {
                        if (pUnknownDocData != IntPtr.Zero)
                        {
                            Marshal.Release(pUnknownDocData);
                        }
                    }
                }
            }
            finally
            {
                if (docData != IntPtr.Zero)
                {
                    Marshal.Release(docData);
                }
            }
        }
示例#13
0
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var toolWindow = _packageProvider.AsyncPackage.FindToolWindow(typeof(HistoryToolWindow), 0, true);

            _window = (IVsWindowFrame)toolWindow.Frame;
            _window.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(_window.Show());
        }
        public void ForceMDIDock()
        {
            IVsWindowFrame gettingStartedWindowFrame = (IVsWindowFrame)this.Frame;

            try
            {
                gettingStartedWindowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
            }
            catch { }
        }
        private static void HideWindow(IVsWindowFrame windowFrame)
        {
            if (windowFrame == null)
            {
                return;
            }

            // HACK! Internal code for setting FrameMode property will set to Docked if already in AutoHide mode.
            // To avoid this, ensure that the window's current FrameMode is not AutoHide. (Set to Dock if necessary.)
            if (IsAutoHideWindow(windowFrame))
            {
                // Temporarily Dock
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock);
            }

            // Hide window (Set to auto-hide)
            System.Diagnostics.Debug.WriteLine($"Hiding window: {GetWindowTitle(windowFrame)}");
            windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE2.VSFM_AutoHide);
        }
示例#16
0
            internal void SetWindowFrame(IVsWindowFrame windowFrame)
            {
                AssertIsForeground();

                if (_windowFrame != null)
                {
                    // We already have a window frame, and we don't expect to get a second one
                    return;
                }

                _windowFrame = windowFrame;

                // We'll override the window frame and never show it as dirty, even if there's an underlying edit
                windowFrame.SetProperty((int)__VSFPROPID2.VSFPROPID_OverrideDirtyState, false);
                windowFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_OverrideCaption, _generatedSourceHintName + " " + ServicesVSResources.generated_suffix);
                windowFrame.SetProperty((int)__VSFPROPID5.VSFPROPID_OverrideToolTip, _generatedSourceHintName + " " + string.Format(ServicesVSResources.generated_by_0_suffix, _generatorTypeName));

                EnsureWindowFrameInfoBarUpdated();
            }
示例#17
0
        public override void Execute()
        {
            rm = new ResourceManager(typeof(Resources));
            System.Diagnostics.Debug.WriteLine("Get Functions");

            IEnumerable <ISyntaxEntity> functions = new List <ISyntaxEntity>();
            CodeFile codeFile;

            //Getting the code text from the active document
            var path     = TalkCodePackage.vsOperations.GetActiveDocumentPath();
            var codeText = TalkCodePackage.vsOperations.GetActiveDocumentCode();

            //Creating a language service
            var lService = new Language(path);

            try
            {
                //Parsing the code
                codeFile = lService.Parse(codeText, path);
            }
            catch (CodeTalkLanguageServiceException)
            {
                MessageBox.Show(rm.GetString("CompilationErrorMessage", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Creating a function collector for getting all the functions
            var functionCollector = new FunctionCollector();

            functionCollector.VisitCodeFile(codeFile);

            //Getting all the functions
            functions = functionCollector.FunctionsInFile;

            if (0 == functions.Count())
            {
                MessageBox.Show(rm.GetString("NoFunctionsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
                return;
            }

            ToolWindowPane listFunctionsWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(AccessibilityToolWindow), 0, true);

            if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;

            windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));

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

            (listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(functions, rm.GetString("FunctionsListTitle", CultureInfo.CurrentCulture));
        }
示例#18
0
        /// <summary>
        /// Docks the specified frame window if it is currently floating.
        /// </summary>
        /// <remarks>Works in VS2010, does not appear to work in VS2008.</remarks>
        /// <param name="frame">The frame.</param>
        private static void DockWindowIfFloating(IVsWindowFrame frame)
        {
            // Get the current tool window frame mode.
            frame.GetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, out object currentFrameMode);

            // If currently floating, switch to dock mode.
            if ((VSFRAMEMODE)currentFrameMode == VSFRAMEMODE.VSFM_Float)
            {
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock);
            }
        }
示例#19
0
    // --------------------------------------------------------------------------------------------
    /// <summary>
    /// Creates a new instance of the class 
    /// </summary>
    /// <param name="frame"></param>
    // --------------------------------------------------------------------------------------------
    public WindowFrame(IVsWindowFrame frame)
    {
      if (frame == null)
      {
        throw new ArgumentNullException("frame");
      }
      _Frame = frame;

      // --- Set up event handlers
      ErrorHandler.ThrowOnFailure(_Frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this));
    }
示例#20
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the class
        /// </summary>
        /// <param name="frame"></param>
        // --------------------------------------------------------------------------------------------
        public WindowFrame(IVsWindowFrame frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException("frame");
            }
            _Frame = frame;

            // --- Set up event handlers
            ErrorHandler.ThrowOnFailure(_Frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this));
        }
示例#21
0
        public bool RunDiff(AnkhDiffArgs args)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            else if (!HasDiff)
            {
                throw new InvalidOperationException();
            }

            if (_ocw2 == null)
            {
                _ocw2 = GetInterfaceDelegate <OpenComparisonWindow2>(_type_IVsDifferenceService, _vsDifferenceService);
            }

            if (_ocw2 == null)
            {
                return(false);
            }

            uint flags = VSDIFFOPT_DetectBinaryFiles;

            if (TempPath != null)
            {
                if (SvnItem.IsBelowRoot(args.BaseFile, TempPath))
                {
                    flags |= VSDIFFOPT_LeftFileIsTemporary;
                }
                if (SvnItem.IsBelowRoot(args.MineFile, TempPath))
                {
                    flags |= VSDIFFOPT_RightFileIsTemporary;
                }
            }

            IVsWindowFrame frame = _ocw2(args.BaseFile, args.MineFile, args.Caption ?? args.MineTitle, "", args.BaseTitle, args.MineTitle, args.Label ?? "", null, flags);

            if (frame != null)
            {
                GC.KeepAlive(new DiffMergeInstance(this, frame));

                if (!args.ShowDiffAsDocument)
                {
                    frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, (int)VSFRAMEMODE.VSFM_Float);
                }

                return(true);
            }

            return(false);
        }
示例#22
0
        public void ShowSearchWindow2()
        {
            ToolWindowPane window = BabePackage.Current.FindToolWindow(typeof(SearchWndPane2), 0, true);

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

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, new WindowFrameSink(SearchWndPane2.Current)));

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
示例#23
0
        protected override void Load(string fileName, bool isReload)
        {
            base.Load(fileName, isReload);
            IVsRunningDocumentTable rdt = this.ServiceProvider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
            uint a, b, c, d, e, f, g, h; string x; IVsHierarchy pp; System.IntPtr docptr;

            rdt.GetDocumentInfo(this.Cookie, out a, out b, out c, out x, out pp, out d, out docptr);

            IVsWindowFrame frame = this.ServiceProvider.GetService(typeof(IVsWindowFrame)) as IVsWindowFrame;

            if (frame != null)
            {
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_EditorCaption, "bloogle");
            }
        }
示例#24
0
        /// <summary>
        /// Used to ReadOnly property for the Rich TextBox and correspondingly update the editor caption
        /// </summary>
        /// <param name="_isFileReadOnly">Indicates whether the file loaded is Read Only or not</param>
        private void SetReadOnly(bool _isFileReadOnly)
        {
            this.editorControl.IsEnabled = !_isFileReadOnly;

            //update editor caption with "[Read Only]" or "" as necessary
            IVsWindowFrame frame         = (IVsWindowFrame)GetService(typeof(SVsWindowFrame));
            string         editorCaption = "";

            if (_isFileReadOnly)
            {
                editorCaption = this.GetResourceString("@100");
            }
            ErrorHandler.ThrowOnFailure(frame.SetProperty((int)__VSFPROPID.VSFPROPID_EditorCaption, editorCaption));
            backupObsolete = true;
        }
示例#25
0
        public bool RunMerge(AnkhMergeArgs args)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            else if (!HasMerge)
            {
                throw new InvalidOperationException();
            }

            if (_ormw == null)
            {
                _ormw = GetInterfaceDelegate <OpenAndRegisterMergeWindow>(_type_IVsFileMergeService, _vsFileMergeService);
                _umw  = GetInterfaceDelegate <UnregisterMergeWindow>(_type_IVsFileMergeService, _vsFileMergeService);
                _qmws = GetInterfaceDelegate <QueryMergeWindowState>(_type_IVsFileMergeService, _vsFileMergeService);
            }

            if (_ormw == null || _umw == null || _qmws == null)
            {
                return(false);
            }

            int cookie;

            IVsWindowFrame frame = _ormw(args.TheirsFile, args.MineFile, args.BaseFile, args.MergedFile,
                                         Path.GetFileName(args.TheirsFile), Path.GetFileName(args.MineFile),
                                         Path.GetFileName(args.BaseFile), Path.GetFileName(args.MergedFile),
                                         args.TheirsTitle, args.MineTitle, args.BaseTitle, args.MergedTitle,
                                         Guid.Empty.ToString(), null, null, out cookie);

            if (frame != null)
            {
                GC.KeepAlive(new DiffMergeInstance(this, frame, _umw, _qmws, cookie));

                if (!args.ShowDiffAsDocument)
                {
                    frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, (int)VSFRAMEMODE.VSFM_Float);
                }

                return(true);
            }

            return(false);
        }
示例#26
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowToolWindow(object sender, EventArgs e)
        {
            // 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.package.FindToolWindow(typeof(ToolWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CmdUIGuid, ToolWindow.ToolWindowGuidString);
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
示例#27
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        protected override void MenuItemCallback(object sender, EventArgs e)
        {
            // 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 = Package.FindToolWindow(typeof(GraphWindow.IncludeGraphToolWindow), 0, true);

            if (window?.Frame == null)
            {
                Output.Instance.ErrorMsg("Failed to open BuildTime Graph window!");
            }
            else
            {
                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CmdUIGuid, GraphWindow.IncludeGraphToolWindow.GUIDString);
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
        }
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private async void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // 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.
            DTE2 dte = await this.ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE2;

            OutputsWindow.outputPane.Activate();

            try
            {
                ToolWindowPane window = this.package.FindToolWindow(typeof(WDotykCmd), 0, true);
                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                if (dte.Solution.Count != 0)
                {
                    if (dte.Solution.Projects.Count != 0)
                    // заполнить окно команды pack, вынести в отдельную функцию класса Filler
                    {
                        WDotykCmdControl wDotykCmdControl = window.Content as WDotykCmdControl;
                        Filler.fillPack(new PackBox()
                        {
                            //SolName = wDotykCmdControl.solution,
                            Conf           = wDotykCmdControl.PackConf,
                            ProjName       = wDotykCmdControl.PackProj,
                            OutpFolderName = wDotykCmdControl.PackOutp
                        }, dte.Solution, ref wDotykCmdControl.solution);
                    }
                }

                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSSETFRAMEPOS.SFP_fTab);
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (Exception)
            {
                MessageBox.Show("Не выбран проект");
            }
        }
示例#29
0
        /// <summary>
        /// Updates the caption for all windows associated to the document.
        /// </summary>
        /// <param name="site">The service provider.</param>
        /// <param name="caption">The new caption.</param>
        /// <param name="docData">The IUnknown interface to a document data object associated with a registered document.</param>
        public static void UpdateCaption(IServiceProvider site, string caption, IntPtr docData)
        {
            if (site == null)
            {
                throw new ArgumentNullException("site");
            }

            if (String.IsNullOrEmpty(caption))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "caption");
            }

            IVsUIShell uiShell = site.GetService(typeof(SVsUIShell)) as IVsUIShell;

            // We need to tell the windows to update their captions.
            IEnumWindowFrames windowFramesEnum;

            ErrorHandler.ThrowOnFailure(uiShell.GetDocumentWindowEnum(out windowFramesEnum));
            IVsWindowFrame[] windowFrames = new IVsWindowFrame[1];
            uint             fetched;

            while (windowFramesEnum.Next(1, windowFrames, out fetched) == VSConstants.S_OK && fetched == 1)
            {
                IVsWindowFrame windowFrame = windowFrames[0];
                object         data;
                ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out data));
                IntPtr ptr = Marshal.GetIUnknownForObject(data);
                try
                {
                    if (ptr == docData)
                    {
                        ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, caption));
                    }
                }
                finally
                {
                    if (ptr != IntPtr.Zero)
                    {
                        Marshal.Release(ptr);
                    }
                }
            }
        }
示例#30
0
 private IVsUserContext GetUserContext()
 {
     RecreateContext();
     if (_Context == null)
     {
         if (_ServiceProvider == null)
         {
             return(null);
         }
         IVsWindowFrame frame = (IVsWindowFrame)_ServiceProvider.GetService(typeof(IVsWindowFrame));
         if (frame != null)
         {
             object obj2;
             NativeMethods.ThrowOnFailure(frame.GetProperty(-3010, out obj2));
             _Context = (IVsUserContext)obj2;
         }
         if (_Context == null)
         {
             IVsMonitorUserContext context =
                 (IVsMonitorUserContext)_ServiceProvider.GetService(typeof(IVsMonitorUserContext));
             if (context != null)
             {
                 NativeMethods.ThrowOnFailure(context.CreateEmptyContext(out _Context));
                 if (((_Context != null) && (frame != null)) && IsToolWindow(frame))
                 {
                     NativeMethods.ThrowOnFailure(frame.SetProperty(-3010, _Context));
                 }
             }
         }
         if ((_SubContextList != null) && (_Context != null))
         {
             foreach (object obj3 in _SubContextList)
             {
                 HelpService service = obj3 as HelpService;
                 if (service != null)
                 {
                     service.RecreateContext();
                 }
             }
         }
     }
     return(_Context);
 }
示例#31
0
        public override void Execute()
        {
            rm = new ResourceManager(typeof(Resources));
            System.Diagnostics.Debug.WriteLine("Get Errors");

            var errors = new List <ISyntaxEntity>();

            //Getting the code text from the active document
            var path     = TalkCodePackage.vsOperations.GetActiveDocumentPath();
            var codeText = TalkCodePackage.vsOperations.GetActiveDocumentCode();

            //Creating a language service
            var lService = new Language(path);

            //Parse the code and get the list of errors
            errors = lService.GetDiagnostics(codeText).ToList().ConvertAll(error => (ISyntaxEntity)error);

            if (0 == errors.Count)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    MessageBox.Show(rm.GetString("NoErrorsString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkString", CultureInfo.CurrentCulture), MessageBoxButtons.OK);
                });
                return;
            }

            ToolWindowPane listFunctionsWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(AccessibilityToolWindow), 0, true);

            if ((null == listFunctionsWindow) || (null == listFunctionsWindow.Frame))
            {
                MessageBox.Show("Cannote create tool window", "Cannot create tool window", MessageBoxButtons.OK);
            }
            else
            {
                IVsWindowFrame windowFrame = (IVsWindowFrame)listFunctionsWindow.Frame;
                windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));

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

                (listFunctionsWindow as AccessibilityToolWindow).windowControl.SetListView(errors, rm.GetString("ErrorListTitle", CultureInfo.CurrentCulture));
            }
        }
示例#32
0
        /// <summary>
        /// Implements IVsProject3::TransferItem
        /// This function is called when an open miscellaneous file is being transferred
        /// to our project. The sequence is for the shell to call AddItemWithSpecific and
        /// then use TransferItem to transfer the open document to our project.
        /// </summary>
        /// <param name="oldMkDoc">Old document name</param>
        /// <param name="newMkDoc">New document name</param>
        /// <param name="frame">Optional frame if the document is open</param>
        /// <returns></returns>
        public virtual int TransferItem(string oldMkDoc, string newMkDoc, IVsWindowFrame frame)
        {
            // Fail if hierarchy already closed
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return VSConstants.E_FAIL;
            }
            //Fail if the document names passed are null.
            if (oldMkDoc == null || newMkDoc == null)
                return VSConstants.E_INVALIDARG;

            int hr = VSConstants.S_OK;
            VSDOCUMENTPRIORITY[] priority = new VSDOCUMENTPRIORITY[1];
            uint itemid = VSConstants.VSITEMID_NIL;
            uint cookie = 0;
            uint grfFlags = 0;

            IVsRunningDocumentTable pRdt = GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
            if (pRdt == null)
                return VSConstants.E_ABORT;

            string doc;
            int found;
            IVsHierarchy pHier;
            uint id, readLocks, editLocks;
            IntPtr docdataForCookiePtr = IntPtr.Zero;
            IntPtr docDataPtr = IntPtr.Zero;
            IntPtr hierPtr = IntPtr.Zero;

            // We get the document from the running doc table so that we can see if it is transient
            try
            {
                ErrorHandler.ThrowOnFailure(pRdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldMkDoc, out pHier, out id, out docdataForCookiePtr, out cookie));
            }
            finally
            {
                if (docdataForCookiePtr != IntPtr.Zero)
                    Marshal.Release(docdataForCookiePtr);
            }

            //Get the document info
            try
            {
                ErrorHandler.ThrowOnFailure(pRdt.GetDocumentInfo(cookie, out grfFlags, out readLocks, out editLocks, out doc, out pHier, out id, out docDataPtr));
            }
            finally
            {
                if (docDataPtr != IntPtr.Zero)
                    Marshal.Release(docDataPtr);
            }

            // Now see if the document is in the project. If not, we fail
            try
            {
                ErrorHandler.ThrowOnFailure(IsDocumentInProject(newMkDoc, out found, priority, out itemid));
                Debug.Assert(itemid != VSConstants.VSITEMID_NIL && itemid != VSConstants.VSITEMID_ROOT);
                hierPtr = Marshal.GetComInterfaceForObject(this, typeof(IVsUIHierarchy));
                // Now rename the document
                ErrorHandler.ThrowOnFailure(pRdt.RenameDocument(oldMkDoc, newMkDoc, hierPtr, itemid));
            }
            finally
            {
                if (hierPtr != IntPtr.Zero)
                    Marshal.Release(hierPtr);
            }

            //Change the caption if we are passed a window frame
            if (frame != null)
            {
                string caption = "%2";
                hr = frame.SetProperty((int)(__VSFPROPID.VSFPROPID_OwnerCaption), caption);
            }
            return hr;
        }
        /// <summary>
        /// Docks the specified frame window if it is currently floating.
        /// </summary>
        /// <remarks>Works in VS2010, does not appear to work in VS2008.</remarks>
        /// <param name="frame">The frame.</param>
        private static void DockWindowIfFloating(IVsWindowFrame frame)
        {
            // Get the current tool window frame mode.
            object currentFrameMode;
            frame.GetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, out currentFrameMode);

            // If currently floating, switch to dock mode.
            if ((VSFRAMEMODE)currentFrameMode == VSFRAMEMODE.VSFM_Float)
            {
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Dock);
            }
        }