Exemplo n.º 1
0
        protected override bool OnPaint(PaintEventArgs eventArgs, Rectangle viewPort, AmbientTheme ambientTheme)
        {
            bool messageHandled = false;

            if (this.draggedDesignerImages != null && DropTargetDesigner is FreeformActivityDesigner)
            {
                using (Region clipRegion = new Region(ActivityDesignerPaint.GetDesignerPath(ParentView.RootDesigner, false)))
                {
                    Region oldRegion = eventArgs.Graphics.Clip;
                    eventArgs.Graphics.Clip = clipRegion;

                    Point[] locations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities);
                    Debug.Assert(locations.Length == DraggedActivities.Count);
                    Debug.Assert(this.draggedDesignerImages.Count == DraggedActivities.Count);

                    for (int i = 0; i < this.draggedDesignerImages.Count; i++)
                    {
                        Size imageSize = this.draggedDesignerImages[i].Size;
                        ActivityDesignerPaint.DrawImage(eventArgs.Graphics, this.draggedDesignerImages[i], new Rectangle(new Point(locations[i].X - 2 * ambientTheme.Margin.Width, locations[i].Y - 2 * ambientTheme.Margin.Height), imageSize), new Rectangle(Point.Empty, imageSize), DesignerContentAlignment.Fill, 0.4f, false);
                    }

                    eventArgs.Graphics.Clip = oldRegion;
                }
            }
            else
            {
                messageHandled = base.OnPaint(eventArgs, viewPort, ambientTheme);
            }

            return(messageHandled);
        }
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics  graphics     = e.Graphics;
            Bitmap    memoryBitmap = viewPortData.MemoryBitmap;
            Rectangle rect         = new Rectangle(Point.Empty, memoryBitmap.Size);

            graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
            if (((base.parentView.RootDesigner != null) && (base.parentView.RootDesigner.Bounds.Width >= 0)) && (base.parentView.RootDesigner.Bounds.Height >= 0))
            {
                GraphicsContainer container = graphics.BeginContainer();
                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;
                using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.parentView.RootDesigner, false)))
                {
                    Region clip = graphics.Clip;
                    graphics.Clip = region;
                    AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
                    graphics.FillRectangle(Brushes.White, base.parentView.RootDesigner.Bounds);
                    if (ambientTheme.WorkflowWatermarkImage != null)
                    {
                        ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, base.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
                    }
                    graphics.Clip = clip;
                }
                graphics.EndContainer(container);
            }
        }
        //

        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;

            Debug.Assert(graphics != null);

            //Get the drawing canvas
            Bitmap memoryBitmap = viewPortData.MemoryBitmap;

            Debug.Assert(memoryBitmap != null);

            //Fill the background using the workspace color so that we communicate the paging concept
            Rectangle workspaceRectangle = new Rectangle(Point.Empty, memoryBitmap.Size);

            graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, workspaceRectangle);
            if (this.parentView.RootDesigner != null &&
                this.parentView.RootDesigner.Bounds.Width >= 0 && this.parentView.RootDesigner.Bounds.Height >= 0)
            {
                GraphicsContainer graphicsState = graphics.BeginContainer();

                //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
                graphics.Transform = transformationMatrix;

                using (Region clipRegion = new Region(ActivityDesignerPaint.GetDesignerPath(this.parentView.RootDesigner, false)))
                {
                    Region oldRegion = graphics.Clip;
                    graphics.Clip = clipRegion;

                    AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
                    graphics.FillRectangle(Brushes.White, this.parentView.RootDesigner.Bounds);

                    if (ambientTheme.WorkflowWatermarkImage != null)
                    {
                        ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, this.parentView.RootDesigner.Bounds, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, AmbientTheme.WatermarkTransparency, false);
                    }

                    graphics.Clip = oldRegion;
                }

                graphics.EndContainer(graphicsState);
            }
        }
Exemplo n.º 4
0
        protected override bool OnPaint(PaintEventArgs eventArgs, Rectangle viewPort, AmbientTheme ambientTheme)
        {
            bool flag = false;

            if ((this.draggedDesignerImages != null) && (base.DropTargetDesigner is FreeformActivityDesigner))
            {
                using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.ParentView.RootDesigner, false)))
                {
                    Region clip = eventArgs.Graphics.Clip;
                    eventArgs.Graphics.Clip = region;
                    Point[] pointArray = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities);
                    for (int i = 0; i < this.draggedDesignerImages.Count; i++)
                    {
                        Size size = this.draggedDesignerImages[i].Size;
                        ActivityDesignerPaint.DrawImage(eventArgs.Graphics, this.draggedDesignerImages[i], new Rectangle(new Point(pointArray[i].X - (2 * ambientTheme.Margin.Width), pointArray[i].Y - (2 * ambientTheme.Margin.Height)), size), new Rectangle(Point.Empty, size), DesignerContentAlignment.Fill, 0.4f, false);
                    }
                    eventArgs.Graphics.Clip = clip;
                    return(flag);
                }
            }
            return(base.OnPaint(eventArgs, viewPort, ambientTheme));
        }