예제 #1
0
 // Checks for the existence of a menu editor service and creates one if one does not already exist.
 // component - The IComponent to ensure has a context menu service.
 // XXX: Not sure exactly what this should do...
 //
 protected virtual void EnsureMenuEditorService(IComponent component)
 {
     if (this.menuEditorService == null && component is ContextMenu)
     {
         menuEditorService = (IMenuEditorService)GetService(typeof(IMenuEditorService));
     }
 }
 protected virtual void EnsureMenuEditorService(IComponent c)
 {
     if ((this.menuEditorService == null) && (c is ContextMenu))
     {
         this.menuEditorService = (IMenuEditorService) this.GetService(typeof(IMenuEditorService));
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
         if (host != null)
         {
             ToolStripAdornerWindowService service = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService));
             if (service != null)
             {
                 service.Dispose();
                 host.RemoveService(typeof(ToolStripAdornerWindowService));
             }
             host.Activated -= new EventHandler(this.OnDesignerActivate);
             host.Deactivated -= new EventHandler(this.OnDesignerDeactivate);
             if (this.componentTray != null)
             {
                 ISplitWindowService service2 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service2 != null)
                 {
                     service2.RemoveSplitWindow(this.componentTray);
                     this.componentTray.Dispose();
                     this.componentTray = null;
                 }
                 host.RemoveService(typeof(ComponentTray));
             }
             IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
             if (service3 != null)
             {
                 service3.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded);
                 service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
                 service3.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
             }
             if (this.undoEngine != null)
             {
                 this.undoEngine.Undoing -= new EventHandler(this.OnUndoing);
                 this.undoEngine.Undone -= new EventHandler(this.OnUndone);
             }
             if (this.toolboxCreator != null)
             {
                 IToolboxService service4 = (IToolboxService) this.GetService(typeof(IToolboxService));
                 if (service4 != null)
                 {
                     service4.RemoveCreator(axClipFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.DataFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.NestedToolboxItemFormat, host);
                 }
                 this.toolboxCreator = null;
             }
         }
         if (this.menuEditorService != null)
         {
             host.RemoveService(typeof(IMenuEditorService));
             this.menuEditorService = null;
         }
         ISelectionService service5 = (ISelectionService) this.GetService(typeof(ISelectionService));
         if (service5 != null)
         {
             service5.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         }
         if (this.behaviorService != null)
         {
             this.behaviorService.Dispose();
             this.behaviorService = null;
         }
         if (this.selectionManager != null)
         {
             this.selectionManager.Dispose();
             this.selectionManager = null;
         }
         if (this.componentTray != null)
         {
             if (host != null)
             {
                 ISplitWindowService service6 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service6 != null)
                 {
                     service6.RemoveSplitWindow(this.componentTray);
                 }
             }
             this.componentTray.Dispose();
             this.componentTray = null;
         }
         if (this.pbrsFwd != null)
         {
             this.pbrsFwd.Dispose();
             this.pbrsFwd = null;
         }
         if (this.frame != null)
         {
             this.frame.Dispose();
             this.frame = null;
         }
         if (this.commandSet != null)
         {
             this.commandSet.Dispose();
             this.commandSet = null;
         }
         if (this.inheritanceService != null)
         {
             this.inheritanceService.Dispose();
             this.inheritanceService = null;
         }
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.Dispose();
             this.inheritanceUI = null;
         }
         if (this.designBindingValueUIHandler != null)
         {
             IPropertyValueUIService service7 = (IPropertyValueUIService) this.GetService(typeof(IPropertyValueUIService));
             if (service7 != null)
             {
                 service7.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem));
                 service7 = null;
             }
             this.designBindingValueUIHandler.Dispose();
             this.designBindingValueUIHandler = null;
         }
         if (this.designerExtenders != null)
         {
             this.designerExtenders.Dispose();
             this.designerExtenders = null;
         }
         if (this.axTools != null)
         {
             this.axTools.Clear();
         }
         if (host != null)
         {
             host.RemoveService(typeof(BehaviorService));
             host.RemoveService(typeof(ToolStripAdornerWindowService));
             host.RemoveService(typeof(SelectionManager));
             host.RemoveService(typeof(IInheritanceService));
             host.RemoveService(typeof(IEventHandlerService));
             host.RemoveService(typeof(IOverlayService));
             host.RemoveService(typeof(ISplitWindowService));
             host.RemoveService(typeof(InheritanceUI));
         }
     }
     base.Dispose(disposing);
 }
예제 #4
0
		// Checks for the existence of a menu editor service and creates one if one does not already exist.
		// component - The IComponent to ensure has a context menu service.
		// XXX: Not sure exactly what this should do...
		//
		protected virtual void EnsureMenuEditorService (IComponent component)
		{
			if (this.menuEditorService == null && component is ContextMenu)
				menuEditorService = (IMenuEditorService) GetService (typeof (IMenuEditorService));
		}
예제 #5
0
        //****
        //****
        //**** 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;
            }
        }
        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;
            }
        }
예제 #7
0
 public MenuEditorService(DocumentDesigner objClientDocumentDesigner, IMenuEditorService objInternalClientDocumentDesigner)
 {
     this.menuEditorService = objInternalClientDocumentDesigner;
     this.parentDesigner    = objClientDocumentDesigner;
 }
 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;
     }
 }