public VSCodeEditorWindow(ServiceBroker sb, UserControl parent) { services = sb; coreEditor = new VSCodeEditor(parent.Handle, services); //Create window IVsCodeWindow win = coreEditor.CodeWindow; cmdTarget = win as IOleCommandTarget; IVsTextView textView; int hr = win.GetPrimaryView(out textView); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } // assign the window handle IntPtr commandHwnd = textView.GetWindowHandle(); AssignHandle(commandHwnd); //Register priority command target hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget( 0, (IOleCommandTarget)this, out cmdTargetCookie); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } //Add message filter Application.AddMessageFilter((System.Windows.Forms.IMessageFilter) this); }
/// <summary> /// Initializes the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="editor">The generic editor.</param> public void Init(ServiceProvider serviceProvider, BaseEditorControl editor) { Editor = editor; ServiceBroker sb = new ServiceBroker(serviceProvider); _nativeWindow = new VSCodeEditorWindow(sb, this); }
public void Dispose() { //Remove message filter Application.RemoveMessageFilter((System.Windows.Forms.IMessageFilter) this); if (services != null) { // Remove this object from the list of the priority command targets. if (cmdTargetCookie != 0) { IVsRegisterPriorityCommandTarget register = services.VsRegisterPriorityCommandTarget; if (null != register) { int hr = register.UnregisterPriorityCommandTarget(cmdTargetCookie); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } } cmdTargetCookie = 0; } services = null; } if (coreEditor != null) { IVsCodeWindow win = coreEditor.CodeWindow; win.Close(); coreEditor = null; } }
/// <summary> /// Initializes a new instance of the <see cref="VSCodeEditor"/> class. /// </summary> /// <param name="windowParent">The parent window.</param> /// <param name="services">The services broker.</param> public VSCodeEditor(VSCodeEditorUserControl windowParent, ServiceBroker services) : this() { parent = windowParent; parentHandle = parent.Handle; this.services = services; CreateCodeWindow(); }
// this method must be externally synchronized internal static void CreateSingleton(ServiceBroker sb) { if (Broker != null) { throw new InvalidOperationException("The singleton broker has alreaby been created."); } Broker = new EditorBroker(sb); }
private EditorBroker(ServiceBroker sb) { // Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc. int hr = sb.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget(0, (IOleCommandTarget)this, out this.CmdTargetCookie); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } Dte = (DTE)sb.Site.GetService(typeof(DTE)); }
public VSCodeEditorWindow(ServiceBroker sb, VSCodeEditorUserControl parent) { Parent = parent; services = sb; coreEditor = new VSCodeEditor(Parent, services); //Create window IVsCodeWindow win = coreEditor.CodeWindow; cmdTarget = win as IOleCommandTarget; IVsTextView textView; int hr = win.GetPrimaryView(out textView); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } // assign the window handle IntPtr commandHwnd = textView.GetWindowHandle(); AssignHandle(commandHwnd); //// Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc. //hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget( // 0, (IOleCommandTarget)CommandBroker.Broker, out cmdTargetCookie); //if (hr != VSConstants.S_OK) // Marshal.ThrowExceptionForHR(hr); lock (typeof(EditorBroker)) { if (EditorBroker.Broker == null) { EditorBroker.CreateSingleton(services); } EditorBroker.RegisterEditor(this); } //Add message filter //Application.AddMessageFilter((System.Windows.Forms.IMessageFilter)this); }
public VSCodeEditor(IOleServiceProvider psp) : this() { services = new ServiceBroker(psp); CreateCodeWindow(); }
public VSCodeEditor(IntPtr parent, ServiceBroker services) : this() { parentHandle = parent; this.services = services; CreateCodeWindow(); }
public void Init(ServiceProvider serviceProvider) { ServiceBroker sb = new ServiceBroker(serviceProvider); nativeWindow = new VSCodeEditorWindow(sb, this); }