//Expand or collapse all composite activities static public byte[] GetWorkflowImageBinary(Activity workflowDefinition, Dictionary <string, ActivityStatusInfo> activityStatusList) { AutoResetEvent waitHandle = new AutoResetEvent(false); byte[] results = null; Thread thread = new Thread(delegate() { Loader loader = new Loader(); WorkflowDesignSurface surface = new WorkflowDesignSurface(new MemberCreationService()); IDesignerHost host = (IDesignerHost)surface.GetService(typeof(IDesignerHost)); if (host == null) { waitHandle.Set(); return; } loader.WorkflowDefinition = workflowDefinition; surface.BeginLoad(loader); if (activityStatusList != null) { IDesignerGlyphProviderService glyphService = surface.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService; WorkflowMonitorDesignerGlyphProvider glyphProvider = new WorkflowMonitorDesignerGlyphProvider(activityStatusList); glyphService.AddGlyphProvider(glyphProvider); } ((IDesignerLoaderHost)host).EndLoad(host.RootComponent.Site.Name, true, null); IDesignerHost designerHost = surface.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null && designerHost.RootComponent != null) { IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner; if (rootDesigner != null) { MemoryStream ms = new MemoryStream(); WorkflowView workflowView = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView; workflowView.SaveWorkflowImage(ms, ImageFormat.Png); results = ms.GetBuffer(); } } waitHandle.Set(); }); thread.IsBackground = true; thread.SetApartmentState(ApartmentState.STA); thread.Start(); waitHandle.WaitOne(); return(results); }
static void TestWorkflowView() { GlobalWorkflowRuntime.StartRuntime("Data source=S2;Initial catalog=ibn48portal;User ID=dev;Password="******"Data source=S2;Initial catalog=ibn48portal;User ID=dev;Password="******"23ec347d-0529-43d4-ab34-d916f754b0df")); #region xaml string string xaml = @"<?xml version=""1.0"" encoding=""utf-16""?><SequentialWorkflowActivity " + @"x:Name=""SequentialWorkflowActivity_Root"" " + @"xmlns:ns0=""clr-namespace:Mediachase.Ibn.Assignments;Assembly=Mediachase.Ibn.Assignments, " + @"Version=4.7.54.0, Culture=neutral, PublicKeyToken=null"" " + @"xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" " + @"xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/workflow"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_ce11db253f434983b25f7a7f5b056145"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_0c22583fd14344d9a82d43cc674ab0d7"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:BlockActivity x:Name=""blockActivity_8ef17c90ba4a4a09bd92d5dc14b3e779"">"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_0f4cb38833a643fabad5fafb88d76657"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_bf381aae62aa4732ba5328140e3b8a09"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" </ns0:BlockActivity>"+ Environment.NewLine + @" <ns0:BlockActivity x:Name=""blockActivity_a6c544f45e3b4b4facba5193b307291e"">"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_7f8498d01af740eda769250ddaa8912b"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_97f018bfd3fb47cdac6c569394d2856e"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_96cf746ba7724deca0a1e3b42e8a6623"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_a05219765fec40d9bb50fb4f463110cc"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_88c79524e0ec44a5985caf02b1735400"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity RequestProperties=""{x:Null}"" "+ @"x:Name=""createAssignmentAndWait_7e3ed79e3a8e4c02bedb6d780f61b416"">" + Environment.NewLine + @" <ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" <ns0:PropertyValueCollection>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""Subject"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:String xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">OZ OverDue Test 3</ns1:String>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" <ns0:PropertyValue Name=""UserId"">"+ Environment.NewLine + @" <ns0:PropertyValue.Value>"+ Environment.NewLine + @" <ns1:Int32 xmlns:ns1=""clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, "+ @"Culture=neutral, PublicKeyToken=b77a5c561934e089"">65</ns1:Int32>" + Environment.NewLine + @" </ns0:PropertyValue.Value>"+ Environment.NewLine + @" </ns0:PropertyValue>"+ Environment.NewLine + @" </ns0:PropertyValueCollection>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity.AssignmentProperties>"+ Environment.NewLine + @" </ns0:CreateAssignmentAndWaitResultActivity>"+ Environment.NewLine + @" </ns0:BlockActivity>"+ Environment.NewLine + @"</SequentialWorkflowActivity>"; #endregion Activity wf = McWorkflowSerializer.GetObject <Activity>(xaml); WorkflowView view = CreateWorkflowView(wf); view.SaveWorkflowImage(@"C:\1.png", System.Drawing.Imaging.ImageFormat.Png); }