Example #1
0
 public virtual void OnCurrentWorkspaceChanged(WorkspaceModel workspace)
 {
     if (CurrentWorkspaceChanged != null)
     {
         CurrentWorkspaceChanged(workspace);
     }
 }
Example #2
0
 public DummyNode(WorkspaceModel workspace)
     : base(workspace)
 {
     this.LegacyNodeName = "DSCoreNodesUI.DummyNode";
     this.LegacyAssembly = string.Empty;
     this.NodeNature = Nature.Unresolved;
 }
Example #3
0
 public ApplyFunction(WorkspaceModel workspaceModel) : base(workspaceModel)
 {
     InPortData.Add(new PortData("func", "Function to apply."));
     OutPortData.Add(new PortData("func(args)", "Result of application."));
     AddInput();
     RegisterAllPorts();
 }
Example #4
0
 public DSFunction(WorkspaceModel ws, FunctionDescriptor definition)
     : base(ws)
 {
     ArgumentLacing = LacingStrategy.Shortest;
     Definition = definition;
     Initialize();
 }
Example #5
0
 public WebRequest(WorkspaceModel workspace)
     : base(workspace)
 {
     InPortData.Add(new PortData("url", "The url for the web request."));
     OutPortData.Add(new PortData("result", "The result of the web request."));
     RegisterAllPorts();
 }
        /// <summary>
        /// This method is called by code that intends to start a graph update.
        /// This method is called on the main thread where node collection in a 
        /// WorkspaceModel can be safely accessed.
        /// </summary>
        /// <param name="controller">Reference to an instance of EngineController 
        /// to assist in generating GraphSyncData object for the given set of nodes.
        /// </param>
        /// <param name="workspace">Reference to the WorkspaceModel from which a 
        /// set of updated nodes is computed. The EngineController generates the 
        /// resulting GraphSyncData from this list of updated nodes.</param>
        /// <returns>Returns true if there is any GraphSyncData, or false otherwise
        /// (in which case there will be no need to schedule UpdateGraphAsyncTask 
        /// for execution).</returns>
        /// 
        internal bool Initialize(EngineController controller, WorkspaceModel workspace)
        {
            try
            {
                engineController = controller;
                TargetedWorkspace = workspace;

                ModifiedNodes = ComputeModifiedNodes(workspace);
                graphSyncData = engineController.ComputeSyncData(workspace.Nodes, ModifiedNodes, verboseLogging);
                if (graphSyncData == null)
                    return false;

                // We clear dirty flags before executing the task. If we clear
                // flags after the execution of task, for example in
                // AsyncTask.Completed or in HandleTaskCompletionCore(), as both
                // are executed in the other thread, although some nodes are
                // modified and we request graph execution, but just before
                // computing sync data, the task completion handler jumps in
                // and clear dirty flags. Now graph sync data will be null and
                // graph is in wrong state.
                foreach (var nodeGuid in graphSyncData.NodeIDs)
                {
                    var node = workspace.Nodes.FirstOrDefault(n => n.GUID.Equals(nodeGuid));
                    if (node != null)
                        node.ClearDirtyFlag();
                }

                return true;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("UpgradeGraphAsyncTask saw: " + e.ToString());
                return false;
            }
        }
Example #7
0
 public Formula(WorkspaceModel workspace)
     : base(workspace)
 {
     ArgumentLacing = LacingStrategy.Shortest;
     OutPortData.Add(new PortData("", "Result of math computation"));
     RegisterAllPorts();
 }
Example #8
0
 protected ElementsQueryBase(WorkspaceModel workspaceModel) : base(workspaceModel)
 {
     var u = RevitDynamoModel.RevitServicesUpdater;
     u.ElementsAdded += Updater_ElementsAdded;
     u.ElementsModified += Updater_ElementsModified;
     u.ElementsDeleted += Updater_ElementsDeleted;
 }
Example #9
0
 internal void OnWorkspaceSaved(WorkspaceModel model)
 {
     if (WorkspaceSaved != null)
     {
         WorkspaceSaved(model);
     }
 }
        /// <summary>
        /// Call this method to determine if the task should be scheduled for 
        /// execution.
        /// </summary>
        /// <param name="workspaceModel">Render packages for all the nodes in 
        /// this workspaceModel will be extracted, if 'nodeModel' parameter is 
        /// null.</param>
        /// <param name="nodeModel">An optional NodeModel from which all upstream 
        /// nodes are to be examined for render packages. If this parameter is 
        /// null, render packages are extracted from all nodes in workspaceModel.
        /// </param>
        /// <returns>Returns true if the task should be scheduled for execution,
        /// or false otherwise.</returns>
        /// 
        internal bool Initialize(WorkspaceModel workspaceModel, NodeModel nodeModel)
        {
            if (workspaceModel == null)
                throw new ArgumentNullException("workspaceModel");

            if (nodeModel == null) // No node is specified, gather all nodes.
            {
                NodeId = Guid.Empty;

                // Duplicate a list of all nodes for consumption later.
                duplicatedNodeReferences = workspaceModel.Nodes.ToList();
            }
            else
            {
                NodeId = nodeModel.GUID;

                // Recursively gather all upstream nodes.
                var gathered = new List<NodeModel>();
                GatherAllUpstreamNodes(nodeModel, gathered);
                duplicatedNodeReferences = gathered;
            }

            Debug.WriteLine(string.Format("Aggregation task initialized for {0}", nodeModel == null?"null":nodeModel.GUID.ToString()));
            return duplicatedNodeReferences.Any();
        }
        /// <summary>
        /// Call this method to determine if the task should be scheduled for 
        /// execution.
        /// </summary>
        /// <param name="workspaceModel">Render packages for all the nodes in 
        /// this workspaceModel will be extracted, if 'nodeModel' parameter is 
        /// null.</param>
        /// <param name="nodeModel">An optional NodeModel from which all upstream 
        /// nodes are to be examined for render packages. If this parameter is 
        /// null, render packages are extracted from all nodes in workspaceModel.
        /// </param>
        /// <returns>Returns true if the task should be scheduled for execution,
        /// or false otherwise.</returns>
        /// 
        internal bool Initialize(WorkspaceModel workspaceModel, NodeModel nodeModel)
        {
            if (workspaceModel == null)
                throw new ArgumentNullException("workspaceModel");

            if (nodeModel == null) // No node is specified, gather all nodes.
            {
                targetedNodeId = Guid.Empty;

                // Duplicate a list of all nodes for consumption later.
                var nodes = workspaceModel.Nodes.Where(n => n.IsVisible);
                duplicatedNodeReferences = nodes.ToList();
            }
            else
            {
                targetedNodeId = nodeModel.GUID;

                // Recursively gather all upstream nodes. Stop 
                // gathering if this node does not display upstream.
                var gathered = new List<NodeModel>();
                WorkspaceUtilities.GatherAllUpstreamNodes(nodeModel,
                    gathered, model => model.IsUpstreamVisible);

                duplicatedNodeReferences = gathered;
            }

            return duplicatedNodeReferences.Any();
        }
Example #12
0
        protected virtual void OnWorkspaceAdded(WorkspaceModel obj)
        {
            var handler = WorkspaceAdded;
            if (handler != null) handler(obj);

            WorkspaceEvents.OnWorkspaceAdded(obj.Guid, obj.Name, obj.GetType());
        }
Example #13
0
        public virtual void OnWorkspaceCleared(WorkspaceModel workspace)
        {
            if (WorkspaceCleared != null)
                WorkspaceCleared(workspace);

            WorkspaceEvents.OnWorkspaceCleared();
        }
Example #14
0
        public WatchImageCore(WorkspaceModel ws) : base(ws)
        {
            InPortData.Add(new PortData("image", "image"));
            OutPortData.Add(new PortData("image", "image"));

            RegisterAllPorts();
        }
Example #15
0
        protected virtual void OnWorkspaceRemoved(WorkspaceModel obj)
        {
            var handler = WorkspaceRemoved;
            if (handler != null) handler(obj);

            WorkspaceEvents.OnWorkspaceRemoved(obj.Guid, obj.Name);
        }
Example #16
0
 public GetWorksheetsFromExcelWorkbook(WorkspaceModel workspace)
     : base(workspace)
 {
     InPortData.Add(new PortData("workbook", "The excel workbook"));
     OutPortData.Add(new PortData("worksheets", "A list of worksheets"));
     RegisterAllPorts();
 }
Example #17
0
        public ElementsOfFamilyType(WorkspaceModel workspaceModel)
            : base(workspaceModel)
        {
            InPortData.Add(new PortData("Family Type", "The Family Type."));
            OutPortData.Add(new PortData("Elements", "The list of elements matching the query."));

            RegisterAllPorts();
        }
Example #18
0
 public GetExcelWorksheetByName(WorkspaceModel workspace)
     : base(workspace)
 {
     InPortData.Add(new PortData("workbook", "The excel workbook"));
     InPortData.Add(new PortData("name", "Name of the worksheet to get"));
     OutPortData.Add(new PortData("worksheet", "The worksheet with the given name"));
     RegisterAllPorts();
 }
Example #19
0
        protected FileSystemBrowser(WorkspaceModel workspace, string tip)
            : base(workspace)
        {
            OutPortData[0].ToolTipString = tip;
            RegisterAllPorts();

            Value = "";
        }
Example #20
0
            public TwoScopedInputs(WorkspaceModel workspaceModel) : base(workspaceModel)
            {
                InPortData.Add(new PortData("port1", "Port1 block"));
                InPortData.Add(new PortData("port2", "Port2 block"));
                OutPortData.Add(new PortData("result", "Result"));

                RegisterAllPorts();
            }
Example #21
0
        public ComposeFunctions(WorkspaceModel workspaceModel)
            : base(workspaceModel)
        {
            InPortData.Add(new PortData("func0", "Function #0"));
            InPortData.Add(new PortData("func1", "Function #1"));

            OutPortData.Add(new PortData("func", "Composed function."));
            RegisterAllPorts();
        }
Example #22
0
        public Map(WorkspaceModel workspace) : base(workspace)
        {
            InPortData.Add(new PortData("list", "The list to map over."));
            InPortData.Add(new PortData("f(x)", "The procedure used to map elements"));

            OutPortData.Add(new PortData("mapped", "Mapped list"));

            RegisterAllPorts();
        }
Example #23
0
        public ScopedIf(WorkspaceModel workspaceModel) : base(workspaceModel)
        {
            InPortData.Add(new PortData("test", "Test block"));
            InPortData.Add(new PortData("true", "True block"));
            InPortData.Add(new PortData("false", "False block"));

            OutPortData.Add(new PortData("result", "Result"));
            RegisterAllPorts();
        }
Example #24
0
        protected BinaryLogic(WorkspaceModel workspaceModel, string symbol, Operator op) : base(workspaceModel)
        {
            _op = op;

            InPortData.Add(new PortData("bool0", "operand"));
            InPortData.Add(new PortData("bool1", "operand"));
            OutPortData.Add(new PortData("", "result"));
            RegisterAllPorts();
        }
Example #25
0
        public CreateList(WorkspaceModel workspace) : base(workspace)
        {
            InPortData.Add(new PortData("index0", "Item Index #0"));
            OutPortData.Add(new PortData("list", "A list"));

            RegisterAllPorts();

            ArgumentLacing = LacingStrategy.Disabled;
        }
Example #26
0
 public CodeBlockNodeModel(string userCode, Guid guid, WorkspaceModel workspace, double xPos, double yPos) : base(workspace)
 {
     ArgumentLacing = LacingStrategy.Disabled;
     this.X = xPos;
     this.Y = yPos;
     this.code = userCode;
     this.GUID = guid;
     this.shouldFocus = false;
     ProcessCodeDirect();
 }
Example #27
0
        protected CombinatorNode(WorkspaceModel workspace) : this(workspace, 3)
        {
            InPortData.Add(new PortData("comb", "Combinator"));
            InPortData.Add(new PortData("list1", "List #1"));
            InPortData.Add(new PortData("list2", "List #2"));

            OutPortData.Add(new PortData("combined", "Combined lists"));

            RegisterAllPorts();
        }
Example #28
0
 /// <summary>
 /// Factory method to create a connector.  Checks to make sure that the start and end ports are valid, 
 /// otherwise returns null.
 /// </summary>
 /// <param name="start">The port where the connector starts</param>
 /// <param name="end">The port where the connector ends</param>
 /// <param name="startIndex"></param>
 /// <param name="endIndex"></param>
 /// <param name="portType"></param>
 /// <returns>The valid connector model or null if the connector is invalid</returns>
 internal static ConnectorModel Make(WorkspaceModel workspaceModel, NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
 {
     if (workspaceModel != null && start != null && end != null && start != end && startIndex >= 0
         && endIndex >= 0 && start.OutPorts.Count > startIndex && end.InPorts.Count > endIndex )
     {
         return new ConnectorModel(workspaceModel, start, end, startIndex, endIndex, portType);
     }
     
     return null;
 }
Example #29
0
        public SunSettings(WorkspaceModel workspaceModel) : base(workspaceModel)
        {
            OutPortData.Add(new PortData("SunSettings", "SunSettings element."));
            
            RegisterAllPorts();
            
            RevitDynamoModel.RevitServicesUpdater.ElementsModified += Updater_ElementsModified;
            DocumentManager.Instance.CurrentUIApplication.ViewActivated += CurrentUIApplication_ViewActivated;

            CurrentUIApplicationOnViewActivated();
        }
Example #30
0
        /// <summary>
        /// This method is called by task creator to associate the trace data with
        /// the current instance of virtual machine. The given WorkspaceModel can
        /// optionally contain saved trace data in a previous execution session. As
        /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData"
        /// data member to ensure the correctness of the execution flow.
        /// </summary>
        /// <param name="controller">Reference to the EngineController on which the 
        /// loaded trace data should be set.</param>
        /// <param name="workspace">The workspace from which the trace data should 
        /// be retrieved.</param>
        /// <returns>If the given WorkspaceModel contains saved trace data, this 
        /// method returns true, in which case the task needs to be scheduled.
        /// Otherwise, the method returns false.</returns>
        /// 
        internal bool Initialize(EngineController controller, WorkspaceModel workspace)
        {
            if (controller == null || (controller.LiveRunnerCore == null))
                return false;

            engineController = controller;
            traceData = workspace.PreloadedTraceData;

            TargetedWorkspace = workspace;
            workspace.PreloadedTraceData = null;
            return ((traceData != null) && traceData.Any());
        }
Example #31
0
 /// <summary>
 ///     Updates relevant parameters on save
 /// </summary>
 /// <param name="model">The workspace that was just saved</param>
 private static void OnWorkspaceSaved(WorkspaceModel model)
 {
     model.LastSaved         = DateTime.Now;
     model.HasUnsavedChanges = false;
     dynSettings.Controller.DynamoViewModel.AddToRecentFiles(model.FileName);
 }
Example #32
0
 public NoteModel(WorkspaceModel workspace, double x, double y)
 {
     this.workspaceModel = workspace;
     X = x;
     Y = y;
 }
 public WorkspaceEventArgs(WorkspaceModel workspace)
 {
     this.Workspace = workspace;
 }