public override void Draw(Graphics graphics) { GraphicsContainer container = graphics.BeginContainer(); Rectangle bounds = base.Bounds; using (Region region = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1))) { graphics.Clip = region; StringFormat format = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.Character, FormatFlags = StringFormatFlags.NoWrap }; int maxVisibleItems = base.MaxVisibleItems; int scrollPosition = base.ScrollPosition; for (int i = scrollPosition; (i < base.Items.Count) && (i < (scrollPosition + maxVisibleItems)); i++) { System.Workflow.ComponentModel.Design.ItemInfo itemInfo = base.Items[i]; Rectangle itemBounds = base.GetItemBounds(itemInfo); int pageFoldSize = itemBounds.Width / 5; GraphicsPath[] pathArray = ActivityDesignerPaint.GetPagePaths(itemBounds, pageFoldSize, DesignerContentAlignment.TopRight); using (GraphicsPath path = pathArray[0]) { using (GraphicsPath path2 = pathArray[1]) { Brush white = Brushes.White; if (base.SelectedItem == itemInfo) { white = PageStrip.SelectionBrush; } else if (base.HighlitedItem == itemInfo) { white = PageStrip.HighliteBrush; } graphics.FillPath(white, path); graphics.DrawPath(Pens.DarkBlue, path); graphics.FillPath(Brushes.White, path2); graphics.DrawPath(Pens.DarkBlue, path2); if (itemInfo.Image == null) { itemBounds.Y += pageFoldSize; itemBounds.Height -= pageFoldSize; graphics.DrawString((i + 1).ToString(CultureInfo.CurrentCulture), Control.DefaultFont, SystemBrushes.ControlText, itemBounds, format); } else { itemBounds.Y += pageFoldSize; itemBounds.Height -= pageFoldSize; itemBounds.X += (itemBounds.Width - itemBounds.Height) / 2; itemBounds.Width = itemBounds.Height; itemBounds.Inflate(-2, -2); ActivityDesignerPaint.DrawImage(graphics, itemInfo.Image, itemBounds, DesignerContentAlignment.Center); } } } } } graphics.EndContainer(container); }
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer) { Rectangle bounds = this.GetBounds(designer, activated); bounds.Inflate(WorkflowTheme.CurrentTheme.AmbientTheme.Margin); ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ReadOnlyImage, bounds, DesignerContentAlignment.TopLeft); }
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); } }
internal void Draw(Graphics graphics) { if ((this.transparency != 0f) && (this.buttons.Count != 0)) { ActivityDesignerPaint.Draw3DButton(graphics, null, this.Bounds, this.transparency - 0.1f, ButtonState.Normal); for (int i = 0; i < this.buttons.Count; i++) { Rectangle buttonBounds = this.GetButtonBounds(i); ActionButton button = this.buttons[i]; if (button.StateImages.Length == 1) { Image image = button.StateImages[0]; if ((button.State == ActionButton.States.Normal) || (button.State == ActionButton.States.Disabled)) { buttonBounds.Inflate(-2, -2); ActivityDesignerPaint.DrawImage(graphics, image, buttonBounds, new Rectangle(Point.Empty, image.Size), DesignerContentAlignment.Fill, this.transparency, button.State == ActionButton.States.Disabled); } else { ButtonState buttonState = (button.State == ActionButton.States.Highlight) ? ButtonState.Normal : ButtonState.Pushed; ActivityDesignerPaint.Draw3DButton(graphics, image, buttonBounds, this.transparency, buttonState); } } else { Image image2 = this.buttons[i].StateImages[(int)this.buttons[i].State]; buttonBounds.Inflate(-2, -2); ActivityDesignerPaint.DrawImage(graphics, image2, buttonBounds, new Rectangle(Point.Empty, image2.Size), DesignerContentAlignment.Fill, this.transparency, false); } } } }
protected override bool OnPaint(PaintEventArgs eventArgs, Rectangle viewPort, AmbientTheme ambientTheme) { bool messageHandled = false; if (this.draggedDesignerImages != null && DropTargetDesigner is FreeformActivityDesigner) { using (Region clipRegion = new Region(ActivityDesignerPaint.GetDesignerPath(ParentView.RootDesigner, false))) { Region oldRegion = eventArgs.Graphics.Clip; eventArgs.Graphics.Clip = clipRegion; Point[] locations = GetDesignerLocations(DragInitiationPoint, this.movedDesignerImagePoint, DraggedActivities); Debug.Assert(locations.Length == DraggedActivities.Count); Debug.Assert(this.draggedDesignerImages.Count == DraggedActivities.Count); for (int i = 0; i < this.draggedDesignerImages.Count; i++) { Size imageSize = this.draggedDesignerImages[i].Size; ActivityDesignerPaint.DrawImage(eventArgs.Graphics, this.draggedDesignerImages[i], new Rectangle(new Point(locations[i].X - 2 * ambientTheme.Margin.Width, locations[i].Y - 2 * ambientTheme.Margin.Height), imageSize), new Rectangle(Point.Empty, imageSize), DesignerContentAlignment.Fill, 0.4f, false); } eventArgs.Graphics.Clip = oldRegion; } } else { messageHandled = base.OnPaint(eventArgs, viewPort, ambientTheme); } return(messageHandled); }
private void DrawScrollIndicators(Graphics graphics) { Image scrollIndicatorImage = AmbientTheme.ScrollIndicatorImage; if (scrollIndicatorImage != null) { WorkflowView parentView = base.ParentView; Size viewPortSize = parentView.ViewPortSize; Point scrollPosition = parentView.ScrollPosition; Rectangle[] scrollIndicatorRectangles = this.ScrollIndicatorRectangles; if (scrollPosition.X > 0) { ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ScrollIndicatorImage, scrollIndicatorRectangles[0], (float)0.7f); } if (scrollPosition.X < (parentView.HScrollBar.Maximum - viewPortSize.Width)) { scrollIndicatorImage.RotateFlip(RotateFlipType.RotateNoneFlipX); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[1], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (scrollPosition.Y > 0) { scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipX); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[2], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipX); } if (scrollPosition.Y < (parentView.VScrollBar.Maximum - viewPortSize.Height)) { scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate270FlipNone); ActivityDesignerPaint.DrawImage(graphics, scrollIndicatorImage, scrollIndicatorRectangles[3], (float)0.7f); scrollIndicatorImage.RotateFlip(RotateFlipType.Rotate90FlipNone); } } }
// 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); } }
protected override bool OnPaintWorkflowAdornments(PaintEventArgs e, Rectangle viewPort, AmbientTheme ambientTheme) { if (this.dragImage != null) { ActivityDesignerPaint.DrawImage(e.Graphics, this.dragImage, new Rectangle(this.dragImagePointInClientCoOrd, this.dragImage.Size), new Rectangle(0, 0, this.dragImage.Width, this.dragImage.Height), DesignerContentAlignment.Center, (this.dragImageSnapped) ? 1.0f : 0.5f, WorkflowTheme.CurrentTheme.AmbientTheme.DrawGrayscale); } return(false); }
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); }
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); }
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer) { Rectangle bounds = GetBounds(designer, false); Rectangle activatedBounds = GetBounds(designer, activated); Region clipRegion = null; Region oldClipRegion = graphics.Clip; try { if (oldClipRegion != null) { clipRegion = oldClipRegion.Clone(); if (activated) { clipRegion.Union(activatedBounds); } graphics.Clip = clipRegion; } if (activated) { graphics.FillRectangle(SystemBrushes.ButtonFace, activatedBounds); graphics.DrawRectangle(SystemPens.ControlDarkDark, activatedBounds.Left, activatedBounds.Top, activatedBounds.Width - 1, activatedBounds.Height - 1); activatedBounds.X += bounds.Width + ambientTheme.Margin.Width; activatedBounds.Width -= (bounds.Width + 2 * ambientTheme.Margin.Width); using (GraphicsPath dropDownIndicator = ActivityDesignerPaint.GetScrollIndicatorPath(activatedBounds, ScrollButton.Down)) { graphics.FillPath(SystemBrushes.ControlText, dropDownIndicator); graphics.DrawPath(SystemPens.ControlText, dropDownIndicator); } } ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ConfigErrorImage, bounds, DesignerContentAlignment.Fill); } finally { if (clipRegion != null) { graphics.Clip = oldClipRegion; clipRegion.Dispose(); } } }
public virtual void OnPaint(ActivityDesignerPaintEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if ((!string.IsNullOrEmpty(this.Text) && !this.TextRectangle.Size.IsEmpty) && ((e.DesignerTheme != null) && (e.DesignerTheme.Font != null))) { using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1f, this.AssociatedDesigner.SmartTagVisible ? FontStyle.Bold : FontStyle.Regular)) { ActivityDesignerPaint.DrawText(e.Graphics, font, this.Text, this.TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush); } } if ((this.Image != null) && !this.ImageRectangle.Size.IsEmpty) { ActivityDesignerPaint.DrawImage(e.Graphics, this.Image, this.ImageRectangle, DesignerContentAlignment.Fill); } }
/// <summary> /// Draws the Header/Footer associated with workflow root designer. /// </summary> /// <param name="e">ActivityDesignerPaintEventArgs holding drawing arguments</param> public virtual void OnPaint(ActivityDesignerPaintEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (!String.IsNullOrEmpty(Text) && !TextRectangle.Size.IsEmpty && e.DesignerTheme != null && e.DesignerTheme.Font != null) { //use bold or regular font based on mouse over status using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, (this.AssociatedDesigner.SmartTagVisible) ? FontStyle.Bold : FontStyle.Regular)) ActivityDesignerPaint.DrawText(e.Graphics, font, Text, TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush); } if (Image != null && !ImageRectangle.Size.IsEmpty) { ActivityDesignerPaint.DrawImage(e.Graphics, Image, ImageRectangle, DesignerContentAlignment.Fill); } }
private void DrawScrollIndicators(Graphics graphics) { Image indicator = AmbientTheme.ScrollIndicatorImage; if (indicator == null) { return; } WorkflowView parentView = ParentView; Size viewPortSize = parentView.ViewPortSize; Point scrollPosition = parentView.ScrollPosition; //Left Right Rectangle[] scrollIndicatorRectangles = ScrollIndicatorRectangles; if (scrollPosition.X > 0) { ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ScrollIndicatorImage, scrollIndicatorRectangles[0], AmbientTheme.ScrollIndicatorTransparency); } if (scrollPosition.X < parentView.HScrollBar.Maximum - viewPortSize.Width) { indicator.RotateFlip(RotateFlipType.Rotate180FlipY); ActivityDesignerPaint.DrawImage(graphics, indicator, scrollIndicatorRectangles[1], AmbientTheme.ScrollIndicatorTransparency); indicator.RotateFlip(RotateFlipType.Rotate180FlipY); } //Up Down if (scrollPosition.Y > 0) { indicator.RotateFlip(RotateFlipType.Rotate90FlipX); ActivityDesignerPaint.DrawImage(graphics, indicator, scrollIndicatorRectangles[2], AmbientTheme.ScrollIndicatorTransparency); indicator.RotateFlip(RotateFlipType.Rotate270FlipY); } if (scrollPosition.Y < parentView.VScrollBar.Maximum - viewPortSize.Height) { indicator.RotateFlip(RotateFlipType.Rotate270FlipNone); ActivityDesignerPaint.DrawImage(graphics, indicator, scrollIndicatorRectangles[3], AmbientTheme.ScrollIndicatorTransparency); indicator.RotateFlip(RotateFlipType.Rotate90FlipNone); } }
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer) { Rectangle bounds = this.GetBounds(designer, false); Rectangle rect = this.GetBounds(designer, activated); Region region = null; Region clip = graphics.Clip; try { if (clip != null) { region = clip.Clone(); if (activated) { region.Union(rect); } graphics.Clip = region; } if (activated) { graphics.FillRectangle(SystemBrushes.ButtonFace, rect); graphics.DrawRectangle(SystemPens.ControlDarkDark, rect.Left, rect.Top, rect.Width - 1, rect.Height - 1); rect.X += bounds.Width + ambientTheme.Margin.Width; rect.Width -= bounds.Width + (2 * ambientTheme.Margin.Width); using (GraphicsPath path = ActivityDesignerPaint.GetScrollIndicatorPath(rect, ScrollButton.Down)) { graphics.FillPath(SystemBrushes.ControlText, path); graphics.DrawPath(SystemPens.ControlText, path); } } ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.ConfigErrorImage, bounds, DesignerContentAlignment.Fill); } finally { if (region != null) { graphics.Clip = clip; region.Dispose(); } } }
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); } }
protected override bool OnPaint(PaintEventArgs eventArgs, Rectangle viewPort, AmbientTheme ambientTheme) { bool flag = false; if ((this.draggedDesignerImages != null) && (base.DropTargetDesigner is FreeformActivityDesigner)) { using (Region region = new Region(ActivityDesignerPaint.GetDesignerPath(base.ParentView.RootDesigner, false))) { Region clip = eventArgs.Graphics.Clip; eventArgs.Graphics.Clip = region; Point[] pointArray = GetDesignerLocations(base.DragInitiationPoint, this.movedDesignerImagePoint, base.DraggedActivities); for (int i = 0; i < this.draggedDesignerImages.Count; i++) { Size size = this.draggedDesignerImages[i].Size; ActivityDesignerPaint.DrawImage(eventArgs.Graphics, this.draggedDesignerImages[i], new Rectangle(new Point(pointArray[i].X - (2 * ambientTheme.Margin.Width), pointArray[i].Y - (2 * ambientTheme.Margin.Height)), size), new Rectangle(Point.Empty, size), DesignerContentAlignment.Fill, 0.4f, false); } eventArgs.Graphics.Clip = clip; return(flag); } } return(base.OnPaint(eventArgs, viewPort, ambientTheme)); }
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer) { ActivityDesignerPaint.DrawImage(graphics, AmbientTheme.DropIndicatorImage, GetBounds(designer, activated), DesignerContentAlignment.Fill); }
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 void Draw(Graphics graphics) { AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme; if (designerTheme != null) { Rectangle stripRectangle = this.StripRectangle; GraphicsPath path = new GraphicsPath(); if (designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle) { path.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(stripRectangle, 4), false); } else { path.AddRectangle(stripRectangle); } path.CloseFigure(); graphics.FillPath(designerTheme.PreviewBackgroundBrush, path); graphics.DrawPath(designerTheme.PreviewBorderPen, path); path.Dispose(); Image leftScrollImageUp = ActivityPreviewDesignerTheme.LeftScrollImageUp; Rectangle buttonBounds = this.GetButtonBounds(ScrollButton.Left); if (this.ActiveScrollButton == ScrollButton.Left) { leftScrollImageUp = ActivityPreviewDesignerTheme.LeftScrollImage; buttonBounds.Offset(1, 1); } if (leftScrollImageUp != null) { ActivityDesignerPaint.DrawImage(graphics, leftScrollImageUp, buttonBounds, DesignerContentAlignment.Center); } leftScrollImageUp = ActivityPreviewDesignerTheme.RightScrollImageUp; buttonBounds = this.GetButtonBounds(ScrollButton.Right); if (this.ActiveScrollButton == ScrollButton.Right) { leftScrollImageUp = ActivityPreviewDesignerTheme.RightScrollImage; buttonBounds.Offset(1, 1); } if (leftScrollImageUp != null) { ActivityDesignerPaint.DrawImage(graphics, leftScrollImageUp, buttonBounds, DesignerContentAlignment.Center); } System.Drawing.Size itemMargin = this.ItemMargin; int width = Math.Max(Math.Min((int)(itemMargin.Width / 4), (int)(itemMargin.Height / 2)), 1); for (int i = this.scrollMarker; (i < this.items.Count) && (i < (this.scrollMarker + this.VisibleItemCount)); i++) { Rectangle itemBounds = this.GetItemBounds(this.items[i]); if (!itemBounds.IsEmpty) { GraphicsPath path2 = new GraphicsPath(); if (designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle) { path2.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(itemBounds, 4), true); } else { path2.AddRectangle(itemBounds); } graphics.FillPath(designerTheme.PreviewForegroundBrush, path2); graphics.DrawPath(designerTheme.PreviewBorderPen, path2); path2.Dispose(); Image image = this.items[i].Image; if (image == null) { Activity activity = this.items[i].UserData[DesignerUserDataKeys.Activity] as Activity; ActivityDesigner designer = ActivityDesigner.GetDesigner(activity); if (designer != null) { image = designer.Image; } } if (image != null) { Rectangle empty = Rectangle.Empty; empty.X = itemBounds.Left + 2; empty.Y = itemBounds.Top + 2; empty.Size = new System.Drawing.Size(itemBounds.Width - 4, itemBounds.Height - 4); ActivityDesignerPaint.DrawImage(graphics, image, empty, DesignerContentAlignment.Center); } if (i == this.items.IndexOf(this.ActiveItem)) { itemBounds.Inflate(width, width); graphics.DrawRectangle(ambientTheme.SelectionForegroundPen, itemBounds); } } } Rectangle[] dropTargets = this.DropTargets; int activeDropTarget = this.ActiveDropTarget; if ((activeDropTarget >= 0) && (activeDropTarget < dropTargets.GetLength(0))) { dropTargets[activeDropTarget].Width = itemMargin.Width; graphics.DrawLine(ambientTheme.DropIndicatorPen, dropTargets[activeDropTarget].Left + (dropTargets[activeDropTarget].Width / 2), dropTargets[activeDropTarget].Top, dropTargets[activeDropTarget].Left + (dropTargets[activeDropTarget].Width / 2), dropTargets[activeDropTarget].Bottom); } else if ((this.items.Count == 0) && (this.helpText.Length > 0)) { stripRectangle.Inflate(-2, -2); Brush textBrush = (this.ActiveDropTarget != -1) ? ambientTheme.DropIndicatorBrush : designerTheme.ForegroundBrush; ActivityDesignerPaint.DrawText(graphics, designerTheme.Font, this.helpText, stripRectangle, StringAlignment.Center, WorkflowTheme.CurrentTheme.AmbientTheme.TextQuality, textBrush); } } }
protected override void OnPrintPage(PrintPageEventArgs printPageArg) { base.OnPrintPage(printPageArg); AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; Graphics graphics = printPageArg.Graphics; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; if (this.currentPrintablePage.IsEmpty) { this.PrepareToPrint(printPageArg); } Margins hardMargins = this.GetHardMargins(graphics); Margins margins2 = new Margins(Math.Max(printPageArg.PageSettings.Margins.Left, hardMargins.Left), Math.Max(printPageArg.PageSettings.Margins.Right, hardMargins.Right), Math.Max(printPageArg.PageSettings.Margins.Top, hardMargins.Top), Math.Max(printPageArg.PageSettings.Margins.Bottom, hardMargins.Bottom)); Size size = new Size(printPageArg.PageBounds.Size.Width - (margins2.Left + margins2.Right), printPageArg.PageBounds.Size.Height - (margins2.Top + margins2.Bottom)); Rectangle rect = new Rectangle(margins2.Left, margins2.Top, size.Width, size.Height); Region region = new Region(rect); try { graphics.TranslateTransform((float)-hardMargins.Left, (float)-hardMargins.Top); graphics.FillRectangle(ambientTheme.BackgroundBrush, rect); graphics.DrawRectangle(ambientTheme.ForegroundPen, rect); if (ambientTheme.WorkflowWatermarkImage != null) { ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, rect, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false); } Matrix transform = graphics.Transform; Region clip = graphics.Clip; graphics.Clip = region; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; Point point = new Point((this.currentPrintablePage.X * size.Width) - this.workflowAlignment.X, (this.currentPrintablePage.Y * size.Height) - this.workflowAlignment.Y); graphics.TranslateTransform((float)(rect.Left - point.X), (float)(rect.Top - point.Y)); graphics.ScaleTransform(this.scaling, this.scaling); Size empty = Size.Empty; empty.Width = Convert.ToInt32(Math.Ceiling((double)(((float)size.Width) / this.scaling))); empty.Height = Convert.ToInt32(Math.Ceiling((double)(((float)size.Height) / this.scaling))); Point point2 = Point.Empty; point2.X = Convert.ToInt32(Math.Ceiling((double)(((float)this.workflowAlignment.X) / this.scaling))); point2.Y = Convert.ToInt32(Math.Ceiling((double)(((float)this.workflowAlignment.Y) / this.scaling))); Rectangle viewPort = new Rectangle((this.currentPrintablePage.X * empty.Width) - point2.X, (this.currentPrintablePage.Y * empty.Height) - point2.Y, empty.Width, empty.Height); using (PaintEventArgs args = new PaintEventArgs(graphics, this.workflowView.RootDesigner.Bounds)) { ((IWorkflowDesignerMessageSink)this.workflowView.RootDesigner).OnPaint(args, viewPort); } graphics.Clip = clip; graphics.Transform = transform; HeaderFooterData headerFooterPrintData = new HeaderFooterData { Font = ambientTheme.Font, PageBounds = printPageArg.PageBounds, PageBoundsWithoutMargin = rect, HeaderFooterMargins = new Margins(0, 0, this.pageSetupData.HeaderMargin, this.pageSetupData.FooterMargin), PrintTime = this.printTime, CurrentPage = (this.currentPrintablePage.X + (this.currentPrintablePage.Y * this.totalPrintablePages.X)) + 1, TotalPages = this.totalPrintablePages.X * this.totalPrintablePages.Y, Scaling = this.scaling }; WorkflowDesignerLoader service = ((IServiceProvider)this.workflowView).GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader; headerFooterPrintData.FileName = (service != null) ? service.FileName : string.Empty; if (this.pageSetupData.HeaderTemplate.Length > 0) { this.PrintHeaderFooter(graphics, true, headerFooterPrintData); } if (this.pageSetupData.FooterTemplate.Length > 0) { this.PrintHeaderFooter(graphics, false, headerFooterPrintData); } printPageArg.HasMorePages = this.MoveNextPage(); } catch (Exception exception) { DesignerHelpers.ShowError(this.workflowView, DR.GetString("SelectedPrinterIsInvalidErrorMessage", new object[0]) + "\n" + exception.Message); printPageArg.Cancel = true; printPageArg.HasMorePages = false; } finally { region.Dispose(); } if (!printPageArg.HasMorePages) { this.workflowView.PerformLayout(); } }
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 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); }
public void Draw(Graphics graphics, Rectangle viewPort) { ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme; if (designerTheme != null) { System.Drawing.Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin; ActivityDesignerPaint.DrawText(graphics, designerTheme.Font, this.PreviewModeDescription, this.previewModeDescRectangle, StringAlignment.Center, WorkflowTheme.CurrentTheme.AmbientTheme.TextQuality, designerTheme.ForegroundBrush); graphics.DrawRectangle(Pens.Black, (int)(this.previewModeButtonRectangle.Left - 1), (int)(this.previewModeButtonRectangle.Top - 1), (int)(this.previewModeButtonRectangle.Width + 1), (int)(this.previewModeButtonRectangle.Height + 1)); ActivityDesignerPaint.Draw3DButton(graphics, null, this.previewModeButtonRectangle, 1f, !this.PreviewMode ? ButtonState.Pushed : ButtonState.Normal); Image image = this.PreviewMode ? ActivityPreviewDesignerTheme.PreviewButtonImage : ActivityPreviewDesignerTheme.EditButtonImage; ActivityDesignerPaint.DrawImage(graphics, image, new Rectangle(this.previewModeButtonRectangle.Left + 2, this.previewModeButtonRectangle.Top + 2, this.previewModeButtonRectangle.Width - 4, this.previewModeButtonRectangle.Height - 4), DesignerContentAlignment.Center); graphics.FillRectangle(designerTheme.PreviewBackgroundBrush, this.canvasBounds); if (this.PreviewMode) { graphics.DrawRectangle(designerTheme.PreviewBorderPen, this.canvasBounds); } else { Rectangle canvasBounds = this.canvasBounds; canvasBounds.Inflate(2, 2); graphics.DrawRectangle(SystemPens.ControlDark, canvasBounds); canvasBounds.Inflate(-1, -1); graphics.DrawLine(SystemPens.ControlDarkDark, canvasBounds.Left, canvasBounds.Top, canvasBounds.Left, canvasBounds.Bottom); graphics.DrawLine(SystemPens.ControlDarkDark, canvasBounds.Left, canvasBounds.Top, canvasBounds.Right, canvasBounds.Top); graphics.DrawLine(SystemPens.ControlLight, canvasBounds.Right, canvasBounds.Top, canvasBounds.Right, canvasBounds.Bottom); graphics.DrawLine(SystemPens.ControlLight, canvasBounds.Left, canvasBounds.Bottom, canvasBounds.Right, canvasBounds.Bottom); canvasBounds.Inflate(-1, -1); graphics.DrawLine(SystemPens.ControlLight, canvasBounds.Left, canvasBounds.Top, canvasBounds.Left, canvasBounds.Bottom); graphics.DrawLine(SystemPens.ControlLight, canvasBounds.Left, canvasBounds.Top, canvasBounds.Right, canvasBounds.Top); graphics.FillRectangle(designerTheme.PreviewBackgroundBrush, canvasBounds); } if (this.PreviewDesigner == null) { Rectangle boundingRect = this.canvasBounds; boundingRect.Inflate(-margin.Width, -margin.Height); string text = DR.GetString("SelectActivityDesc", new object[0]); ActivityDesignerPaint.DrawText(graphics, designerTheme.Font, text, boundingRect, StringAlignment.Center, WorkflowTheme.CurrentTheme.AmbientTheme.TextQuality, designerTheme.ForegroundBrush); } if (this.PreviewMode) { Image image2 = this.GeneratePreview(graphics); if (image2 != null) { Rectangle empty = Rectangle.Empty; System.Drawing.Size size2 = new System.Drawing.Size(this.canvasBounds.Width - (2 * margin.Width), this.canvasBounds.Height - (2 * margin.Height)); double num = ((double)image2.Width) / ((double)size2.Width); num = Math.Max(Math.Max(num, ((double)image2.Height) / ((double)size2.Height)), 1.2999999523162842); empty.Width = Convert.ToInt32(Math.Ceiling((double)(((double)image2.Width) / num))); empty.Height = Convert.ToInt32(Math.Ceiling((double)(((double)image2.Height) / num))); empty.X = (this.canvasBounds.Left + (this.canvasBounds.Width / 2)) - (empty.Width / 2); empty.Y = (this.canvasBounds.Top + (this.canvasBounds.Height / 2)) - (empty.Height / 2); graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.DrawImage(image2, empty, new Rectangle(Point.Empty, image2.Size), GraphicsUnit.Pixel); } Rectangle destination = this.canvasBounds; destination.Inflate(-margin.Width, -margin.Height); ActivityDesignerPaint.DrawImage(graphics, ActivityPreviewDesignerTheme.PreviewImage, destination, DesignerContentAlignment.TopLeft); } else if (this.PreviewDesigner != null) { Rectangle bounds = this.PreviewDesigner.Bounds; bounds.Inflate(margin.Width, margin.Height); using (PaintEventArgs args = new PaintEventArgs(graphics, bounds)) { ((IWorkflowDesignerMessageSink)this.PreviewDesigner).OnPaint(args, bounds); } } } }
protected override void OnPrintPage(PrintPageEventArgs printPageArg) { base.OnPrintPage(printPageArg); AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme; Graphics graphics = printPageArg.Graphics; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; //STEP1: We get the printer graphics only in the OnPrintPage function hence for layouting we need to call this function if (this.currentPrintablePage.IsEmpty) { PrepareToPrint(printPageArg); } //STEP2: GET ALL THE VALUES NEEDED FOR CALCULATION Margins hardMargins = GetHardMargins(graphics); Margins margins = new Margins(Math.Max(printPageArg.PageSettings.Margins.Left, hardMargins.Left), Math.Max(printPageArg.PageSettings.Margins.Right, hardMargins.Right), Math.Max(printPageArg.PageSettings.Margins.Top, hardMargins.Top), Math.Max(printPageArg.PageSettings.Margins.Bottom, hardMargins.Bottom)); Size printableArea = new Size(printPageArg.PageBounds.Size.Width - (margins.Left + margins.Right), printPageArg.PageBounds.Size.Height - (margins.Top + margins.Bottom)); Rectangle boundingRectangle = new Rectangle(margins.Left, margins.Top, printableArea.Width, printableArea.Height); Region clipRegion = new Region(boundingRectangle); try { graphics.TranslateTransform(-hardMargins.Left, -hardMargins.Top); graphics.FillRectangle(ambientTheme.BackgroundBrush, boundingRectangle); graphics.DrawRectangle(ambientTheme.ForegroundPen, boundingRectangle); //Draw the watermark image if (ambientTheme.WorkflowWatermarkImage != null) { ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, boundingRectangle, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, AmbientTheme.WatermarkTransparency, false); } Matrix oldTransform = graphics.Transform; Region oldClipRegion = graphics.Clip; graphics.Clip = clipRegion; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; //STEP3: PRINT //Printer bitmap starts at the unprintable top left corner, hence, need to take it into account - move by the unprintable area: //Setup the translation and scaling for the page printing Point pageOffset = new Point(this.currentPrintablePage.X * printableArea.Width - this.workflowAlignment.X, this.currentPrintablePage.Y * printableArea.Height - this.workflowAlignment.Y); graphics.TranslateTransform(boundingRectangle.Left - pageOffset.X, boundingRectangle.Top - pageOffset.Y); graphics.ScaleTransform(this.scaling, this.scaling); //Calculate the viewport by reverse scaling the printable area size Size viewPortSize = Size.Empty; viewPortSize.Width = Convert.ToInt32(Math.Ceiling((float)printableArea.Width / this.scaling)); viewPortSize.Height = Convert.ToInt32(Math.Ceiling((float)printableArea.Height / this.scaling)); Point scaledAlignment = Point.Empty; scaledAlignment.X = Convert.ToInt32(Math.Ceiling((float)this.workflowAlignment.X / this.scaling)); scaledAlignment.Y = Convert.ToInt32(Math.Ceiling((float)this.workflowAlignment.Y / this.scaling)); Rectangle viewPort = new Rectangle(this.currentPrintablePage.X * viewPortSize.Width - scaledAlignment.X, this.currentPrintablePage.Y * viewPortSize.Height - scaledAlignment.Y, viewPortSize.Width, viewPortSize.Height); using (PaintEventArgs paintEventArgs = new PaintEventArgs(graphics, this.workflowView.RootDesigner.Bounds)) { ((IWorkflowDesignerMessageSink)this.workflowView.RootDesigner).OnPaint(paintEventArgs, viewPort); } graphics.Clip = oldClipRegion; graphics.Transform = oldTransform; //Now prepare the graphics for header footer printing HeaderFooterData headerFooterData = new HeaderFooterData(); headerFooterData.Font = ambientTheme.Font; headerFooterData.PageBounds = printPageArg.PageBounds; headerFooterData.PageBoundsWithoutMargin = boundingRectangle; headerFooterData.HeaderFooterMargins = new Margins(0, 0, this.pageSetupData.HeaderMargin, this.pageSetupData.FooterMargin); headerFooterData.PrintTime = this.printTime; headerFooterData.CurrentPage = this.currentPrintablePage.X + this.currentPrintablePage.Y * this.totalPrintablePages.X + 1; headerFooterData.TotalPages = this.totalPrintablePages.X * this.totalPrintablePages.Y; headerFooterData.Scaling = this.scaling; WorkflowDesignerLoader serviceDesignerLoader = ((IServiceProvider)this.workflowView).GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader; headerFooterData.FileName = (serviceDesignerLoader != null) ? serviceDesignerLoader.FileName : String.Empty; //Print the header if (this.pageSetupData.HeaderTemplate.Length > 0) { PrintHeaderFooter(graphics, true, headerFooterData); } //footer if (this.pageSetupData.FooterTemplate.Length > 0) { PrintHeaderFooter(graphics, false, headerFooterData); } //are there more pages left? printPageArg.HasMorePages = MoveNextPage(); } catch (Exception exception) { DesignerHelpers.ShowError(this.workflowView, DR.GetString(DR.SelectedPrinterIsInvalidErrorMessage) + "\n" + exception.Message); printPageArg.Cancel = true; printPageArg.HasMorePages = false; } finally { clipRegion.Dispose(); } if (!printPageArg.HasMorePages) { this.workflowView.PerformLayout(); //no more pages - redo regular layout using screen graphics } }