/// <summary> /// Creates a new Workflow Designer instance with C# Expression Editor /// </summary> /// <param name="sourceFile">Workflow FileName</param> public static void NewInstanceCSharp(string sourceFile = _defaultWorkflowCSharp) { _expressionEditorService = new RoslynExpressionEditorService(); ExpressionTextBox.RegisterExpressionActivityEditor(new CSharpValue <string>().Language, typeof(RoslynExpressionEditor), CSharpExpressionHelper.CreateExpressionFromString); _wfDesigner = new WorkflowDesigner(); _wfDesigner.Context.Services.GetService <DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5)); _wfDesigner.Context.Services.GetService <DesignerConfigurationService>().LoadingFromUntrustedSourceEnabled = true; _wfDesigner.Context.Services.Publish <IExpressionEditorService>(_expressionEditorService); //associates all of the basic activities with their designers new DesignerMetadata().Register(); //load Workflow Xaml _wfDesigner.Load(sourceFile); SelectHelper._wfDesigner = _wfDesigner; if (!SelectHelper.WorkflowDictionary.ContainsKey(sourceFile)) { SelectHelper.WorkflowDictionary.Add(sourceFile, _wfDesigner); } else { SelectHelper.WorkflowDictionary[sourceFile] = _wfDesigner; } if (!SelectHelper.RuntimeApplicationHelperDictionary.ContainsKey(sourceFile)) { SelectHelper.RuntimeApplicationHelperDictionary.Add(sourceFile, new RuntimeApplicationHelper()); } }
/// <summary> /// Creates a new Workflow Designer instance with C# Expression Editor /// </summary> /// <param name="sourceFile">Workflow FileName</param> public static WorkflowDesigner NewInstance(string sourceFile = _defaultActivity) { if (string.IsNullOrWhiteSpace(sourceFile)) { sourceFile = Path.Combine(AssemblyDirectory, _defaultActivity); } var expressionEditorService = new RoslynExpressionEditorService(); ExpressionTextBox.RegisterExpressionActivityEditor(new CSharpValue <string>().Language, typeof(RoslynExpressionEditor), CSharpExpressionHelper.CreateExpressionFromString); var wfDesigner = new WorkflowDesigner(); var dcs = wfDesigner.Context.Services.GetService <DesignerConfigurationService>(); dcs.TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 6, 1)); dcs.LoadingFromUntrustedSourceEnabled = true; wfDesigner.Context.Services.Publish <IExpressionEditorService>(expressionEditorService); //associates all of the basic activities with their designers new DesignerMetadata().Register(); string temp = File.ReadAllText(Path.Combine(AssemblyDirectory, @"colors.xaml")); StringReader reader = new StringReader(temp); XmlReader xmlReader = XmlReader.Create(reader); ResourceDictionary fontAndColorDictionary = (ResourceDictionary)System.Windows.Markup.XamlReader.Load(xmlReader); //var keys = GetColorKeys(); //foreach (var key in keys) //{ // fontAndColorDictionary[key] = Brushes.Pink; //} Hashtable hashTable = new Hashtable(); foreach (var key in fontAndColorDictionary.Keys) { hashTable.Add(key, fontAndColorDictionary[key]); } wfDesigner.PropertyInspectorFontAndColorData = XamlServices.Save(hashTable); //load Workflow Xaml wfDesigner.Load(sourceFile); //var g = wfDesigner.View as Grid; //g.Background = Brushes.Pink; return(wfDesigner); }