protected override void OnUnload() { try { // Clear the vidyo panel reference _vidyoPanel = null; // Clean up the element host if (!_elementHost.IsDisposed) { _elementHost.Child = null; _elementHost.Dispose(); } _elementHost = null; // Close the debug window if (_window != null) { _window.Close(); } } catch (Exception ex) { VidyoIntegration.VidyoAddin.Trace.Main.exception(ex, ex.Message); } finally { base.OnUnload(); } }
/// <summary> /// Create and initialize an ElementHost object in an exception-safe way /// </summary> public static ElementHost CreateElementHost(System.Windows.UIElement child) { // see http://msdn.microsoft.com/en-us/library/ms182289(VS.100).aspx ElementHost host = null; ElementHost tempHost = null; try { tempHost = new ElementHost(); tempHost.AutoSize = true; tempHost.Dock = DockStyle.Fill; tempHost.Child = child; // if we're here, no exceptions occurred while calling initialization properties/methods host = tempHost; tempHost = null; // don't Dispose() in "finally" block } finally { // tempHost will be null UNLESS an exception occurred if (tempHost != null) { tempHost.Dispose(); // in the middle of an exception, clean up new()'d instance } } return(host); }
protected override void Dispose(bool disposing) { if (disposing) { _elementHost.Dispose(); } base.Dispose(disposing); }
/// <summary> /// Dispose the <see cref="ElementHost"/> /// </summary> public void Dispose() { if (_host != null) { _host.Controls.Clear(); _host.Child = null; _host.Dispose(); } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="FrameworkElementUITypeEditor"/> and optionally releases the managed resources. /// </summary> /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources. </param> protected virtual void Dispose(bool disposing) { if (disposing) { host.Resize -= HostResize; host.Dispose(); hostContainer.Dispose(); } }
public void SmartIsRemovedWhenElementHostIsDisposed() { workspace.Show(smartPart); Assert.AreEqual(1, workspace.SmartParts.Count); ElementHost host = catalog.Hosts[smartPart]; host.Dispose(); Assert.IsTrue(smartPart.IsDisposed); Assert.AreEqual(0, workspace.SmartParts.Count); }
internal void FreeEverything() { menuStrip1.Dispose(); fileToolStripMenuItem.Dispose(); closeToolStripMenuItem.Dispose(); TopPanel.Dispose(); ThreeDPanel.Dispose(); MainElementHost.Dispose(); textBox1.Dispose(); // ViewPort.Dispose(); // Scene; }
public void PreviousSmartPartActivatedWhenActiveElementHostDisposed() { MockWPFSmartPart smartPartA = new MockWPFSmartPart(); MockWPFSmartPart smartPartB = new MockWPFSmartPart(); workspace.Show(smartPartA); workspace.Show(smartPartB); ElementHost hostB = catalog.Hosts[smartPartB]; hostB.Dispose(); Assert.IsFalse(workspace.Contains(hostB)); Assert.AreSame(smartPartA, workspace.ActiveSmartPart); }
public void DisposeNonActiveElementHostDoesNotChangeActiveOne() { ControlSmartPart smartPartA = new ControlSmartPart(); ControlSmartPart smartPartB = new ControlSmartPart(); ControlSmartPart smartPartC = new ControlSmartPart(); workspace.Show(smartPartA); workspace.Show(smartPartB); workspace.Show(smartPartC); ElementHost hostB = catalog.Hosts[smartPartB]; hostB.Dispose(); Assert.AreSame(smartPartC, workspace.ActiveSmartPart); }
void Dispose(bool disposing) { if (!disposed) { disposed = true; // to prevent infinite loop. Probably elementHost should not be part of this class if (disposing) { // Dispose managed resources. elementHost.Dispose(); } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } disposed = true; }
public void Deactivate() { if (_snapshotDebugConfigManager != null) { _snapshotDebugConfigManager.ConfigurationChanged -= SnapshotDebugConfigManager_ConfigurationChanged; _snapshotDebugConfigManager = null; } if (_elementHost != null) { _elementHost.Child = null; _elementHost.Dispose(); _elementHost = null; } _pageSite = null; }
public static void DisposeWpfElement(UIElement e) { Server currentServer = Server.CurrentServer; if (currentServer != null) { PluginWindowManager pluginWindowManager = currentServer.PluginWindowManager; if ((pluginWindowManager != null) && (pluginWindowManager.Form != null)) { ElementHost host = pluginWindowManager.Form.Controls.OfType <ElementHost>().FirstOrDefault <ElementHost>(h => h.Child == e); if (host != null) { host.Dispose(); } } } }
public void Deactivate() { if (_elementHost != null) { _elementHost.Child = null; _elementHost.Dispose(); _elementHost = null; } if (_propertyPageControl != null) { _propertyPageControl.Dispose(); _propertyPageControl = null; } _pageSite = null; }
protected void DisposePage() { // 释放托管状态(托管对象)。 if (_host != null) { _host.Parent = null; _host.Child = null; _host.Dispose(); } Marshal.FinalReleaseComObject(Page); Marshal.FinalReleaseComObject(PMPageWinformHandle); Page = null; PMPageWinformHandle = null; _wpfGroup = null; _doc = null; App = null; }
void DisposeTextEditor() { if (textEditorHost == null) { return; } if (verticalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { verticalSplitContainer.Panel2.Controls.Remove(textEditorHost); } if (horizontalSplitContainer != null && horizontalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { horizontalSplitContainer.Panel2.Controls.Remove(textEditorHost); } textEditor.MouseDoubleClick -= TextEditorDoubleClick; textEditorHost.Dispose(); textEditorHost = null; }
protected override void Dispose(bool disposing) { try { if (disposing) { if (timer != null) { timer.Stop(); timer.Dispose(); timer = null; } RegisterIndependentView(false); if (editorControl != null) { editorControl.Dispose(); editorControl = null; } if (host != null) { host.Dispose(); host = null; } var builderDispose = builder as IDisposable; if (builderDispose != null) { builderDispose.Dispose(); } GC.SuppressFinalize(this); } } finally { base.Dispose(disposing); } }
public override void Dispose() { base.Dispose(); _nativeControl.Dispose(); }