private void ApplyToolWindowStateAction(WindowState windowState) { switch (windowState) { case WindowState.Nothing: break; case WindowState.Show: _windowFrame.Show(); break; case WindowState.ShowNoActivate: _windowFrame.ShowNoActivate(); break; case WindowState.Hide: Hide(); break; case WindowState.Close: _windowFrame.Hide(); break; default: throw new ArgumentOutOfRangeException(nameof(windowState)); } }
public override void ShowAndActivate() { _serviceProvider.GetUIThread().Invoke(() => { ErrorHandler.ThrowOnFailure(_pane.Activate()); if (_window != null) { ErrorHandler.ThrowOnFailure(_window.ShowNoActivate()); } }); }
public void bringToFront() { IVsWindowFrame frame = Frame as IVsWindowFrame; int onScreen = 0; if (frame != null) { frame.IsOnScreen(out onScreen); } if (frame != null && onScreen == 0) { frame.ShowNoActivate(); } }
public override void ShowAndActivate() { try { GetUIThread(_serviceProvider).Invoke(() => { ErrorHandler.ThrowOnFailure(_pane.Activate()); if (_window != null) { ErrorHandler.ThrowOnFailure(_window.ShowNoActivate()); } }); } catch (Exception ex) when(!ex.IsCriticalException()) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); } }
protected void UpdatePropertyView(WorkitemDescriptor selectedItem) { //Try to get PropertiesFrame if (propertiesFrame == null) { var shell = GetService <IVsUIShell>(typeof(SVsUIShell)); if (shell != null) { var guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out propertiesFrame); } } if (propertiesFrame == null) { return; } int visible; propertiesFrame.IsOnScreen(out visible); if (visible == 1) { propertiesFrame.ShowNoActivate(); // Show() in original } var selectionContainer = new SelectionContainer(); if (selectedItem != null) { selectionContainer.SelectedObjects = new object[] { selectedItem }; CurrentWorkitemId = selectedItem.Entity.Id; } else { CurrentWorkitemId = null; } var track = GetService <ITrackSelection>(typeof(STrackSelection)); if (track != null) { track.OnSelectChange(selectionContainer); } }
public void Execute() { IEnumerable <string> filesToLoad = _filesProvider.Get().Where(p => p.ToLower().EndsWith(".clj") || p.ToLower().EndsWith(".cljs")); if (filesToLoad.Count() == 0) { throw new Exception("No files to load."); } StringBuilder loadFileExpression = new StringBuilder("(map load-file '("); filesToLoad.ToList().ForEach(path => loadFileExpression.Append(" \"").Append(path.Replace("\\", "\\\\")).Append("\"")); loadFileExpression.Append("))"); _writer.WriteBehindTheSceneExpressionToRepl(loadFileExpression.ToString()); ErrorHandler.ThrowOnFailure(_replToolWindowFrame.ShowNoActivate()); }
public static void Show() { ThreadHelper.JoinableTaskFactory.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsUIShell uiShell = await ServiceProvider.GetGlobalServiceAsync <SVsUIShell, IVsUIShell>(); IVsWindowFrame outputWindowFrame = null; Guid outoutToolWindowGuid = new Guid("{ 0x34e76e81, 0xee4a, 0x11d0, {0xae, 0x2e, 0x00, 0xa0, 0xc9, 0x0f, 0xff, 0xc3 } }"); int hr = uiShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref outoutToolWindowGuid, out outputWindowFrame); if (ErrorHandler.Succeeded(hr) && outputWindowFrame != null) { hr = outputWindowFrame.ShowNoActivate(); if (ErrorHandler.Succeeded(hr) && OutputPane != null) { OutputPane.Activate(); } } }); }
protected int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction, bool reopen = false) { windowFrame = null; if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) { return(VSConstants.E_FAIL); } Debug.Assert(this.Node != null, "No node has been initialized for the document manager"); Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager"); Debug.Assert(this.Node is FileNode, "Node is not FileNode object"); int returnValue = VSConstants.S_OK; string caption = this.GetOwnerCaption(); string fullPath = this.GetFullPathForDocument(); IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; Assumes.Present(uiShellOpenDocument); IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; Assumes.Present(serviceProvider); var openState = uiShellOpenDocument as IVsUIShellOpenDocument3; bool showDialog = !reopen && (openState == null || !((__VSNEWDOCUMENTSTATE)openState.NewDocumentState).HasFlag(__VSNEWDOCUMENTSTATE.NDS_Provisional)); // Make sure that the file is on disk before we open the editor and display message if not found if (!((FileNode)this.Node).IsFileOnDisk(showDialog)) { // Bail since we are not able to open the item // Do not return an error code otherwise an internal error message is shown. The scenario for this operation // normally is already a reaction to a dialog box telling that the item has been removed. return(VSConstants.S_FALSE); } try { this.Node.ProjectMgr.OnOpenItem(fullPath); int result = VSConstants.E_FAIL; if (openWith) { result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { __VSOSEFLAGS openFlags = 0; if (newFile) { openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; } //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid // of the node being opened, otherwise the debugger doesn't work. if (editorType != Guid.Empty) { result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } } if (result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) { ErrorHandler.ThrowOnFailure(result); } if (windowFrame != null) { object var; if (newFile) { ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); IVsPersistDocData persistDocData = (IVsPersistDocData)var; ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); } var = null; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); this.Node.DocCookie = (uint)(int)var; if (windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(windowFrame.Show()); } else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate()); } else if (windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(windowFrame.Hide()); } } } catch (COMException e) { XSharpProjectPackage.Instance.DisplayException(e); returnValue = e.ErrorCode; CloseWindowFrame(ref windowFrame); } return(returnValue); }
private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) { windowFrame = null; if(this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) { return VSConstants.E_FAIL; } Debug.Assert(this.Node != null, "No node has been initialized for the document manager"); Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager"); Debug.Assert(this.Node is FileNode, "Node is not FileNode object"); int returnValue = VSConstants.S_OK; string caption = this.GetOwnerCaption(); string fullPath = this.GetFullPathForDocument(); // Make sure that the file is on disk before we open the editor and display message if not found if(!((FileNode)this.Node).IsFileOnDisk(true)) { // Inform clients that we have an invalid item (wrong icon) this.Node.OnInvalidateItems(this.Node.Parent); // Bail since we are not able to open the item // Do not return an error code otherwise an internal error message is shown. The scenario for this operation // normally is already a reaction to a dialog box telling that the item has been removed. return VSConstants.S_FALSE; } IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; try { this.Node.ProjectMgr.OnOpenItem(fullPath); int result = VSConstants.E_FAIL; if(openWith) { result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { __VSOSEFLAGS openFlags = 0; if(newFile) { openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; } //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid // of the node being opened, otherwise the debugger doesn't work. if(editorType != Guid.Empty) { result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } } if(result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) { ErrorHandler.ThrowOnFailure(result); } if(windowFrame != null) { object var; if(newFile) { ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); IVsPersistDocData persistDocData = (IVsPersistDocData)var; ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); } var = null; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); this.Node.DocCookie = (uint)(int)var; if(windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(windowFrame.Show()); } else if(windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate()); } else if(windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(windowFrame.Hide()); } } } catch(COMException e) { Trace.WriteLine("Exception e:" + e.Message); returnValue = e.ErrorCode; CloseWindowFrame(ref windowFrame); } return returnValue; }
private int OpenItem(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) { frame = null; if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) { return VSConstants.E_FAIL; } int result = VSConstants.S_OK; uint[] ppItemId = new uint[1]; ppItemId[0] = this.ID; int open; IVsUIHierarchy project; string fullPath = GetMkDocument(); // check if the file exists if (!System.IO.File.Exists(fullPath)) { // TODO Inform clients that we have an invalid item (wrong icon) //// Inform clients that we have an invalid item (wrong icon) //this.Node.OnInvalidateItems(this.Node.Parent); return VSConstants.S_FALSE; } IVsUIShellOpenDocument sod = (this.ProjectMgr as CogaenEditProject).Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (sod != null) { try { // try to get hold of the open file sod.IsDocumentOpen(this.ProjectMgr , this.ID , GetMkDocument() , ref logicalView /* LOGVIEWID_Code to show xml behind */ , (uint)__VSIDOFLAGS.IDO_ActivateIfOpen , out project , ppItemId , out frame , out open); // file is not open if (open == 0) { // TODO load doc data Load(fullPath, 0, 0); docDataExisting = Marshal.GetIUnknownForObject(ObjectBuilder); if (openWith) { result = sod.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog//(uint)__VSOSEFLAGS.OSE_ChooseBestStdEditor , GetMkDocument() , ref logicalView /* VSConstants.LOGVIEWID.Code_guid for xml behind*/ , Caption , this.ProjectMgr , this.ID // TODO pass docData!!!! , docDataExisting , this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider , out frame); } else { __VSOSEFLAGS openFlags = 0; if (newFile) { openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; } openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; if (editorType != Guid.Empty) { result = sod.OpenSpecificEditor(editorFlags , fullPath , ref editorType , physicalView , ref logicalView , Caption , this.ProjectMgr , this.ID , docDataExisting , this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider , out frame); } else { result = sod.OpenStandardEditor((uint)openFlags , GetMkDocument() , ref logicalView /* VSConstants.LOGVIEWID.Code_guid for xml behind*/ , Caption , this.ProjectMgr , this.ID , docDataExisting , this.ProjectMgr.Site as Microsoft.VisualStudio.OLE.Interop.IServiceProvider , out frame); } } if (result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) { ErrorHandler.ThrowOnFailure(result); } // eventually show window if (frame != null) { object var; if (newFile) { ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); IVsPersistDocData persistDocData = (IVsPersistDocData)var; ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); } var = null; ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); this.DocCookie = (uint)(int)var; if (windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(frame.Show()); } else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(frame.ShowNoActivate()); } else if (windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(frame.Hide()); } } } // file is already open else { ObjectBuilder = Marshal.GetObjectForIUnknown(docDataExisting) as ObjectBuilder; Marshal.Release(docDataExisting); if (frame != null) { if (windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(frame.Show()); } else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(frame.ShowNoActivate()); } else if (windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(frame.Hide()); } } } } catch (COMException e) { Trace.WriteLine("Exception e:" + e.Message); result = e.ErrorCode; CloseWindowFrame(ref frame); } } return result; }
private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) { windowFrame = null; if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) { return(VSConstants.E_FAIL); } Debug.Assert(this.Node != null, "No node has been initialized for the document manager"); Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager"); Debug.Assert(this.Node is FileNode, "Node is not FileNode object"); int returnValue = VSConstants.S_OK; string caption = this.GetOwnerCaption(); string fullPath = this.GetFullPathForDocument(); // Make sure that the file is on disk before we open the editor and display message if not found if (!((FileNode)this.Node).IsFileOnDisk(true)) { // Inform clients that we have an invalid item (wrong icon) this.Node.OnInvalidateItems(this.Node.Parent); // Bail since we are not able to open the item return(VSConstants.E_FAIL); } IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; try { this.Node.ProjectMgr.OnOpenItem(fullPath); int result = VSConstants.E_FAIL; if (openWith) { result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { __VSOSEFLAGS openFlags = 0; if (newFile) { openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; } //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid // of the node being opened, otherwise the debugger doesn't work. if (editorType != Guid.Empty) { result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } else { openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); } } if (result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) { ErrorHandler.ThrowOnFailure(result); } if (windowFrame != null) { object var; if (newFile) { ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); IVsPersistDocData persistDocData = (IVsPersistDocData)var; ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); } var = null; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); this.Node.DocCookie = (uint)(int)var; if (windowFrameAction == WindowFrameShowAction.Show) { ErrorHandler.ThrowOnFailure(windowFrame.Show()); } else if (windowFrameAction == WindowFrameShowAction.ShowNoActivate) { ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate()); } else if (windowFrameAction == WindowFrameShowAction.Hide) { ErrorHandler.ThrowOnFailure(windowFrame.Hide()); } } } catch (COMException e) { Trace.WriteLine("Exception e:" + e.Message); returnValue = e.ErrorCode; this.CloseWindowFrame(ref windowFrame); } return(returnValue); }
public void ShowNoActivate() { _windowFrame.ShowNoActivate(); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Shows or makes a window visible and brings it to the top, but does not make it the /// active window. /// </summary> /// <returns> /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// </returns> // -------------------------------------------------------------------------------------------- int IVsWindowFrame.ShowNoActivate() { return(_Frame.ShowNoActivate()); }