Esempio n. 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;
         }
     }
 }
Esempio n. 2
0
 public Views.WFDesigner getWorkflowDesignerById(string Id)
 {
     Views.WFDesigner designer = null;
     foreach (TabItem tab in mainTabControl.Items)
     {
         if (tab.Content is Views.WFDesigner)
         {
             designer = (Views.WFDesigner)tab.Content;
             if (designer.Workflow._id == Id)
             {
                 return(designer);
             }
         }
     }
     return(null);
 }
Esempio n. 3
0
 public Views.WFDesigner getWorkflowDesignerByFilename(string Filename)
 {
     Views.WFDesigner designer = null;
     foreach (TabItem tab in mainTabControl.Items)
     {
         if (tab.Content is Views.WFDesigner)
         {
             designer = (Views.WFDesigner)tab.Content;
             if (designer.Workflow.FilePath == Filename)
             {
                 return(designer);
             }
         }
     }
     return(null);
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 private void WFDesigneronChanged(Views.WFDesigner view)
 {
     AutomationHelper.syncContext.Post(o =>
     {
         Views.WFDesigner designer = null;
         foreach (TabItem tab in mainTabControl.Items)
         {
             if (tab.Content is Views.WFDesigner)
             {
                 designer = (Views.WFDesigner)tab.Content;
                 if (designer.Workflow.FilePath == view.Workflow.FilePath)
                 {
                     var t   = (Views.ClosableTab)tab;
                     t.Title = (designer.HasChanged ? designer.Workflow.name + "*" : designer.Workflow.name);
                     CommandManager.InvalidateRequerySuggested();
                     return;
                 }
             }
         }
     }, null);
     //_syncContext.Post(o => CommandManager.InvalidateRequerySuggested(), null);
 }
Esempio n. 6
0
        private async void onDelete(object item)
        {
            var view = item as Views.OpenProject;

            if (view == null)
            {
                return;
            }
            var val = view.listWorkflows.SelectedValue;
            var wf  = val as Workflow;
            var p   = val as Project;


            if (wf != null)
            {
                Views.WFDesigner designer = getWorkflowDesignerByFilename(wf.FilePath);
                if (designer == null && !string.IsNullOrEmpty(wf._id))
                {
                    designer = getWorkflowDesignerById(wf._id);
                }
                if (designer != null)
                {
                    designer.tab.Close();
                }

                var messageBoxResult = MessageBox.Show("Delete " + wf.name + " ?", "Delete Confirmation", MessageBoxButton.YesNo);
                if (messageBoxResult != MessageBoxResult.Yes)
                {
                    return;
                }

                await wf.Delete();
            }
            if (p != null)
            {
                if (p.Workflows.Count > 0)
                {
                    var messageBoxResult = MessageBox.Show("Delete project " + p.name + " containing " + p.Workflows.Count() + " workflows", "Delete Confirmation", MessageBoxButton.YesNo);
                    if (messageBoxResult != MessageBoxResult.Yes)
                    {
                        return;
                    }
                    foreach (var _wf in p.Workflows.ToList())
                    {
                        Views.WFDesigner designer = getWorkflowDesignerByFilename(_wf.FilePath);
                        if (designer == null && !string.IsNullOrEmpty(_wf._id))
                        {
                            designer = getWorkflowDesignerById(_wf._id);
                        }
                        if (designer != null)
                        {
                            designer.tab.Close();
                        }
                        await _wf.Delete();
                    }
                }
                await p.Delete();

                Projects.Remove(p);
            }
        }