locked
Could not generate view for RRS feed

  • Question

  • Hi,

     

    Could you please tell me why I get "Could not generate view for Action", where classes Action and Designer are as follows

     

    using System;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Collections;
    using System.Drawing;
    using System.Workflow.ComponentModel;
    using System.Workflow.ComponentModel.Design;
    using System.Workflow.ComponentModel.Compiler;
    using System.Workflow.ComponentModel.Serialization;
    using System.Workflow.Runtime;
    using System.Workflow.Activities;
    using System.Workflow.Activities.Rules;
    using System.Drawing.Drawing2D;
    
    namespace Microsoft.Samples
    {
      [Designer(typeof(ActionDesigner), typeof(IDesigner))]
      public partial class Action : System.Activities.CodeActivity
      {
        public Action()
        {
        }
    
        protected override void Execute(System.Activities.CodeActivityContext context)
        {
          
        }
      }
    
      public class ActionDesigner : FreeformActivityDesigner
      {
        protected Rectangle frameRect;
        protected Rectangle pageRect;
    
        private Color _baseColor;
    
        private Color BaseColor
        {
          get { return _baseColor; }
          set { _baseColor = value; }
        }
    
        private Color _lightingColor;
    
        private Color LightingColor
        {
          get { return _lightingColor; }
          set { _lightingColor = value; }
        }
    
        private Color _titleLightingColor;
    
        private Color TitleLightingColor
        {
          get { return _titleLightingColor; }
          set { _titleLightingColor = value; }
        }
    
        private Color _titleBaseColor;
    
        private Color TitleBaseColor
        {
          get { return _titleBaseColor; }
          set { _titleBaseColor = value; }
        }
    
    
        private bool _isExecuting;
    
        public bool IsExecuting
        {
          get { return _isExecuting; }
          set { _isExecuting = value; }
        }
    
    
    
        protected override void OnDragDrop(ActivityDragEventArgs e)
        {
          base.OnDragDrop(e);
        }
    
        public ActionDesigner()
        {
          BaseColor = Color.FromArgb(255, 255, 255, 255);
          LightingColor = Color.FromArgb(255, 176, 186, 198);
          TitleBaseColor = Color.FromArgb(255, 0, 0, 0);
          TitleLightingColor = Color.FromArgb(255, 50, 50, 50);
        }
    
        protected override void OnPaint(System.Workflow.ComponentModel.Design.ActivityDesignerPaintEventArgs e)
        {
          frameRect = new Rectangle(this.Location.X + 6, this.Location.Y + 3, this.Size.Width - 12, this.Size.Height - 13);
          Rectangle shadowRect = new Rectangle(frameRect.X + 4, frameRect.Y + 6, frameRect.Width - 8, frameRect.Height - 6);
          pageRect = new Rectangle(frameRect.X + 10, frameRect.Y + 22, frameRect.Width - 8, frameRect.Height - 28);
          Rectangle titleRect = new Rectangle(frameRect.X + 20, frameRect.Y + 5, frameRect.Width / 2 + 15, 15);
          Rectangle imageRect = new Rectangle(frameRect.X + 20, frameRect.Y + frameRect.Height / 2 - 20, 40, 40);
    
    
          Brush titleBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + 25), TitleBaseColor, TitleLightingColor);
          Brush glossBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + 13), Color.FromArgb(120, 255, 255, 255), Color.FromArgb(16, 255, 255, 255));// SolidBrush(Color.FromArgb(32, 255, 255, 255));
          Brush frameBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Bottom), BaseColor, LightingColor);
    
    
          Graphics outputGraphics = e.Graphics;
          shadowRect = DropRoundedRectangleShadow(shadowRect, outputGraphics);
    
          e.Graphics.FillPath(frameBrush, RoundedRect(frameRect));
          e.Graphics.DrawPath(Pens.Gray, RoundedRect(frameRect));
          e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
          e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
          e.Graphics.DrawString(Activity.QualifiedName, new Font("Calibri", 9), Brushes.Black, titleRect);
    
          base.PaintContainedDesigners(e);
    
        }
    
    
    
        private Rectangle DropRoundedRectangleShadow(Rectangle shadowRect, Graphics outputGraphics)
        {
          int shadowIntensity = 1;
          Pen shadowPen = new Pen(Color.FromArgb(shadowIntensity, 0, 0, 0));
          Brush shadowBrush = new SolidBrush(shadowPen.Color);
          shadowPen.Width = 24;
          for (int i = 0; i < 12; i++)
          {
            outputGraphics.DrawPath(shadowPen, RoundedRect(shadowRect));
            if (IsExecuting)
              shadowPen.Color = Color.FromArgb(10 + shadowIntensity - 1, 0, 120, 255);
            else
              shadowPen.Color = Color.FromArgb(shadowIntensity - 1, 0, 0, 0);
            shadowIntensity += 4;
            shadowPen.Width = shadowPen.Width - 2; ;
            //shadowRect = Rectangle.Inflate(shadowRect, -1, -1);
          }
          return shadowRect;
        }
    
    
        private GraphicsPath RoundedRectTopHalf(Rectangle frame, int height)
        {
          GraphicsPath path = new GraphicsPath();
          int radius = 7;
          int diameter = radius * 2;
          Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter);
          path.AddArc(arc, 180, 90);
          arc.X = frame.Right - diameter;
          path.AddArc(arc, 270, 90);
          Point[] curvePoints = new Point[3];
          curvePoints[0] = new Point(frame.Right, frame.Top + height);
          curvePoints[1] = new Point((frame.Left + frame.Right) / 2, frame.Top + height);
          curvePoints[2] = new Point(frame.Left, frame.Top + height);
          path.AddCurve(curvePoints);
          //path.AddLine(new Point(frame.Right, frame.Top + 26), new Point(frame.Left, frame.Top + 26));
          path.CloseFigure();
          return path;
        }
    
        private GraphicsPath RoundedRect(Rectangle frame)
        {
          GraphicsPath path = new GraphicsPath();
          int radius = 7;
          int diameter = radius * 2;
          Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter);
          path.AddArc(arc, 180, 90);
          arc.X = frame.Right - diameter;
          path.AddArc(arc, 270, 90);
          arc.Y = frame.Bottom - diameter;
          path.AddArc(arc, 0, 90);
          arc.X = frame.Left;
          path.AddArc(arc, 90, 90);
          path.CloseFigure();
          return path;
        }
        public override Size MinimumSize
        {
          get
          {
            return new Size(100, 80);
          }
        }
    
    
        protected override void OnConnected(ConnectionPoint source, ConnectionPoint target)
        {
          base.OnConnected(source, target);
        }
      }
    }
    
    
    Thank you very much

    Monday, August 30, 2010 10:24 AM

Answers

  • Hi SL1234,

    It looks like you are trying to mix WF 4.0 activities and WF 3.0 designer code. I think you may have searched for custom activity designers and found a WF 3 sample/guide without realizing it. This probably won't work out. Try having a look at the WF 4 basic samples instead.

    http://msdn.microsoft.com/en-us/library/dd699771.aspx

    Tim

    • Proposed as answer by Andrew_Zhu Thursday, September 2, 2010 7:40 AM
    • Marked as answer by Andrew_Zhu Monday, September 6, 2010 2:03 AM
    Monday, August 30, 2010 4:38 PM

All replies

  • Hi SL1234,

    Using "Action" isn't really a good idea it is the name of an other important delegate used in .net and WF.

    Try to use an other name not reserved ;)


    Jérémy Jeanson MCP, MCTS http://blogs.codes-sources.com/JeremyJeanson/ (French or English spoken)
    Monday, August 30, 2010 12:25 PM
  • Thank you very much for answering.

    I have changed from Action to Action123 and I got same result.

    Could you tell me where I could find a sample of WWF re hosted and FreeFormActivityDesigner so I can start from there? I need free layout.

    Once again, thank you very much for answering

    Monday, August 30, 2010 12:41 PM
  • Hi SL1234,

    do you really need to use GDI?

    a simple WF3 ActivityDesignerTheme like this sould be a nice base for you?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Workflow.ComponentModel.Design;
    using System.Drawing;
    
    namespace Activitys
    {
      [ActivityDesignerThemeAttribute(typeof(RunDesignerTheme))]
      internal class RunDesigner : ActivityDesigner
    	{
    	}
    
      internal class RunDesignerTheme : ActivityDesignerTheme
      {
        public RunDesignerTheme(WorkflowTheme theme)
          : base(theme)
        {
          this.BackColorStart = Color.Black;
          this.BackColorEnd = Color.Gray;
          this.ForeColor = Color.White;
          this.BackgroundStyle = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
          this.BorderColor = Color.White;
        }
      }
    }
    

    Jérémy Jeanson MCP, MCTS http://blogs.codes-sources.com/JeremyJeanson/ (French or English spoken)
    Monday, August 30, 2010 12:48 PM
  • I need FreeFormActivityDesigner because I want to use it as a base for free layout( to add other activities with design class also  derived from FreeFormActivityDesigner)  and override needed methods (OnConnectorAdded, OnMouseDoubleClick etc). Of course, code provided here is just a sample as I'm trying to figure out how to do this.

    Thank you very much for answering

    Monday, August 30, 2010 12:57 PM
  • Hi SL1234,

    It looks like you are trying to mix WF 4.0 activities and WF 3.0 designer code. I think you may have searched for custom activity designers and found a WF 3 sample/guide without realizing it. This probably won't work out. Try having a look at the WF 4 basic samples instead.

    http://msdn.microsoft.com/en-us/library/dd699771.aspx

    Tim

    • Proposed as answer by Andrew_Zhu Thursday, September 2, 2010 7:40 AM
    • Marked as answer by Andrew_Zhu Monday, September 6, 2010 2:03 AM
    Monday, August 30, 2010 4:38 PM
  • Just to get this clear , my question for "FreeFormActivityDesigner sample" in WWF 4.0 is useless?

    I see that this class and the base activity need to use System.Workflow.ComponentModel, so I guess that's why when I add to a Sequence for example gives me the error with "could not generate view for".

    If that's so, that's a bummer because I would've really liked having the CanConnect property for example.

    What do you recommend for me to use in WWF 4 so I can use methods like CanConnect and all the other properties related to Connectors?

    In fact, let me create a new question :) (http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/e46acf18-e369-4191-8b4f-3234b957ece8)

    Thank you very much

    Tuesday, August 31, 2010 7:37 AM
  • Another thing that I have noticed is that Connectors aren't available( I can't connect 2 Activity1). Am I missing something?

    Thank you

    Tuesday, August 31, 2010 2:02 PM