Exemple #1
0
        protected override void OnPaint(ActivityDesignerPaintEventArgs e)
        {
            base.OnPaint(e);

            CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if (Expanded && compositeDesignerTheme != null)
            {
                //Draw the connectors
                Rectangle helpTextRectangle = HelpTextRectangle;
                if (CurrentDropTarget == -1 && !helpTextRectangle.Size.IsEmpty)
                {
                    Rectangle[] connectors = GetConnectors();
                    if (connectors.Length > 0)
                    {
                        DrawConnectors(e.Graphics, compositeDesignerTheme.ForegroundPen, new Point[] { new Point(connectors[0].X + connectors[0].Width / 2, connectors[0].Y + 2), new Point(connectors[0].X + connectors[0].Width / 2, helpTextRectangle.Top - 2) }, compositeDesignerTheme.ConnectorStartCap, LineAnchor.None);
                        DrawConnectors(e.Graphics, compositeDesignerTheme.ForegroundPen, new Point[] { new Point(connectors[0].X + connectors[0].Width / 2, helpTextRectangle.Bottom + 2), new Point(connectors[0].X + connectors[0].Width / 2, connectors[0].Bottom - 2) }, LineAnchor.None, compositeDesignerTheme.ConnectorEndCap);
                    }

                    ActivityDesignerPaint.DrawText(e.Graphics, compositeDesignerTheme.Font, this.HelpText, helpTextRectangle, StringAlignment.Center, e.AmbientTheme.TextQuality, compositeDesignerTheme.ForegroundBrush);
                }
                else
                {
                    Rectangle[] connectors = GetConnectors();
                    for (int i = 0; i < connectors.Length; i++)
                    {
                        Pen        pen      = (i == CurrentDropTarget) ? e.AmbientTheme.DropIndicatorPen : compositeDesignerTheme.ForegroundPen;
                        LineAnchor startCap = ((i == 0 && connectors.Length > 2) || i == connectors.Length - 1) ? LineAnchor.None : compositeDesignerTheme.ConnectorStartCap;
                        LineAnchor endCap   = (i == 0 || (i == connectors.Length - 1 && connectors.Length > 2)) ? LineAnchor.None : compositeDesignerTheme.ConnectorEndCap;
                        DrawConnectors(e.Graphics, pen, new Point[] { new Point(connectors[i].Left + connectors[i].Width / 2, connectors[i].Top + 2), new Point(connectors[i].Left + connectors[i].Width / 2, connectors[i].Bottom - 2) }, startCap, endCap);
                    }
                }
            }
        }
Exemple #2
0
            protected override void OnPaint(PaintEventArgs paintArgs)
            {
                Graphics graphics = paintArgs.Graphics;

                graphics.FillRectangle(SystemBrushes.Window, this.formRectangle);
                graphics.DrawRectangle(SystemPens.ControlDarkDark, this.formRectangle.X, this.formRectangle.Y, this.formRectangle.Width - 1, this.formRectangle.Height - 1);
                using (Brush brush = new LinearGradientBrush(new Point(this.leftGradientRectangle.Left, this.leftGradientRectangle.Top), new Point(this.leftGradientRectangle.Right, this.leftGradientRectangle.Top), SystemColors.Window, SystemColors.ScrollBar))
                {
                    graphics.FillRectangle(brush, this.leftGradientRectangle);
                }
                for (int i = 0; i < this.enabledItems.Count; i++)
                {
                    Rectangle itemBounds = this.GetItemBounds(i);
                    if (this.activeIndex == i)
                    {
                        graphics.FillRectangle(SystemBrushes.InactiveCaptionText, itemBounds.X, itemBounds.Y, itemBounds.Width - 1, itemBounds.Height - 1);
                        graphics.DrawRectangle(SystemPens.ActiveCaption, itemBounds.X, itemBounds.Y, itemBounds.Width - 1, itemBounds.Height - 1);
                    }
                    if (this.enabledItems[i].Image != null)
                    {
                        Point location = new Point(itemBounds.Left + 3, itemBounds.Top + 3);
                        Size  size     = this.enabledItems[i].Image.Size;
                        graphics.DrawImage(this.enabledItems[i].Image, new Rectangle(location, size), new Rectangle(Point.Empty, size), GraphicsUnit.Pixel);
                    }
                    Rectangle boundingRect = new Rectangle(((itemBounds.Left + 20) + 5) + 2, itemBounds.Top + 1, this.itemWidth - 0x1d, this.itemHeight - 3);
                    int       num2         = boundingRect.Height - this.maxTextHeight;
                    num2 = (num2 > 0) ? (num2 / 2) : 0;
                    boundingRect.Height        = Math.Min(boundingRect.Height, this.maxTextHeight);
                    boundingRect.Y            += num2;
                    graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                    string text = this.enabledItems[i].Text.Replace("&", "");
                    ActivityDesignerPaint.DrawText(graphics, this.Font, text, boundingRect, StringAlignment.Near, TextQuality.Aliased, SystemBrushes.ControlText);
                }
            }
Exemple #3
0
        protected override void OnPaint(ActivityDesignerPaintEventArgs e)
        {
            base.OnPaint(e);
            CompositeDesignerTheme designerTheme = e.DesignerTheme as CompositeDesignerTheme;

            if (this.Expanded && (designerTheme != null))
            {
                Rectangle helpTextRectangle = this.HelpTextRectangle;
                if ((this.CurrentDropTarget == -1) && !helpTextRectangle.Size.IsEmpty)
                {
                    Rectangle[] connectors = this.GetConnectors();
                    if (connectors.Length > 0)
                    {
                        Point[] points = new Point[] { new Point(connectors[0].X + (connectors[0].Width / 2), connectors[0].Y + 2), new Point(connectors[0].X + (connectors[0].Width / 2), helpTextRectangle.Top - 2) };
                        base.DrawConnectors(e.Graphics, designerTheme.ForegroundPen, points, designerTheme.ConnectorStartCap, LineAnchor.None);
                        Point[] pointArray2 = new Point[] { new Point(connectors[0].X + (connectors[0].Width / 2), helpTextRectangle.Bottom + 2), new Point(connectors[0].X + (connectors[0].Width / 2), connectors[0].Bottom - 2) };
                        base.DrawConnectors(e.Graphics, designerTheme.ForegroundPen, pointArray2, LineAnchor.None, designerTheme.ConnectorEndCap);
                    }
                    ActivityDesignerPaint.DrawText(e.Graphics, designerTheme.Font, this.HelpText, helpTextRectangle, StringAlignment.Center, e.AmbientTheme.TextQuality, designerTheme.ForegroundBrush);
                }
                else
                {
                    Rectangle[] rectangleArray2 = this.GetConnectors();
                    for (int i = 0; i < rectangleArray2.Length; i++)
                    {
                        Pen        pen         = (i == this.CurrentDropTarget) ? e.AmbientTheme.DropIndicatorPen : designerTheme.ForegroundPen;
                        LineAnchor startCap    = (((i == 0) && (rectangleArray2.Length > 2)) || (i == (rectangleArray2.Length - 1))) ? LineAnchor.None : designerTheme.ConnectorStartCap;
                        LineAnchor endCap      = ((i == 0) || ((i == (rectangleArray2.Length - 1)) && (rectangleArray2.Length > 2))) ? LineAnchor.None : designerTheme.ConnectorEndCap;
                        Point[]    pointArray3 = new Point[] { new Point(rectangleArray2[i].Left + (rectangleArray2[i].Width / 2), rectangleArray2[i].Top + 2), new Point(rectangleArray2[i].Left + (rectangleArray2[i].Width / 2), rectangleArray2[i].Bottom - 2) };
                        base.DrawConnectors(e.Graphics, pen, pointArray3, startCap, endCap);
                    }
                }
            }
        }
Exemple #4
0
        protected override void OnPaint(ActivityDesignerPaintEventArgs e)
        {
            base.OnPaint(e);
            string targetState = this.TargetState;

            ActivityDesignerPaint.DrawText(e.Graphics, e.DesignerTheme.Font, targetState, this.TargetStateRectangle, StringAlignment.Center, e.AmbientTheme.TextQuality, e.DesignerTheme.ForegroundBrush);
        }
Exemple #5
0
 public virtual void OnPaint(ActivityDesignerPaintEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if ((!string.IsNullOrEmpty(this.Text) && !this.TextRectangle.Size.IsEmpty) && ((e.DesignerTheme != null) && (e.DesignerTheme.Font != null)))
     {
         using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1f, this.AssociatedDesigner.SmartTagVisible ? FontStyle.Bold : FontStyle.Regular))
         {
             ActivityDesignerPaint.DrawText(e.Graphics, font, this.Text, this.TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush);
         }
     }
     if ((this.Image != null) && !this.ImageRectangle.Size.IsEmpty)
     {
         ActivityDesignerPaint.DrawImage(e.Graphics, this.Image, this.ImageRectangle, DesignerContentAlignment.Fill);
     }
 }
        /// <summary>
        /// Draws the Header/Footer associated with workflow root designer.
        /// </summary>
        /// <param name="e">ActivityDesignerPaintEventArgs holding drawing arguments</param>
        public virtual void OnPaint(ActivityDesignerPaintEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (!String.IsNullOrEmpty(Text) && !TextRectangle.Size.IsEmpty && e.DesignerTheme != null && e.DesignerTheme.Font != null)
            {
                //use bold or regular font based on mouse over status
                using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, (this.AssociatedDesigner.SmartTagVisible) ? FontStyle.Bold : FontStyle.Regular))
                    ActivityDesignerPaint.DrawText(e.Graphics, font, Text, TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush);
            }

            if (Image != null && !ImageRectangle.Size.IsEmpty)
            {
                ActivityDesignerPaint.DrawImage(e.Graphics, Image, ImageRectangle, DesignerContentAlignment.Fill);
            }
        }
Exemple #7
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);
                    }
                }
            }
        }