public void LoadDocument(DesignerLoader designerLoader) { try { this.designerLoader = designerLoader; this.documentWindow = new SampleDocumentWindow(this); this.Load(false); } catch (Exception t) { Debug.Fail(t.ToString()); throw; } }
//**** //**** //**** IDisposable Implementation //**** //**** /// Disposes of the DesignContainer. This cleans up any objects we may be holding /// and removes any services that we created. public void Dispose() { // Dispose the loader before destroying the designer. Otherwise, the // act of destroying all the components on the designer surface will // be reflected in the loader, deleting the user's file. if (designerLoader != null) { try { designerLoader.Flush(); } catch (Exception e1) { Debug.Fail("Designer loader '" + designerLoader.GetType().Name + "' threw during Flush: " + e1.ToString()); e1 = null; } try { designerLoader.Dispose(); } catch (Exception e2) { Debug.Fail("Designer loader '" + designerLoader.GetType().Name + "' threw during Dispose: " + e2.ToString()); e2 = null; } designerLoader = null; } // Unload the document. UnloadDocument(); // No services after this! serviceContainer = null; // Now tear down all of our services. if (menuEditorService != null) { IDisposable d = menuEditorService as IDisposable; if (d != null) d.Dispose(); menuEditorService = null ; } if (selectionService != null) { IDisposable d = selectionService as IDisposable; if (d != null) d.Dispose(); selectionService = null; } if (menuCommandService != null) { IDisposable d = menuCommandService as IDisposable; if (d != null) d.Dispose(); menuCommandService = null; } if (toolboxService != null) { IDisposable d = toolboxService as IDisposable; if (d != null) d.Dispose(); toolboxService = null; } if (helpService != null) { IDisposable d = helpService as IDisposable; if (d != null) d.Dispose(); helpService = null; } if (referenceService != null) { IDisposable d = referenceService as IDisposable; if (d != null) d.Dispose(); referenceService = null; } // Destroy our document window. if (documentWindow != null) { documentWindow.Dispose(); documentWindow = null; } }
/// Load the contents of the designer public void LoadDocument(DesignerLoader designerLoader) { try { this.designerLoader = designerLoader; // Create the Design View documentWindow = new SampleDocumentWindow(this); // Load the document Load(false); } catch (Exception t) { Debug.Fail(t.ToString()); throw; } }
public void Dispose() { IDisposable d; if (this.designerLoader != null) { try { this.designerLoader.Flush(); } catch (Exception e1) { Debug.Fail("Designer loader '" + this.designerLoader.GetType().Name + "' threw during Flush: " + e1.ToString()); e1 = null; } try { this.designerLoader.Dispose(); } catch (Exception e2) { Debug.Fail("Designer loader '" + this.designerLoader.GetType().Name + "' threw during Dispose: " + e2.ToString()); e2 = null; } this.designerLoader = null; } this.UnloadDocument(); this.serviceContainer = null; if (this.menuEditorService != null) { d = this.menuEditorService as IDisposable; if (d != null) { d.Dispose(); } this.menuEditorService = null; } if (this.selectionService != null) { d = this.selectionService as IDisposable; if (d != null) { d.Dispose(); } this.selectionService = null; } if (this.menuCommandService != null) { d = this.menuCommandService as IDisposable; if (d != null) { d.Dispose(); } this.menuCommandService = null; } if (this.toolboxService != null) { d = this.toolboxService as IDisposable; if (d != null) { d.Dispose(); } this.toolboxService = null; } if (this.helpService != null) { d = this.helpService as IDisposable; if (d != null) { d.Dispose(); } this.helpService = null; } if (this.referenceService != null) { d = this.referenceService as IDisposable; if (d != null) { d.Dispose(); } this.referenceService = null; } if (this.documentWindow != null) { this.documentWindow.Dispose(); this.documentWindow = null; } }