private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) { // Close the toolbar host. if (null != toolbarHost) { toolbarHost.Close(0); toolbarHost = null; } // Close and dispose the main pane. if (null != containedForm) { ((IVsWindowPane)containedForm).ClosePane(); containedForm = null; } // Check if we are still registered as priority command target if ((0 != commandTargetCookie) && (null != provider)) { IVsRegisterPriorityCommandTarget registerCommandTarget = GetService(typeof(SVsRegisterPriorityCommandTarget)) as IVsRegisterPriorityCommandTarget; if (null != registerCommandTarget) { registerCommandTarget.UnregisterPriorityCommandTarget(commandTargetCookie); } commandTargetCookie = 0; } if (null != e) { e.Cancel = false; } }
public override void OnToolWindowCreated() { base.OnToolWindowCreated(); var frame = (IVsWindowFrame)Frame; object ouhw; ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out ouhw)); // initialie w/ our hierarchy var hw = ouhw as IVsUIHierarchyWindow; _sessions = new SessionsNode((IServiceProvider)Package, hw); object punk; ErrorHandler.ThrowOnFailure(hw.Init( _sessions, (uint)(__UIHWINFLAGS.UIHWF_SupportToolWindowToolbars | __UIHWINFLAGS.UIHWF_InitWithHiddenParentRoot | __UIHWINFLAGS.UIHWF_HandlesCmdsAsActiveHierarchy), out punk )); // add our toolbar which is defined in our VSCT file object otbh; ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_ToolbarHost, out otbh)); IVsToolWindowToolbarHost tbh = otbh as IVsToolWindowToolbarHost; Guid guidPerfMenuGroup = GuidList.guidPythonProfilingCmdSet; ErrorHandler.ThrowOnFailure(tbh.AddToolbar(VSTWT_LOCATION.VSTWT_TOP, ref guidPerfMenuGroup, PkgCmdIDList.menuIdPerfToolbar)); }
/// <summary> /// Initialize here after we have the frame so we can grab the toolbar host /// </summary> protected override void Initialize() { base.Initialize(); IVsToolWindowToolbarHost host = ToolBarHost; Debug.Assert(host != null); // Should be set with HasToolbar true if (host != null) { CommandID command = ORMDesignerDocView.ORMDesignerCommandIds.ViewSamplePopulationEditor; Guid commandGuid = command.Guid; host.AddToolbar(VSTWT_LOCATION.VSTWT_LEFT, ref commandGuid, (uint)command.ID); } }
/// <summary> /// Initialize here after we have the frame so we can grab the toolbar host /// </summary> protected override void Initialize() { base.Initialize(); IVsToolWindowToolbarHost host = ToolBarHost; Debug.Assert(host != null); // Should be set with HasToolbar true if (host != null) { CommandID command = ORMDesignerDocView.ORMDesignerCommandIds.VerbalizationToolBar; Guid commandGuid = command.Guid; host.AddToolbar(VSTWT_LOCATION.VSTWT_LEFT, ref commandGuid, (uint)command.ID); } // create the string writer to hold the html StringBuilder builder = new StringBuilder(); myStringWriter = new StringWriter(builder, CultureInfo.CurrentCulture); UpdateVerbalization(); }
public override void OnToolBarAdded() { base.OnToolBarAdded(); if (ExtraToolBarId != AnkhToolBar.None) { IVsWindowFrame frame = (IVsWindowFrame)this.Frame; object obj; if (frame != null && VSErr.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_ToolbarHost, out obj))) { IVsToolWindowToolbarHost host = obj as IVsToolWindowToolbarHost; Guid g = AnkhId.CommandSetGuid; host.AddToolbar((VSTWT_LOCATION)ToolBarLocation, ref g, (uint)ExtraToolBarId); } } _twControl.OnFrameCreated(EventArgs.Empty); }
public int SetupToolbar(IntPtr hwnd, IVsToolWindowToolbar ptwt, out IVsToolWindowToolbarHost pptwth) { throw new NotImplementedException(); }
private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) { // Close the toolbar host. if (null != toolbarHost) { toolbarHost.Close(0); toolbarHost = null; } // Close and dispose the main pane. if (null != containedForm) { ((IVsWindowPane)containedForm).ClosePane(); containedForm = null; } // Check if we are still registered as priority command target if ( (0 != commandTargetCookie) && (null != provider) ) { IVsRegisterPriorityCommandTarget registerCommandTarget = GetService(typeof(SVsRegisterPriorityCommandTarget)) as IVsRegisterPriorityCommandTarget; if (null != registerCommandTarget) registerCommandTarget.UnregisterPriorityCommandTarget(commandTargetCookie); commandTargetCookie = 0; } if (null != e) e.Cancel = false; }
int IVsUIShell.SetupToolbar(IntPtr hwnd, IVsToolWindowToolbar ptwt, out IVsToolWindowToolbarHost pptwth) { throw new NotImplementedException(); }
/// <summary> /// Filters out a message before it is dispatched. /// </summary> /// <param name="m">The message to be dispatched. You cannot modify this message.</param> /// <returns> /// true to filter the message and stop it from being dispatched; false to allow the message to continue to the next filter or control. /// </returns> public bool PreFilterMessage(ref Message m) { int hr; IVsToolWindowToolbarHost host = _tbHost; if (host != null) { int lResult; hr = host.ProcessMouseActivationModal(m.HWnd, (uint)m.Msg, (uint)m.WParam, (int)m.LParam, out lResult); // Check for errors. if (VSErr.Succeeded(hr)) { // ProcessMouseActivationModal returns S_FALSE to stop the message processing, but this // function has to return true in this case. if (hr == VSErr.S_FALSE) { m.Result = (IntPtr)lResult; return(true); } } } if (!Enabled) { return(false); } const int WM_KEYFIRST = 0x0100; const int WM_IME_KEYLAST = 0x010F; const int WM_KEYDOWN = 0x0100; const int WM_KEYUP = 0x0101; //const int WM_CHAR = 0x0102; //const int WM_DEADCHAR = 0x0103; const int WM_SYSKEYDOWN = 0x0104; const int WM_SYSKEYUP = 0x0105; //const int WM_SYSCHAR = 0x0106; //const int WM_SYSDEADCHAR = 0x0107; //const int WM_UNICHAR = 0x0109; if (m.Msg < WM_KEYFIRST || m.Msg > WM_IME_KEYLAST) { return(false); // Only key translation below } VSContainerMode mode = _vsForm.ContainerMode; if (m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) { switch ((Keys)(int)m.WParam) { case Keys.Tab: if ((Control.ModifierKeys & Keys.Control) != 0) { return(false); // Navigation } break; case Keys.Return: if (Control.ModifierKeys == Keys.Control) { mode = VSContainerMode.Default; // No translate } break; case Keys.Escape: // Escape key should exit dialog return(false); } } if (m.Msg == WM_SYSKEYDOWN || m.Msg == WM_SYSKEYUP) { switch ((Keys)(int)m.WParam) { case Keys.F4: return(false); // Should close dialog } } MSG[] messages = new MSG[1]; messages[0].hwnd = m.HWnd; messages[0].lParam = m.LParam; messages[0].wParam = m.WParam; messages[0].message = (uint)m.Msg; if (_fKeys != null && 0 != (mode & (VSContainerMode.TranslateKeys | VSContainerMode.UseTextEditorScope))) { Guid cmdGuid; uint cmdCode; int cmdTranslated; int keyComboStarts; uint dwFlags = (uint)__VSTRANSACCELEXFLAGS.VSTAEXF_AllowModalState; if ((mode & VSContainerMode.UseTextEditorScope) != 0) { dwFlags |= (uint)__VSTRANSACCELEXFLAGS.VSTAEXF_UseTextEditorKBScope; } hr = _fKeys.TranslateAcceleratorEx(messages, dwFlags, 0, null, out cmdGuid, out cmdCode, out cmdTranslated, out keyComboStarts); if (hr == VSErr.S_OK) { if (cmdTranslated != 0) { return(true); } } } if (_paneList != null) { foreach (IVsWindowPane pane in _paneList) { if (pane.TranslateAccelerator(messages) == 0) { return(true); } } } if (!_vsWpf && (m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYDOWN || m.Msg == WM_SYSKEYUP)) { // The old text editor handled commands and then forwarded them anyway // With VS2010+ we assume that this is no longer a problem Control c = _form.ActiveControl; { IContainerControl cc; Control ac; while (null != (cc = c as IContainerControl) && null != (ac = cc.ActiveControl) && ac != cc) { c = ac; } } if (c != null) { IAnkhLegacyKeyMessageSuppressFilter filter = c as IAnkhLegacyKeyMessageSuppressFilter; if (filter != null && filter.PreFilterKeyMessage((Keys)(int)m.WParam)) { return(true); } } } return(false); }
int IVsUIShell.SetupToolbar(IntPtr hwnd, IVsToolWindowToolbar ptwt, out IVsToolWindowToolbarHost pptwth) { throw new Exception("The method or operation is not implemented."); }