/// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.IVsUIElementPane.CreateUIElementPane"]/*' /> /// <internalonly/> /// <devdoc> /// IVsUIElementPane implementation. /// </devdoc> int IVsUIElementPane.CreateUIElementPane(out object uiElement) { uiElement = null; if (InitializationMode != PaneInitializationMode.Uninitialized) { throw new InvalidOperationException("The WindowPane is already initialized"); } // Indicate to derived classes that IVsUIElementPane.CreateUIElementPane was used, and not IVsWindowPane.CreatePaneWindow InitializationMode = PaneInitializationMode.IVsUIElementPane; // We should call OnCreate one time for derived classes to pre-initialize themselves. // This should be called before accessing the Content or Window properties. OnCreate(); if (Content != null) { uiElement = Content; } else if (Window != null) { win32Wrapper = new UIWin32ElementWrapper(this); uiElement = win32Wrapper; } else { return(VSConstants.E_UNEXPECTED); } return(VSConstants.S_OK); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (win32Wrapper != null) { win32Wrapper.Dispose(); } win32Wrapper = null; IDisposable disposableWindow = null; if (Content != null) { disposableWindow = Content as IDisposable; } else { disposableWindow = Window as IDisposable; } if (disposableWindow != null) { try { disposableWindow.Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose window"); } } disposableWindow = null; if (_commandService != null && _commandService is IDisposable) { try { ((IDisposable)_commandService).Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose command service"); } } _commandService = null; if (_parentProvider != null) { _parentProvider = null; } if (_helpService != null) { _helpService = null; } // Do not clear _provider. SetSite will do it for us. _zombie = true; } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (win32Wrapper != null) win32Wrapper.Dispose(); win32Wrapper = null; IDisposable disposableWindow = null; if (Content != null) { disposableWindow = Content as IDisposable; } else { disposableWindow = Window as IDisposable; } if (disposableWindow != null) { try { disposableWindow.Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose window"); } } disposableWindow = null; if (_commandService != null && _commandService is IDisposable) { try { ((IDisposable)_commandService).Dispose(); } catch (Exception) { Debug.Fail("Failed to dispose command service"); } } _commandService = null; if (_parentProvider != null) _parentProvider = null; if (_helpService != null) _helpService = null; // Do not clear _provider. SetSite will do it for us. _zombie = true; } }
int IVsWindowPane.CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr hwnd) { if (InitializationMode != PaneInitializationMode.Uninitialized) throw new InvalidOperationException("The WindowPane is already initialized"); // Indicate to derived classes that IVsWindowPane.CreatePaneWindow was used, and not IVsUIElementPane.CreateUIElementPane InitializationMode = PaneInitializationMode.IVsWindowPane; // We should call OnCreate one time for derived classes to pre-initialize themselves. // This should be called before accessing the Content or Window properties. OnCreate(); hwnd = IntPtr.Zero; if (Content == null && Window == null) throw new InvalidOperationException("A WindowPane derived type must provide either a content control or a HWND. If the tool is WPF based IVsUIElementPane.CreteUIElement should be used."); int hresult = NativeMethods.S_OK; if (Content != null) { // This path is unusual in that the content of this frame is WPF but it is being requested as an HWND through this // obsolete API. Create a HwndSource wrapper around the FrameworkElement using the provided parent if (Content is FrameworkElement || Content is IVsUIWpfElement) { // Create a HwndSource for the the content HwndSource contentSource = new HwndSource(/* classStyle */ 0, NativeMethods.WS_CHILD | NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_VISIBLE, /* exStyle */ 0, /* x, y */ 0, 0, /* name */ "", // no name for this item. hwndParent); contentSource.SizeToContent = SizeToContent.Manual; if (Content is IVsUIWpfElement) { object element = null; ((IVsUIWpfElement)Content).CreateFrameworkElement(out element); contentSource.RootVisual = (FrameworkElement)element; } else { contentSource.RootVisual = (FrameworkElement)Content; } contentSource.Disposed += delegate(object sender, EventArgs e) { this.Dispose(); }; hwnd = contentSource.Handle; } // If the content is already win32 and impliments the IVsUIWin32Element, we have little to do else if (Content is IVsUIWin32Element) { hresult = ((IVsUIWin32Element)Content).Create(hwndParent, out hwnd); } } else if (Window != null) { // If our derived class provided a Win32 control, create it with the provided parent win32Wrapper = new UIWin32ElementWrapper(this); hresult = win32Wrapper.Create(hwndParent, out hwnd); } return hresult; }
/// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.IVsUIElementPane.CreateUIElementPane"]/*' /> /// <internalonly/> /// <devdoc> /// IVsUIElementPane implementation. /// </devdoc> int IVsUIElementPane.CreateUIElementPane(out object uiElement) { uiElement = null; if (InitializationMode != PaneInitializationMode.Uninitialized) throw new InvalidOperationException("The WindowPane is already initialized"); // Indicate to derived classes that IVsUIElementPane.CreateUIElementPane was used, and not IVsWindowPane.CreatePaneWindow InitializationMode = PaneInitializationMode.IVsUIElementPane; // We should call OnCreate one time for derived classes to pre-initialize themselves. // This should be called before accessing the Content or Window properties. OnCreate(); if (Content != null) uiElement = Content; else if (Window != null) { win32Wrapper = new UIWin32ElementWrapper(this); uiElement = win32Wrapper; } else return VSConstants.E_UNEXPECTED; return VSConstants.S_OK; }
int IVsWindowPane.CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr hwnd) { if (InitializationMode != PaneInitializationMode.Uninitialized) { throw new InvalidOperationException("The WindowPane is already initialized"); } // Indicate to derived classes that IVsWindowPane.CreatePaneWindow was used, and not IVsUIElementPane.CreateUIElementPane InitializationMode = PaneInitializationMode.IVsWindowPane; // We should call OnCreate one time for derived classes to pre-initialize themselves. // This should be called before accessing the Content or Window properties. OnCreate(); hwnd = IntPtr.Zero; if (Content == null && Window == null) { throw new InvalidOperationException("A WindowPane derived type must provide either a content control or a HWND. If the tool is WPF based IVsUIElementPane.CreteUIElement should be used."); } int hresult = NativeMethods.S_OK; if (Content != null) { // This path is unusual in that the content of this frame is WPF but it is being requested as an HWND through this // obsolete API. Create a HwndSource wrapper around the FrameworkElement using the provided parent if (Content is FrameworkElement || Content is IVsUIWpfElement) { // Create a HwndSource for the the content HwndSource contentSource = new HwndSource(/* classStyle */ 0, NativeMethods.WS_CHILD | NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_VISIBLE, /* exStyle */ 0, /* x, y */ 0, 0, /* name */ "", // no name for this item. hwndParent); contentSource.SizeToContent = SizeToContent.Manual; if (Content is IVsUIWpfElement) { object element = null; ((IVsUIWpfElement)Content).CreateFrameworkElement(out element); contentSource.RootVisual = (FrameworkElement)element; } else { contentSource.RootVisual = (FrameworkElement)Content; } contentSource.Disposed += delegate(object sender, EventArgs e) { this.Dispose(); }; hwnd = contentSource.Handle; } // If the content is already win32 and impliments the IVsUIWin32Element, we have little to do else if (Content is IVsUIWin32Element) { hresult = ((IVsUIWin32Element)Content).Create(hwndParent, out hwnd); } } else if (Window != null) { // If our derived class provided a Win32 control, create it with the provided parent win32Wrapper = new UIWin32ElementWrapper(this); hresult = win32Wrapper.Create(hwndParent, out hwnd); } return(hresult); }