protected override void OnDragLeave(EventArgs e) { base.OnDragLeave(e); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnDragLeave()) { goto Label_0050; } } } Label_0050: this.dragDropInProgress = false; }
protected override void WndProc(ref Message m) { using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).ProcessMessage(m)) { break; } } if (m.Msg == 0x7b) { int lParam = (int) m.LParam; Point screenMenuPoint = (lParam != -1) ? new Point(lParam) : Control.MousePosition; foreach (WorkflowDesignerMessageFilter filter2 in data.Filters) { if (((IWorkflowDesignerMessageSink) filter2).OnShowContextMenu(screenMenuPoint)) { break; } } m.Result = IntPtr.Zero; return; } } if ((this.workflowToolTip != null) && (m.Msg == 0x4e)) { this.workflowToolTip.RelayParentNotify(ref m); } try { if (m.Result == IntPtr.Zero) { base.WndProc(ref m); } } catch (Exception exception) { if (exception != CheckoutException.Canceled) { DesignerHelpers.ShowError(this, exception); } } }
protected override void OnDragDrop(DragEventArgs dragEventArgs) { base.OnDragDrop(dragEventArgs); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, dragEventArgs)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnDragDrop(dragEventArgs)) { goto Label_004D; } } } Label_004D: this.dragDropInProgress = false; }
protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnMouseWheel(e)) { return; } } } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnMouseDoubleClick(e)) break; } } }
protected override void OnKeyUp(KeyEventArgs e) { using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnKeyUp(e)) { goto Label_0046; } } } Label_0046: if (!e.Handled) { base.OnKeyUp(e); } }
protected override void OnMouseCaptureChanged(EventArgs e) { base.OnMouseCaptureChanged(e); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnMouseCaptureChanged()) { return; } } } }
//This function will give snapshot of what is drawn on the screen at any point of time //It will scale and translate the designers and drawing based on the viewport data //We need this function in OnPaint and taking snapshot of magnifier bitmap //At the end of this function; the ViewPortData.MemoryBitmap will contain the bitmap of the //workflow to be drawn as per layout internal static void TakeWorkflowSnapShot(WorkflowView workflowView, ViewPortData viewPortData) { //Get the drawing canvas Bitmap memoryBitmap = viewPortData.MemoryBitmap; Debug.Assert(memoryBitmap != null); using (Graphics viewPortGraphics = Graphics.FromImage(memoryBitmap)) { //We set the highest quality interpolation so that we do not loose the image quality viewPortGraphics.SmoothingMode = SmoothingMode.HighQuality; viewPortGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; using (PaintEventArgs eventArgs = new PaintEventArgs(viewPortGraphics, viewPortData.LogicalViewPort)) { workflowView.ActiveLayout.OnPaint(eventArgs, viewPortData); } //Create the scaling matrix Matrix transformationMatrix = new Matrix(); transformationMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend); //When we draw on the viewport we draw in scaled and translated. //So that we minimize the calls to DrawImage //Make sure that we scale down the logical view port origin in order to take care of scaling factor //Before we select the transform factor we make sure that logicalviewport origin is scaled down Point[] logicalViewPortOrigin = new Point[] { viewPortData.LogicalViewPort.Location }; transformationMatrix.TransformPoints(logicalViewPortOrigin); //For performance improvement and to eliminate one extra DrawImage...we draw the designers on the viewport //bitmap with visual depth consideration transformationMatrix.Translate(-logicalViewPortOrigin[0].X + viewPortData.ShadowDepth.Width, -logicalViewPortOrigin[0].Y + viewPortData.ShadowDepth.Height, MatrixOrder.Append); //Select the transform into viewport graphics. //Viewport bitmap has the scaled and translated designers which we then map to //the actual graphics based on page layout viewPortGraphics.Transform = transformationMatrix; //Draw the designers on bitmap if (workflowView.RootDesigner != null) { using (Region clipRegion = new Region()) using (GraphicsPath designerPath = ActivityDesignerPaint.GetDesignerPath(workflowView.RootDesigner, false)) { Region oldRegion = viewPortGraphics.Clip; //First draw the grid and rectangle with the designer clip region clipRegion.MakeEmpty(); clipRegion.Union(designerPath); viewPortGraphics.Clip = clipRegion; AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; viewPortGraphics.FillRectangle(ambientTheme.BackgroundBrush, workflowView.RootDesigner.Bounds); if (ambientTheme.ShowGrid) ActivityDesignerPaint.DrawGrid(viewPortGraphics, workflowView.RootDesigner.Bounds); viewPortGraphics.Clip = oldRegion; //Then draw the root with clip region extended try { using (PaintEventArgs paintEventArgs = new PaintEventArgs(viewPortGraphics, viewPortData.LogicalViewPort)) { ((IWorkflowDesignerMessageSink)workflowView.RootDesigner).OnPaint(paintEventArgs, viewPortData.LogicalViewPort); } } catch (Exception e) { //Eat the exception thrown in draw Debug.WriteLine(e); } } } //Draw all the filters using (PaintEventArgs paintArgs = new PaintEventArgs(viewPortGraphics, workflowView.RootDesigner.Bounds)) { using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(workflowView, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { try { if (((IWorkflowDesignerMessageSink)filter).OnPaint(paintArgs, viewPortData.LogicalViewPort)) break; } catch (Exception e) { Debug.WriteLine(e); } } } } viewPortGraphics.Transform = new Matrix(); //Now that we have a bitmap which is bit offseted based visual depth we need to take copy of it //This is done so as to avoid expensive DrawImage call, what I am assuming here is that time it //will take to create a new bitmap from an existing one is less expensive in terms of speed than space //As you just need to copy bitmap bits in memory than to perform expesive Image Drawing operation if (!viewPortData.ShadowDepth.IsEmpty) { Bitmap temporaryBitmap = new Bitmap(memoryBitmap); //THEMETODO: WE JUST NEED TO GRAYSCALE THIS, RATHER THAN DRAWING A SHADOW //Now that we have taken a copy we will draw over the existing bitmap so that we can make it as shadow bitmap using (Brush shadowDepthBrush = new SolidBrush(Color.FromArgb(220, Color.White))) viewPortGraphics.FillRectangle(shadowDepthBrush, new Rectangle(Point.Empty, new Size(memoryBitmap.Size.Width - viewPortData.ShadowDepth.Width - 1, memoryBitmap.Size.Height - viewPortData.ShadowDepth.Height - 1))); //Now make sure that we draw the image from the temporary bitmap with white color set as transparent //so that we achive the 3D effect //Make sure that we take into consideration the transparency key ImageAttributes transparentColorKey = new ImageAttributes(); transparentColorKey.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Default); transparentColorKey.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Bitmap); viewPortGraphics.DrawImage(temporaryBitmap, new Rectangle(-viewPortData.ShadowDepth.Width, -viewPortData.ShadowDepth.Height, memoryBitmap.Width, memoryBitmap.Height), 0, 0, memoryBitmap.Width, memoryBitmap.Height, GraphicsUnit.Pixel, transparentColorKey); //Now dispose the temporary bitmap temporaryBitmap.Dispose(); } } }
private void OnScroll(object sender, EventArgs e) { //Lets speedup the scrolling logic InvalidateClientRectangle(Rectangle.Empty); ScrollBar scrollBar = sender as ScrollBar; if (scrollBar != null) { using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { try { ((IWorkflowDesignerMessageSink)filter).OnScroll(scrollBar, scrollBar.Value); } catch (Exception ex) { Debug.WriteLine(ex); } } } } }
protected override void OnDragEnter(DragEventArgs dragEventArgs) { base.OnDragEnter(dragEventArgs); this.dragDropInProgress = true; using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, dragEventArgs)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnDragEnter(dragEventArgs)) break; } } }
protected override void WndProc(ref Message m) { using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).ProcessMessage(m)) break; } const int WM_CONTEXTMENU = 0x007B; if (m.Msg == WM_CONTEXTMENU) { int LParam = (int)m.LParam; Point location = (LParam != -1) ? new Point(LParam) : Control.MousePosition; foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnShowContextMenu(location)) break; } //mark the message handled m.Result = IntPtr.Zero; //dont pass the message to the base but return immediatly return; } } if (this.workflowToolTip != null && m.Msg == NativeMethods.WM_NOTIFY) this.workflowToolTip.RelayParentNotify(ref m); try { if (m.Result == IntPtr.Zero) base.WndProc(ref m); } catch (Exception e) { if (e != CheckoutException.Canceled) DesignerHelpers.ShowError(this, e); } }
protected override void OnKeyDown(KeyEventArgs e) { using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnKeyDown(e)) break; } } if (!e.Handled) base.OnKeyDown(e); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnMouseLeave()) break; } } }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); Point clientPoint = PointToClient(Control.MousePosition); MouseEventArgs eventArgs = new MouseEventArgs(Control.MouseButtons, 1, clientPoint.X, clientPoint.Y, 0); using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, eventArgs)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { if (((IWorkflowDesignerMessageSink)filter).OnMouseEnter(eventArgs)) break; } } }
protected override void OnDragOver(DragEventArgs dragEventArgs) { base.OnDragOver(dragEventArgs); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, dragEventArgs)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnDragOver(dragEventArgs)) { return; } } } }
protected override void OnQueryContinueDrag(QueryContinueDragEventArgs qcdevent) { base.OnQueryContinueDrag(qcdevent); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, qcdevent)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnQueryContinueDrag(qcdevent)) { return; } } } }
protected override void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) { base.OnGiveFeedback(gfbevent); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, gfbevent)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnGiveFeedback(gfbevent)) { return; } } } }
private void OnScroll(object sender, EventArgs e) { this.InvalidateClientRectangle(Rectangle.Empty); ScrollBar bar = sender as ScrollBar; if (bar != null) { using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, e)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { try { ((IWorkflowDesignerMessageSink) filter).OnScroll(bar, bar.Value); } catch (Exception) { } } } } }
protected override void OnLayout(LayoutEventArgs levent) { base.OnLayout(levent); ScrollBar hScrollBar = this.HScrollBar; ScrollBar vScrollBar = this.VScrollBar; if (base.Controls.Contains(hScrollBar)) { hScrollBar.Bounds = new Rectangle(0, Math.Max(0, base.Height - SystemInformation.HorizontalScrollBarHeight), Math.Max(base.Width - (vScrollBar.Visible ? SystemInformation.VerticalScrollBarWidth : 0), 0), SystemInformation.HorizontalScrollBarHeight); } if (base.Controls.Contains(vScrollBar)) { vScrollBar.Bounds = new Rectangle(Math.Max(0, base.Width - SystemInformation.VerticalScrollBarWidth), 0, SystemInformation.VerticalScrollBarWidth, Math.Max(base.Height - (hScrollBar.Visible ? SystemInformation.HorizontalScrollBarHeight : 0), 0)); } if (this.toolContainer != null) { this.toolContainer.Location = new Point(base.Width - this.toolContainer.Width, 0); this.toolContainer.Height = base.Height - (hScrollBar.Visible ? hScrollBar.Height : 0); } using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, levent)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { ((IWorkflowDesignerMessageSink) filter).OnLayout(levent); } } using (Graphics graphics = base.CreateGraphics()) { this.activeLayout.Update(graphics, WorkflowLayout.LayoutUpdateReason.LayoutChanged); if (this.rootDesigner != null) { this.rootDesigner.Location = this.activeLayout.RootDesignerAlignment; } } this.UpdateScrollRange(); this.InvalidateClientRectangle(Rectangle.Empty); }
internal void OnThemeChange(object sender, EventArgs e) { this.ShadowDepth = WorkflowTheme.CurrentTheme.AmbientTheme.ShadowDepth; using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { try { ((IWorkflowDesignerMessageSink) filter).OnThemeChange(); } catch (Exception) { } } } base.PerformLayout(); }
protected override void OnMouseHover(EventArgs e) { base.OnMouseHover(e); Point point = base.PointToClient(Control.MousePosition); MouseEventArgs args = new MouseEventArgs(Control.MouseButtons, 1, point.X, point.Y, 0); using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(this, args)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { if (((IWorkflowDesignerMessageSink) filter).OnMouseHover(args)) { return; } } } }
internal static void TakeWorkflowSnapShot(WorkflowView workflowView, ViewPortData viewPortData) { Bitmap memoryBitmap = viewPortData.MemoryBitmap; using (Graphics graphics = Graphics.FromImage(memoryBitmap)) { graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; using (PaintEventArgs args = new PaintEventArgs(graphics, viewPortData.LogicalViewPort)) { workflowView.ActiveLayout.OnPaint(args, viewPortData); } Matrix matrix = new Matrix(); matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend); Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location }; matrix.TransformPoints(pts); matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append); graphics.Transform = matrix; if (workflowView.RootDesigner != null) { using (Region region = new Region()) { using (GraphicsPath path = ActivityDesignerPaint.GetDesignerPath(workflowView.RootDesigner, false)) { Region clip = graphics.Clip; region.MakeEmpty(); region.Union(path); graphics.Clip = region; AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; graphics.FillRectangle(ambientTheme.BackgroundBrush, workflowView.RootDesigner.Bounds); if (ambientTheme.ShowGrid) { ActivityDesignerPaint.DrawGrid(graphics, workflowView.RootDesigner.Bounds); } graphics.Clip = clip; try { using (PaintEventArgs args2 = new PaintEventArgs(graphics, viewPortData.LogicalViewPort)) { ((IWorkflowDesignerMessageSink) workflowView.RootDesigner).OnPaint(args2, viewPortData.LogicalViewPort); } } catch (Exception) { } } } } using (PaintEventArgs args3 = new PaintEventArgs(graphics, workflowView.RootDesigner.Bounds)) { using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(workflowView, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data.Filters) { try { if (((IWorkflowDesignerMessageSink) filter).OnPaint(args3, viewPortData.LogicalViewPort)) { goto Label_0230; } } catch (Exception) { } } } } Label_0230: graphics.Transform = new Matrix(); if (!viewPortData.ShadowDepth.IsEmpty) { Bitmap image = new Bitmap(memoryBitmap); using (Brush brush = new SolidBrush(Color.FromArgb(220, Color.White))) { graphics.FillRectangle(brush, new Rectangle(Point.Empty, new Size((memoryBitmap.Size.Width - viewPortData.ShadowDepth.Width) - 1, (memoryBitmap.Size.Height - viewPortData.ShadowDepth.Height) - 1))); } ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Default); imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Bitmap); graphics.DrawImage(image, new Rectangle(-viewPortData.ShadowDepth.Width, -viewPortData.ShadowDepth.Height, memoryBitmap.Width, memoryBitmap.Height), 0, 0, memoryBitmap.Width, memoryBitmap.Height, GraphicsUnit.Pixel, imageAttr); image.Dispose(); } } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); GraphicsContainer container = e.Graphics.BeginContainer(); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; bool flag = (this.viewPortBitmap == null) || (this.viewPortBitmap.Size != this.ViewPortSize); if (flag) { if (this.viewPortBitmap != null) { this.viewPortBitmap.Dispose(); } this.viewPortBitmap = new Bitmap(Math.Max(1, this.ViewPortSize.Width), Math.Max(1, this.ViewPortSize.Height), e.Graphics); } ViewPortData viewPortData = new ViewPortData { LogicalViewPort = this.ClientRectangleToLogical(new Rectangle(Point.Empty, this.ViewPortSize)), MemoryBitmap = this.viewPortBitmap, Scaling = new SizeF(this.ScaleZoomFactor, this.ScaleZoomFactor), Translation = this.ScrollPosition, ShadowDepth = new Size(this.shadowDepth, this.shadowDepth), ViewPortSize = this.ViewPortSize }; if ((this.layoutEventHandler == null) || flag) { TakeWorkflowSnapShot(this, viewPortData); } try { this.activeLayout.OnPaintWorkflow(e, viewPortData); } catch (Exception) { } using (WorkflowMessageDispatchData data2 = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in data2.Filters) { try { if (((IWorkflowDesignerMessageSink) filter).OnPaintWorkflowAdornments(e, this.ViewPortRectangle)) { goto Label_01A0; } } catch (Exception) { } } } Label_01A0: e.Graphics.EndContainer(container); e.Graphics.FillRectangle(SystemBrushes.Control, new Rectangle(base.Width - SystemInformation.VerticalScrollBarWidth, base.Height - SystemInformation.HorizontalScrollBarHeight, SystemInformation.VerticalScrollBarWidth, SystemInformation.HorizontalScrollBarHeight)); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //We set the highest quality interpolation so that we do not loose the image quality GraphicsContainer graphicsState = e.Graphics.BeginContainer(); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; bool takeWorkflowSnapShot = (this.viewPortBitmap == null || this.viewPortBitmap.Size != ViewPortSize); if (takeWorkflowSnapShot) { if (this.viewPortBitmap != null) this.viewPortBitmap.Dispose(); this.viewPortBitmap = new Bitmap(Math.Max(1, ViewPortSize.Width), Math.Max(1, ViewPortSize.Height), e.Graphics); } //Create viewport information and take the workflow snapshot before passing on the information to the active layout ViewPortData viewPortData = new ViewPortData(); viewPortData.LogicalViewPort = ClientRectangleToLogical(new Rectangle(Point.Empty, ViewPortSize)); viewPortData.MemoryBitmap = this.viewPortBitmap; viewPortData.Scaling = new SizeF(ScaleZoomFactor, ScaleZoomFactor); viewPortData.Translation = ScrollPosition; viewPortData.ShadowDepth = new Size(this.shadowDepth, this.shadowDepth); viewPortData.ViewPortSize = ViewPortSize; //capture the workflow onto in-memory bitmap if (this.layoutEventHandler == null || takeWorkflowSnapShot) WorkflowView.TakeWorkflowSnapShot(this, viewPortData); //copy workflow from the bitmap onto corresponding pages on the screen try { this.activeLayout.OnPaintWorkflow(e, viewPortData); } catch (Exception ex) { //If a layout throws an exception then we will not draw the layout // Debug.WriteLine(ex); } //If any of the message filters throws an exception we continue to draw using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(this, EventArgs.Empty)) { foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters) { try { if (((IWorkflowDesignerMessageSink)filter).OnPaintWorkflowAdornments(e, ViewPortRectangle)) break; } catch (Exception ex) { //Ignore the filter throwing the exception and continue to function Debug.WriteLine(ex); } } } e.Graphics.EndContainer(graphicsState); e.Graphics.FillRectangle(SystemBrushes.Control, new Rectangle(Width - SystemInformation.VerticalScrollBarWidth, Height - SystemInformation.HorizontalScrollBarHeight, SystemInformation.VerticalScrollBarWidth, SystemInformation.HorizontalScrollBarHeight)); }