internal static GraphicsPath GetDesignerPath(ActivityDesigner designer, Rectangle bounds, ActivityDesignerTheme designerTheme)
        {
            GraphicsPath designerPath = new GraphicsPath();

            if (designer == GetSafeRootDesigner(designer.Activity.Site) && ((IWorkflowRootDesigner)designer).InvokingDesigner == null)
            {
                designerPath.AddRectangle(bounds);
            }
            else
            {
                // Work around: This should come from AmbientTheme.ArcDiameter
                // but it is internal
                int arcDiameter = 8;
                if (designerTheme != null && designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle)
                {
                    designerPath.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(bounds, arcDiameter), true);
                }
                else
                {
                    designerPath.AddRectangle(bounds);
                }
            }

            return(designerPath);
        }
        //

        internal static GraphicsPath GetLineCap(LineAnchor lineCap, int capsize, out float capinset)
        {
            //WE DO NOT SUPPORT ARROWCAPS FOR ANGULAR CONNECTORS FOR NOW
            capinset = 0.0f;
            capinset = (float)capsize / 2;
            Size capSize = new Size(capsize, capsize);

            GraphicsPath lineCapPath = new GraphicsPath();

            switch (lineCap)
            {
            case LineAnchor.Arrow:
            case LineAnchor.ArrowAnchor:
                int arcRadius = capSize.Height / 3;
                lineCapPath.AddLine(capSize.Width / 2, -capSize.Height, 0, 0);
                lineCapPath.AddLine(0, 0, -capSize.Width / 2, -capSize.Height);
                lineCapPath.AddLine(-capSize.Width / 2, -capSize.Height, 0, -capSize.Height + arcRadius);
                lineCapPath.AddLine(0, -capSize.Height + arcRadius, capSize.Width / 2, -capSize.Height);
                capinset = capSize.Height - arcRadius;
                break;

            case LineAnchor.Diamond:
            case LineAnchor.DiamondAnchor:
                lineCapPath.AddLine(0, -capSize.Height, capSize.Width / 2, -capSize.Height / 2);
                lineCapPath.AddLine(capSize.Width / 2, -capSize.Height / 2, 0, 0);
                lineCapPath.AddLine(0, 0, -capSize.Width / 2, -capSize.Height / 2);
                lineCapPath.AddLine(-capSize.Width / 2, -capSize.Height / 2, 0, -capSize.Height);
                break;

            case LineAnchor.Round:
            case LineAnchor.RoundAnchor:
                lineCapPath.AddEllipse(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height));
                break;

            case LineAnchor.Rectangle:
            case LineAnchor.RectangleAnchor:
                lineCapPath.AddRectangle(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height));
                break;

            case LineAnchor.RoundedRectangle:
            case LineAnchor.RoundedRectangleAnchor:
                arcRadius = capSize.Height / 4;
                lineCapPath.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(new Rectangle(-capSize.Width / 2, -capSize.Height, capSize.Width, capSize.Height), arcRadius), true);
                break;
            }

            lineCapPath.CloseFigure();
            return(lineCapPath);
        }
Exemple #3
0
        internal static GraphicsPath GetLineCap(LineAnchor lineCap, int capsize, out float capinset)
        {
            int num;

            capinset = 0f;
            capinset = ((float)capsize) / 2f;
            Size         size = new Size(capsize, capsize);
            GraphicsPath path = new GraphicsPath();

            switch (lineCap)
            {
            case LineAnchor.Arrow:
            case LineAnchor.ArrowAnchor:
                num = size.Height / 3;
                path.AddLine(size.Width / 2, -size.Height, 0, 0);
                path.AddLine(0, 0, -size.Width / 2, -size.Height);
                path.AddLine(-size.Width / 2, -size.Height, 0, -size.Height + num);
                path.AddLine(0, -size.Height + num, size.Width / 2, -size.Height);
                capinset = size.Height - num;
                break;

            case LineAnchor.Diamond:
            case LineAnchor.DiamondAnchor:
                path.AddLine(0, -size.Height, size.Width / 2, -size.Height / 2);
                path.AddLine(size.Width / 2, -size.Height / 2, 0, 0);
                path.AddLine(0, 0, -size.Width / 2, -size.Height / 2);
                path.AddLine(-size.Width / 2, -size.Height / 2, 0, -size.Height);
                break;

            case LineAnchor.Round:
            case LineAnchor.RoundAnchor:
                path.AddEllipse(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height));
                break;

            case LineAnchor.Rectangle:
            case LineAnchor.RectangleAnchor:
                path.AddRectangle(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height));
                break;

            case LineAnchor.RoundedRectangle:
            case LineAnchor.RoundedRectangleAnchor:
                num = size.Height / 4;
                path.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(new Rectangle(-size.Width / 2, -size.Height, size.Width, size.Height), num), true);
                break;
            }
            path.CloseFigure();
            return(path);
        }
Exemple #4
0
        internal static GraphicsPath GetDesignerPath(ActivityDesigner designer, Rectangle bounds, ActivityDesignerTheme designerTheme)
        {
            GraphicsPath path = new GraphicsPath();

            if ((designer == GetSafeRootDesigner(designer.Activity.Site)) && (((IWorkflowRootDesigner)designer).InvokingDesigner == null))
            {
                path.AddRectangle(bounds);
                return(path);
            }
            int radius = 8;

            if ((designerTheme != null) && (designerTheme.DesignerGeometry == DesignerGeometry.RoundedRectangle))
            {
                path.AddPath(ActivityDesignerPaint.GetRoundedRectanglePath(bounds, radius), true);
                return(path);
            }
            path.AddRectangle(bounds);
            return(path);
        }
Exemple #5
0
        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);
                }
            }
        }