Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment

Programmatically adding a child activity from the activity designer

A child activity can be added to a composite activity using the composite activity’s designer object using the following method
This is useful when you have to add a specific child or a bunch of children based on an designer verb, (  e.g. using context menu).

Posted in Uncategorized | 2 Comments

How to determine if a given composite activity is a custom activity

When walking the workflow’s activity tree, you’ll encounter all the child activities of composite activities including, the children that were dropped into activity.xoml or activity.cs of  the composite activity. If you ever need to find just  the activities dropped into the current workflow, and not the ones indireclty in the tree throgu the custom activities, here is what you can do.
Ignore an activity if somewhere in its path to the root exists a composite such that, an instance of that composite activity type when created using activator create instance ,has child activities in it already.
Posted in Windows Workflow Foundation | 11 Comments

Yod’m 3D

A very nice virtual desktop manager for Windows.
Posted in Computers and Internet | Leave a comment

Rehosted Workflow designer and State machine designer layout

If you wondered why all your states were stacked on each other when rehosting the workflow designer, here is what you need to do.

The workflow designer saves the layout information in a .layout file corresponding to the workflow file. ( StateMachineWorkflow1.xoml or StateMachineWorkflow1.cs will have a StateMachineWorkflow1.layout generated by the VS workflow designer).

When rehosting the state machine workflow, in your rehosting app, use a derived WorfklowDesignerLoader instead of the base and inside PerformLoad() call LoadDesignerLayout() and point the xml reader to your layout file.

LoadDesignerLayout(XmlReader layoutReader, out IList layoutLoadErrors)

alternatively if you are loading the workflow from a compiled assembly you could use this method

LoadDesignerLayoutFromResource(Type type, string manifestResourceName, out IList errors)

Posted in Uncategorized | 8 Comments

Winforms and non-STA Threads

Recently I came across a request for a workaround the STAThread problem from a customer. He wanted to show a Save file dialog from within a CallExternalMethod activity. Since this thread is owned by the workflow instance there is no way to set the apartment state of this thread to ApartmentState.STA. This snippet works around the problem. ( Although In general using block UI elements like this inside of workflows is not recommended)

string fileSavePath;
Thread newThread = new Thread(delegate()
          using (SaveFileDialog saveFileDialog = new SaveFileDialog())
                 if (saveFileDialog.ShowDialog() == DialogResult.OK)
                           fileSavePath = saveFileDialog.FileName;

Posted in Windows Workflow Foundation | 35 Comments

Zune Zune

I won a Zune a few days back in raffle that was a part of the Microsoft’s CSD Giving Campaign. The Zune will be released on Nov 14th 2006. Eagerly waiting for my Zune 🙂
Posted in Uncategorized | 9 Comments

Updating UI from a different thread

Recently we came across a situation where we had to update the UI from a thread other than the UI thread in a WPF application. In windows forms this can be easily handled by some thing like
(where this is a Form object or a control object owned by the UI thread)

void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
      this.Invoke(new System.Windows.Forms.MethodInvoker(delegate
.ProgressBar.Value = e.ProgressPercentage;

After some digging I figured out that the WPF equivalent of the above is as follow. this here is the Window.

void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
      this.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Windows.Forms.MethodInvoker(delegate()
           this.ProgressBar.Value = e.ProgressPercentage;

Although this works perfectly I’m still using the Windows.Forms.MethodInvoker, need to find an equivalent in the WPF world.

Update: just found this works and doesn’t need the winforms reference anymore.

void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
      this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)( ()=>
           this.ProgressBar.Value = e.ProgressPercentage;

Posted in WPF | 83 Comments

IDataObject WPF Winforms Interop

I encountered  a strange problem today when writing an App which involved WPF and Winform interop. While drag dropping from a winforms control into a WPF control,  the WPF control gives you System.Windows.IDataObject in its drag event args. But I needed the dataObject as a System.Windows.Forms.IDataObject object. After looking for solutions to convert , I figured out this tiny bit of code will takee care of it 🙂
System.Windows.Forms.DataObject winformDataobject = new System.Windows.Forms.DataObject();
foreach (string format in wpfDataObject.GetFormats())
         winformDataobject.SetData(format, wpfDataObject.GetData(format));
Posted in WPF | 56 Comments

Flowchart workflow – FreeFormActivityDesigner sample

Here is the long due sample for writing custom activity designers utilizing the freeform activitydesigner. This is still a very crude sample, so we will try to post improved versions from time to time. Thanks to Arjun for the Executors and Validators. The validators show a false positive sometimes because of a bug that we will be fixing soon.


here is a preview of the flowchart workflowtype get http://www.thispointer.com/workflows/FlowChart.jpg

Posted in Windows Workflow Foundation | 20 Comments