Exemplo n.º 1
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("所选的工作流在数据库中不存在,请检查!");
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 private void AddDesigner()
 {
     _designer = new WorkflowDesigner();
     Grid.SetColumn(_designer.View, 1);
     Grid.SetRow(_designer.View, 1);
     grid1.Children.Add(_designer.View);
 }
        private void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog _ofd = new OpenFileDialog();

            _ofd.DefaultExt = "xaml";
            _ofd.Filter     = "Xaml Files | *.xaml";
            Nullable <bool> result = _ofd.ShowDialog();

            if (result == true)
            {
                string filename = _ofd.FileName;
                this._WorkflowDesigner = new WorkflowDesigner();
                Grid.SetColumn(this._WorkflowDesigner.View, 1);
                this._WorkflowDesigner.Load(filename);
                this._WorkflowDesigner.Context.Services.GetService <DesignerView>().WorkflowShellBarItemVisibility = ShellBarItemVisibility.All;
                MainGrid.Children.Add(this._WorkflowDesigner.View);
                foreach (string dll in Directory.GetFiles(Directory.GetCurrentDirectory() + "\\References", "*.dll"))
                {
                    try
                    {
                        Assembly temp = Assembly.LoadFrom(dll);
                        AddDynamicAssembly(Assembly.LoadFrom(dll));
                    }
                    catch (Exception exception)
                    {
                        //log exception
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Default constructor, creates a hidden designer view and a property inspector
        /// </summary>
        public WpfPropertyGrid()
        {
            this.Designer = new WorkflowDesigner();
            var inspector = Designer.PropertyInspectorView;

            System.Type inspectorType = inspector.GetType();

            inspector.Visibility = System.Windows.Visibility.Visible;
            this.Children.Add(inspector);

            var methods = inspectorType.GetMethods(System.Reflection.BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                                   BindingFlags.DeclaredOnly);

            //MethodInfo[] ms = inspectorType.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);

            this.RefreshMethod = inspectorType.GetMethod("RefreshPropertyList",
                                                         BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            this.OnSelectionChangedMethod = inspectorType.GetMethod("OnSelectionChanged",
                                                                    BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            this.SelectionTypeLabel = inspectorType.GetMethod("get_SelectionTypeLabel",
                                                              BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                                              BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as TextBlock;

            this.SelectionTypeLabel.Text = string.Empty;
        }
        public void SetDesigner(WorkflowDesigner designer)
        {
            if (_designer != null)
            {
                mSearchBox.Text = String.Empty;
                SetCommandTarget(null);
                _designer.View.PreviewKeyDown -= new KeyEventHandler(View_PreviewKeyDown);
                this.mContentControl.Content   = null;
                _textBlockComparer             = null;
                _designerPresenter             = null;
                _mainScrollViewer              = null;
            }

            _designer = designer;

            if (designer != null)
            {
                // set some view params to hide stuff and expand all items
                DesignerView designerView = _designer.Context.Services.GetService <DesignerView>();
                designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.None;
                designerView.ShouldExpandAll   = false;
                designerView.ShouldCollapseAll = true;

                RuleDesignerHelper.HideExpandCollapseControl(designerView);
                RuleDesignerHelper.ChangeRuleContentAlighment(designerView);

                _mainScrollViewer  = LogicalTreeHelper.FindLogicalNode(designerView, "scrollViewer") as ScrollViewer;               // NOXLATE
                _designerPresenter = LogicalTreeHelper.FindLogicalNode(_mainScrollViewer, "designerPresenter") as FrameworkElement; // NOXLATE
                _textBlockComparer = new TextBlockComparer(_designerPresenter);

                this.mContentControl.Content  = designer.View;
                designer.View.PreviewKeyDown += new KeyEventHandler(View_PreviewKeyDown);
                SetCommandTarget(designerView);
            }
        }
Exemplo n.º 7
0
        private void LoadDesigner()
        {
            Designer = new WorkflowDesigner();

            var tbx = GetToolboxControl();

            grid_designsurface.Children.Add(tbx);
            grid_designsurface.Children.Add(Designer.View);
            grid_designsurface.Children.Add(Designer.PropertyInspectorView);

            Grid.SetColumn(tbx, 0);
            Grid.SetColumn(Designer.View, 1);
            Grid.SetColumn(Designer.PropertyInspectorView, 2);


            /**
             * Load activity designers
             *
             **/
            (new DesignerMetadata()).Register();
            AttributeTableBuilder builder = new AttributeTableBuilder();

            //Register Custom Designers.
            builder.AddCustomAttributes(typeof(CADesigner), new DesignerAttribute(typeof(CADesigner)));
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        void OnContextChanged()
        {
            this.targetFramework = WorkflowDesigner.GetTargetFramework(this.Context);

            AttachedPropertiesService attachedPropertyService = this.Context.Services.GetService <AttachedPropertiesService>();

            Fx.Assert(attachedPropertyService != null, "AttachedPropertiesService shouldn't be null in EditingContext.");
            attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <string>(ErrorMessagePropertyName));
            attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <bool>(IsInvalidPropertyName));
            //clear any defaults because it's meant to be set by host and not serialized to XAML
            VisualBasicSettings.Default.ImportReferences.Clear();

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

            Fx.Assert(modelService != null, "ModelService shouldn't be null in EditingContext.");
            Fx.Assert(modelService.Root != null, "model must have a root");
            this.importsModelItem = modelService.Root.Properties[NamespaceListPropertyDescriptor.ImportCollectionPropertyName].Collection;
            Fx.Assert(this.importsModelItem != null, "root must have imports");
            this.importsModelItem.CollectionChanged += this.OnImportsModelItemCollectionChanged;

            this.importedNamespacesItem = this.Context.Items.GetValue <ImportedNamespaceContextItem>();
            this.importedNamespacesItem.EnsureInitialized(this.Context);

            if (this.availableNamespaces == null)
            {
                //change to available namespace should not be a model change so we access the dictionary directly
                this.availableNamespaces = this.importsModelItem.Properties[NamespaceListPropertyDescriptor.AvailableNamespacesPropertyName].ComputedValue as Dictionary <string, List <string> >;
                Fx.Assert(this.availableNamespaces != null, "Available namespace dictionary is not in right format");
            }
            RefreshNamespaces();
        }
Exemplo n.º 10
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);
                }
            }
        }
Exemplo n.º 11
0
        private void AddDesigner(string filename)
        {
            //Create an instance of WorkflowDesigner class.
            this.wd = new WorkflowDesigner();

            textBox = new System.Windows.Controls.TextBox();
            //ad.
            //Place the designer canvas in the middle column of the grid.
            Grid.SetColumn(this.wd.View, 1);
            Grid.SetRowSpan(this.wd.View, 2);

            //Adding annotations
            wd.Context.Services.GetService <DesignerConfigurationService>().AnnotationEnabled = true;
            //Targeting the .NET 4.5 Framework for the configuration service for the WF Designer control
            wd.Context.Services.GetService <DesignerConfigurationService>().TargetFrameworkName = new
                                                                                                  System.Runtime.Versioning.FrameworkName(".NET Framework", new Version(4, 5));

            //Load a new Sequence as default.
            if (string.IsNullOrEmpty(filename))
            {
                this.wd.Load(BuildBaseActivity());
            }
            else
            {
                this.wd.Load(filename);
            }


            //Add the designer canvas to the grid.
            grid1.Children.Add(this.wd.View);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes the WF designer host.
        /// </summary>
        private void InitializeDesigner()
        {
            bool firstTime = (_designer == null);

            _designer = new WorkflowDesigner();

            DesignerConfigurationService dcs = _designer.Context.Services.GetService <DesignerConfigurationService>();

            // Set the runtime Framework version to 4.5
            dcs.TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));

            // Turn on designer features
            dcs.AnnotationEnabled = true;
            dcs.AutoSurroundWithSequenceEnabled   = true;
            dcs.LoadingFromUntrustedSourceEnabled = true;
            dcs.RubberBandSelectionEnabled        = true;

            // Add the UI
            outlineView.Content          = _designer.OutlineView;
            inspectorPlaceholder.Content = _designer.PropertyInspectorView;
            designerPlaceholder.Content  = _designer.View;

            if (firstTime)
            {
                ToolboxControl toolbox = BuildToolbox();
                toolboxPlaceholder.Content = toolbox;

                (new DesignerMetadata()).Register();
            }

            _designer.Context.Services.Publish <IValidationErrorService>(new ValidationErrorService(ViewModel.Errors));
            _designer.Context.Services.Publish <IExpressionEditorService>(new EditorService());
        }
Exemplo n.º 13
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>MyExpressionEditorInstance</c> class.
        /// </summary>
        /// <param name="designer">The <see cref="WorkflowDesigner"/> that owns the instance.</param>
        /// <param name="variableModels">The variable list.</param>
        /// <param name="language">The <see cref="ISyntaxLanguage"/> to use.</param>
        public MyExpressionEditorInstance(WorkflowDesigner designer, List <ModelItem> variableModels, ISyntaxLanguage language)
        {
            if (designer == null)
            {
                throw new ArgumentNullException("designer");
            }
            if (language == null)
            {
                throw new ArgumentNullException("language");
            }

            this.designer       = designer;
            this.variableModels = variableModels;

            // Create a SyntaxEditor
            editor = new SyntaxEditor();
            editor.BorderThickness             = new Thickness(0);
            editor.CanSplitHorizontally        = false;
            editor.IsDefaultContextMenuEnabled = false;
            editor.IsMultiLine = false;
            editor.IsOutliningMarginVisible      = false;
            editor.IsSelectionMarginVisible      = false;
            editor.Document.Language             = language;
            editor.IsKeyboardFocusWithinChanged += OnSyntaxEditorIsKeyboardFocusWithinChanged;
            editor.DocumentTextChanged          += OnSyntaxEditorDocumentTextChanged;
            editor.Unloaded += OnSyntaxEditorUnloaded;

            // Use this line to change the editor's font, but not affect IntelliPrompt popups
            // AmbientHighlightingStyleRegistry.Instance[new DisplayItemClassificationTypeProvider().PlainText].FontFamilyName = "Consolas";

            // Initialize header and footer text (so we edit an expression and variables appear in automated IntelliPrompt)
            this.InitializeHeaderAndFooter();
        }
Exemplo n.º 14
0
        public WorkflowViewModel(bool disableDebugViewOutput)
        {
            this.workflowDesigner = new WorkflowDesigner();
            this.id = ++designerCount;
            this.validationErrors       = new List <ValidationErrorInfo>();
            this.validationErrorService = new ValidationErrorService(this.validationErrors);
            this.workflowDesigner.Context.Services.Publish <IValidationErrorService>(this.validationErrorService);

            this.workflowDesigner.ModelChanged += delegate(object sender, EventArgs args)
            {
                this.modelChanged = true;
                this.OnPropertyChanged("DisplayNameWithModifiedIndicator");
            };

            this.validationErrorsView = new ValidationErrorsUserControl();

            this.outputTextBox          = new TextBox();
            this.output                 = new TextBoxStreamWriter(this.outputTextBox, this.DisplayName);
            this.disableDebugViewOutput = disableDebugViewOutput;

            this.workflowDesigner.Context.Services.GetService <DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));
            this.workflowDesigner.Context.Services.GetService <DesignerConfigurationService>().LoadingFromUntrustedSourceEnabled = bool.Parse(ConfigurationManager.AppSettings["LoadingFromUntrustedSourceEnabled"]);

            this.validationErrorService.ErrorsChangedEvent += delegate(object sender, EventArgs args)
            {
                DispatcherService.Dispatch(() =>
                {
                    this.validationErrorsView.ErrorsDataGrid.ItemsSource = this.validationErrors;
                    this.validationErrorsView.ErrorsDataGrid.Items.Refresh();
                });
            };
        }
Exemplo n.º 15
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);
 }
Exemplo n.º 16
0
        private void InitializeDesigner()
        {
            //cleanup the previous designer
            if (wd != null)
            {
                wd.ModelChanged -= new EventHandler(Designer_ModelChanged);
            }

            //designer
            wd = new WorkflowDesigner();
            designerArea.Child = wd.View;

            //property grid
            propertiesArea.Child = wd.PropertyInspectorView;

            //event handler
            wd.ModelChanged += new EventHandler(Designer_ModelChanged);

#if VALIDATION
            //error service
            wd.Context.Services.Publish <IValidationErrorService>(errorService);
#endif

#if FLOWCHART
            //ModelService ms = wd.Context.Services.GetService<ModelService>();
            wd.Context.Items.Subscribe <Selection>(OnItemSelected);
#endif
        }
        public WorkflowDebuggerBase(TextWriter output, string workflowName, WorkflowDesigner workflowDesigner, bool disableDebugViewOutput)
        {
            this.output           = output;
            this.workflowDesigner = workflowDesigner;
            this.workflowName     = workflowName;

            this.debugView               = new DataGrid();
            this.debugView.IsReadOnly    = true;
            this.debugView.SelectionMode = DataGridSelectionMode.Single;

            this.debugView.SelectionChanged += delegate(object sender, SelectionChangedEventArgs args)
            {
                this.HighlightActivity(this.debugView.SelectedIndex);
            };

            this.disableDebugViewOutput = disableDebugViewOutput;
            this.debugTraceSource       = new TraceSource(Path.GetFileNameWithoutExtension(workflowName) + "Debug");
            this.allDebugTraceSource    = new TraceSource("AllDebug");

            ConfigurationManager.RefreshSection("appSettings");

            string pauseBetweenDebugStepsInMillisecondsValue = ConfigurationManager.AppSettings["PauseBetweenDebugStepsInMilliseconds"];

            if (!string.IsNullOrEmpty(pauseBetweenDebugStepsInMillisecondsValue))
            {
                this.pauseBetweenDebugStepsInMilliseconds = int.Parse(pauseBetweenDebugStepsInMillisecondsValue);
            }
        }
Exemplo n.º 18
0
 private void AddDesigner()
 {
     wd = new WorkflowDesigner();
     Grid.SetColumn(wd.View, 1);
     wd.Load(new Sequence());
     grid1.Children.Add(wd.View);
 }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
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());
            }
        }
Exemplo n.º 21
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());
            }
        }
Exemplo n.º 22
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // 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();
        }
Exemplo n.º 23
0
        //构造函数
        public designerDebugTracking(WorkflowDesigner designer)
        {
            //(1)
            this.designer     = designer;
            this.debugService = designer.DebugManagerView as DebuggerService;;

            //ziyunhx 2013-8-8 add debug status
            DebugStatus debug = new DebugStatus();

            debug.status = 1;

            //(2) TrackingProfile
            TrackingProfile    trackingProfile    = new TrackingProfile();
            ActivityStateQuery activityStateQuery = new ActivityStateQuery()
            {
                ActivityName = "*",
                States       = { ActivityStates.Executing },
                Variables    = { "*" },
                Arguments    = { "*" }
            };

            trackingProfile.Queries.Add(activityStateQuery);

            this.TrackingProfile = trackingProfile;

            //(3)
            clearTrackInfo();

            //(4)
            sourceLocationList = getSourceLocationMap();
            activityMapList    = getActivityMapList(sourceLocationList);
        } //end
        private void InitilizeDesigner()
        {
            // 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;
            }

            // Ajout du service de validation (liste d'erreurs)
            _validationErrorService = new ValidationErrorService();
            _designer.Context.Services.Publish <IValidationErrorService>(_validationErrorService);
        }
Exemplo n.º 25
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;
        }
 public WorkflowDesignerViewModelMock(IWorkflowDesignerWrapper workflowDesignerWrapper, IContextualResourceModel resource, IWorkflowHelper workflowHelper, IEventAggregator eventAggregator, WorkflowDesigner workflowDesigner, bool createDesigner = false)
     : base(workflowDesignerWrapper,
            eventAggregator,
            resource, workflowHelper,
            new Mock <IPopupController>().Object, new SynchronousAsyncWorker(), createDesigner, false)
 {
     _wd = workflowDesigner;
 }
 /// <summary>
 /// Contructeur
 /// </summary>
 /// <param name="designer"></param>
 internal VisualTracking(WorkflowDesigner designer, Boolean slowTrack)
 {
     _designer  = designer;
     _slowTrack = slowTrack;
     _tracks    = new ObservableCollection <String>();
     BindingOperations.EnableCollectionSynchronization(_tracks, _tracksLock);
     VisualMapping.GetMaps(_designer, out _wfElementToSourceLocationMap, out _activityIdToWfElementMap);
 }
 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>();
 }
Exemplo n.º 29
0
        private void SaveWorkflow(string filePath)
        {
            WorkflowDesigner.Save(filePath);

            FilePath = filePath;
            IsSaved  = true;
            IsDirty  = false;
            Title    = Path.GetFileName(filePath);
        }
Exemplo n.º 30
0
        private void New_OnClick(object sender, RoutedEventArgs e)
        {
            var wd = CreateWorkflowDesigner();

            wd.Load(new ActivityBuilder {
                Name = "Workflow", Implementation = new Flowchart()
            });
            this.Designer = wd;
        }
Exemplo n.º 31
0
        private void AddDesigner()
        {
            //Create an instance of WorkflowDesigner class.
            this.wd = new WorkflowDesigner();

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

            //Load a new Sequence as default.
            this.wd.Load(new Sequence());

            //Add the designer canvas to the grid.
            WFDesignerGrid.Children.Add(this.wd.View);
        }
        public ModelSearchServiceImpl(WorkflowDesigner designer)
        {
            if (designer == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("designer"));
            }
            this.designer = designer;
            this.editingContext = this.designer.Context;

            this.editingContext.Services.Subscribe<ModelService>(new SubscribeServiceCallback<ModelService>(this.OnModelServiceAvailable));
            this.editingContext.Services.Subscribe<DesignerView>(new SubscribeServiceCallback<DesignerView>(this.OnDesignerViewAvailable));
            this.editingContext.Services.Subscribe<ModelTreeManager>(new SubscribeServiceCallback<ModelTreeManager>(this.OnModelTreeManagerAvailable));
            this.editingContext.Items.Subscribe<Selection>(this.OnSelectionChanged);

            // At the first time, we should generate the TextImage.
            this.isModelTreeChanged = true;
        }