コード例 #1
0
        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;
     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 OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     Rectangle destination = new Rectangle(Point.Empty, memoryBitmap.Size);
     ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, destination, destination, DesignerContentAlignment.Fill, 1f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
 }
コード例 #4
0
        //

        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);
            }
        }
コード例 #5
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics  graphics     = e.Graphics;
            Bitmap    memoryBitmap = viewPortData.MemoryBitmap;
            Rectangle destination  = new Rectangle(Point.Empty, memoryBitmap.Size);

            ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, destination, destination, DesignerContentAlignment.Fill, 1f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
        }
コード例 #6
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;

            Debug.Assert(graphics != null);

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

            Debug.Assert(memoryBitmap != null);
            Rectangle bitmapArea = new Rectangle(Point.Empty, memoryBitmap.Size);

            ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, bitmapArea, bitmapArea, DesignerContentAlignment.Fill, 1.0f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
        }
コード例 #7
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            base.OnPaint(e, viewPortData);

            Graphics graphics = e.Graphics;

            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;

                Rectangle rootBounds = this.parentView.RootDesigner.Bounds;
                graphics.ExcludeClip(rootBounds);
                rootBounds.Inflate(ActivityRootLayout.Separator.Width / 2, ActivityRootLayout.Separator.Height / 2);
                ActivityDesignerPaint.DrawDropShadow(graphics, rootBounds, AmbientTheme.WorkflowBorderPen.Color, AmbientTheme.DropShadowWidth, LightSourcePosition.Left | LightSourcePosition.Top, 0.2f, false);

                graphics.FillRectangle(WorkflowTheme.CurrentTheme.AmbientTheme.BackgroundBrush, rootBounds);
                graphics.DrawRectangle(AmbientTheme.WorkflowBorderPen, rootBounds);

                graphics.EndContainer(graphicsState);
            }
        }
コード例 #8
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics     graphics     = e.Graphics;
            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
            Bitmap       memoryBitmap = viewPortData.MemoryBitmap;

            graphics.FillRectangle(Brushes.White, new Rectangle(Point.Empty, memoryBitmap.Size));
            if (ambientTheme.WorkflowWatermarkImage != null)
            {
                GraphicsContainer container = graphics.BeginContainer();
                Matrix            matrix    = new Matrix();
                matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                matrix.Invert();
                Point[] pts = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
                matrix.TransformPoints(pts);
                Rectangle rect = new Rectangle(pts[0], new Size(pts[1]));
                matrix = new Matrix();
                matrix.Scale((viewPortData.Scaling.Width / ((float)base.parentView.Zoom)) * 100f, (viewPortData.Scaling.Height / ((float)base.parentView.Zoom)) * 100f);
                Matrix matrix2 = new Matrix();
                matrix2.Scale(((float)base.parentView.Zoom) / 100f, ((float)base.parentView.Zoom) / 100f);
                graphics.Transform = matrix2;
                foreach (PageLayoutData data in this.pageLayoutInfo)
                {
                    if (data.PageBounds.IntersectsWith(rect))
                    {
                        Rectangle empty = Rectangle.Empty;
                        empty.X      = data.LogicalPageBounds.X - viewPortData.LogicalViewPort.X;
                        empty.Y      = data.LogicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                        empty.Width  = data.LogicalPageBounds.Width;
                        empty.Height = data.LogicalPageBounds.Height;
                        pts          = new Point[] { empty.Location, new Point(empty.Size) };
                        matrix.TransformPoints(pts);
                        empty.Location = pts[0];
                        empty.Size     = new Size(pts[1]);
                        ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, empty, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
                    }
                }
                graphics.EndContainer(container);
            }
        }
 public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
 {
     base.OnPaint(e, viewPortData);
     Graphics graphics = e.Graphics;
     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;
         Rectangle bounds = base.parentView.RootDesigner.Bounds;
         graphics.ExcludeClip(bounds);
         bounds.Inflate(DefaultWorkflowLayout.Separator.Width / 2, DefaultWorkflowLayout.Separator.Height / 2);
         ActivityDesignerPaint.DrawDropShadow(graphics, bounds, AmbientTheme.WorkflowBorderPen.Color, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.2f, false);
         graphics.FillRectangle(WorkflowTheme.CurrentTheme.AmbientTheme.BackgroundBrush, bounds);
         graphics.DrawRectangle(AmbientTheme.WorkflowBorderPen, bounds);
         graphics.EndContainer(container);
     }
 }
コード例 #10
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            base.OnPaint(e, viewPortData);
            Graphics graphics = e.Graphics;

            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;
                Rectangle bounds = base.parentView.RootDesigner.Bounds;
                graphics.ExcludeClip(bounds);
                bounds.Inflate(DefaultWorkflowLayout.Separator.Width / 2, DefaultWorkflowLayout.Separator.Height / 2);
                ActivityDesignerPaint.DrawDropShadow(graphics, bounds, AmbientTheme.WorkflowBorderPen.Color, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.2f, false);
                graphics.FillRectangle(WorkflowTheme.CurrentTheme.AmbientTheme.BackgroundBrush, bounds);
                graphics.DrawRectangle(AmbientTheme.WorkflowBorderPen, bounds);
                graphics.EndContainer(container);
            }
        }
コード例 #11
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics          graphics     = e.Graphics;
            Bitmap            memoryBitmap = viewPortData.MemoryBitmap;
            AmbientTheme      ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
            GraphicsContainer container    = graphics.BeginContainer();
            Rectangle         rect         = new Rectangle(Point.Empty, memoryBitmap.Size);

            graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
            using (Font font = new Font(ambientTheme.Font.FontFamily, ambientTheme.Font.Size / this.scaling, ambientTheme.Font.Style))
            {
                int    num     = 0;
                Matrix matrix  = new Matrix();
                Matrix matrix2 = new Matrix();
                matrix2.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                matrix2.Invert();
                Point[] pts = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
                matrix2.TransformPoints(pts);
                matrix2.Invert();
                Rectangle rectangle2 = new Rectangle(pts[0], new Size(pts[1]));
                WorkflowPrintDocument.HeaderFooterData headerFooterPrintData = new WorkflowPrintDocument.HeaderFooterData {
                    HeaderFooterMargins = this.headerFooterMargins,
                    PrintTime           = this.previewTime,
                    TotalPages          = this.pageLayoutInfo.Count,
                    Scaling             = this.scaling,
                    Font = font
                };
                WorkflowDesignerLoader service = base.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                headerFooterPrintData.FileName = (service != null) ? service.FileName : string.Empty;
                Matrix matrix3 = new Matrix();
                matrix3.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                matrix3.Translate((float)-viewPortData.Translation.X, (float)-viewPortData.Translation.Y, MatrixOrder.Append);
                foreach (PageLayoutData data2 in this.pageLayoutInfo)
                {
                    num++;
                    if ((data2.PageBounds.IntersectsWith(rectangle2) && (data2.PageBounds.Width > 0)) && (data2.PageBounds.Height > 0))
                    {
                        graphics.Transform = matrix3;
                        graphics.FillRectangle(Brushes.White, data2.PageBounds);
                        ActivityDesignerPaint.DrawDropShadow(graphics, data2.PageBounds, Color.Black, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.2f, false);
                        Rectangle logicalPageBounds = data2.LogicalPageBounds;
                        logicalPageBounds.Intersect(viewPortData.LogicalViewPort);
                        if (!logicalPageBounds.IsEmpty)
                        {
                            graphics.Transform = matrix;
                            Point empty = Point.Empty;
                            empty.X = data2.ViewablePageBounds.X + Math.Abs((int)(data2.LogicalPageBounds.X - logicalPageBounds.X));
                            empty.Y = data2.ViewablePageBounds.Y + Math.Abs((int)(data2.LogicalPageBounds.Y - logicalPageBounds.Y));
                            pts     = new Point[] { empty };
                            matrix2.TransformPoints(pts);
                            empty = new Point(pts[0].X - viewPortData.Translation.X, pts[0].Y - viewPortData.Translation.Y);
                            Rectangle source = Rectangle.Empty;
                            source.X      = logicalPageBounds.X - viewPortData.LogicalViewPort.X;
                            source.Y      = logicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                            source.Width  = logicalPageBounds.Width;
                            source.Height = logicalPageBounds.Height;
                            pts           = new Point[] { source.Location, new Point(source.Size) };
                            matrix2.TransformPoints(pts);
                            source.Location = pts[0];
                            source.Size     = new Size(pts[1]);
                            ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, new Rectangle(empty, source.Size), source, DesignerContentAlignment.Fill, 1f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
                        }
                        graphics.Transform = matrix3;
                        graphics.DrawRectangle(Pens.Black, data2.PageBounds);
                        graphics.DrawRectangle(ambientTheme.ForegroundPen, (int)(data2.ViewablePageBounds.Left - 3), (int)(data2.ViewablePageBounds.Top - 3), (int)(data2.ViewablePageBounds.Width + 6), (int)(data2.ViewablePageBounds.Height + 6));
                        headerFooterPrintData.PageBounds = data2.PageBounds;
                        headerFooterPrintData.PageBoundsWithoutMargin = data2.ViewablePageBounds;
                        headerFooterPrintData.CurrentPage             = num;
                        if (this.printDocument.PageSetupData.HeaderTemplate.Length > 0)
                        {
                            this.printDocument.PrintHeaderFooter(graphics, true, headerFooterPrintData);
                        }
                        if (this.printDocument.PageSetupData.FooterTemplate.Length > 0)
                        {
                            this.printDocument.PrintHeaderFooter(graphics, false, headerFooterPrintData);
                        }
                    }
                }
                graphics.EndContainer(container);
            }
        }
 public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
     GraphicsContainer container = graphics.BeginContainer();
     Rectangle rect = new Rectangle(Point.Empty, memoryBitmap.Size);
     graphics.FillRectangle(AmbientTheme.WorkspaceBackgroundBrush, rect);
     using (Font font = new Font(ambientTheme.Font.FontFamily, ambientTheme.Font.Size / this.scaling, ambientTheme.Font.Style))
     {
         int num = 0;
         Matrix matrix = new Matrix();
         Matrix matrix2 = new Matrix();
         matrix2.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         matrix2.Invert();
         Point[] pts = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
         matrix2.TransformPoints(pts);
         matrix2.Invert();
         Rectangle rectangle2 = new Rectangle(pts[0], new Size(pts[1]));
         WorkflowPrintDocument.HeaderFooterData headerFooterPrintData = new WorkflowPrintDocument.HeaderFooterData {
             HeaderFooterMargins = this.headerFooterMargins,
             PrintTime = this.previewTime,
             TotalPages = this.pageLayoutInfo.Count,
             Scaling = this.scaling,
             Font = font
         };
         WorkflowDesignerLoader service = base.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
         headerFooterPrintData.FileName = (service != null) ? service.FileName : string.Empty;
         Matrix matrix3 = new Matrix();
         matrix3.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         matrix3.Translate((float) -viewPortData.Translation.X, (float) -viewPortData.Translation.Y, MatrixOrder.Append);
         foreach (PageLayoutData data2 in this.pageLayoutInfo)
         {
             num++;
             if ((data2.PageBounds.IntersectsWith(rectangle2) && (data2.PageBounds.Width > 0)) && (data2.PageBounds.Height > 0))
             {
                 graphics.Transform = matrix3;
                 graphics.FillRectangle(Brushes.White, data2.PageBounds);
                 ActivityDesignerPaint.DrawDropShadow(graphics, data2.PageBounds, Color.Black, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.2f, false);
                 Rectangle logicalPageBounds = data2.LogicalPageBounds;
                 logicalPageBounds.Intersect(viewPortData.LogicalViewPort);
                 if (!logicalPageBounds.IsEmpty)
                 {
                     graphics.Transform = matrix;
                     Point empty = Point.Empty;
                     empty.X = data2.ViewablePageBounds.X + Math.Abs((int) (data2.LogicalPageBounds.X - logicalPageBounds.X));
                     empty.Y = data2.ViewablePageBounds.Y + Math.Abs((int) (data2.LogicalPageBounds.Y - logicalPageBounds.Y));
                     pts = new Point[] { empty };
                     matrix2.TransformPoints(pts);
                     empty = new Point(pts[0].X - viewPortData.Translation.X, pts[0].Y - viewPortData.Translation.Y);
                     Rectangle source = Rectangle.Empty;
                     source.X = logicalPageBounds.X - viewPortData.LogicalViewPort.X;
                     source.Y = logicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                     source.Width = logicalPageBounds.Width;
                     source.Height = logicalPageBounds.Height;
                     pts = new Point[] { source.Location, new Point(source.Size) };
                     matrix2.TransformPoints(pts);
                     source.Location = pts[0];
                     source.Size = new Size(pts[1]);
                     ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, new Rectangle(empty, source.Size), source, DesignerContentAlignment.Fill, 1f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
                 }
                 graphics.Transform = matrix3;
                 graphics.DrawRectangle(Pens.Black, data2.PageBounds);
                 graphics.DrawRectangle(ambientTheme.ForegroundPen, (int) (data2.ViewablePageBounds.Left - 3), (int) (data2.ViewablePageBounds.Top - 3), (int) (data2.ViewablePageBounds.Width + 6), (int) (data2.ViewablePageBounds.Height + 6));
                 headerFooterPrintData.PageBounds = data2.PageBounds;
                 headerFooterPrintData.PageBoundsWithoutMargin = data2.ViewablePageBounds;
                 headerFooterPrintData.CurrentPage = num;
                 if (this.printDocument.PageSetupData.HeaderTemplate.Length > 0)
                 {
                     this.printDocument.PrintHeaderFooter(graphics, true, headerFooterPrintData);
                 }
                 if (this.printDocument.PageSetupData.FooterTemplate.Length > 0)
                 {
                     this.printDocument.PrintHeaderFooter(graphics, false, headerFooterPrintData);
                 }
             }
         }
         graphics.EndContainer(container);
     }
 }
 public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
 {
     Graphics graphics = e.Graphics;
     AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     graphics.FillRectangle(Brushes.White, new Rectangle(Point.Empty, memoryBitmap.Size));
     if (ambientTheme.WorkflowWatermarkImage != null)
     {
         GraphicsContainer container = graphics.BeginContainer();
         Matrix matrix = new Matrix();
         matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         matrix.Invert();
         Point[] pts = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
         matrix.TransformPoints(pts);
         Rectangle rect = new Rectangle(pts[0], new Size(pts[1]));
         matrix = new Matrix();
         matrix.Scale((viewPortData.Scaling.Width / ((float) base.parentView.Zoom)) * 100f, (viewPortData.Scaling.Height / ((float) base.parentView.Zoom)) * 100f);
         Matrix matrix2 = new Matrix();
         matrix2.Scale(((float) base.parentView.Zoom) / 100f, ((float) base.parentView.Zoom) / 100f);
         graphics.Transform = matrix2;
         foreach (PageLayoutData data in this.pageLayoutInfo)
         {
             if (data.PageBounds.IntersectsWith(rect))
             {
                 Rectangle empty = Rectangle.Empty;
                 empty.X = data.LogicalPageBounds.X - viewPortData.LogicalViewPort.X;
                 empty.Y = data.LogicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                 empty.Width = data.LogicalPageBounds.Width;
                 empty.Height = data.LogicalPageBounds.Height;
                 pts = new Point[] { empty.Location, new Point(empty.Size) };
                 matrix.TransformPoints(pts);
                 empty.Location = pts[0];
                 empty.Size = new Size(pts[1]);
                 ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, empty, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
             }
         }
         graphics.EndContainer(container);
     }
 }
コード例 #14
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;
            Debug.Assert(graphics != null);
            Bitmap memoryBitmap = viewPortData.MemoryBitmap;
            Debug.Assert(memoryBitmap != null);

            //Get the drawing canvas
            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            //We set the highest quality interpolation so that we do not loose the image quality
            GraphicsContainer graphicsState = graphics.BeginContainer();

            //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);

            using (Font headerFooterFont = new Font(ambientTheme.Font.FontFamily, ambientTheme.Font.Size / this.scaling, ambientTheme.Font.Style))
            {
                int currentPage = 0;
                Matrix emptyMatrix = new Matrix();

                //Create the transformation matrix and calculate the physical viewport without translation and scaling
                //We need to get the physical view port due to the fact that there can be circustances when zoom percentage
                //is very high, logical view port can be empty in such cases 
                Matrix coOrdTxMatrix = new Matrix();
                coOrdTxMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                coOrdTxMatrix.Invert();
                Point[] points = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
                coOrdTxMatrix.TransformPoints(points);
                coOrdTxMatrix.Invert();
                Rectangle physicalViewPort = new Rectangle(points[0], new Size(points[1]));

                //Create the data for rendering header/footer
                WorkflowPrintDocument.HeaderFooterData headerFooterData = new WorkflowPrintDocument.HeaderFooterData();
                headerFooterData.HeaderFooterMargins = this.headerFooterMargins;
                headerFooterData.PrintTime = this.previewTime;
                headerFooterData.TotalPages = this.pageLayoutInfo.Count;
                headerFooterData.Scaling = this.scaling;
                headerFooterData.Font = headerFooterFont;
                WorkflowDesignerLoader serviceDesignerLoader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                headerFooterData.FileName = (serviceDesignerLoader != null) ? serviceDesignerLoader.FileName : String.Empty;

                //Create the viewport transformation matrix
                Matrix viewPortMatrix = new Matrix();
                viewPortMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                viewPortMatrix.Translate(-viewPortData.Translation.X, -viewPortData.Translation.Y, MatrixOrder.Append);

                //We now have the viewport properly drawn, now we need to draw it on the actual graphics object
                //Now that we have the designer bitmap we start splicing it based on the pages
                //Note that this is quite expensive operation and hence one should try to use
                //The memory bitmap we have got is scaled appropriately
                foreach (PageLayoutData pageLayoutData in this.pageLayoutInfo)
                {
                    currentPage += 1;

                    //We do not draw the non intersecting pages, get the intersected viewport
                    //We purposely use the physical viewport here because, there are cases in which the viewport
                    //will not contain any logical bitmap areas in which case we atleast need to draw the pages properly
                    if (!pageLayoutData.PageBounds.IntersectsWith(physicalViewPort) || pageLayoutData.PageBounds.Width <= 0 || pageLayoutData.PageBounds.Height <= 0)
                        continue;

                    //******START PAGE DRAWING, FIRST DRAW THE OUTLINE
                    //Scale and translate so that we can draw the pages
                    graphics.Transform = viewPortMatrix;
                    graphics.FillRectangle(Brushes.White, pageLayoutData.PageBounds);
                    ActivityDesignerPaint.DrawDropShadow(graphics, pageLayoutData.PageBounds, Color.Black, AmbientTheme.DropShadowWidth, LightSourcePosition.Left | LightSourcePosition.Top, 0.2f, false);

                    //***START BITMAP SPLICING
                    //Draw spliced bitmap for the page if we have any displayable area
                    Rectangle intersectedViewPort = pageLayoutData.LogicalPageBounds;
                    intersectedViewPort.Intersect(viewPortData.LogicalViewPort);
                    if (!intersectedViewPort.IsEmpty)
                    {
                        //Make sure that we now clear the translation factor
                        graphics.Transform = emptyMatrix;
                        //Paint bitmap on the pages
                        //Now that the page rectangle is actually drawn, we will scale down the Location of page rectangle
                        //so that we can draw the viewport bitmap part on it
                        Point bitmapDrawingPoint = Point.Empty;
                        bitmapDrawingPoint.X = pageLayoutData.ViewablePageBounds.X + Math.Abs(pageLayoutData.LogicalPageBounds.X - intersectedViewPort.X);
                        bitmapDrawingPoint.Y = pageLayoutData.ViewablePageBounds.Y + Math.Abs(pageLayoutData.LogicalPageBounds.Y - intersectedViewPort.Y);
                        points = new Point[] { bitmapDrawingPoint };
                        coOrdTxMatrix.TransformPoints(points);
                        bitmapDrawingPoint = new Point(points[0].X - viewPortData.Translation.X, points[0].Y - viewPortData.Translation.Y);

                        //This is the area of the viewport bitmap we need to copy on the page
                        Rectangle viewPortBitmapArea = Rectangle.Empty;
                        viewPortBitmapArea.X = intersectedViewPort.X - viewPortData.LogicalViewPort.X;
                        viewPortBitmapArea.Y = intersectedViewPort.Y - viewPortData.LogicalViewPort.Y;
                        viewPortBitmapArea.Width = intersectedViewPort.Width;
                        viewPortBitmapArea.Height = intersectedViewPort.Height;

                        //This rectangle is in translated logical units, we need to scale it down
                        points = new Point[] { viewPortBitmapArea.Location, new Point(viewPortBitmapArea.Size) };
                        coOrdTxMatrix.TransformPoints(points);
                        viewPortBitmapArea.Location = points[0];
                        viewPortBitmapArea.Size = new Size(points[1]);

                        ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, new Rectangle(bitmapDrawingPoint, viewPortBitmapArea.Size), viewPortBitmapArea, DesignerContentAlignment.Fill, 1.0f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
                    }
                    //***END BITMAP SPLICING

                    //Draw the page outline
                    graphics.Transform = viewPortMatrix;
                    graphics.DrawRectangle(Pens.Black, pageLayoutData.PageBounds);

                    //Draw the printable page outline
                    graphics.DrawRectangle(ambientTheme.ForegroundPen, pageLayoutData.ViewablePageBounds.Left - 3, pageLayoutData.ViewablePageBounds.Top - 3, pageLayoutData.ViewablePageBounds.Width + 6, pageLayoutData.ViewablePageBounds.Height + 6);

                    //Draw the header and footer after we draw the actual page
                    headerFooterData.PageBounds = pageLayoutData.PageBounds;
                    headerFooterData.PageBoundsWithoutMargin = pageLayoutData.ViewablePageBounds;
                    headerFooterData.CurrentPage = currentPage;

                    //Draw the header
                    if (this.printDocument.PageSetupData.HeaderTemplate.Length > 0)
                        this.printDocument.PrintHeaderFooter(graphics, true, headerFooterData);

                    //Draw footer
                    if (this.printDocument.PageSetupData.FooterTemplate.Length > 0)
                        this.printDocument.PrintHeaderFooter(graphics, false, headerFooterData);
                    //***END DRAWING HEADER FOOTER
                }

                graphics.EndContainer(graphicsState);
            }
        }
コード例 #15
0
 public abstract void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData);
コード例 #16
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;

            Debug.Assert(graphics != null);
            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            //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
            graphics.FillRectangle(Brushes.White, new Rectangle(Point.Empty, memoryBitmap.Size));

            //Fill the background using the workspace color so that we communicate the paging concept
            //if there is no workflow watermark, just return
            if (ambientTheme.WorkflowWatermarkImage == null)
            {
                return;
            }

            //Create the transformation matrix and calculate the physical viewport without translation and scaling
            //We need to get the physical view port due to the fact that there can be circustances when zoom percentage
            //is very high, logical view port can be empty in such cases
            GraphicsContainer graphicsState = graphics.BeginContainer();
            Matrix            coOrdTxMatrix = new Matrix();

            coOrdTxMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
            coOrdTxMatrix.Invert();

            Point[] points = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
            coOrdTxMatrix.TransformPoints(points);
            Rectangle physicalViewPort = new Rectangle(points[0], new Size(points[1]));

            //because the watermark image needs to be scaled according to the zoom level, we
            //a) scale the graphics of the bitmap up by the zoom factor
            //a) scale the coordinates transform matrix down by the zoom factor
            coOrdTxMatrix = new Matrix();
            coOrdTxMatrix.Scale(viewPortData.Scaling.Width / (float)this.parentView.Zoom * 100.0f, viewPortData.Scaling.Height / (float)this.parentView.Zoom * 100.0f);

            //Make sure that we now clear the translation factor
            Matrix graphicsMatrics = new Matrix();

            graphicsMatrics.Scale((float)this.parentView.Zoom / 100.0f, (float)this.parentView.Zoom / 100.0f);
            graphics.Transform = graphicsMatrics;

            foreach (PageLayoutData pageLayoutData in this.pageLayoutInfo)
            {
                //We do not draw the non intersecting pages, get the intersected viewport
                //We purposely use the physical viewport here because, there are cases in which the viewport
                //will not contain any logical bitmap areas in which case we atleast need to draw the pages properly
                if (!pageLayoutData.PageBounds.IntersectsWith(physicalViewPort))
                {
                    continue;
                }

                //Draw the watermark into the in-memory bitmap
                //This is the area of the viewport bitmap we need to copy on the page
                Rectangle viewPortBitmapArea = Rectangle.Empty;
                viewPortBitmapArea.X      = pageLayoutData.LogicalPageBounds.X - viewPortData.LogicalViewPort.X;
                viewPortBitmapArea.Y      = pageLayoutData.LogicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                viewPortBitmapArea.Width  = pageLayoutData.LogicalPageBounds.Width;
                viewPortBitmapArea.Height = pageLayoutData.LogicalPageBounds.Height;

                //This rectangle is in translated logical units, we need to scale it down
                points = new Point[] { viewPortBitmapArea.Location, new Point(viewPortBitmapArea.Size) };
                coOrdTxMatrix.TransformPoints(points);
                viewPortBitmapArea.Location = points[0];
                viewPortBitmapArea.Size     = new Size(points[1]);

                ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, viewPortBitmapArea, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, AmbientTheme.WatermarkTransparency, false);
            }

            //Now clear the matrix
            graphics.EndContainer(graphicsState);
        }
コード例 #17
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;
            Debug.Assert(graphics != null);
            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            //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
            graphics.FillRectangle(Brushes.White, new Rectangle(Point.Empty, memoryBitmap.Size));

            //Fill the background using the workspace color so that we communicate the paging concept
            //if there is no workflow watermark, just return
            if (ambientTheme.WorkflowWatermarkImage == null)
                return;

            //Create the transformation matrix and calculate the physical viewport without translation and scaling
            //We need to get the physical view port due to the fact that there can be circustances when zoom percentage
            //is very high, logical view port can be empty in such cases 
            GraphicsContainer graphicsState = graphics.BeginContainer();
            Matrix coOrdTxMatrix = new Matrix();
            coOrdTxMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
            coOrdTxMatrix.Invert();

            Point[] points = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
            coOrdTxMatrix.TransformPoints(points);
            Rectangle physicalViewPort = new Rectangle(points[0], new Size(points[1]));

            //because the watermark image needs to be scaled according to the zoom level, we
            //a) scale the graphics of the bitmap up by the zoom factor
            //a) scale the coordinates transform matrix down by the zoom factor
            coOrdTxMatrix = new Matrix();
            coOrdTxMatrix.Scale(viewPortData.Scaling.Width / (float)this.parentView.Zoom * 100.0f, viewPortData.Scaling.Height / (float)this.parentView.Zoom * 100.0f);

            //Make sure that we now clear the translation factor
            Matrix graphicsMatrics = new Matrix();
            graphicsMatrics.Scale((float)this.parentView.Zoom / 100.0f, (float)this.parentView.Zoom / 100.0f);
            graphics.Transform = graphicsMatrics;

            foreach (PageLayoutData pageLayoutData in this.pageLayoutInfo)
            {
                //We do not draw the non intersecting pages, get the intersected viewport
                //We purposely use the physical viewport here because, there are cases in which the viewport
                //will not contain any logical bitmap areas in which case we atleast need to draw the pages properly
                if (!pageLayoutData.PageBounds.IntersectsWith(physicalViewPort))
                    continue;

                //Draw the watermark into the in-memory bitmap
                //This is the area of the viewport bitmap we need to copy on the page
                Rectangle viewPortBitmapArea = Rectangle.Empty;
                viewPortBitmapArea.X = pageLayoutData.LogicalPageBounds.X - viewPortData.LogicalViewPort.X;
                viewPortBitmapArea.Y = pageLayoutData.LogicalPageBounds.Y - viewPortData.LogicalViewPort.Y;
                viewPortBitmapArea.Width = pageLayoutData.LogicalPageBounds.Width;
                viewPortBitmapArea.Height = pageLayoutData.LogicalPageBounds.Height;

                //This rectangle is in translated logical units, we need to scale it down
                points = new Point[] { viewPortBitmapArea.Location, new Point(viewPortBitmapArea.Size) };
                coOrdTxMatrix.TransformPoints(points);
                viewPortBitmapArea.Location = points[0];
                viewPortBitmapArea.Size = new Size(points[1]);

                ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, viewPortBitmapArea, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, AmbientTheme.WatermarkTransparency, false);
            }

            //Now clear the matrix
            graphics.EndContainer(graphicsState);
        }
コード例 #18
0
 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();
         }
     }
 }
コード例 #19
0
        //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();
                }
            }
        }
コード例 #20
0
        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));
        }
コード例 #21
0
 public abstract void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData);
コード例 #22
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;

            Debug.Assert(graphics != null);
            Bitmap memoryBitmap = viewPortData.MemoryBitmap;

            Debug.Assert(memoryBitmap != null);

            //Get the drawing canvas
            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            //We set the highest quality interpolation so that we do not loose the image quality
            GraphicsContainer graphicsState = graphics.BeginContainer();

            //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);

            using (Font headerFooterFont = new Font(ambientTheme.Font.FontFamily, ambientTheme.Font.Size / this.scaling, ambientTheme.Font.Style))
            {
                int    currentPage = 0;
                Matrix emptyMatrix = new Matrix();

                //Create the transformation matrix and calculate the physical viewport without translation and scaling
                //We need to get the physical view port due to the fact that there can be circustances when zoom percentage
                //is very high, logical view port can be empty in such cases
                Matrix coOrdTxMatrix = new Matrix();
                coOrdTxMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                coOrdTxMatrix.Invert();
                Point[] points = new Point[] { viewPortData.Translation, new Point(viewPortData.ViewPortSize) };
                coOrdTxMatrix.TransformPoints(points);
                coOrdTxMatrix.Invert();
                Rectangle physicalViewPort = new Rectangle(points[0], new Size(points[1]));

                //Create the data for rendering header/footer
                WorkflowPrintDocument.HeaderFooterData headerFooterData = new WorkflowPrintDocument.HeaderFooterData();
                headerFooterData.HeaderFooterMargins = this.headerFooterMargins;
                headerFooterData.PrintTime           = this.previewTime;
                headerFooterData.TotalPages          = this.pageLayoutInfo.Count;
                headerFooterData.Scaling             = this.scaling;
                headerFooterData.Font = headerFooterFont;
                WorkflowDesignerLoader serviceDesignerLoader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                headerFooterData.FileName = (serviceDesignerLoader != null) ? serviceDesignerLoader.FileName : String.Empty;

                //Create the viewport transformation matrix
                Matrix viewPortMatrix = new Matrix();
                viewPortMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
                viewPortMatrix.Translate(-viewPortData.Translation.X, -viewPortData.Translation.Y, MatrixOrder.Append);

                //We now have the viewport properly drawn, now we need to draw it on the actual graphics object
                //Now that we have the designer bitmap we start splicing it based on the pages
                //Note that this is quite expensive operation and hence one should try to use
                //The memory bitmap we have got is scaled appropriately
                foreach (PageLayoutData pageLayoutData in this.pageLayoutInfo)
                {
                    currentPage += 1;

                    //We do not draw the non intersecting pages, get the intersected viewport
                    //We purposely use the physical viewport here because, there are cases in which the viewport
                    //will not contain any logical bitmap areas in which case we atleast need to draw the pages properly
                    if (!pageLayoutData.PageBounds.IntersectsWith(physicalViewPort) || pageLayoutData.PageBounds.Width <= 0 || pageLayoutData.PageBounds.Height <= 0)
                    {
                        continue;
                    }

                    //******START PAGE DRAWING, FIRST DRAW THE OUTLINE
                    //Scale and translate so that we can draw the pages
                    graphics.Transform = viewPortMatrix;
                    graphics.FillRectangle(Brushes.White, pageLayoutData.PageBounds);
                    ActivityDesignerPaint.DrawDropShadow(graphics, pageLayoutData.PageBounds, Color.Black, AmbientTheme.DropShadowWidth, LightSourcePosition.Left | LightSourcePosition.Top, 0.2f, false);

                    //***START BITMAP SPLICING
                    //Draw spliced bitmap for the page if we have any displayable area
                    Rectangle intersectedViewPort = pageLayoutData.LogicalPageBounds;
                    intersectedViewPort.Intersect(viewPortData.LogicalViewPort);
                    if (!intersectedViewPort.IsEmpty)
                    {
                        //Make sure that we now clear the translation factor
                        graphics.Transform = emptyMatrix;
                        //Paint bitmap on the pages
                        //Now that the page rectangle is actually drawn, we will scale down the Location of page rectangle
                        //so that we can draw the viewport bitmap part on it
                        Point bitmapDrawingPoint = Point.Empty;
                        bitmapDrawingPoint.X = pageLayoutData.ViewablePageBounds.X + Math.Abs(pageLayoutData.LogicalPageBounds.X - intersectedViewPort.X);
                        bitmapDrawingPoint.Y = pageLayoutData.ViewablePageBounds.Y + Math.Abs(pageLayoutData.LogicalPageBounds.Y - intersectedViewPort.Y);
                        points = new Point[] { bitmapDrawingPoint };
                        coOrdTxMatrix.TransformPoints(points);
                        bitmapDrawingPoint = new Point(points[0].X - viewPortData.Translation.X, points[0].Y - viewPortData.Translation.Y);

                        //This is the area of the viewport bitmap we need to copy on the page
                        Rectangle viewPortBitmapArea = Rectangle.Empty;
                        viewPortBitmapArea.X      = intersectedViewPort.X - viewPortData.LogicalViewPort.X;
                        viewPortBitmapArea.Y      = intersectedViewPort.Y - viewPortData.LogicalViewPort.Y;
                        viewPortBitmapArea.Width  = intersectedViewPort.Width;
                        viewPortBitmapArea.Height = intersectedViewPort.Height;

                        //This rectangle is in translated logical units, we need to scale it down
                        points = new Point[] { viewPortBitmapArea.Location, new Point(viewPortBitmapArea.Size) };
                        coOrdTxMatrix.TransformPoints(points);
                        viewPortBitmapArea.Location = points[0];
                        viewPortBitmapArea.Size     = new Size(points[1]);

                        ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, new Rectangle(bitmapDrawingPoint, viewPortBitmapArea.Size), viewPortBitmapArea, DesignerContentAlignment.Fill, 1.0f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
                    }
                    //***END BITMAP SPLICING

                    //Draw the page outline
                    graphics.Transform = viewPortMatrix;
                    graphics.DrawRectangle(Pens.Black, pageLayoutData.PageBounds);

                    //Draw the printable page outline
                    graphics.DrawRectangle(ambientTheme.ForegroundPen, pageLayoutData.ViewablePageBounds.Left - 3, pageLayoutData.ViewablePageBounds.Top - 3, pageLayoutData.ViewablePageBounds.Width + 6, pageLayoutData.ViewablePageBounds.Height + 6);

                    //Draw the header and footer after we draw the actual page
                    headerFooterData.PageBounds = pageLayoutData.PageBounds;
                    headerFooterData.PageBoundsWithoutMargin = pageLayoutData.ViewablePageBounds;
                    headerFooterData.CurrentPage             = currentPage;

                    //Draw the header
                    if (this.printDocument.PageSetupData.HeaderTemplate.Length > 0)
                    {
                        this.printDocument.PrintHeaderFooter(graphics, true, headerFooterData);
                    }

                    //Draw footer
                    if (this.printDocument.PageSetupData.FooterTemplate.Length > 0)
                    {
                        this.printDocument.PrintHeaderFooter(graphics, false, headerFooterData);
                    }
                    //***END DRAWING HEADER FOOTER
                }

                graphics.EndContainer(graphicsState);
            }
        }
コード例 #23
0
        //Gets the snapshot of the entire workflow
        private Bitmap TakeWorkflowSnapShot()
        {
            Bitmap bitmap = null;
            ActivityDesigner rootDesigner = RootDesigner;
            if (rootDesigner != null)
            {
                using (Graphics graphics = CreateGraphics())
                {
                    ViewPortData viewPortData = new ViewPortData();
                    viewPortData.LogicalViewPort = new Rectangle(Point.Empty, new Size(rootDesigner.Bounds.Width + 2 * DefaultWorkflowLayout.Separator.Width, rootDesigner.Bounds.Height + 2 * DefaultWorkflowLayout.Separator.Height));
                    viewPortData.MemoryBitmap = new Bitmap(viewPortData.LogicalViewPort.Width, viewPortData.LogicalViewPort.Height, graphics);
                    viewPortData.Scaling = new SizeF(1, 1);
                    viewPortData.Translation = Point.Empty;
                    viewPortData.ShadowDepth = new Size(0, 0);
                    viewPortData.ViewPortSize = viewPortData.LogicalViewPort.Size;
                    TakeWorkflowSnapShot(this, viewPortData);
                    bitmap = viewPortData.MemoryBitmap;
                }
            }

            return bitmap;
        }
コード例 #24
0
        //

        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);
            }
        }
コード例 #25
0
 private Bitmap TakeWorkflowSnapShot()
 {
     Bitmap bitmap = null;
     ActivityDesigner rootDesigner = this.RootDesigner;
     if (rootDesigner == null)
     {
         return bitmap;
     }
     using (Graphics graphics = base.CreateGraphics())
     {
         ViewPortData data;
         data = new ViewPortData {
             LogicalViewPort = new Rectangle(Point.Empty, new Size(rootDesigner.Bounds.Width + (2 * DefaultWorkflowLayout.Separator.Width), rootDesigner.Bounds.Height + (2 * DefaultWorkflowLayout.Separator.Height))),
             MemoryBitmap = new Bitmap(data.LogicalViewPort.Width, data.LogicalViewPort.Height, graphics),
             Scaling = new SizeF(1f, 1f),
             Translation = Point.Empty,
             ShadowDepth = new Size(0, 0),
             ViewPortSize = data.LogicalViewPort.Size
         };
         TakeWorkflowSnapShot(this, data);
         return data.MemoryBitmap;
     }
 }
コード例 #26
0
        public override void OnPaintWorkflow(PaintEventArgs e, ViewPortData viewPortData)
        {
            Graphics graphics = e.Graphics;
            Debug.Assert(graphics != null);

            //Get the drawing canvas
            Bitmap memoryBitmap = viewPortData.MemoryBitmap;
            Debug.Assert(memoryBitmap != null);
            Rectangle bitmapArea = new Rectangle(Point.Empty, memoryBitmap.Size);
            ActivityDesignerPaint.DrawImage(graphics, memoryBitmap, bitmapArea, bitmapArea, DesignerContentAlignment.Fill, 1.0f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale);
        }
コード例 #27
0
 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));
 }
コード例 #28
0
        public override void OnPaint(PaintEventArgs e, ViewPortData viewPortData)
        {
            base.OnPaint(e, viewPortData);

            Graphics graphics = e.Graphics;
            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;

                Rectangle rootBounds = this.parentView.RootDesigner.Bounds;
                graphics.ExcludeClip(rootBounds);
                rootBounds.Inflate(ActivityRootLayout.Separator.Width / 2, ActivityRootLayout.Separator.Height / 2);
                ActivityDesignerPaint.DrawDropShadow(graphics, rootBounds, AmbientTheme.WorkflowBorderPen.Color, AmbientTheme.DropShadowWidth, LightSourcePosition.Left | LightSourcePosition.Top, 0.2f, false);

                graphics.FillRectangle(WorkflowTheme.CurrentTheme.AmbientTheme.BackgroundBrush, rootBounds);
                graphics.DrawRectangle(AmbientTheme.WorkflowBorderPen, rootBounds);

                graphics.EndContainer(graphicsState);
            }
        }