protected override void Dispose(bool disposing)
            {
                if (disposing && this.surface != null)
                {
                    IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;
                    if (host != null && host.RootComponent != null)
                        WorkflowDesignerLoader.RemoveActivityFromDesigner(this.surface, host.RootComponent as Activity);

                    ReadonlyWorkflow workflowView = (Controls.Count > 0) ? Controls[0] as ReadonlyWorkflow : null;
                    Controls.Clear();
                    if (workflowView != null)
                    {
                        workflowView.Dispose();
                        workflowView = null;
                    }

                    this.surface.Dispose();
                    this.surface = null;
                }

                base.Dispose(disposing);
            }
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     base.SuspendLayout();
     this.surface = new PreviewDesignSurface(this.parent.serviceProvider);
     PreviewWorkflowDesignerLoader loader = new PreviewWorkflowDesignerLoader();
     this.surface.BeginLoad(loader);
     IDesignerHost service = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
     Activity activity = service.CreateComponent(System.Type.GetType("System.Workflow.Activities.SequentialWorkflowActivity, System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")) as Activity;
     activity.Name = "ThemeSequentialWorkflow";
     WorkflowDesignerLoader.AddActivityToDesigner(this.surface, activity);
     ReadonlyWorkflow workflow = new ReadonlyWorkflow(this.parent, this.surface) {
         TabStop = false,
         Dock = DockStyle.Fill
     };
     base.Controls.Add(workflow);
     service.Activate();
     base.ResumeLayout(true);
 }
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);

                SuspendLayout();

                this.surface = new PreviewDesignSurface(this.parent.serviceProvider);
                PreviewWorkflowDesignerLoader loader = new PreviewWorkflowDesignerLoader();
                this.surface.BeginLoad(loader);

                //Add the root activity
                IDesignerHost host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
                Debug.Assert(host != null);

                //
                Activity rootDecl = host.CreateComponent(Type.GetType(DesignerHelpers.SequentialWorkflowTypeRef)) as Activity;
                rootDecl.Name = "ThemeSequentialWorkflow";
                WorkflowDesignerLoader.AddActivityToDesigner(this.surface, rootDecl as Activity);

                //Create the readonly workflow
                ReadonlyWorkflow workflowView = new ReadonlyWorkflow(this.parent, this.surface as IServiceProvider);
                workflowView.TabStop = false;
                workflowView.Dock = DockStyle.Fill;
                Controls.Add(workflowView);

                host.Activate();

                ResumeLayout(true);
            }
 protected override void Dispose(bool disposing)
 {
     if (disposing && (this.surface != null))
     {
         IDesignerHost service = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
         if ((service != null) && (service.RootComponent != null))
         {
             WorkflowDesignerLoader.RemoveActivityFromDesigner(this.surface, service.RootComponent as Activity);
         }
         ReadonlyWorkflow workflow = (base.Controls.Count > 0) ? (base.Controls[0] as ReadonlyWorkflow) : null;
         base.Controls.Clear();
         if (workflow != null)
         {
             workflow.Dispose();
             workflow = null;
         }
         this.surface.Dispose();
         this.surface = null;
     }
     base.Dispose(disposing);
 }