none
Freeform Custom Activity Designers using ICompositeView

Answers

  • Hi SL1234,

    I thought you might be having that exact problem too. However, I ran your solution and I now think the problem is a bit different. I fixed the zipped code to read wd.Load(new CanvasActivity) as you pasted above

    Once I had canvasActivity visible I could see the problem you are talking about. However, I could debug it by setting breapoints in the OnDragEnter etc. methods.

    If we look at the fields on the DragEventArgs, e.AllowedEffects is for some reason Copy | Link. When we bitwise & that with DragDropEffects.Move we will get zero, which is why drag/drop becomes disabled.

    Question is why is AllowedEffects Copy | Link originally?

    Well, I currently have no idea what the answer is. And the bigger question is how did the original code ever work?! And did it suddenly stop working, or what?

    As far as I can tell the System.Activities.Presentation ToolboxControl has always set allowed effects to Copy | Link. But another way it could stop working is if there was e.g. a fix to WPF which changed how allowed effects is processed...

    Anyway, the workaround or fix seems to be setting

    e.Effects = DragDropEffects.All;

    instead of doing that bitwise & logic which (mysteriously!) used to work. Thanks for a very interesting question.

    P.S. thought about this some more, and realized that maybe it used to work because I did all of my testing inside of VS instead of inside the rehosted app. In which case the toolbox could set up the drag-drop object data slightly differently. Again thanks for the blog bug report.

    Tim

    Monday, August 30, 2010 5:17 PM
    Moderator

All replies

  • From what I see, the problem might be that it's derived from NativeActivity and it's not something composite. Could you give me some pointers, please?
    Thursday, August 26, 2010 2:04 PM
  • Hi, are you using code from later in the series (e.g. post 7 or 8)? The earlier code has lots of bugs, the later code has more features/bug fixes. But it is not nearly as fully featured as the state machine activity which has source code released on wf.codeplex.com. It shouldn't matter what class your activity class is, by the way. I don't know if it's possible to make the canvas activity fill the workflow designer. You can selectively stop people deleting it by intercepting the delete command.
    Tim

    Friday, August 27, 2010 6:19 AM
    Moderator
  • Hi,

    I'm using code from post 7( Reacting to ViewState Changes … and finally using AttachedPropertiesService) http://blogs.msdn.com/b/tilovell/archive/2010/01/25/reacting-to-viewstate-changes.aspx. I was unable to find post 8. Please give me a link.

    Thank you for replying

     

     

    Friday, August 27, 2010 9:17 AM
  • Sorry, just said 7 or 8 because I couldn't remember how many posts there actually were. :)

    So, starting with the questions again, the drag and drop isn't working at all for you? Is your activity set as the root activity? Does it start working if your activity is within sequence instead?

    Or is it something a bit different?

    Tim

    Saturday, August 28, 2010 12:31 AM
    Moderator
  • Hi,

     

    The drag & drop doesn't work at all. The code for adding Canvas is

     // create the workflow designer
          WorkflowDesigner wd = new WorkflowDesigner();
          wd.Load(new CanvasActivity());
          DesignerBorder.Child = wd.View;
          PropertyBorder.Child = wd.PropertyInspectorView;
    

    Maybe that's wrong.

    Yes, it does add Activity1 when I set

    wd.Load(new Sequence());
    
    You may download the code (if it's not asking too much) from 

    http://uploading.com/files/dbfbc9b2/WorkflowItemPresenter.zip/

    Saturday, August 28, 2010 3:03 PM
  • On the posted code, there is a small mistake, there should be

     

    wd.Load(new CanvasActivity());

    like in the previous post. The following code is executed (if returns true, methods OnDragEnter and OnDragOver)

     

     if (DragDropHelper.AllowDrop(
    
     e.Data,
     this.Context,
     typeof(Activity)))
     {
     e.Effects = (DragDropEffects.Move & e.AllowedEffects);
     e.Handled = true;
     }

    but the OnDrop is never called.

    Am I doing something wrong other than that ?

    Thank you

    P.S. I seem to have the issues from post 4 http://blogs.msdn.com/b/tilovell/archive/2010/01/06/freeform-custom-activity-designers-using-icompositeview-part-4.aspx. Should I be using OnPreview?

    Edit: used OnPreviewDrop with no results

    Monday, August 30, 2010 6:12 AM
  • I found this post: http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/ca2cf16f-fece-4df1-9b9e-e2f909b7fbb5

    which is exactly the problem I'm dealing with. However he changed the content of the designer. I also can catch the OnDragLeave event.

    However, his solution doesn't help me too much because it only works in his case.

    Could you tell me how I could solve the OnDragDrop not firing problem?

    Thank you

    • Edited by SL1234 Monday, August 30, 2010 9:26 AM
    Monday, August 30, 2010 8:29 AM
  • I wouldn't use this if I didn't really need arbitrary layout
    Monday, August 30, 2010 9:08 AM
  • Hi SL1234,

    I thought you might be having that exact problem too. However, I ran your solution and I now think the problem is a bit different. I fixed the zipped code to read wd.Load(new CanvasActivity) as you pasted above

    Once I had canvasActivity visible I could see the problem you are talking about. However, I could debug it by setting breapoints in the OnDragEnter etc. methods.

    If we look at the fields on the DragEventArgs, e.AllowedEffects is for some reason Copy | Link. When we bitwise & that with DragDropEffects.Move we will get zero, which is why drag/drop becomes disabled.

    Question is why is AllowedEffects Copy | Link originally?

    Well, I currently have no idea what the answer is. And the bigger question is how did the original code ever work?! And did it suddenly stop working, or what?

    As far as I can tell the System.Activities.Presentation ToolboxControl has always set allowed effects to Copy | Link. But another way it could stop working is if there was e.g. a fix to WPF which changed how allowed effects is processed...

    Anyway, the workaround or fix seems to be setting

    e.Effects = DragDropEffects.All;

    instead of doing that bitwise & logic which (mysteriously!) used to work. Thanks for a very interesting question.

    P.S. thought about this some more, and realized that maybe it used to work because I did all of my testing inside of VS instead of inside the rehosted app. In which case the toolbox could set up the drag-drop object data slightly differently. Again thanks for the blog bug report.

    Tim

    Monday, August 30, 2010 5:17 PM
    Moderator
  • Thank you very much for answering this question and the other question. I really appreciate it.

     

    Tuesday, August 31, 2010 7:36 AM