Пример #1
0
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     base.OnLayoutPosition(e);
     if (this.Expanded && (base.ActiveDesigner == this))
     {
         CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
         if (designerTheme != null)
         {
             ReadOnlyCollection <Point> innerConnections = this.GetInnerConnections(DesignerEdges.Bottom | DesignerEdges.Top);
             Point point = (innerConnections.Count > 0) ? new Point(this.Location.X, innerConnections[0].Y) : this.Location;
             int   num   = 0;
             int   num2  = (designerTheme.ConnectorSize.Height * 3) / 2;
             foreach (ActivityDesigner designer in this.ContainedDesigners)
             {
                 num += e.AmbientTheme.SelectionSize.Width;
                 num += designerTheme.ConnectorSize.Width;
                 Size size = designer.Size;
                 designer.Location = new Point(point.X + num, point.Y + num2);
                 num += size.Width;
                 num += e.AmbientTheme.SelectionSize.Width;
             }
         }
     }
 }
Пример #2
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);
            CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if ((this.Expanded && (base.ActiveDesigner == this)) && (designerTheme != null))
            {
                Size empty = Size.Empty;
                foreach (ActivityDesigner designer in this.ContainedDesigners)
                {
                    Size size3 = designer.Size;
                    empty.Width += e.AmbientTheme.SelectionSize.Width;
                    empty.Width += designerTheme.ConnectorSize.Width;
                    empty.Width += size3.Width;
                    empty.Width += e.AmbientTheme.SelectionSize.Width;
                    empty.Height = Math.Max(empty.Height, size3.Height);
                }
                empty.Width += (this.ContainedDesigners.Count > 0) ? designerTheme.ConnectorSize.Width : 0;
                foreach (ActivityDesigner designer2 in this.ContainedDesigners)
                {
                    designer2.Size = new Size(designer2.Size.Width, empty.Height);
                }
                empty.Height += 3 * designerTheme.ConnectorSize.Height;
                size.Width    = Math.Max(size.Width, empty.Width);
                size.Height  += empty.Height;
            }
            return(size);
        }
Пример #3
0
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            base.OnLayoutPosition(e);

            if (Expanded)
            {
                ActivityDesigner activeDesigner = ActiveDesigner;
                if (activeDesigner != null && activeDesigner != this)
                {
                    Point location = Location;
                    location.X += (Size.Width - activeDesigner.Size.Width) / 2;
                    location.Y += e.AmbientTheme.SelectionSize.Height;
                    activeDesigner.Location = location;
                }

                int titleHeight = TitleHeight;
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    activityDesigner.Location = new Point(activityDesigner.Location.X, activityDesigner.Location.Y + titleHeight);
                }
            }
        }
Пример #4
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);
            CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if ((this.Expanded && (base.ActiveDesigner == this)) && (designerTheme != null))
            {
                if (this.HelpText.Length > 0)
                {
                    this.helpTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, designerTheme.Font, this.HelpText, StringAlignment.Center, DefaultHelpTextSize);
                }
                size.Height += designerTheme.ConnectorSize.Height;
                foreach (ActivityDesigner designer in this.ContainedDesigners)
                {
                    Size size2 = designer.Size;
                    size.Width   = Math.Max(size.Width, size2.Width);
                    size.Height += size2.Height;
                    size.Height += designerTheme.ConnectorSize.Height;
                }
                if (this.ContainedDesigners.Count == 0)
                {
                    Rectangle helpTextRectangle = this.HelpTextRectangle;
                    size.Width   = Math.Max(helpTextRectangle.Width, size.Width);
                    size.Height += helpTextRectangle.Height;
                    size.Height += designerTheme.ConnectorSize.Height;
                }
                size.Width  = Math.Max(size.Width, designerTheme.Size.Width);
                size.Width += 3 * e.AmbientTheme.Margin.Width;
                size.Width += 2 * e.AmbientTheme.SelectionSize.Width;
                size.Height = Math.Max(size.Height, designerTheme.Size.Height);
            }
            return(size);
        }
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     base.OnLayoutPosition(e);
     if (this.AutoSize)
     {
         Point     location           = this.Location;
         Rectangle enclosingRectangle = this.GetEnclosingRectangle();
         if (!enclosingRectangle.IsEmpty)
         {
             if (this.AutoSizeMode == System.Windows.Forms.AutoSizeMode.GrowOnly)
             {
                 location.X = Math.Min(location.X, enclosingRectangle.Left);
                 location.Y = Math.Min(location.Y, enclosingRectangle.Top);
             }
             else
             {
                 location = enclosingRectangle.Location;
             }
         }
         this.retainContainedDesignerLocations = true;
         this.Location = location;
         this.retainContainedDesignerLocations = false;
     }
     foreach (Connector connector in this.connectors)
     {
         connector.OnLayout(e);
     }
 }
 protected override void OnLayout(ActivityDesignerLayoutEventArgs e)
 {
     if (!this.RootStateDesigner.HasActiveDesigner)
     {
         base.OnLayout(e);
     }
 }
Пример #7
0
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            base.OnLayoutPosition(e);

            if (Expanded && ActiveDesigner == this)
            {
                CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;
                if (compositeDesignerTheme != null)
                {
                    ReadOnlyCollection <Point> connectionPoints = GetInnerConnections(DesignerEdges.Top | DesignerEdges.Bottom);
                    Point location = (connectionPoints.Count > 0) ? new Point(Location.X, connectionPoints[0].Y) : Location;

                    int width  = 0;
                    int height = compositeDesignerTheme.ConnectorSize.Height * 3 / 2;
                    foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                    {
                        width += e.AmbientTheme.SelectionSize.Width;
                        width += compositeDesignerTheme.ConnectorSize.Width;
                        Size designerSize = activityDesigner.Size;
                        activityDesigner.Location = new Point(location.X + width, location.Y + height);
                        width += designerSize.Width;
                        width += e.AmbientTheme.SelectionSize.Width;
                    }
                }
            }
        }
Пример #8
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);
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
     if ((designerTheme != null) && this.Expanded)
     {
         size.Width += 2 * designerTheme.ConnectorSize.Width;
         size.Height += designerTheme.ConnectorSize.Height;
     }
     return size;
 }
Пример #10
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;
            if (compositeDesignerTheme != null && Expanded)
            {
                containerSize.Width += 2 * compositeDesignerTheme.ConnectorSize.Width;
                containerSize.Height += compositeDesignerTheme.ConnectorSize.Height;
            }

            return containerSize;
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     string targetState = this.TargetState;
     if (string.IsNullOrEmpty(targetState))
     {
         targetState = "M";
     }
     Font font = e.DesignerTheme.Font;
     this.targetStateSize = StateMachineDesignerPaint.MeasureString(e.Graphics, font, targetState, StringAlignment.Near, Size.Empty);
     size.Height += this.targetStateSize.Height;
     return size;
 }
        /// <summary>
        /// Layouts the visual cues inside Header/Footer
        /// </summary>
        /// <param name="e">ActivityDesignerLayoutEventArgs holding layouting arguments</param>
        public virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (!String.IsNullOrEmpty(Text) && e.DesignerTheme != null && e.DesignerTheme.Font != null)
            {
                using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, FontStyle.Bold))
                    this.textSize = ActivityDesignerPaint.MeasureString(e.Graphics, font, Text, StringAlignment.Center, Size.Empty);
            }
        }
 protected internal virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
 {
     if ((this.segments.Count > 0) && ((this.segments[0] != this.Source.Location) || (this.segments[this.segments.Count - 1] != this.Target.Location)))
     {
         this.connectorModified = false;
     }
     if (!this.connectorModified && (this.ParentDesigner != null))
     {
         Point[] collection = ActivityDesignerConnectorRouter.Route(this.Source.AssociatedDesigner.Activity.Site, this.Source, this.Target, this.ExcludedRoutingRectangles);
         this.segments.Clear();
         this.segments.AddRange(collection);
     }
 }
 public virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if ((!string.IsNullOrEmpty(this.Text) && (e.DesignerTheme != null)) && (e.DesignerTheme.Font != null))
     {
         using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1f, FontStyle.Bold))
         {
             this.textSize = ActivityDesignerPaint.MeasureString(e.Graphics, font, this.Text, StringAlignment.Center, Size.Empty);
         }
     }
 }
Пример #15
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);
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     WorkflowFooter footer = this.Footer as WorkflowFooter;
     if (footer != null)
     {
         size.Height += (footer.ImageRectangle.Height + (2 * e.AmbientTheme.Margin.Height)) + footer.FooterBarRectangle.Size.Height;
     }
     if (this.Header != null)
     {
         this.Header.OnLayout(e);
     }
     if (this.Footer != null)
     {
         this.Footer.OnLayout(e);
     }
     return size;
 }
Пример #17
0
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (ActiveDesigner == this && Expanded)
            {
                Rectangle bounds = Bounds;
                this.previewStrip.Location = new Point(bounds.Left + bounds.Width / 2 - this.previewStrip.Size.Width / 2, Location.Y + TitleHeight + e.AmbientTheme.Margin.Height);

                //Make sure that we dont call this after positioning the preview window
                base.OnLayoutPosition(e);

                //Do not position the preview window before positioning the base designers
                if (ShowPreview)
                {
                    Rectangle previewStripRectangle = this.previewStrip.Bounds;
                    this.previewWindow.Location = new Point(bounds.Left + bounds.Width / 2 - this.previewWindow.Size.Width / 2, previewStripRectangle.Bottom + 3 * e.AmbientTheme.Margin.Height);

                    this.separatorLine[0].X  = bounds.Left + e.AmbientTheme.Margin.Width;
                    this.separatorLine[0].Y  = previewStripRectangle.Bottom;
                    this.separatorLine[0].Y += e.AmbientTheme.Margin.Height + e.AmbientTheme.Margin.Height / 2;

                    this.separatorLine[1].X  = bounds.Right - e.AmbientTheme.Margin.Width;
                    this.separatorLine[1].Y  = previewStripRectangle.Bottom;
                    this.separatorLine[1].Y += e.AmbientTheme.Margin.Height + e.AmbientTheme.Margin.Height / 2;
                }
                else
                {
                    int headerHeight = this.previewStrip.Bounds.Bottom - Location.Y;
                    if (PreviewedDesigner != null)
                    {
                        PreviewedDesigner.Location = new Point(Location.X + (Size.Width - PreviewedDesigner.Size.Width) / 2, Location.Y + headerHeight + 2 * e.AmbientTheme.Margin.Height);
                    }
                }
            }
            else
            {
                base.OnLayoutPosition(e);
            }
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            if (this.Expanded)
            {
                ActivityDesigner activeDesigner = this.ActiveDesigner;
                if ((activeDesigner != null) && (activeDesigner != this))
                {
                    size.Width   = Math.Max(size.Width, activeDesigner.Size.Width);
                    size.Height += activeDesigner.Size.Height;
                    size.Width  += 2 * e.AmbientTheme.SelectionSize.Width;
                    size.Width  += 3 * e.AmbientTheme.Margin.Width;
                    size.Height += e.AmbientTheme.Margin.Height;
                    size.Height += 2 * e.AmbientTheme.SelectionSize.Height;
                }
            }
            return(size);
        }
Пример #19
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size           size   = base.OnLayoutSize(e);
            WorkflowFooter footer = this.Footer as WorkflowFooter;

            if (footer != null)
            {
                size.Height += (footer.ImageRectangle.Height + (2 * e.AmbientTheme.Margin.Height)) + footer.FooterBarRectangle.Size.Height;
            }
            if (this.Header != null)
            {
                this.Header.OnLayout(e);
            }
            if (this.Footer != null)
            {
                this.Footer.OnLayout(e);
            }
            return(size);
        }
Пример #20
0
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            base.OnLayoutPosition(e);

            if (Expanded && ActiveDesigner == this)
            {
                CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;

                //This condition is to center align the children
                int height = 0;

                ReadOnlyCollection <Point> connectionPoints = GetInnerConnections(DesignerEdges.Top | DesignerEdges.Bottom);
                Point location = (connectionPoints.Count > 0) ? connectionPoints[0] : Location;

                if (ContainedDesigners.Count == 1)
                {
                    int heightDelta = 0;
                    if (connectionPoints.Count > 0)
                    {
                        heightDelta = Size.Height - (connectionPoints[connectionPoints.Count - 1].Y - connectionPoints[0].Y);
                    }
                    height += (Size.Height - heightDelta) / 2 - ContainedDesigners[0].Size.Height / 2;
                }
                else
                {
                    height += ((compositeDesignerTheme != null) ? compositeDesignerTheme.ConnectorSize.Height : 0);
                }

                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size designerSize = activityDesigner.Size;
                    activityDesigner.Location = new Point(location.X - (designerSize.Width / 2), location.Y + height);
                    height += designerSize.Height + ((compositeDesignerTheme != null) ? compositeDesignerTheme.ConnectorSize.Height : 0);
                }
            }
        }
Пример #21
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            if (Expanded)
            {
                ActivityDesigner activeDesigner = ActiveDesigner;
                if (activeDesigner != null && activeDesigner != this)
                {
                    containerSize.Width   = Math.Max(containerSize.Width, activeDesigner.Size.Width);
                    containerSize.Height += activeDesigner.Size.Height;

                    containerSize.Width  += 2 * e.AmbientTheme.SelectionSize.Width;
                    containerSize.Width  += 3 * e.AmbientTheme.Margin.Width;
                    containerSize.Height += e.AmbientTheme.Margin.Height;
                    containerSize.Height += 2 * e.AmbientTheme.SelectionSize.Height;
                }
            }

            return(containerSize);
        }
Пример #22
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if (Expanded && ActiveDesigner == this && compositeDesignerTheme != null)
            {
                if (this.HelpText.Length > 0)
                {
                    this.helpTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, compositeDesignerTheme.Font, this.HelpText, StringAlignment.Center, SequentialActivityDesigner.DefaultHelpTextSize);
                }

                //Calculate the size based on child size
                containerSize.Height += compositeDesignerTheme.ConnectorSize.Height; //Add the height of first connector

                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size childSize = activityDesigner.Size;
                    containerSize.Width   = Math.Max(containerSize.Width, childSize.Width);
                    containerSize.Height += childSize.Height;
                    containerSize.Height += compositeDesignerTheme.ConnectorSize.Height;
                }

                if (ContainedDesigners.Count == 0)
                {
                    Rectangle helpTextRectangle = HelpTextRectangle;
                    containerSize.Width   = Math.Max(helpTextRectangle.Width, containerSize.Width);
                    containerSize.Height += helpTextRectangle.Height;
                    containerSize.Height += compositeDesignerTheme.ConnectorSize.Height; //Add the height of last connector
                }

                containerSize.Width  = Math.Max(containerSize.Width, compositeDesignerTheme.Size.Width);
                containerSize.Width += 3 * e.AmbientTheme.Margin.Width;
                containerSize.Width += 2 * e.AmbientTheme.SelectionSize.Width;
                containerSize.Height = Math.Max(containerSize.Height, compositeDesignerTheme.Size.Height);
            }

            return(containerSize);
        }
Пример #23
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if (Expanded && ActiveDesigner == this && compositeDesignerTheme != null)
            {
                //Calculate the container size
                Size containerSize = Size.Empty;

                //Calculate the size based on child size
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size childSize = activityDesigner.Size;
                    containerSize.Width += e.AmbientTheme.SelectionSize.Width;
                    containerSize.Width += compositeDesignerTheme.ConnectorSize.Width;
                    containerSize.Width += childSize.Width;
                    containerSize.Width += e.AmbientTheme.SelectionSize.Width;
                    containerSize.Height = Math.Max(containerSize.Height, childSize.Height);
                }
                containerSize.Width += (ContainedDesigners.Count > 0) ? compositeDesignerTheme.ConnectorSize.Width : 0;

                //Once this happens then make sure that all the branches are of same size
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    activityDesigner.Size = new Size(activityDesigner.Size.Width, containerSize.Height);
                }

                //Add the margin for drawing the parallel connectors
                containerSize.Height += 3 * compositeDesignerTheme.ConnectorSize.Height;

                //Now consider the base classe's size
                size.Width   = Math.Max(size.Width, containerSize.Width);
                size.Height += containerSize.Height;
            }

            return(size);
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Rectangle bounds = base.Bounds;
            Size      size   = bounds.Size;

            base.OnLayoutSize(e);
            if (!this.AutoSize)
            {
                return(size);
            }
            if (this.AutoSizeMode == System.Windows.Forms.AutoSizeMode.GrowOnly)
            {
                Rectangle enclosingRectangle = this.GetEnclosingRectangle();
                if (!enclosingRectangle.IsEmpty)
                {
                    size.Width  += Math.Max(bounds.Left - enclosingRectangle.Left, 0);
                    size.Width  += Math.Max(enclosingRectangle.Right - bounds.Right, 0);
                    size.Height += Math.Max(bounds.Top - enclosingRectangle.Top, 0);
                    size.Height += Math.Max(enclosingRectangle.Bottom - bounds.Bottom, 0);
                }
                return(size);
            }
            return(this.MinimumSize);
        }
Пример #25
0
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     base.OnLayoutPosition(e);
     if (this.Expanded && (base.ActiveDesigner == this))
     {
         CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
         int num = 0;
         ReadOnlyCollection <Point> innerConnections = this.GetInnerConnections(DesignerEdges.Bottom | DesignerEdges.Top);
         Point point = (innerConnections.Count > 0) ? innerConnections[0] : this.Location;
         if (this.ContainedDesigners.Count == 1)
         {
             int num2 = 0;
             if (innerConnections.Count > 0)
             {
                 Point point2 = innerConnections[innerConnections.Count - 1];
                 Point point3 = innerConnections[0];
                 num2 = this.Size.Height - (point2.Y - point3.Y);
             }
             num += ((this.Size.Height - num2) / 2) - (this.ContainedDesigners[0].Size.Height / 2);
         }
         else
         {
             num += (designerTheme != null) ? designerTheme.ConnectorSize.Height : 0;
         }
         foreach (ActivityDesigner designer in this.ContainedDesigners)
         {
             Size size = designer.Size;
             designer.Location = new Point(point.X - (size.Width / 2), point.Y + num);
             num += size.Height + ((designerTheme != null) ? designerTheme.ConnectorSize.Height : 0);
         }
     }
 }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            //Make sure that we set the minimum size
            WorkflowFooter footer = Footer as WorkflowFooter;

            if (footer != null)
            {
                size.Height += footer.ImageRectangle.Height + 2 * e.AmbientTheme.Margin.Height + footer.FooterBarRectangle.Size.Height;
            }

            if (Header != null)
            {
                Header.OnLayout(e);
            }

            if (Footer != null)
            {
                Footer.OnLayout(e);
            }

            return(size);
        }
Пример #27
0
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if ((base.ActiveDesigner == this) && this.Expanded)
     {
         Rectangle bounds = base.Bounds;
         this.previewStrip.Location = new Point((bounds.Left + (bounds.Width / 2)) - (this.previewStrip.Size.Width / 2), (this.Location.Y + this.TitleHeight) + e.AmbientTheme.Margin.Height);
         base.OnLayoutPosition(e);
         if (this.ShowPreview)
         {
             Rectangle rectangle2 = this.previewStrip.Bounds;
             this.previewWindow.Location = new Point((bounds.Left + (bounds.Width / 2)) - (this.previewWindow.Size.Width / 2), rectangle2.Bottom + (3 * e.AmbientTheme.Margin.Height));
             this.separatorLine[0].X     = bounds.Left + e.AmbientTheme.Margin.Width;
             this.separatorLine[0].Y     = rectangle2.Bottom;
             this.separatorLine[0].Y    += e.AmbientTheme.Margin.Height + (e.AmbientTheme.Margin.Height / 2);
             this.separatorLine[1].X     = bounds.Right - e.AmbientTheme.Margin.Width;
             this.separatorLine[1].Y     = rectangle2.Bottom;
             this.separatorLine[1].Y    += e.AmbientTheme.Margin.Height + (e.AmbientTheme.Margin.Height / 2);
         }
         else
         {
             int num = this.previewStrip.Bounds.Bottom - this.Location.Y;
             if (this.PreviewedDesigner != null)
             {
                 this.PreviewedDesigner.Location = new Point(this.Location.X + ((this.Size.Width - this.PreviewedDesigner.Size.Width) / 2), (this.Location.Y + num) + (2 * e.AmbientTheme.Margin.Height));
             }
         }
     }
     else
     {
         base.OnLayoutPosition(e);
     }
 }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
     if ((this.Expanded && (base.ActiveDesigner == this)) && (designerTheme != null))
     {
         if (this.HelpText.Length > 0)
         {
             this.helpTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, designerTheme.Font, this.HelpText, StringAlignment.Center, DefaultHelpTextSize);
         }
         size.Height += designerTheme.ConnectorSize.Height;
         foreach (ActivityDesigner designer in this.ContainedDesigners)
         {
             Size size2 = designer.Size;
             size.Width = Math.Max(size.Width, size2.Width);
             size.Height += size2.Height;
             size.Height += designerTheme.ConnectorSize.Height;
         }
         if (this.ContainedDesigners.Count == 0)
         {
             Rectangle helpTextRectangle = this.HelpTextRectangle;
             size.Width = Math.Max(helpTextRectangle.Width, size.Width);
             size.Height += helpTextRectangle.Height;
             size.Height += designerTheme.ConnectorSize.Height;
         }
         size.Width = Math.Max(size.Width, designerTheme.Size.Width);
         size.Width += 3 * e.AmbientTheme.Margin.Width;
         size.Width += 2 * e.AmbientTheme.SelectionSize.Width;
         size.Height = Math.Max(size.Height, designerTheme.Size.Height);
     }
     return size;
 }
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     base.OnLayoutPosition(e);
     if (this.Expanded && (base.ActiveDesigner == this))
     {
         CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
         int num = 0;
         ReadOnlyCollection<Point> innerConnections = this.GetInnerConnections(DesignerEdges.Bottom | DesignerEdges.Top);
         Point point = (innerConnections.Count > 0) ? innerConnections[0] : this.Location;
         if (this.ContainedDesigners.Count == 1)
         {
             int num2 = 0;
             if (innerConnections.Count > 0)
             {
                 Point point2 = innerConnections[innerConnections.Count - 1];
                 Point point3 = innerConnections[0];
                 num2 = this.Size.Height - (point2.Y - point3.Y);
             }
             num += ((this.Size.Height - num2) / 2) - (this.ContainedDesigners[0].Size.Height / 2);
         }
         else
         {
             num += (designerTheme != null) ? designerTheme.ConnectorSize.Height : 0;
         }
         foreach (ActivityDesigner designer in this.ContainedDesigners)
         {
             Size size = designer.Size;
             designer.Location = new Point(point.X - (size.Width / 2), point.Y + num);
             num += size.Height + ((designerTheme != null) ? designerTheme.ConnectorSize.Height : 0);
         }
     }
 }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            //Calculate the size of internal designers
            foreach (ActivityDesigner activityDesigner in ContainedDesigners)
            {
                try
                {
                    ((IWorkflowDesignerMessageSink)activityDesigner).OnLayoutSize(e.Graphics);
                    activityDesigner.DrawingState &= (~DrawingStates.InvalidSize);
                }
                catch
                {
                    //Eat the exception thrown
                    activityDesigner.Size = activityDesigner.DesignerTheme.Size;
                    activityDesigner.DrawingState |= DrawingStates.InvalidSize;
                }
            }

            if (!String.IsNullOrEmpty(Text))
                this.actualTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, e.DesignerTheme.BoldFont, Text, StringAlignment.Center, Size.Empty);
            else
                this.actualTextSize = Size.Empty;

            if (Expanded)
                containerSize.Height = TitleHeight;
            else
                containerSize.Height = TitleHeight + WorkflowTheme.CurrentTheme.AmbientTheme.Margin.Height;

            return containerSize;
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     foreach (ActivityDesigner designer in this.ContainedDesigners)
     {
         try
         {
             ((IWorkflowDesignerMessageSink) designer).OnLayoutSize(e.Graphics);
             designer.DrawingState &= ~ActivityDesigner.DrawingStates.InvalidSize;
         }
         catch
         {
             designer.Size = designer.DesignerTheme.Size;
             designer.DrawingState |= ActivityDesigner.DrawingStates.InvalidSize;
         }
     }
     if (!string.IsNullOrEmpty(this.Text))
     {
         this.actualTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, e.DesignerTheme.BoldFont, this.Text, StringAlignment.Center, Size.Empty);
     }
     else
     {
         this.actualTextSize = Size.Empty;
     }
     if (this.Expanded)
     {
         size.Height = this.TitleHeight;
         return size;
     }
     size.Height = this.TitleHeight + WorkflowTheme.CurrentTheme.AmbientTheme.Margin.Height;
     return size;
 }
 /// <summary>
 /// Called to layout the position of contained visual cues or designers.
 /// </summary>
 /// <param name="e">ActivityDesignerLayoutEventArgs holding layout arguments</param>
 protected virtual void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
         throw new ArgumentNullException("e");
 }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;
            if (Expanded && ActiveDesigner == this && compositeDesignerTheme != null)
            {
                //Calculate the container size
                Size containerSize = Size.Empty;

                //Calculate the size based on child size
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size childSize = activityDesigner.Size;
                    containerSize.Width += e.AmbientTheme.SelectionSize.Width;
                    containerSize.Width += compositeDesignerTheme.ConnectorSize.Width;
                    containerSize.Width += childSize.Width;
                    containerSize.Width += e.AmbientTheme.SelectionSize.Width;
                    containerSize.Height = Math.Max(containerSize.Height, childSize.Height);
                }
                containerSize.Width += (ContainedDesigners.Count > 0) ? compositeDesignerTheme.ConnectorSize.Width : 0;

                //Once this happens then make sure that all the branches are of same size
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                    activityDesigner.Size = new Size(activityDesigner.Size.Width, containerSize.Height);

                //Add the margin for drawing the parallel connectors
                containerSize.Height += 3 * compositeDesignerTheme.ConnectorSize.Height;

                //Now consider the base classe's size
                size.Width = Math.Max(size.Width, containerSize.Width);
                size.Height += containerSize.Height;
            }

            return size;
        }
Пример #34
0
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
#if DEBUG
            try
            {
#endif
            if (this.IsRootStateDesigner)
                this.PerformingLayout = true;

            if (this.HasActiveDesigner)
            {
                // If we are in the event driven view, 
                // then we need to make sure that the size
                // of this designer will be as small as possible
                _minimumSize = Size.Empty;
                this.Size = Size.Empty;
            }
            else
            {
                this.NeedsAutoLayout = this.Size.IsEmpty;
            }

            Size newSize = base.OnLayoutSize(e);

            Graphics graphics = e.Graphics;
            ActivityDesignerTheme designerTheme = e.DesignerTheme;
            AmbientTheme ambientTheme = e.AmbientTheme;

            RefreshRootDesignerLayout();

            this.RootDesignerLayout.OnLayoutSize(graphics, designerTheme, ambientTheme, newSize);
            _minimumSize = this.RootDesignerLayout.MinimumSize;

            return this.RootDesignerLayout.Size;
#if DEBUG
            }
            catch (Exception exception)
            {
                Trace.WriteLine(String.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Unhandled exception in {0}.OnLayoutSize: {1}",
                    typeof(StateDesigner), exception));
                throw;
            }
#endif
        }
Пример #35
0
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            try
            {
                if (this.IsRootStateDesigner)
                {
                    if (this.ActiveDesigner == null)
                    {
                        // UpdateConnectors depends on having the 
                        // RootDesignerLayout refreshed at least once
                        this.UpdateConnectors();
                    }
                }

                Graphics graphics = e.Graphics;
                ActivityDesignerTheme designerTheme = e.DesignerTheme;
                AmbientTheme ambientTheme = e.AmbientTheme;
                this.RootDesignerLayout.Location = this.Location;
                this.RootDesignerLayout.OnLayoutPosition(graphics, designerTheme, ambientTheme);

                if (!this.HasActiveDesigner)
                    RelocateStates();

                base.OnLayoutPosition(e);

                if (!this.HasActiveDesigner && this.NeedsAutoLayout)
                    RepositionStates();

                if (IsRootDesigner && InvokingDesigner == null)
                    RecalculateRootDesignerSize();

            }
#if DEBUG
            catch (Exception exception)
            {
                Trace.WriteLine(String.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Unhandled exception in {0}.OnLayoutPosition: {1}",
                    typeof(StateDesigner), exception));
                throw;
            }
#endif
            finally
            {
                if (this.IsRootStateDesigner)
                    this.PerformingLayout = false;
            }
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Size size = base.OnLayoutSize(e);
     CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
     if ((this.Expanded && (base.ActiveDesigner == this)) && (designerTheme != null))
     {
         Size empty = Size.Empty;
         foreach (ActivityDesigner designer in this.ContainedDesigners)
         {
             Size size3 = designer.Size;
             empty.Width += e.AmbientTheme.SelectionSize.Width;
             empty.Width += designerTheme.ConnectorSize.Width;
             empty.Width += size3.Width;
             empty.Width += e.AmbientTheme.SelectionSize.Width;
             empty.Height = Math.Max(empty.Height, size3.Height);
         }
         empty.Width += (this.ContainedDesigners.Count > 0) ? designerTheme.ConnectorSize.Width : 0;
         foreach (ActivityDesigner designer2 in this.ContainedDesigners)
         {
             designer2.Size = new Size(designer2.Size.Width, empty.Height);
         }
         empty.Height += 3 * designerTheme.ConnectorSize.Height;
         size.Width = Math.Max(size.Width, empty.Width);
         size.Height += empty.Height;
     }
     return size;
 }
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     base.OnLayoutPosition(e);
     if (this.Expanded && (base.ActiveDesigner == this))
     {
         CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;
         if (designerTheme != null)
         {
             ReadOnlyCollection<Point> innerConnections = this.GetInnerConnections(DesignerEdges.Bottom | DesignerEdges.Top);
             Point point = (innerConnections.Count > 0) ? new Point(this.Location.X, innerConnections[0].Y) : this.Location;
             int num = 0;
             int num2 = (designerTheme.ConnectorSize.Height * 3) / 2;
             foreach (ActivityDesigner designer in this.ContainedDesigners)
             {
                 num += e.AmbientTheme.SelectionSize.Width;
                 num += designerTheme.ConnectorSize.Width;
                 Size size = designer.Size;
                 designer.Location = new Point(point.X + num, point.Y + num2);
                 num += size.Width;
                 num += e.AmbientTheme.SelectionSize.Width;
             }
         }
     }
 }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            if (ActiveDesigner == this && Expanded)
            {
                Rectangle bounds = Bounds;
                this.previewStrip.Location = new Point(bounds.Left + bounds.Width / 2 - this.previewStrip.Size.Width / 2, Location.Y + TitleHeight + e.AmbientTheme.Margin.Height);

                //Make sure that we dont call this after positioning the preview window
                base.OnLayoutPosition(e);

                //Do not position the preview window before positioning the base designers
                if (ShowPreview)
                {
                    Rectangle previewStripRectangle = this.previewStrip.Bounds;
                    this.previewWindow.Location = new Point(bounds.Left + bounds.Width / 2 - this.previewWindow.Size.Width / 2, previewStripRectangle.Bottom + 3 * e.AmbientTheme.Margin.Height);

                    this.separatorLine[0].X = bounds.Left + e.AmbientTheme.Margin.Width;
                    this.separatorLine[0].Y = previewStripRectangle.Bottom;
                    this.separatorLine[0].Y += e.AmbientTheme.Margin.Height + e.AmbientTheme.Margin.Height / 2;

                    this.separatorLine[1].X = bounds.Right - e.AmbientTheme.Margin.Width;
                    this.separatorLine[1].Y = previewStripRectangle.Bottom;
                    this.separatorLine[1].Y += e.AmbientTheme.Margin.Height + e.AmbientTheme.Margin.Height / 2;
                }
                else
                {
                    int headerHeight = this.previewStrip.Bounds.Bottom - Location.Y;
                    if (PreviewedDesigner != null)
                        PreviewedDesigner.Location = new Point(Location.X + (Size.Width - PreviewedDesigner.Size.Width) / 2, Location.Y + headerHeight + 2 * e.AmbientTheme.Margin.Height);
                }
            }
            else
            {
                base.OnLayoutPosition(e);
            }
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;
            if (Expanded && ActiveDesigner == this && compositeDesignerTheme != null)
            {
                if (this.HelpText.Length > 0)
                    this.helpTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, compositeDesignerTheme.Font, this.HelpText, StringAlignment.Center, SequentialActivityDesigner.DefaultHelpTextSize);

                //Calculate the size based on child size
                containerSize.Height += compositeDesignerTheme.ConnectorSize.Height; //Add the height of first connector

                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size childSize = activityDesigner.Size;
                    containerSize.Width = Math.Max(containerSize.Width, childSize.Width);
                    containerSize.Height += childSize.Height;
                    containerSize.Height += compositeDesignerTheme.ConnectorSize.Height;
                }

                if (ContainedDesigners.Count == 0)
                {
                    Rectangle helpTextRectangle = HelpTextRectangle;
                    containerSize.Width = Math.Max(helpTextRectangle.Width, containerSize.Width);
                    containerSize.Height += helpTextRectangle.Height;
                    containerSize.Height += compositeDesignerTheme.ConnectorSize.Height; //Add the height of last connector
                }

                containerSize.Width = Math.Max(containerSize.Width, compositeDesignerTheme.Size.Width);
                containerSize.Width += 3 * e.AmbientTheme.Margin.Width;
                containerSize.Width += 2 * e.AmbientTheme.SelectionSize.Width;
                containerSize.Height = Math.Max(containerSize.Height, compositeDesignerTheme.Size.Height);
            }

            return containerSize;
        }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            base.OnLayoutPosition(e);

            if (Expanded && ActiveDesigner == this)
            {
                CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;

                //This condition is to center align the children
                int height = 0;

                ReadOnlyCollection<Point> connectionPoints = GetInnerConnections(DesignerEdges.Top | DesignerEdges.Bottom);
                Point location = (connectionPoints.Count > 0) ? connectionPoints[0] : Location;

                if (ContainedDesigners.Count == 1)
                {
                    int heightDelta = 0;
                    if (connectionPoints.Count > 0)
                        heightDelta = Size.Height - (connectionPoints[connectionPoints.Count - 1].Y - connectionPoints[0].Y);
                    height += (Size.Height - heightDelta) / 2 - ContainedDesigners[0].Size.Height / 2;
                }
                else
                {
                    height += ((compositeDesignerTheme != null) ? compositeDesignerTheme.ConnectorSize.Height : 0);
                }

                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                {
                    Size designerSize = activityDesigner.Size;
                    activityDesigner.Location = new Point(location.X - (designerSize.Width / 2), location.Y + height);
                    height += designerSize.Height + ((compositeDesignerTheme != null) ? compositeDesignerTheme.ConnectorSize.Height : 0);
                }
            }
        }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            base.OnLayoutPosition(e);

            if (Expanded)
            {
                ActivityDesigner activeDesigner = ActiveDesigner;
                if (activeDesigner != null && activeDesigner != this)
                {
                    Point location = Location;
                    location.X += (Size.Width - activeDesigner.Size.Width) / 2;
                    location.Y += e.AmbientTheme.SelectionSize.Height;
                    activeDesigner.Location = location;
                }

                int titleHeight = TitleHeight;
                foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                    activityDesigner.Location = new Point(activityDesigner.Location.X, activityDesigner.Location.Y + titleHeight);
            }
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size size = base.OnLayoutSize(e);

            //Make sure that we set the minimum size
            WorkflowFooter footer = Footer as WorkflowFooter;
            if (footer != null)
                size.Height += footer.ImageRectangle.Height + 2 * e.AmbientTheme.Margin.Height + footer.FooterBarRectangle.Size.Height;

            if (Header != null)
                Header.OnLayout(e);

            if (Footer != null)
                Footer.OnLayout(e);

            return size;
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Rectangle bounds = Bounds;
            Size size = bounds.Size;

            base.OnLayoutSize(e);

            if (AutoSize)
            {
                if (AutoSizeMode == AutoSizeMode.GrowOnly)
                {
                    Rectangle childRectangle = GetEnclosingRectangle();
                    if (!childRectangle.IsEmpty)
                    {
                        size.Width += Math.Max(bounds.Left - childRectangle.Left, 0);
                        size.Width += Math.Max(childRectangle.Right - bounds.Right, 0);
                        size.Height += Math.Max(bounds.Top - childRectangle.Top, 0);
                        size.Height += Math.Max(childRectangle.Bottom - bounds.Bottom, 0);
                    }
                }
                else
                {
                    size = MinimumSize;
                }
            }

            return size;
        }
        /// <summary>
        /// Called to set the size of the visual cues or designers contained within the designer.
        /// </summary>
        /// <param name="e">ActivityDesignerLayoutEventArgs holding layout arguments</param>
        protected virtual Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            //GetVisible is an expensive call so we make sure that we keep it buffered in OnLayoutSize
            //otherwise drawing slows down. The visiblity change always triggers layouting and hence we
            //can safely buffer this variable
            this.isVisible = GetVisible();

            if (!String.IsNullOrEmpty(Text))
            {
                //Calculate the size of the text, we allow 10 characters per line and maximum of 2 lines
                Size actualTextSize = ActivityDesignerPaint.MeasureString(e.Graphics, e.DesignerTheme.BoldFont, Text, StringAlignment.Center, Size.Empty);
                Size requestedLineSize = actualTextSize;
                requestedLineSize.Width /= Text.Length;
                requestedLineSize.Width += ((requestedLineSize.Width % Text.Length) > 0) ? 1 : 0;
                requestedLineSize.Width *= Math.Min(Text.Length, ActivityDesigner.MaximumCharsPerLine - 1);

                this.textSize.Width = MinimumSize.Width - 2 * e.AmbientTheme.Margin.Width;
                if (Image != null)
                    this.textSize.Width -= e.DesignerTheme.ImageSize.Width + e.AmbientTheme.Margin.Width;
                this.textSize.Width = Math.Min(this.textSize.Width, actualTextSize.Width);
                this.textSize.Width = Math.Max(this.textSize.Width, requestedLineSize.Width);

                //We calculate the text size in onlayoutsize as we get access to the graphics and font information in this function
                this.textSize.Height = requestedLineSize.Height;
                int textLines = actualTextSize.Width / this.textSize.Width;
                textLines += ((actualTextSize.Width % this.textSize.Width) > 0) ? 1 : 0;
                textLines = Math.Min(textLines, ActivityDesigner.MaximumTextLines);
                this.textSize.Height *= textLines;
            }
            else
            {
                this.textSize = Size.Empty;
            }

            Size size = Size.Empty;
            size.Width = 2 * e.AmbientTheme.Margin.Width + ((Image != null) ? (e.DesignerTheme.ImageSize.Width + e.AmbientTheme.Margin.Width) : 0) + this.textSize.Width;
            size.Height = e.AmbientTheme.Margin.Height + Math.Max(e.DesignerTheme.ImageSize.Height, this.textSize.Height) + e.AmbientTheme.Margin.Height;
            return size;
        }
 protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
 {
     Rectangle bounds = base.Bounds;
     Size size = bounds.Size;
     base.OnLayoutSize(e);
     if (!this.AutoSize)
     {
         return size;
     }
     if (this.AutoSizeMode == System.Windows.Forms.AutoSizeMode.GrowOnly)
     {
         Rectangle enclosingRectangle = this.GetEnclosingRectangle();
         if (!enclosingRectangle.IsEmpty)
         {
             size.Width += Math.Max(bounds.Left - enclosingRectangle.Left, 0);
             size.Width += Math.Max(enclosingRectangle.Right - bounds.Right, 0);
             size.Height += Math.Max(bounds.Top - enclosingRectangle.Top, 0);
             size.Height += Math.Max(enclosingRectangle.Bottom - bounds.Bottom, 0);
         }
         return size;
     }
     return this.MinimumSize;
 }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            base.OnLayoutPosition(e);

            foreach (ActivityDesigner activityDesigner in ContainedDesigners)
            {
                try
                {
                    ((IWorkflowDesignerMessageSink)activityDesigner).OnLayoutPosition(e.Graphics);
                    activityDesigner.DrawingState &= (~DrawingStates.InvalidPosition);
                }
                catch
                {
                    //Eat the exception thrown
                    activityDesigner.DrawingState |= DrawingStates.InvalidPosition;
                }
            }
        }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            base.OnLayoutPosition(e);

            if (Expanded && ActiveDesigner == this)
            {
                CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;
                if (compositeDesignerTheme != null)
                {
                    ReadOnlyCollection<Point> connectionPoints = GetInnerConnections(DesignerEdges.Top | DesignerEdges.Bottom);
                    Point location = (connectionPoints.Count > 0) ? new Point(Location.X, connectionPoints[0].Y) : Location;

                    int width = 0;
                    int height = compositeDesignerTheme.ConnectorSize.Height * 3 / 2;
                    foreach (ActivityDesigner activityDesigner in ContainedDesigners)
                    {
                        width += e.AmbientTheme.SelectionSize.Width;
                        width += compositeDesignerTheme.ConnectorSize.Width;
                        Size designerSize = activityDesigner.Size;
                        activityDesigner.Location = new Point(location.X + width, location.Y + height);
                        width += designerSize.Width;
                        width += e.AmbientTheme.SelectionSize.Width;
                    }
                }
            }
        }
        protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
        {
            base.OnLayoutPosition(e);

            if (AutoSize)
            {
                Point newLocation = Location;

                Rectangle childRectangle = GetEnclosingRectangle();
                if (!childRectangle.IsEmpty)
                {
                    if (AutoSizeMode == AutoSizeMode.GrowOnly)
                    {
                        newLocation.X = Math.Min(newLocation.X, childRectangle.Left);
                        newLocation.Y = Math.Min(newLocation.Y, childRectangle.Top);
                    }
                    else
                    {
                        newLocation = childRectangle.Location;
                    }
                }

                this.retainContainedDesignerLocations = true;
                Location = newLocation;
                this.retainContainedDesignerLocations = false;
            }

            foreach (Connector connector in this.connectors)
                connector.OnLayout(e);
        }
        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;
        }
        protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
        {
            Size containerSize = base.OnLayoutSize(e);

            if (Expanded)
            {
                ActivityDesigner activeDesigner = ActiveDesigner;
                if (activeDesigner != null && activeDesigner != this)
                {
                    containerSize.Width = Math.Max(containerSize.Width, activeDesigner.Size.Width);
                    containerSize.Height += activeDesigner.Size.Height;

                    containerSize.Width += 2 * e.AmbientTheme.SelectionSize.Width;
                    containerSize.Width += 3 * e.AmbientTheme.Margin.Width;
                    containerSize.Height += e.AmbientTheme.Margin.Height;
                    containerSize.Height += 2 * e.AmbientTheme.SelectionSize.Height;
                }
            }

            return containerSize;
        }
 protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
 {
     base.OnLayoutPosition(e);
     if (this.AutoSize)
     {
         Point location = this.Location;
         Rectangle enclosingRectangle = this.GetEnclosingRectangle();
         if (!enclosingRectangle.IsEmpty)
         {
             if (this.AutoSizeMode == System.Windows.Forms.AutoSizeMode.GrowOnly)
             {
                 location.X = Math.Min(location.X, enclosingRectangle.Left);
                 location.Y = Math.Min(location.Y, enclosingRectangle.Top);
             }
             else
             {
                 location = enclosingRectangle.Location;
             }
         }
         this.retainContainedDesignerLocations = true;
         this.Location = location;
         this.retainContainedDesignerLocations = false;
     }
     foreach (Connector connector in this.connectors)
     {
         connector.OnLayout(e);
     }
 }