Beispiel #1
0
 private async void NewTabItem_OnClose(object sender, RoutedEventArgs e)
 {
     Views.ClosableTab tab      = sender as Views.ClosableTab;
     Views.WFDesigner  designer = tab.Content as Views.WFDesigner;
     if (designer == null)
     {
         return;
     }
     if (!designer.HasChanged)
     {
         return;
     }
     if (designer.HasChanged && (global.isConnected?global.webSocketClient.user.hasRole("robot admins"):true))
     {
         MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Save " + designer.Workflow.name + " ?", "Workflow unsaved", MessageBoxButton.YesNoCancel);
         if (messageBoxResult == MessageBoxResult.Yes)
         {
             await designer.Save();
         }
         else if (messageBoxResult != MessageBoxResult.No)
         {
             e.Handled = true;
         }
     }
 }
Beispiel #2
0
 private void onOpen(object item)
 {
     AutomationHelper.syncContext.Post(o =>
     {
         foreach (TabItem tab in mainTabControl.Items)
         {
             if (tab.Content is Views.OpenProject)
             {
                 tab.IsSelected = true;
                 return;
             }
         }
         var view                     = new Views.OpenProject(this);
         view.onOpenProject          += onOpenProject;
         view.onOpenWorkflow         += onOpenWorkflow;
         Views.ClosableTab newTabItem = new Views.ClosableTab
         {
             Title   = "Open project",
             Name    = "openproject",
             Content = view
         };
         newTabItem.OnClose += NewTabItem_OnClose;
         mainTabControl.Items.Add(newTabItem);
         newTabItem.IsSelected = true;
     }, null);
 }
Beispiel #3
0
 public void onOpenWorkflow(Workflow workflow)
 {
     AutomationHelper.syncContext.Post(o =>
     {
         Views.WFDesigner designer = getWorkflowDesignerByFilename(workflow.FilePath);
         if (designer == null && !string.IsNullOrEmpty(workflow._id))
         {
             designer = getWorkflowDesignerById(workflow._id);
         }
         if (designer != null)
         {
             designer.tab.IsSelected = true;
             return;
         }
         try
         {
             Views.ClosableTab newTabItem = new Views.ClosableTab
             {
                 Title = "Open project",
                 Name  = "openproject"
             };
             newTabItem.OnClose += NewTabItem_OnClose;
             var types           = new List <Type>();
             foreach (var p in Plugins.recordPlugins)
             {
                 types.Add(p.GetType());
             }
             var view           = new Views.WFDesigner((Views.ClosableTab)newTabItem, workflow, types.ToArray());
             view.onChanged    += WFDesigneronChanged;
             newTabItem.Content = view;
             mainTabControl.Items.Add(newTabItem);
             newTabItem.IsSelected = true;
         }
         catch (Exception ex)
         {
             Log.Error(ex, "");
             MessageBox.Show(ex.Message);
         }
     }, null);
 }
Beispiel #4
0
        // private static RoslynExpressionEditorService _expressionEditorService;
        // private static EditorService _expressionEditorServiceVB;
        public WFDesigner(ClosableTab tab, Workflow workflow, Type[] extratypes)
        {
            this.tab = tab;
            InitializeComponent();
            ;
            WfToolboxBorder.Child = InitializeActivitiesToolbox();
            Workflow = workflow;
            Workflow.OnIdleOrComplete += onIdleOrComplete;
            wfDesigner = new WorkflowDesigner();

            // Register the runtime metadata for the designer.
            new DesignerMetadata().Register();



            DesignerConfigurationService configService = wfDesigner.Context.Services.GetRequiredService <DesignerConfigurationService>();

            configService.TargetFrameworkName             = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));
            configService.AnnotationEnabled               = true;
            configService.AutoConnectEnabled              = true;
            configService.AutoSplitEnabled                = true;
            configService.AutoSurroundWithSequenceEnabled = true;
            configService.BackgroundValidationEnabled     = true;
            configService.MultipleItemsContextMenuEnabled = true;
            configService.MultipleItemsDragDropEnabled    = true;
            configService.NamespaceConversionEnabled      = true;
            configService.PanModeEnabled                    = true;
            configService.RubberBandSelectionEnabled        = true;
            configService.LoadingFromUntrustedSourceEnabled = false;

            //if (_expressionEditorServiceVB == null) _expressionEditorServiceVB = new EditorService();
            //wfDesigner.Context.Services.Publish<IExpressionEditorService>(_expressionEditorServiceVB);

            wfDesigner.Context.Services.Publish <IExpressionEditorService>(new EditorService());

            if (!string.IsNullOrEmpty(workflow.Xaml))
            {
                wfDesigner.Text = workflow.Xaml;
                wfDesigner.Load();
                //wfDesigner.Load(workflow.Filename);
            }
            else
            {
                Activity wf = new System.Activities.Statements.Sequence {
                };
                var ab      = new ActivityBuilder();
                ab.Name           = workflow.name;
                ab.Implementation = wf;
                AddVBNamespaceSettings(ab, typeof(Action),
                                       typeof(Microsoft.VisualBasic.Collection),
                                       typeof(System.Xml.XmlNode),
                                       typeof(OpenRPA.Workflow),
                                       typeof(OpenRPA.UIElement),
                                       typeof(System.Data.DataSet),
                                       typeof(System.Linq.Enumerable)
                                       );
                AddVBNamespaceSettings(ab, extratypes);

                //if (workflow.language == entity.workflowLanguage.CSharp)
                //{
                //    System.Activities.Presentation.Expressions.ExpressionActivityEditor.SetExpressionActivityEditor(ab, "C#");
                //}
                wfDesigner.Load(ab);
            }
            HasChanged = false;
            wfDesigner.ModelChanged += (sender, e) =>
            {
                HasChanged = true;
                onChanged?.Invoke(this);
            };

            WfDesignerBorder.Child = wfDesigner.View;
            WfPropertyBorder.Child = wfDesigner.PropertyInspectorView;

            OutputMessages = MainWindow.tracing.OutputMessages;
            TraceMessages  = MainWindow.tracing.TraceMessages;


            var modelItem = wfDesigner.Context.Services.GetService <ModelService>().Root;

            workflow.name = modelItem.GetValue <string>("Name");
            tab.Title     = workflow.name;

            wfDesigner.Context.Items.Subscribe <Selection>(new SubscribeContextCallback <Selection>(SelectionChanged));

            WeakEventManager <System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.PropertyChangedEventArgs> .
            AddHandler(MainWindow.tracing, "PropertyChanged", traceOnPropertyChanged);
        }