Exemplo n.º 1
0
                protected override void OnPaint(PaintEventArgs e)
                {
                    base.OnPaint(e);
                    Rectangle formRectangle = this.parent.formRectangle;

                    formRectangle.Offset(-ItemPalette.Palette.DropShadowWidth, -ItemPalette.Palette.DropShadowWidth);
                    ActivityDesignerPaint.DrawDropShadow(e.Graphics, formRectangle, Color.Black, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.2f, false);
                }
 protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
 {
     if (!this.GetBounds(designer, activated).Size.IsEmpty)
     {
         bool roundEdges = (designer.DesignerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle) && !designer.IsRootDesigner;
         ActivityDesignerPaint.DrawDropShadow(graphics, designer.Bounds, designer.DesignerTheme.BorderPen.Color, 4, LightSourcePosition.Top | LightSourcePosition.Left, 0.5f, roundEdges);
     }
 }
        protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
        {
            Rectangle bounds = GetBounds(designer, activated);

            if (!bounds.Size.IsEmpty)
            {
                bool drawRounded = (designer.DesignerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle && !designer.IsRootDesigner);
                ActivityDesignerPaint.DrawDropShadow(graphics, designer.Bounds, designer.DesignerTheme.BorderPen.Color, AmbientTheme.DropShadowWidth, LightSourcePosition.Left | LightSourcePosition.Top, 0.5f, drawRounded);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }