Exemplo n.º 1
0
        private void OnPreviewGraphCompleted(AsyncTask asyncTask)
        {
            var updateTask = asyncTask as PreviewGraphAsyncTask;

            if (updateTask != null)
            {
                var nodeGuids             = updateTask.previewGraphData;
                var deltaComputeStateArgs = new DeltaComputeStateEventArgs(nodeGuids, graphExecuted);
                OnSetNodeDeltaState(deltaComputeStateArgs);
            }
        }
Exemplo n.º 2
0
 private void hwm_SetNodeDeltaState(object sender, DeltaComputeStateEventArgs e)
 {
     // Using Nodes here is not thread safe, as nodes can be added/removed by the UI thread midway.
     // Dispatching this to the UI thread would help to avoid concurrency issues but has caveats.
     // When Dynamo is shutting down, a deadlock situation can occur, where each thread waits on the other.
     // Moreover, tight periodic runs can create situations where we cannot safely check if we are shutting down.
     // In summary, even if locking may be more costly, it is the safer approach.
     lock (Nodes)
     {
         UpdateNodesDeltaState(e.NodeGuidList, e.GraphExecuted);
     }
 }
Exemplo n.º 3
0
        private void hwm_SetNodeDeltaState(object sender, DeltaComputeStateEventArgs e)
        {
            var nodeGuids = e.NodeGuidList;

            // if runsettings is manual, and if the graph is not executed, then turing on showrunpreview
            //should turn on showexectionpreview on every node.
            if (nodeGuids.Count == 0 && !e.GraphExecuted)
            {
                foreach (var nodeModel in Nodes)
                {
                    nodeModel.ShowExecutionPreview = DynamoViewModel.ShowRunPreview;
                }
            }

            //if the graph is executed then set the node preview to false , provided
            // there is no error on that node.
            if (nodeGuids.Count == 0 && e.GraphExecuted)
            {
                foreach (var nodeViewModel in Nodes)
                {
                    if (nodeViewModel.State != ElementState.Error && nodeViewModel.State != ElementState.Warning)
                    {
                        nodeViewModel.ShowExecutionPreview = false;
                        nodeViewModel.IsNodeAddedRecently  = false;
                    }
                }
            }

            foreach (Guid t in nodeGuids)
            {
                var nodeViewModel = Nodes.FirstOrDefault(x => x.NodeModel.GUID == t);
                if (nodeViewModel != null)
                {
                    nodeViewModel.ShowExecutionPreview = nodeViewModel.DynamoViewModel.ShowRunPreview;
                    nodeViewModel.IsNodeAddedRecently  = false;
                }
            }

            /* Color the recently added nodes */
            var addedNodes = Nodes.Where(x => x.IsNodeAddedRecently).ToList();

            foreach (var nodes in addedNodes)
            {
                if (nodes.ShowExecutionPreview)
                {
                    nodes.ShowExecutionPreview = nodes.DynamoViewModel.ShowRunPreview;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This function gets the set of nodes that will get executed in the next run.
        /// This function will be called when the nodes are modified or when showrunpreview is set
        /// the executing nodes will be sent via SetNodeDeltaState event.
        /// </summary>
        /// <param name="showRunPreview">This parameter controls the delta state computation </param>
        internal void GetExecutingNodes(bool showRunPreview)
        {
            var task = new PreviewGraphAsyncTask(scheduler, VerboseLogging);

            //The Graph is executed and Show node execution is checked on the Settings menu
            if (graphExecuted && showRunPreview)
            {
                if (task.Initialize(EngineController, this) != null)
                {
                    task.Completed += OnPreviewGraphCompleted;
                    scheduler.ScheduleForExecution(task);
                }
            }
            //Show node exection is checked but the graph has not RUN
            else
            {
                var deltaComputeStateArgs = new DeltaComputeStateEventArgs(new List <Guid>(), graphExecuted);
                OnSetNodeDeltaState(deltaComputeStateArgs);
            }
        }