예제 #1
0
        // SCRIPT evaluate python script in nodes signed with stamp in node link [F9]
        private void Evaluate(Diagram.Diagram diagram, DiagramView diagramView)
        {
            Nodes nodes = null;

            if (diagramView.selectedNodes.Count() > 0)
            {
                nodes = new Nodes(diagramView.selectedNodes);
            }
            else
            {
                nodes = new Nodes(diagram.GetAllNodes());
            }
            // remove nodes whit link other then [ ! | eval | evaluate | !#num_order | eval#num_order |  evaluate#num_order]
            // higest number is executed first
            Regex regex = new Regex(@"^\s*(eval(uate)|!){1}(#\w+){0,1}\s*$");
            nodes.RemoveAll(n => !regex.Match(n.link).Success);

            nodes.OrderByLink();
            nodes.Reverse();

            String clipboard = Os.GetTextFormClipboard();

#if !DEBUG
            Job.DoJob(
                new DoWorkEventHandler(
                    delegate (object o, DoWorkEventArgs args)
                    {
#endif
                        this.Evaluate(diagram, diagramView, nodes, clipboard);
#if !DEBUG
                    }
                )
            );
#endif
        }
예제 #2
0
        public bool ClickOnNodeAction(Diagram.Diagram diagram, DiagramView diagramView, Node node)
        {
            if (node.link.Trim() == "#csharp")  // OPEN SCRIPT node with link "script" is executed as script
            {
                String clipboard = Os.GetTextFormClipboard();

                try
                {
                    this.EvaluateAsync(diagram, diagramView, node, clipboard).Wait();
                }
                catch (System.AggregateException ae)
                {
                    ae.Handle(ex =>
                    {
                        Program.log.Write("Exception in embed csharp script: " + ex.Message);
                        return(true);
                    });
                }


                return(true);
            }

            return(false);
        }