public WorkflowView(IServiceProvider serviceProvider)
 {
     this.zoomLevel = 1f;
     this.shadowDepth = WorkflowTheme.CurrentTheme.AmbientTheme.ShadowDepth;
     this.stockMessageFilters = new List<WorkflowDesignerMessageFilter>();
     this.customMessageFilters = new List<WorkflowDesignerMessageFilter>();
     this.prePreviewZoom = 100;
     this.prePreviewScroll = Point.Empty;
     this.messageHitTestContexts = new Stack<System.Workflow.ComponentModel.Design.HitTestInfo>();
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     base.SuspendLayout();
     this.AllowDrop = true;
     this.AutoScroll = false;
     base.HScroll = false;
     base.VScroll = false;
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.EnableNotifyMessage | ControlStyles.AllPaintingInWmPaint | ControlStyles.Selectable | ControlStyles.Opaque | ControlStyles.UserPaint, true);
     this.serviceProvider = serviceProvider;
     IServiceContainer container = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
     if (container != null)
     {
         container.RemoveService(typeof(WorkflowView));
         container.AddService(typeof(WorkflowView), this);
     }
     IUIService service = this.serviceProvider.GetService(typeof(IUIService)) as IUIService;
     if (service != null)
     {
         WorkflowTheme.UIService = service;
     }
     this.EnsureScrollBars(new System.Windows.Forms.HScrollBar(), new System.Windows.Forms.VScrollBar());
     this.workflowToolTip = new WorkflowToolTip(this);
     WorkflowTheme.ThemeChanged += new EventHandler(this.OnThemeChange);
     this.PopulateMessageFilters(true);
     this.RootDesigner = ActivityDesigner.GetSafeRootDesigner(this);
     this.fitAllAction = this.CreateDynamicAction();
     if ((this.activeLayout == null) || (this.defaultLayout == null))
     {
         this.ActiveLayout = this.DefaultLayout = new WorkflowRootLayout(this.serviceProvider);
     }
     if (this.GetService(typeof(IMenuCommandService)) is IMenuCommandService)
     {
         this.commandSet = new System.Workflow.ComponentModel.Design.CommandSet(this);
         this.commandSet.UpdatePanCommands(true);
     }
     ISelectionService service3 = this.GetService(typeof(ISelectionService)) as ISelectionService;
     if (service3 != null)
     {
         service3.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     Application.AddMessageFilter(this);
     base.ResumeLayout(true);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             base.SuspendLayout();
             Application.RemoveMessageFilter(this);
             if (this.layoutEventHandler != null)
             {
                 this.Idle -= this.layoutEventHandler;
                 this.layoutEventHandler = null;
             }
             if (this.ensureVisibleEventHandler != null)
             {
                 this.Idle -= this.ensureVisibleEventHandler;
                 this.ensureVisibleEventHandler = null;
             }
             if (this.idleEventHandler != null)
             {
                 this.idleEventListeners = null;
                 Form topLevelControl = base.TopLevelControl as Form;
                 if (!Application.MessageLoop || ((topLevelControl != null) && topLevelControl.Modal))
                 {
                     WorkflowTimer.Default.Unsubscribe(this.idleEventHandler);
                 }
                 else
                 {
                     Application.Idle -= this.idleEventHandler;
                 }
                 this.idleEventHandler = null;
             }
             ISelectionService service = this.GetService(typeof(ISelectionService)) as ISelectionService;
             if (service != null)
             {
                 service.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
             }
             WorkflowTheme.ThemeChanged -= new EventHandler(this.OnThemeChange);
             if (this.fitAllAction != null)
             {
                 this.fitAllAction.Dispose();
                 this.fitAllAction = null;
             }
             if (this.workflowToolTip != null)
             {
                 ((IDisposable) this.workflowToolTip).Dispose();
                 this.workflowToolTip = null;
             }
             this.DisposeMessageFilters(false);
             this.DisposeMessageFilters(true);
             this.activeLayout = null;
             if (this.defaultLayout != null)
             {
                 this.defaultLayout.Dispose();
                 this.defaultLayout = null;
             }
             if (this.viewPortBitmap != null)
             {
                 this.viewPortBitmap.Dispose();
                 this.viewPortBitmap = null;
             }
             if (this.commandSet != null)
             {
                 this.commandSet.Dispose();
                 this.commandSet = null;
             }
             this.HScrollBar.ValueChanged -= new EventHandler(this.OnScroll);
             this.VScrollBar.ValueChanged -= new EventHandler(this.OnScroll);
             if (this.toolContainer != null)
             {
                 base.Controls.Remove(this.toolContainer);
                 this.toolContainer.TabStrip.Tabs.Clear();
                 this.toolContainer.Dispose();
                 this.toolContainer = null;
             }
             IServiceContainer container = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
             if (container != null)
             {
                 container.RemoveService(typeof(WorkflowView));
             }
         }
         finally
         {
             base.ResumeLayout(false);
         }
     }
     base.Dispose(disposing);
 }