Exemplo n.º 1
0
 public NodeHelpPrompt(dynNodeModel node)
 {
     this.DataContext = node;
     this.Owner = dynSettings.Bench;
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     InitializeComponent();
 }
Exemplo n.º 2
0
        public dynNodeViewModel(dynNodeModel logic)
        {
            nodeLogic = logic;

            //respond to collection changed events to sadd
            //and remove port model views
            logic.InPorts.CollectionChanged += inports_collectionChanged;
            logic.OutPorts.CollectionChanged += outports_collectionChanged;

            logic.PropertyChanged += logic_PropertyChanged;
            dynSettings.Controller.DynamoViewModel.Model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Model_PropertyChanged);

            DeleteCommand = new DelegateCommand(DeleteNodeAndItsConnectors, CanDeleteNode);
            SetLacingTypeCommand = new DelegateCommand<string>(new Action<string>(SetLacingType), CanSetLacingType);
            SetStateCommand = new DelegateCommand<object>(SetState, CanSetState);
            SelectCommand = new DelegateCommand(Select, CanSelect);
            ViewCustomNodeWorkspaceCommand = new DelegateCommand(ViewCustomNodeWorkspace, CanViewCustomNodeWorkspace);
            SetLayoutCommand = new DelegateCommand<object>(SetLayout, CanSetLayout);
            SetupCustomUIElementsCommand = new DelegateCommand<dynNodeView>(SetupCustomUIElements, CanSetupCustomUIElements);
            ValidateConnectionsCommand = new DelegateCommand(ValidateConnections, CanValidateConnections);

            //Do a one time setup of the initial ports on the node
            //we can not do this automatically because this constructor
            //is called after the node's constructor where the ports
            //are initially registered
            SetupInitialPortViewModels();

            dynSettings.Controller.RequestNodeSelect += new NodeEventHandler(Controller_RequestNodeSelect);
        }
Exemplo n.º 3
0
 public dynPortModel(int index, PortType portType, dynNodeModel owner, string name)
 {
     Index = index;
     IsConnected = false;
     PortType = portType;
     Owner = owner;
     PortName = name;
 }
Exemplo n.º 4
0
 /// <summary>
 /// The class constructor for a built-in type that is already loaded. </summary>
 /// <param name="node">The local node</param>
 public NodeSearchElement(dynNodeModel node)
 {
     this.Node = node;
     this._name = Node.NickName;
     this.Weight = 1;
     this.Keywords = String.Join(" ", node.Tags);
     this._type = "Node";
     this._description = node.Description;
 }
Exemplo n.º 5
0
 public dynPortViewModel(dynPortModel port, dynNodeModel node)
 {
     _node = node;
     _port = port;
     _port.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_port_PropertyChanged);
     _node.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_node_PropertyChanged);
     ConnectCommand = new DelegateCommand(Connect, CanConnect);
     HighlightCommand = new DelegateCommand(Highlight, CanHighlight);
     UnHighlightCommand = new DelegateCommand(UnHighlight, CanUnHighlight);
 }
Exemplo n.º 6
0
 /// <summary>
 /// The class constructor for a built-in type that is already loaded. </summary>
 /// <param name="node">The local node</param>
 public NodeSearchElement(dynNodeModel node)
 {
     ToggleDescriptionVisibilityCommand = new DelegateCommand(ToggleIsVisible);
     this.Node = node;
     this._name = Node.NickName;
     this.Weight = 1;
     this.Keywords = String.Join(" ", node.Tags);
     this._type = "Node";
     this._description = node.Description;
 }
Exemplo n.º 7
0
        private dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType )
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            pStart = start.OutPorts[startIndex];

            dynPortModel endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
            sw.Stop();
            Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
Exemplo n.º 8
0
        public dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType, bool visible)
        {
            //don't try to create a connector with a bad start,
            //end, or if we're trying to connector the same
            //port to itself.
            if (start == null || end == null || start == end)
            {
                throw new Exception("Attempting to create connector with invalid start or end nodes.");
            }

            pStart = start.OutPorts[startIndex];

            dynPortModel endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
        }
Exemplo n.º 9
0
 internal void ConnectInput(int inputData, int outputData, dynNodeModel node)
 {
     Inputs[inputData] = Tuple.Create(outputData, node);
     CheckPortsForRecalc();
 }
Exemplo n.º 10
0
 public dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType)
     : this(start, end, startIndex, endIndex, portType, true)
 {
 }
Exemplo n.º 11
0
        private bool traverseAny(dynNodeModel entry)
        {
            bool result;
            if (resultDict.TryGetValue(entry, out result))
                return result;

            result = predicate(entry);
            resultDict[entry] = result;
            if (result)
                return result;

            if (entry is dynFunction)
            {
                var symbol = Guid.Parse((entry as dynFunction).Symbol);
                if (!dynSettings.Controller.CustomNodeManager.Contains(symbol))
                {
                    dynSettings.Controller.DynamoViewModel.Log("WARNING -- No implementation found for node: " + symbol);
                    entry.Error("Could not find .dyf definition file for this node.");
                    return false;
                }

                result = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(symbol)
                    .Workspace.GetTopMostNodes().Any(ContinueTraversalUntilAny);
            }
            resultDict[entry] = result;
            if (result)
                return result;

            return entry.Inputs.Values.Any(x => x != null && traverseAny(x.Item2));
        }
Exemplo n.º 12
0
 public bool TraverseUntilAny(dynNodeModel entry)
 {
     inProgress = true;
     bool result = traverseAny(entry);
     resultDict.Clear();
     inProgress = false;
     return result;
 }
Exemplo n.º 13
0
 public bool ContinueTraversalUntilAny(dynNodeModel entry)
 {
     if (inProgress)
         return traverseAny(entry);
     else
         throw new Exception("ContinueTraversalUntilAny cannot be used except in a traversal predicate.");
 }
Exemplo n.º 14
0
 internal void DisconnectOutput(int portData, int inPortData, dynNodeModel nodeModel)
 {
     HashSet<Tuple<int, dynNodeModel>> output;
     if (Outputs.TryGetValue(portData, out output))
         output.RemoveWhere(x => x.Item2 == nodeModel && x.Item1 == inPortData);
     CheckPortsForRecalc();
 }
Exemplo n.º 15
0
 public void Log(dynNodeModel node)
 {
     string exp = node.PrintExpression();
     Log("> " + exp);
 }
Exemplo n.º 16
0
        private static void DeleteNodeAndItsConnectors(dynNodeModel node)
        {
            foreach (var conn in node.AllConnectors().ToList())
            {
                conn.NotifyConnectedPortsOfDeletion();
                dynSettings.Controller.DynamoViewModel.Model.CurrentSpace.Connectors.Remove(conn);
            }

            node.DisableReporting();
            node.Destroy();
            node.Cleanup();
            DynamoSelection.Instance.Selection.Remove(node);
            node.WorkSpace.Nodes.Remove(node);
        }
Exemplo n.º 17
0
        internal void ShowElement(dynNodeModel e)
        {
            if (dynamicRun)
                return;

            if (!_model.Nodes.Contains(e))
            {
                if (_model.HomeSpace != null && _model.HomeSpace.Nodes.Contains(e))
                {
                    //Show the homespace
                    ViewHomeWorkspace();
                }
                else
                {
                    foreach (FunctionDefinition funcDef in Controller.CustomNodeManager.GetLoadedDefinitions())
                    {
                        if (funcDef.Workspace.Nodes.Contains(e))
                        {
                            ViewCustomNodeWorkspace(funcDef);
                            break;
                        }
                    }
                }
            }

            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.OnRequestCenterViewOnElement(this, new ModelEventArgs(e,null));
        }
Exemplo n.º 18
0
 public NodeEventArgs(dynNodeModel n, Dictionary<string, object> d )
 {
     Node = n;
     Data = d;
 }
Exemplo n.º 19
0
 internal void ConnectOutput(int portData, int inputData, dynNodeModel nodeLogic)
 {
     if (!Outputs.ContainsKey(portData))
         Outputs[portData] = new HashSet<Tuple<int, dynNodeModel>>();
     Outputs[portData].Add(Tuple.Create(inputData, nodeLogic));
 }
Exemplo n.º 20
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>
        public static dynConnectorModel Make(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType)
        {
            if (start != null && end != null && start != end && startIndex >= 0
                && endIndex >= 0 && start.OutPorts.Count > startIndex && end.InPorts.Count > endIndex )
            {
                return new dynConnectorModel(start, end, startIndex, endIndex, portType);
            }

            return null;
        }