internal void Draw(Graphics graphics)
 {
     if ((this.transparency != 0f) && (this.buttons.Count != 0))
     {
         ActivityDesignerPaint.Draw3DButton(graphics, null, this.Bounds, this.transparency - 0.1f, ButtonState.Normal);
         for (int i = 0; i < this.buttons.Count; i++)
         {
             Rectangle    buttonBounds = this.GetButtonBounds(i);
             ActionButton button       = this.buttons[i];
             if (button.StateImages.Length == 1)
             {
                 Image image = button.StateImages[0];
                 if ((button.State == ActionButton.States.Normal) || (button.State == ActionButton.States.Disabled))
                 {
                     buttonBounds.Inflate(-2, -2);
                     ActivityDesignerPaint.DrawImage(graphics, image, buttonBounds, new Rectangle(Point.Empty, image.Size), DesignerContentAlignment.Fill, this.transparency, button.State == ActionButton.States.Disabled);
                 }
                 else
                 {
                     ButtonState buttonState = (button.State == ActionButton.States.Highlight) ? ButtonState.Normal : ButtonState.Pushed;
                     ActivityDesignerPaint.Draw3DButton(graphics, image, buttonBounds, this.transparency, buttonState);
                 }
             }
             else
             {
                 Image image2 = this.buttons[i].StateImages[(int)this.buttons[i].State];
                 buttonBounds.Inflate(-2, -2);
                 ActivityDesignerPaint.DrawImage(graphics, image2, buttonBounds, new Rectangle(Point.Empty, image2.Size), DesignerContentAlignment.Fill, this.transparency, false);
             }
         }
     }
 }
        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);
                    }
                }
            }
        }