The Problem Solver

Tell me and I will forget
Show me and I will remember
Involve me and I will understand
- Confucius -

Google Ads

This Blog

Syndication

Search

Tags

News





  • View Maurice De Beijer's profile on LinkedIn

Community

Email Notifications

Explore

Archives

January 2008 - Posts

Last week I did a session on VSTO for the Dutch VBcentral user group. You can download the samples and PowerPoint slides from their web site over here. Keep in mind that the sheets are in Dutch Smile.

Enjoy the samples, I enjoyed the presentation!

Posted by Maurice | with no comments
Filed under: , ,

State workflows are very useful when it comes to modeling human interaction workflows. But having a workflow to handle the business end is just one part of the equation, the user interface is another. Most of the time this user interface will need to have buttons and/or menu options to perform one of the possible actions. And how do you know which actions are possible in a given state? Well that is where the StateMachineWorkflowInstance class comes into play. Unfortunately this class is a little harder to find than the better known WorkflowInstance class. Why, well the WorkflowRuntime has a function GetWorkflow() taking a workflowId parameter to return a WorkflowInstance type but there is no matching function to return a StateMachineWorkflowInstance object. In fact you need to new up the StateMachineWorkflowInstance object passing in the WorkflowRuntime and the workflowId.

StateMachineWorkflowInstance stateMachine = _

new StateMachineWorkflowInstance(runtime, instanceId);

 

foreach (string possibleState in stateMachine.PossibleStateTransitions)

Console.WriteLine("We can transition to {0}", possibleState);

 

Among the more useful features of the StateMachineWorkflowInstance is the possibility to determine the current state, use the CurrentStateName or CurrentState properties, and the ability to determine all possible state transitions from the current state using the PossibleStateTransitions collections. This last collection tells you all the names of states that you can switch to from the current state. That is according to the state workflow as designed. Actually you can force a state switch to any other state using the SetState() function if you really want to but I guess that is a power feature that you should only use sparingly as it might be very confusing. So you need to know all the states in the StateWorkflow? Use the States collection and you are all done.

stateMachine.SetState("NewStateName");

 

If you are using one or more HandleExternalEventActivity objects to force the state changes there are even more goodies to be found. This time not specific to state workflows as the regular WorkflowInstance object is the provider, use the WorkflowInstance property if you already have a reference to a StateMachineWorkflowInstance object. This time you want to take a good look at the GetWorkflowQueueData() function. This returns a collection of WorkflowQueueInfo objects. One of the properties these WorkflowQueueInfo objects expose if the IComparable QueueName. No big deal you might think as this queue name is usually a string or a Guid. Not in this case, now we get a an EventQueueName object back describing the interface and the event configured for the HandleExternalEventActivity we are using.

foreach (WorkflowQueueInfo queueInfo in _

stateMachine.WorkflowInstance.GetWorkflowQueueData())

{

EventQueueName eventQueue = queueInfo.QueueName as EventQueueName;

if (eventQueue != null)

Console.WriteLine("Interface: {0} and method: {1}", _

        eventQueue.InterfaceType.FullName, _

eventQueue.MethodName);

}

 

Enjoy!

Posted by Maurice | with no comments
Filed under: , , , ,

If you want to add functionality to a specific Office document a Visual Studio Tools for Office (VSTO) ActionsPane is a very convenient way of doing so if you are a .NET developer.

Each document has a single associated ActionsPane so in this respect it is very different from a custom task pane as you can have multiple task panes. The actions pane is basically a WinForms UserControl, ok with the additional functionality of being able to work with Office, so adding controls is easy. Just like this:

Me.ActionsPane.Controls.Add(New TextBox())

Of course adding separate controls like this is probably not the best way to go. I would suggest designing your UI in one or more UserControls and adding these as it makes the layout so much easier.

When designing you controls you need to keep in mind that an actions pane can be moved and the orientation can change from vertical to horizontal. When this happens the ActionsPane.OrientationChanged event fires so that one is easy to take care of.

Private Sub OrientationChangedHandler() _

Handles ActionsPane.OrientationChanged

 

If Me.ActionsPane.Orientation = Orientation.Vertical Then

Else

' Me.ActionsPane.Orientation = Orientation.Horizontal

End If

End Sub

 

One thing I find less than intuitive is showing or hiding the actions pane. I would have expected something like a visible property to do so. Not so as this only makes the contents visible or invisible if the action pane is shown. If the actions pane itself is invisible you need to use the DisplayDocumentActionTaskPane property scoped to the application object. Somewhat confusing and judging from the property name so was the original developer. What am I showing here? An ActionsPane or a TaskPane? Hmm not sure, let's just put both in the name so everyone will be as confused as I am Sad O well, except for this inconsistency its really easy to use the ActionsPane Smile

Private Sub Button1_Click( _

ByVal sender As System.Object, _

ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) _

Handles Button1.Click

 

Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = True

End Sub

 

Did I mention you can even add WPF content to an actions pane? Hmm guess I forgot to say you can. Just make sure you wrap it in a System.Windows.Forms.Integration.ElementHost control.

Enjoy!

Posted by Maurice | 1 comment(s)
Filed under: , , ,

Installing MOSS 2007 is quite a bit of work and very easy to mess up if you do it in the wring order Sad

To help Tony Zink has created a very detailed series of blog posts showing the complete process. He is very detailed and has a lot of useful tips so make sure you read this before you start!

Enjoy MOSS!

Posted by Maurice | with no comments
Filed under: , , ,

VMware is a really nice product to use; it should save me heaps of problems with my machine while working on different projects. But even with a new laptop with 200Gb disk space I seem to be running short. In part because of the loads of pictures I keep on my disk and in part because these virtual disks tend to be rather large.

Cleaning up my pictures is something I just need to do, guess I should just remove a bunch and archive the bulk of the remainder to an external hard drive. Guess there is no way around that, I really need to do it myself Sad

But when it comes down to VMware disks there is a nice solution called Invirtus called vOptimizer. I used this for a test and turned a 38Gm Vista images into a 13.5 Gb file. Still a big file but less than half, very impressive Smile. And the desktop version costing $ 76.00 is just about free when you are paid in Euros Smile So you would expect me to buy it right? Well I would except for one small problem and that is the fact that it only runs on a 32bits host and I am running the 64bits version of Vista. They tell me that a 64bits version is coming, in fact they offered to include me in the beta, so stay tuned for more.

Enjoy!

Posted by Maurice | with no comments
Filed under: ,