首先将工作流加载到设计器中。
您应该已经知道要突出显示的“活动”。工作流程中有选择服务,您可以使用它来选择适当的模型项目。此示例显示单个选择,但有多个。
ModelService modelService = wd.Context.Services.GetService<ModelService>();
IEnumerable<ModelItem> activityCollection = modelService.Find(modelService.Root, typeof(Activity));
Selection.Select(wd.Context, activityCollection.ElementAt(5));
在工作流设计器上有一个按钮可以将工作流复制为图像或类似的东西。此链接将向您展示如何从 WorkflowDesigner.View 获取 jpg。
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b781c8df-608a-485a-80e3-a795d800f08d
const double DPI = 96.0;
Rect size = VisualTreeHelper.GetDescendantBounds(view);
int imageWidth = (int)size.Width;
int imageHeight = (int)size.Height;
RenderTargetBitmap renderBitmap = new RenderTargetBitmap(imageWidth, imageHeight, DPI, DPI, PixelFormats.Pbgra32);
renderBitmap.Render(view);
BitmapFrame bf = BitmapFrame.Create(renderBitmap);
using (FileStream fs = new FileStream(@"c:\test.jpg", FileMode.Create))
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bf));
encoder.Save(fs);
fs.Close();
}
作为补充说明,您应该查看 Kushals 示例:
http://blogs.msdn.com/b/kushals/archive/2009/12/22/visualworkflowtracking-aka-workflowsimulator.aspx