public void OnLayoutSize(Graphics graphics, int minWidth)
        {
            ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme;

            if (designerTheme != null)
            {
                System.Drawing.Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
                if (!this.PreviewMode && (this.PreviewDesigner != null))
                {
                    this.canvasBounds.Size = this.PreviewDesigner.Bounds.Size;
                    this.canvasBounds.Inflate(margin.Width * 2, margin.Height * 2);
                    int introduced12 = Math.Max(this.canvasBounds.Width, designerTheme.PreviewWindowSize.Width);
                    this.canvasBounds.Size = new System.Drawing.Size(introduced12, Math.Max(this.canvasBounds.Height, designerTheme.PreviewWindowSize.Height));
                }
                else
                {
                    this.canvasBounds.Size = designerTheme.PreviewWindowSize;
                }
                this.canvasBounds.Width = Math.Max(this.canvasBounds.Width, minWidth);
                SizeF ef    = graphics.MeasureString(this.PreviewModeDescription, designerTheme.Font);
                int   width = Convert.ToInt32(Math.Ceiling((double)ef.Width));
                this.previewDescTextSize               = new System.Drawing.Size(width, Convert.ToInt32(Math.Ceiling((double)ef.Height)));
                this.previewDescTextSize.Width         = Math.Min((this.canvasBounds.Size.Width - margin.Width) - this.previewModeButtonRectangle.Size.Width, this.previewDescTextSize.Width);
                this.previewModeDescRectangle.Size     = this.previewDescTextSize;
                this.previewModeButtonRectangle.Height = Math.Min(designerTheme.PreviewButtonSize.Height, this.previewDescTextSize.Height);
                this.previewModeButtonRectangle.Width  = this.previewModeButtonRectangle.Size.Height;
                System.Drawing.Size empty = System.Drawing.Size.Empty;
                empty.Width      = this.canvasBounds.Width + (2 * margin.Width);
                empty.Height     = Math.Max(this.previewModeButtonRectangle.Size.Height, this.previewDescTextSize.Height);
                empty.Height    += margin.Height;
                empty.Height    += this.canvasBounds.Height;
                this.bounds.Size = empty;
            }
        }
        private void EnsureValidDesignerPreview(ActivityDesigner designer)
        {
            CompositeActivityDesigner designer2 = designer as CompositeActivityDesigner;

            if ((designer2 != null) && designer2.Expanded)
            {
                ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme;
                if (designerTheme != null)
                {
                    System.Drawing.Size previewWindowSize = designerTheme.PreviewWindowSize;
                    System.Drawing.Size size = designer2.Size;
                    float num = ((float)previewWindowSize.Width) / ((float)size.Width);
                    if (Math.Min(num, ((float)previewWindowSize.Height) / ((float)size.Height)) < 0.1f)
                    {
                        if (!designer2.CanExpandCollapse && (designer2.ContainedDesigners.Count > 0))
                        {
                            designer2 = designer2.ContainedDesigners[0] as CompositeActivityDesigner;
                        }
                        if (designer2 != null)
                        {
                            designer2.Expanded = false;
                        }
                    }
                }
            }
        }
示例#3
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            if (Expanded && ActiveDesigner == this)
            {
                this.previewStrip.OnLayoutSize(e.Graphics);

                Size containerSize = Size.Empty;
                containerSize.Width   = Math.Max(containerSize.Width, this.previewStrip.Size.Width);
                containerSize.Height += this.previewStrip.Size.Height;
                containerSize.Height += e.AmbientTheme.Margin.Height;

                if (this.previewWindow != null)
                {
                    this.previewWindow.Refresh();
                    this.previewWindow.OnLayoutSize(e.Graphics, containerSize.Width);

                    containerSize.Width   = Math.Max(containerSize.Width, this.previewWindow.Size.Width);
                    containerSize.Width  += 2 * e.AmbientTheme.Margin.Width;
                    containerSize.Height += TitleHeight;
                    containerSize.Height += 4 * e.AmbientTheme.Margin.Height;
                    containerSize.Height += this.previewWindow.Size.Height;
                    containerSize.Height += e.AmbientTheme.Margin.Height;
                }
                else
                {
                    containerSize.Width   = Math.Max(containerSize.Width, size.Width);
                    containerSize.Width  += 3 * e.AmbientTheme.Margin.Width;
                    containerSize.Width  += 2 * e.AmbientTheme.SelectionSize.Width;
                    containerSize.Height += size.Height;
                }

                containerSize.Width  = Math.Max(containerSize.Width, MinimumSize.Width);
                containerSize.Height = Math.Max(containerSize.Height, MinimumSize.Height);

                if (!ShowPreview && PreviewedDesigner != null)
                {
                    ActivityPreviewDesignerTheme previewDesignerTheme = e.DesignerTheme as ActivityPreviewDesignerTheme;
                    if (previewDesignerTheme != null)
                    {
                        containerSize.Height -= previewDesignerTheme.ConnectorSize.Height;
                        containerSize.Height -= 2 * e.AmbientTheme.Margin.Height;
                        containerSize.Height -= 2 * e.AmbientTheme.SelectionSize.Height;
                    }

                    Size margins = new Size(2 * e.AmbientTheme.Margin.Width + 2 * e.AmbientTheme.SelectionSize.Width, 2 * e.AmbientTheme.Margin.Height + 2 * e.AmbientTheme.SelectionSize.Height);
                    PreviewedDesigner.Size = new Size(containerSize.Width - margins.Width, containerSize.Height - (TitleHeight + this.previewStrip.Size.Height + margins.Height));
                }

                size = containerSize;
            }

            return(size);
        }
示例#4
0
        public void OnLayoutSize(Graphics graphics)
        {
            ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme;

            System.Drawing.Size itemMargin = this.ItemMargin;
            System.Drawing.Size itemSize   = this.ItemSize;
            this.bounds.Width  = 2 * WorkflowTheme.CurrentTheme.AmbientTheme.Margin.Width;
            this.bounds.Width += itemSize.Width * ((designerTheme != null) ? designerTheme.PreviewItemCount : 0);
            this.bounds.Width += itemMargin.Width * (((designerTheme != null) ? designerTheme.PreviewItemCount : 0) + 1);
            this.bounds.Width += this.GetButtonBounds(ScrollButton.Left).Size.Width;
            this.bounds.Width += this.GetButtonBounds(ScrollButton.Right).Size.Width;
            this.bounds.Height = itemSize.Height + (2 * itemMargin.Height);
            this.EnsureScrollMarker();
        }
示例#5
0
        private Point SnapInToPreviewStripDropTarget(ActivityDragEventArgs e)
        {
            int activeDropTarget = this.previewStrip.ActiveDropTarget;

            Rectangle[] dropTargets = this.previewStrip.DropTargets;
            if ((activeDropTarget < 0) || (activeDropTarget >= dropTargets.Length))
            {
                return(Point.Empty);
            }
            Rectangle rectangle = dropTargets[activeDropTarget];
            ActivityPreviewDesignerTheme designerTheme = base.DesignerTheme as ActivityPreviewDesignerTheme;

            rectangle.Width = (rectangle.Width > ((designerTheme != null) ? designerTheme.ConnectorSize.Width : 0)) ? ((designerTheme != null) ? designerTheme.ConnectorSize.Width : 0) : rectangle.Width;
            return(new Point(rectangle.Left + (rectangle.Width / 2), rectangle.Top + (rectangle.Height / 2)));
        }
示例#6
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            if (!this.Expanded || (base.ActiveDesigner != this))
            {
                return(size);
            }
            this.previewStrip.OnLayoutSize(e.Graphics);
            Size empty = Size.Empty;

            empty.Width   = Math.Max(empty.Width, this.previewStrip.Size.Width);
            empty.Height += this.previewStrip.Size.Height;
            empty.Height += e.AmbientTheme.Margin.Height;
            if (this.previewWindow != null)
            {
                this.previewWindow.Refresh();
                this.previewWindow.OnLayoutSize(e.Graphics, empty.Width);
                empty.Width   = Math.Max(empty.Width, this.previewWindow.Size.Width);
                empty.Width  += 2 * e.AmbientTheme.Margin.Width;
                empty.Height += this.TitleHeight;
                empty.Height += 4 * e.AmbientTheme.Margin.Height;
                empty.Height += this.previewWindow.Size.Height;
                empty.Height += e.AmbientTheme.Margin.Height;
            }
            else
            {
                empty.Width   = Math.Max(empty.Width, size.Width);
                empty.Width  += 3 * e.AmbientTheme.Margin.Width;
                empty.Width  += 2 * e.AmbientTheme.SelectionSize.Width;
                empty.Height += size.Height;
            }
            empty.Width  = Math.Max(empty.Width, this.MinimumSize.Width);
            empty.Height = Math.Max(empty.Height, this.MinimumSize.Height);
            if (!this.ShowPreview && (this.PreviewedDesigner != null))
            {
                ActivityPreviewDesignerTheme designerTheme = e.DesignerTheme as ActivityPreviewDesignerTheme;
                if (designerTheme != null)
                {
                    empty.Height -= designerTheme.ConnectorSize.Height;
                    empty.Height -= 2 * e.AmbientTheme.Margin.Height;
                    empty.Height -= 2 * e.AmbientTheme.SelectionSize.Height;
                }
                Size size3 = new Size((2 * e.AmbientTheme.Margin.Width) + (2 * e.AmbientTheme.SelectionSize.Width), (2 * e.AmbientTheme.Margin.Height) + (2 * e.AmbientTheme.SelectionSize.Height));
                this.PreviewedDesigner.Size = new Size(empty.Width - size3.Width, empty.Height - ((this.TitleHeight + this.previewStrip.Size.Height) + size3.Height));
            }
            return(empty);
        }
示例#7
0
        private Point SnapInToPreviewStripDropTarget(ActivityDragEventArgs e)
        {
            int activeDropTarget = this.previewStrip.ActiveDropTarget;

            Rectangle[] dropTargets = this.previewStrip.DropTargets;

            if (activeDropTarget < 0 || activeDropTarget >= dropTargets.Length)
            {
                return(Point.Empty);
            }

            Rectangle dropConnector = dropTargets[activeDropTarget];
            ActivityPreviewDesignerTheme designerTheme = DesignerTheme as ActivityPreviewDesignerTheme;

            dropConnector.Width = (dropConnector.Width > ((designerTheme != null) ? designerTheme.ConnectorSize.Width : 0)) ? ((designerTheme != null) ? designerTheme.ConnectorSize.Width : 0) : dropConnector.Width;
            return(new Point(dropConnector.Left + dropConnector.Width / 2, dropConnector.Top + dropConnector.Height / 2));
        }
示例#8
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);
                }
            }
        }
        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);
                    }
                }
            }
        }