/// <summary> /// Remove the current workflow from the designer /// </summary> private void ClearWorkflow() { if (_designSurface != null) { IDesignerHost designer = _designSurface.GetService( typeof(IDesignerHost)) as IDesignerHost; if (designer != null) { if (designer.Container.Components.Count > 0) { _wfLoader.RemoveFromDesigner(designer, designer.RootComponent as Activity); } } } if (_designSurface != null) { _designSurface.Dispose(); _designSurface = null; } if (_workflowView != null) { ISelectionService selectionService = ((IServiceProvider)_workflowView).GetService( typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { selectionService.SelectionChanged -= new EventHandler( selectionService_SelectionChanged); } Controls.Remove(_workflowView); _workflowView.Dispose(); _workflowView = null; } if (_toolboxControl != null) { Controls.Remove(_toolboxControl); } }