WF Designer: Glyph provider is not being used by my viewer

Hi all,

I have a web page that displays the workflow image for a given workflow instance id. I based this code on the WorkflowMonitor in the June CTP SDK. To avoid CAS issues, my workflowViewer saves the workflow image as a stream which is returned to the web page for rendering (as opposed to hosting a designer surface directly in a web page).

This is working fine, however I am unable to hook in the glyph provider to mark Closed and Executing activities, as is done in the SDK.

Here's the relevant code extract:

IDesignerGlyphProviderService glyphService = (IDesignerGlyphProviderService)designSurface.GetService(typeof(IDesignerGlyphProviderService));
WorkflowMonitorDesignerGlyphProvider glyphProvider = new WorkflowMonitorDesignerGlyphProvider(activityStatusListValue);
glyphService.AddGlyphProvider(glyphProvider);

using (workflowView = new WorkflowView(designSurface))
{
workflowView.Dock = DockStyle.Fill;
((IDesignerLoaderHost)designerHost).EndLoad(designerHost.RootComponent.Site.Name, true, null);
workflowView.SaveWorkflowImage(stream, imageInfo.ImageFormat);
}
return stream;

The WorkflowMonitorDesignerGlyphProvider is identical to the corresponding class in the SDK.

When I debug the SDK WorkflowMonitor I see that the IDesignerGlyphProvider.GetGlyphs in the Glyph provider is called at some point after the .EndLoad() call. However in my implementation, GetGlyphs is never called and I am trying to find out why?

I thought perhaps this is because I don't have a control container that my workflow viewer is added to. In my case I keep the workflow viewer in memory, save the workflow image as a stream, then dispose. I tried creating a temporary form control object and adding the workflowView to it to see if that would trigger the GetGlyphs call - but it didn't.

So, does anyone know what calls the GetGlyph method of the Glyph provider and how I might go about invoking this myself to mimic what happens in the win form environment.

Any and all help is greatly appreciated.

Thanks

Steve

[2139 byte] By [SteveNesbitt] at [2007-12-24]
# 1
Steve - I think workflowView.PerformLayout might be the thing you are looking for (although I am not 100% sure)
JonFlanders at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

A good suggestion, Jon, but sadly it didnt work for me. I tried adding that statement before and after the EndLoad() call.

Thanks

Steve

SteveNesbitt at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Do your glyphs work if your control is hosted in a windows form?
JonFlanders at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Yes they do, and I have copied the same provider class into my web environment.
SteveNesbitt at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
Feel free to send me the project - I'll try to see what the problem is
JonFlanders at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Thanks very much Jon - I forwarded the project files to your gmail account.

Steve

SteveNesbitt at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 7

I think I have traced it down to the fact that in a windows form enviornment the System.Workflow.ComponentModel.Design.WorkflowView object is added to a panel object, where as in the web environment I instantiated the WorkflowView object in memory and just used it to SaveWorkflowImage. I suspect that it is the Paint event of the panel that is firing the IDesignerGlyphProvider.GetGlyphs() method. I have tried creating an in memory panel object, adding the WorkflowView object to it and calling panel.Show(), but that doesnt work either. (Also tried panel.Refresh() and panel.PerformLayout()).

Does anyone know another way I can manually call the Paint event for a control?

Thanks

Steve

SteveNesbitt at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 8
If anyone is following this thread to solve a similar problem, I tracked down my issue to the fact I was disposing the workflowDefinition too early.
SteveNesbitt at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified