public DesignerViewModel()
        {
            #region Préparation du designer

            // Enregistrment des meta WF pour utiliser le designer
            new DesignerMetadata().Register();

            InitilizeDesigner();

            // Créer une zone de travail
            _designer.Load(new ActivityBuilder {
                Name = "Designer"
            });

            // Création de la toolbox
            _toolbox = new ToolboxControl();
            // Activité de base
            // AddToToolbox("Built In WF", typeof(Sequence).Assembly);
            ToolboxHelper.AddAll(_toolbox);

            #endregion

            #region Préparation des commandes

            _openCommand        = new Command(Properties.Resources.OpenCommand, Open);
            _saveCommand        = new Command(Properties.Resources.SaveCommand, Save);
            _saveAsCommand      = new Command(Properties.Resources.SaveAsCommand, SaveAs);
            _newActivityCommand = new Command(Properties.Resources.NewActivityCommand, NewActivity);
            _newServiceCommand  = new Command(Properties.Resources.NewServiceCommand, NewService);

            #endregion
        }
Esempio n. 2
0
        private void StartNewWorkflow()
        {
            wd.Load(new ActivityBuilder
            {
                Name = "Activity1"
            });
            currentXamlPath = null;
            isModified      = false;

            RemoveAutoAddedToolboxCategory();
        }
Esempio n. 3
0
        public WorkflowDocumentContent(WorkflowViewModel model, WorkflowTypes workflowType)
            : base()
        {
            this.DataContext = model;

            string defaultWorkflowValue = ConfigurationManager.AppSettings["DefaultWorkflow"];

            if (!string.IsNullOrEmpty(defaultWorkflowValue))
            {
                this.defaultWorkflow = defaultWorkflowValue;
            }

            string defaultWorkflowServiceValue = ConfigurationManager.AppSettings["DefaultWorkflowService"];

            if (!string.IsNullOrEmpty(defaultWorkflowServiceValue))
            {
                this.defaultWorkflowService = defaultWorkflowServiceValue;
            }

            WorkflowDesigner designer = model.Designer;

            try
            {
                if (string.IsNullOrEmpty(model.FullFilePath))
                {
                    if (workflowType == WorkflowTypes.Activity)
                    {
                        designer.Load(Path.GetFullPath(this.defaultWorkflow));
                    }
                    else
                    {
                        designer.Load(Path.GetFullPath(this.defaultWorkflowService));
                    }
                }
                else
                {
                    designer.Load(model.FullFilePath);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format(Properties.Resources.ErrorLoadingDialogMessage, ExceptionHelper.FormatStackTrace(e)), Properties.Resources.ErrorLoadingDialogTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            this.Content = model.Designer.View;

            model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.Model_PropertyChanged);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates the designer.
        /// </summary>
        private void CreateDesigner()
        {
            // Create an instance of WorkflowDesigner class.
            designer = new WorkflowDesigner();

            // Load a Sequence as a default
            var root = new Sequence()
            {
                Activities =
                {
                    new Assign(),
                    new WriteLine()
                }
            };

            designer.Load(root);

            // Create an expression editor service
            expressionEditorService = new ExpressionEditorService(designer);
            designer.Context.Services.Publish <IExpressionEditorService>(expressionEditorService);

            // Add to a document window
            var documentWindow = new DocumentWindow(dockSite, "Designer1", "Designer1", null, designer.View);

            documentWindow.CanClose = false;
            documentWindow.Activate();
        }
Esempio n. 5
0
        /// <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());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a new Workflow Designer instance (VB)
        /// </summary>
        /// <param name="sourceFile">Workflow FileName</param>
        public static void NewInstance(string sourceFile = _defaultWorkflow)
        {
            _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.GetService <DesignerConfigurationService>().AutoConnectEnabled = true;
            _wfDesigner.Context.Services.Publish <IExpressionEditorService>(_expressionEditorServiceVB);
            //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());
            }
        }
Esempio n. 7
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            // register metadata
            (new DesignerMetadata()).Register();
            RegisterCustomMetadata();
            // add custom activity to toolbox

            Toolbox.Categories.Add(new ToolboxCategory("Custom activities"));

            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(AddDataColumn)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(AddDataRow)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(BuildDataTable)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(ClearDataTable)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(GetRowItem)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(OutputDataTable)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(RemoveDataColumn)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(RemoveDataRow)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(RemoveDuplicateRows)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(RemoveDuplicateValues)));

            // create the workflow designer
            WorkflowDesigner wd = new WorkflowDesigner();

            wd.Load(new Sequence());
            DesignerBorder.Child = wd.View;

            PropertyBorder.Child = wd.PropertyInspectorView;
        }
 private void AddDesigner()
 {
     wd = new WorkflowDesigner();
     Grid.SetColumn(wd.View, 1);
     wd.Load(new Sequence());
     grid1.Children.Add(wd.View);
 }
Esempio n. 9
0
        public void OpenWorkflow(int workflowID)
        {
            Workflow = SystemService.GetDynObjectByID("Workflow", workflowID);
            if (Workflow != null)
            {
                _designer   = new WorkflowDesigner();
                _undoEngine = _designer.Context.Services.GetService <UndoEngine>();
                _undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                {
                    _designer.Flush();
                    CanUndo = true;
                };

                DesignerView    = _designer.View;
                PropertyContent = _designer.PropertyInspectorView;
                _designer.Text  = Workflow["Definition"].ToString();
                _designer.Load();
                WorkflowName = Workflow["WorkflowName"].ToString();
                EditState    = "modify";
                CanUndo      = false;
                CanRedo      = false;
                DeleteCommand.RaiseCanExecuteChanged();
            }
            else
            {
                MessageBox.Show("所选的工作流在数据库中不存在,请检查!");
            }
        }
Esempio n. 10
0
        public WorkflowDesignerViewModel()
        {
            (new DesignerMetadata()).Register();
            _workflowToolboxControl = new ToolboxControl()
            {
                Categories = WorkflowToolbox.LoadToolbox()
            };

            _designer   = new WorkflowDesigner();
            _undoEngine = _designer.Context.Services.GetService <UndoEngine>();
            _undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
            {
                _designer.Flush();
                CanUndo = true;
            };
            DesignerView    = _designer.View;
            PropertyContent = _designer.PropertyInspectorView;
            _designer.Text  = "<Activity mc:Ignorable=\"sap\" x:Class=\"WorkflowInvokerSample.流程图\" xmlns=\"http://schemas.microsoft.com/netfx/2009/xaml/activities\" xmlns:av=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:mv=\"clr-namespace:Microsoft.VisualBasic;assembly=System\" xmlns:mva=\"clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:s1=\"clr-namespace:System;assembly=System\" xmlns:s2=\"clr-namespace:System;assembly=System.Xml\" xmlns:s3=\"clr-namespace:System;assembly=System.Core\" xmlns:s4=\"clr-namespace:System;assembly=System.ServiceModel\" xmlns:sad=\"clr-namespace:System.Activities.Debugger;assembly=System.Activities\" xmlns:sap=\"http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation\" xmlns:scg=\"clr-namespace:System.Collections.Generic;assembly=mscorlib\" xmlns:scg1=\"clr-namespace:System.Collections.Generic;assembly=System\" xmlns:scg2=\"clr-namespace:System.Collections.Generic;assembly=System.ServiceModel\" xmlns:scg3=\"clr-namespace:System.Collections.Generic;assembly=System.Core\" xmlns:sd=\"clr-namespace:System.Data;assembly=System.Data\" xmlns:sl=\"clr-namespace:System.Linq;assembly=System.Core\" xmlns:st=\"clr-namespace:System.Text;assembly=mscorlib\" xmlns:w=\"clr-namespace:WorkflowInvokerSample\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">\r\n  <x:Members>\r\n    <x:Property Name=\"WorkflowInstanceID\" Type=\"InArgument(x:Int32)\" />\r\n    <x:Property Name=\"ExchangeParams\" Type=\"InOutArgument(scg:Dictionary(x:String, x:Object))\" />\r\n    <x:Property Name=\"FirstActor\" Type=\"InArgument(x:String)\" />\r\n    <x:Property Name=\"LastActor\" Type=\"InOutArgument(x:String)\" />\r\n  </x:Members>\r\n  <sap:VirtualizedContainerService.HintSize>654,676</sap:VirtualizedContainerService.HintSize>\r\n  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>\r\n  <Flowchart DisplayName=\"流程图\" sad:XamlDebuggerXmlReader.FileName=\"C:\\Users\\Administrator\\Downloads\\WorkflowInvokerSample\\WorkflowInvokerSample\\流程图.xaml\" sap:VirtualizedContainerService.HintSize=\"614,636\">\r\n    <sap:WorkflowViewStateService.ViewState>\r\n      <scg:Dictionary x:TypeArguments=\"x:String, x:Object\">\r\n        <x:Boolean x:Key=\"IsExpanded\">False</x:Boolean>\r\n        <av:Point x:Key=\"ShapeLocation\">270,2.5</av:Point>\r\n        <av:Size x:Key=\"ShapeSize\">60,75</av:Size>\r\n        <av:PointCollection x:Key=\"ConnectorLocation\">300,77.5 300,107.5 300,189</av:PointCollection>\r\n      </scg:Dictionary>\r\n    </sap:WorkflowViewStateService.ViewState>\r\n    <Flowchart.StartNode>\r\n      <x:Null />\r\n    </Flowchart.StartNode>\r\n  </Flowchart>\r\n</Activity>";
            _designer.Load();
            WorkflowName = "新建工作流";
            CanUndo      = false;
            CanRedo      = false;
            EditState    = "add";

            OpenCommand   = new DelegateCommand <object>(OpenWorkflowListWindow);
            AddCommand    = new DelegateCommand <object>(Add);
            DeleteCommand = new DelegateCommand <object>(Delete, CanDeleteWorkflowExecute);
            SaveCommand   = new DelegateCommand <object>(Save);
            UndoCommand   = new DelegateCommand <object>(Undo);
            RedoCommand   = new DelegateCommand <object>(Redo);
            DebugCommand  = new DelegateCommand <object>(Debug);
        }
Esempio n. 11
0
 public Designer()
 {
     InitializeComponent();
     EditingScopes    = new ObservableCollection <ModelEditingScope>();
     workflowDesigner = new WorkflowDesigner();
     this.DataContext = this;
     (new DesignerMetadata()).Register();
     workflowDesigner.Load(new Sequence
     {
         Activities =
         {
             new If
             {
                 Then = new Sequence
                 {
                     Activities =
                     {
                         new Persist(),
                         new WriteLine {
                             Text = "foo"
                         }
                     }
                 }
             }
         }
     });
     Grid.SetColumn(workflowDesigner.View, 1);
     Grid.SetColumn(workflowDesigner.PropertyInspectorView, 2);
     ApplicationGrid.Children.Add(workflowDesigner.View);
     ApplicationGrid.Children.Add(workflowDesigner.PropertyInspectorView);
 }
Esempio n. 12
0
        private void FileTypeItem_Loaded(object sender, RoutedEventArgs e)
        {
            if (_fileTypeDto.Id == 0)
            {
                DesignerMetadata designerMetadata = new DesignerMetadata();
                designerMetadata.Register();
                _workflowDesigner = new WorkflowDesigner();
                Optin45();
                BrdDesigner.Child   = _workflowDesigner.View;
                BrdProperties.Child = _workflowDesigner.PropertyInspectorView;
                BrdActivities.Child = GetToolboxControl();
                var activityBuilder = new ActivityBuilder();
                _workflowDesigner.Load(activityBuilder);
                AddDefaultArguments();
            }
            else
            {
                DesignerMetadata designerMetadata = new DesignerMetadata();
                designerMetadata.Register();
                _workflowDesigner = new WorkflowDesigner();
                Optin45();
                BrdDesigner.Child   = _workflowDesigner.View;
                BrdProperties.Child = _workflowDesigner.PropertyInspectorView;
                BrdActivities.Child = GetToolboxControl();

                string tempFile = System.IO.Path.GetTempFileName();
                System.IO.File.WriteAllBytes(tempFile, _fileTypeDto.Workflow);
                _workflowDesigner.Load(tempFile);
            }
        }
Esempio n. 13
0
        private void ImportFromFile(object sender, RoutedEventArgs e)
        {
            OpenFileDialog myDialog = new OpenFileDialog
            {
                Filter          = "XAML Files" + " (*.xaml)|*.xaml",
                CheckFileExists = true,
                Multiselect     = false
            };

            if (myDialog.ShowDialog() == true)
            {
                if (!string.IsNullOrWhiteSpace(myDialog.FileName))
                {
                    DesignerMetadata designerMetadata = new DesignerMetadata();
                    designerMetadata.Register();
                    _workflowDesigner = new WorkflowDesigner();
                    Optin45();
                    BrdDesigner.Child   = _workflowDesigner.View;
                    BrdProperties.Child = _workflowDesigner.PropertyInspectorView;
                    BrdActivities.Child = GetToolboxControl();

                    _workflowDesigner.Load(myDialog.FileName);
                }
            }
        }
Esempio n. 14
0
        private void AddDesigner(string fileName = null)
        {
            ////Wait till create Intellisense List
            //while (creating)
            //{
            //    System.Threading.Thread.Sleep(1);
            //}

            //Create an instance of WorkflowDesigner class.
            this.wd = new WorkflowDesigner();

            DesignerConfigurationService configurationService = wd.Context.Services.GetService <DesignerConfigurationService>();

            configurationService.TargetFrameworkName = new FrameworkName(".NETFramework", new System.Version(4, 5));

            configurationService.LoadingFromUntrustedSourceEnabled = true;

            #region Intellisense
            var expEditor = new EditorService()
            {
                IntellisenseData = _inttelisenseList,
                EditorKeyWord    = this.CreateKeywords()
            };

            wd.Context.Services.Publish <IExpressionEditorService>(expEditor);
            #endregion


            wd.Context.Items.Subscribe <Selection>(SelectionChanged);

            //Place the designer canvas in the middle column of the grid.
            Grid.SetColumn(this.wd.View, 1);


            if (fileName == null)
            {
                var activityBuilder = new ActivityBuilder();
                wd.Load(activityBuilder);
                //Load a new Sequence as default.
                activityBuilder.Implementation = new Sequence();
            }
            else
            {
                this.wd.Load(fileName);
            }

            //// view options
            //var designerView = wd.Context.Services.GetService<DesignerView>();

            //designerView.WorkflowShellBarItemVisibility =
            //    ShellBarItemVisibility.Imports |
            //    ShellBarItemVisibility.MiniMap |
            //    ShellBarItemVisibility.Variables |
            //     ShellBarItemVisibility.Arguments | // <-- Uncomment to show again
            //    ShellBarItemVisibility.Zoom;

            DesignerBorder.Child = wd.View;
            PropertyBorder.Child = wd.PropertyInspectorView;
        }
Esempio n. 15
0
        public void ExecuteNew(object parameter)
        {
            WorkflowDesignerObj = new WorkflowDesigner();

            WorkflowDesignerObj.ModelChanged += new EventHandler(workflowDesigner_ModelChanged);

            if (File.Exists(TemplateXaml))
            {
                WorkflowDesignerObj.Load(TemplateXaml);
            }
            else
            {
                WorkflowDesignerObj.Load(new Sequence());
            }

            WorkflowDesignerObj.Flush();
        }
 protected override void OnInitialized(EventArgs e)
 {
     base.OnInitialized();
     wd = new WorkflowDesigner();
     wd.Load(workflowFilePathName);
     workflowDesignerPanel.Content = wd.View;
     // this doesn't work here:
     // var designerView = wd.Context.Services.GetService<DesignerView>();
 }
Esempio n. 17
0
        private void OnOpenClick(object sender, System.Windows.RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog();

            if (dlg.ShowDialog().Value)
            {
                InitializeDesigner();
                _designer.Load(dlg.FileName);
            }
        }
Esempio n. 18
0
        //object obj = new object();
        private void ReloadDesigner(int action = 0)
        {
            //lock (obj)
            //{
            SelectHelper.StartSimulation = false;
            if (string.IsNullOrEmpty(currentFile))
            {
                return;
            }

            if (action == 1)
            {
                if (File.Exists(currentFile))
                {
                    File.Delete(currentFile);
                }
            }

            if (!string.IsNullOrEmpty(currentFile))
            {
                if (SelectHelper.WorkflowDictionary.ContainsKey(currentFile))
                {
                    WorkflowDesigner _wfDesigner = SelectHelper.WorkflowDictionary[currentFile];
                    if (action == 1)
                    {
                        _wfDesigner.Save(currentFile);
                    }

                    _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;

                    //associates all of the basic activities with their designers
                    new DesignerMetadata().Register();
                    _wfDesigner.Load(currentFile);

                    if (SelectHelper.WorkflowDictionary.ContainsKey(currentFile))
                    {
                        SelectHelper.WorkflowDictionary[currentFile] = _wfDesigner;
                    }

                    if (currentFile == SelectHelper._currentworkflowfile)
                    {
                        _wfDesigner.View.UpdateLayout();
                        _wfDesigner.OutlineView.UpdateLayout();
                        System.Windows.Controls.Border WfDesignerBorder = (System.Windows.Controls.Border)SelectHelper.Border;
                        WfDesignerBorder.Child = _wfDesigner.View;
                        SelectHelper._wfPropertyBorder.Child = _wfDesigner.PropertyInspectorView;
                        SelectHelper._wfOutlineBorder.Child  = _wfDesigner.OutlineView;
                    }
                }
            }
            //}
        }
Esempio n. 19
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     wd = new WorkflowDesigner();
     wd.Load(ReturnSequence());
     Grid.SetColumn(wd.PropertyInspectorView, 1);
     windowGrid.Children.Add(wd.PropertyInspectorView);
     treeView1.DataContext = new List <ModelItem> {
         wd.Context.Services.GetService <ModelService>().Root
     };
     ChangeButton.IsEnabled = true;
 }
Esempio n. 20
0
        /// <summary>
        /// This creates a new (empty) document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnNew(object sender, ExecutedRoutedEventArgs e)
        {
            // If we have a workflow which has been saved, make sure it's ok to throw it out.
            if (ViewModel.HasWorkflow && !ReferenceEquals(ViewModel.WorkflowFile, NewFilePlaceholder))
            {
                if (MessageBox.Show("You have an existing file open. Do you want to throw away changes?",
                                    "File already open", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }
            }

            // Set our new file placeholder.
            ViewModel.WorkflowFile = NewFilePlaceholder;
            string emptyFile = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\NewActivity.xaml";

            // Initialize the WF host
            InitializeDesigner();
            _designer.Load(emptyFile);
        }
Esempio n. 21
0
        /// <summary>
        /// Creates a new Workflow Designer instance (VB)
        /// </summary>
        /// <param name="sourceFile">Workflow FileName</param>
        public static void NewInstance(string sourceFile = _defaultWorkflow)
        {
            _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;

            //associates all of the basic activities with their designers
            new DesignerMetadata().Register();

            //load Workflow Xaml
            _wfDesigner.Load(sourceFile);
        }
Esempio n. 22
0
 /// <summary>
 /// Adds the designer.
 /// </summary>
 /// <remarks></remarks>
 private void AddDesigner()
 {
     //Create an instance of WorkflowDesigner class.
     _wd = new WorkflowDesigner();
     //Place the designer canvas in the middle column of the grid.
     Grid.SetColumn(_wd.View, 1);
     //Load a new Sequence as default.
     _chrt = new Flowchart();
     _wd.Load(_chrt);
     //Add the designer canvas to the grid.
     grdDesigner.Children.Add(_wd.View);
 }
Esempio n. 23
0
        /// <summary>
        /// Creates a new Workflow Designer instance (VB) with Intellisense
        /// </summary>
        /// <param name="sourceFile">Workflow FileName</param>
        public static void NewInstanceVB(string sourceFile = _defaultWorkflow)
        {
            _expressionEditorServiceVB = new VbExpressionEditorService();

            _wfDesigner = new WorkflowDesigner();

            Hashtable hashTable = new Hashtable
            {
                { WorkflowDesignerColors.DesignerViewShellBarControlBackgroundColorKey, SystemColors.HighlightBrush },
                { WorkflowDesignerColors.DesignerViewShellBarColorGradientBeginKey, SystemColors.HighlightBrush },
                { WorkflowDesignerColors.DesignerViewShellBarColorGradientEndKey, SystemColors.HighlightBrush },
            };

            _wfDesigner.PropertyInspectorFontAndColorData = System.Xaml.XamlServices.Save(hashTable);

            _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.GetService <DesignerConfigurationService>().AutoConnectEnabled         = true;
            _wfDesigner.Context.Services.GetService <DesignerConfigurationService>().RubberBandSelectionEnabled = true;
            _wfDesigner.Context.Services.Publish <IExpressionEditorService>(_expressionEditorServiceVB);

            //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());
            }

            WorkflowEntity workflowEntity = new WorkflowEntity();

            if (!SelectHelper.WorkflowEntityDictionary.ContainsKey(sourceFile))
            {
                SelectHelper.WorkflowEntityDictionary.Add(sourceFile, workflowEntity);
            }
            else
            {
                SelectHelper.WorkflowEntityDictionary[sourceFile] = workflowEntity;
            }
        }
Esempio n. 24
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            // register metadata
            (new DesignerMetadata()).Register();

            // create the workflow designer
            WorkflowDesigner wd = new WorkflowDesigner();

            wd.Load(new Sequence());
            DesignerBorder.Child = wd.View;
            PropertyBorder.Child = wd.PropertyInspectorView;
        }
        /// <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);
        }
Esempio n. 26
0
        //加载流程
        void loadWorkflowFromFile(string workflowFilePathName)
        {
            desienerPanel.Content = null;
            // propertyPanel.Content = null;


            designer = new WorkflowDesigner();


            try
            {
                designer.Load(workflowFilePathName);

                modelService = designer.Context.Services.GetService <ModelService>();

                rootModelItem = modelService.Root;

                undoEngine = designer.Context.Services.GetService <UndoEngine>();

                undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                {
                    designer.Flush();                            //调用Flush使designer.Text得到数据
                    desigeerActionList.Items.Add(string.Format("{0}  ,   {1}", DateTime.Now.ToString(), ee.UndoUnit.Description));
                };

                designerView = designer.Context.Services.GetService <DesignerView>();



                designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.Arguments    //如果不使用Activity做根,无法出现参数选项
                                                              | ShellBarItemVisibility.Imports
                                                              | ShellBarItemVisibility.MiniMap
                                                              | ShellBarItemVisibility.Variables
                                                              | ShellBarItemVisibility.Zoom
                ;

                desienerPanel.Content = designer.View;

                //propertyPanel.Content = designer.PropertyInspectorView;

                propertyGrid.setWfDesigner(designer);

                //this.xamlTextBox.Text = designer.Text;
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }  //end
Esempio n. 27
0
        public DesignerViewModel()
        {
            // Enregistrment des meta WF pour utiliser le designer
            new DesignerMetadata().Register();

            // Instancition du designer
            _designer = new WorkflowDesigner();


            // Récupération duservice de configuration
            var configurationService = _designer.Context.Services.GetService <DesignerConfigurationService>();

            // Cibler le framework (voir constantes en haut de class)
            configurationService.TargetFrameworkName = new FrameworkName(FrameworkName, new Version(FrameworVersionMajor, FrameworVersionMinor));

            // Activer toutes les nouvelles fonctionnalité du designer présentes de puis .net 4.5
            configurationService.AutoConnectEnabled = true;
            configurationService.AutoSplitEnabled   = true;
            configurationService.AutoSurroundWithSequenceEnabled   = true;
            configurationService.BackgroundValidationEnabled       = true;
            configurationService.LoadingFromUntrustedSourceEnabled = true;
            configurationService.MultipleItemsContextMenuEnabled   = true;
            configurationService.MultipleItemsDragDropEnabled      = true;
            configurationService.NamespaceConversionEnabled        = true;
            configurationService.PanModeEnabled             = true;
            configurationService.RubberBandSelectionEnabled = true;

            // fcontionnalité présentes à partir de .net 4.5
            if (FrameworVersionMajor >= 4 && FrameworVersionMinor >= 5)
            {
                configurationService.AnnotationEnabled = true;
            }

            // Créer une zone de travail
            _designer.Load(new ActivityBuilder {
                Name = "Designer"
            });

            // Ajout du service de validation (liste d'erreurs)
            _validationErrorService = new ValidationErrorService();
            _designer.Context.Services.Publish <IValidationErrorService>(_validationErrorService);

            // Création de la toolbox
            _toolbox = new ToolboxControl();
            // Activité de base
            AddToToolbox("Built In WF", typeof(Sequence).Assembly);
            _toolbox.Loaded += _toolbox_Loaded;
        }
        public void Debug()
        {
            if (IsExecuting || !Save(true))
            {
                return;
            }

            // HACK ZONE

            // WorkflowDesigner have to be loaded all over again through WorkflowDesigner.Load(filepath) otherwise
            // SourceLocationProvider.CollectMapping() won't collect nothing later on WorkflowDebugger and
            // becaquse of that debug process won't work as expected.

            // Activities not loaded with WorkflowDesigner.Load(filepath) won't be recognized at all.

            // That's the only motive for the workflow to be saved before debug.

            // More info: http://social.msdn.microsoft.com/forums/en-us/wfprerelease/thread/2DEE4DD9-D3F7-4430-BCC7-D613859074D1
            //            http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/0a28cade-bd8d-417b-a1e4-efbc0d9ccd43
            //            http://blogs.msdn.com/b/tilovell/archive/2011/06/08/wf4-visual-workflow-tracking-and-workflowinspectionservices.aspx

            // This needs to be addressed by MS. Didn't test it on NET4.5
            // Should check this in detail later

            WorkflowDesigner = new WorkflowDesigner();
            WorkflowDesigner.Load(FilePath);

            // END OF HACK ZONE

            if (WorkflowType == WorkflowType.Activity)
            {
                executer = new ActivityDebugger(WorkflowDesigner, outputTextWriter);
            }
            else
            {
                executer = new WorkflowServiceDebugger(WorkflowDesigner, outputTextWriter);
            }

            ((IWorkflowDebugger)executer).DebugStepAdded += (sender, args) =>
            {
                Application.Current.Dispatcher.Invoke(
                    DispatcherPriority.Normal,
                    (Action)(() => DebugSteps.Add(args.DebugStep)));
            };

            executer.ExecutingStateChanged += OnExecuterRunningStateChanged;
            executer.Start();
        }
Esempio n. 29
0
        private void RecreateWorkflowDesigner(Activity workflow)
        {
            _wd = new WorkflowDesigner();
            DesignerBorder.Child = _wd.View;
            PropertyBorder.Child = _wd.PropertyInspectorView;
            _wd.Load(workflow);
            _wd.TextChanged  += _wd_TextChanged;
            _wd.ModelChanged += _wd_ModelChanged;

            var modelService = _wd.Context.Services.GetService <ModelService>();

            if (modelService != null)
            {
                modelService.ModelChanged += new EventHandler <ModelChangedEventArgs>(RehostingWfDesigner_ModelChanged);
            }
        }
Esempio n. 30
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            // register metadata
            (new DesignerMetadata()).Register();
            RegisterCustomMetadata();
            // add custom activity to toolbox
            Toolbox.Categories.Add(new ToolboxCategory("Custom activities"));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(Statistical.R.RScope)));
            Toolbox.Categories[1].Add(new ToolboxItemWrapper(typeof(Statistical.R.RunRScript)));
            // create the workflow designer
            WorkflowDesigner wd = new WorkflowDesigner();

            wd.Load(new Sequence());
            DesignerBorder.Child = wd.View;
            PropertyBorder.Child = wd.PropertyInspectorView;
        }