예제 #1
0
        protected SelectionBase(PortData outPortData)
            : this()
        {
            OutPortData.Add(outPortData);
            RegisterAllPorts();

            dynRevitSettings.Controller.RevitDocumentChanged += Controller_RevitDocumentChanged;
        }
예제 #2
0
        public void SetPortData(PortData data)
        {
            portData = data;

            UsingDefaultValue = portData.DefaultValue != null;
            RaisePropertyChanged("DefaultValueEnabled");
            RaisePropertyChanged("PortName");
            RaisePropertyChanged("TooltipContent");
        }
예제 #3
0
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType    = portType;
            Owner       = owner;

            SetPortData(data);

            MarginThickness = new Thickness(0);
            Height          = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #4
0
파일: PortModel.cs 프로젝트: Steell/Dynamo
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected         = false;
            PortType            = portType;
            Owner               = owner;
            PortName            = data.NickName;
            UsingDefaultValue   = false;
            DefaultValueEnabled = false;
            MarginThickness     = new Thickness(0);

            Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #5
0
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType    = portType;
            Owner       = owner;

            SetPortData(data);

            if (PortType == Models.PortType.Input)
            {
                MarginThickness = new Thickness(0);
            }
            else
            {
                MarginThickness = new Thickness(0, data.VerticalMargin, 0, 0);
            }

            Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #6
0
파일: PortModel.cs 프로젝트: hipigod/Dynamo
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected         = false;
            PortType            = portType;
            Owner               = owner;
            PortName            = data.NickName;
            UsingDefaultValue   = false;
            DefaultValueEnabled = false;
            MarginThickness     = new Thickness(0);

            if (data.Height == 0)
            {
                this.Height = Configurations.PortHeightInPixels;
            }
            else
            {
                this.Height = data.Height;
            }
        }
예제 #7
0
 protected MultipleElementSelectionBase(PortData outData)
 {
     OutPortData.Add(outData);
     RegisterAllPorts();
     dynSettings.Controller.DynamoViewModel.PropertyChanged += DynamoViewModel_PropertyChanged;
     CanSelect = true;
 }
예제 #8
0
 protected ElementSelectionBase(PortData outPortData)
     : base(outPortData)
 {
 }
예제 #9
0
파일: Function.cs 프로젝트: RobertiF/Dynamo
        protected override void LoadNode(XmlNode nodeElement)
        {
            List<XmlNode> childNodes = nodeElement.ChildNodes.Cast<XmlNode>().ToList();

            XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name"));
            if (nameNode != null && nameNode.Attributes != null)
                NickName = nameNode.Attributes[0].Value;

            XmlNode idNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("ID"));
            if (idNode != null && idNode.Attributes != null)
            {
                string id = idNode.Attributes[0].Value;
                Guid funcId;
                if (!Guid.TryParse(id, out funcId) && nodeElement.Attributes != null)
                    funcId = GuidUtility.Create(GuidUtility.UrlNamespace, nodeElement.Attributes["nickname"].Value);
                if (!VerifyFuncId(ref funcId))
                {
                    LoadProxyCustomNode(funcId);
                }
                Definition = Workspace.DynamoModel.CustomNodeManager.GetFunctionDefinition(funcId);

                if (Definition.IsProxy)
                {
                    Error("Cannot load custom node");
                }
            }

            foreach (XmlNode subNode in childNodes)
            {
                if (subNode.Name.Equals("Outputs"))
                {
                    var data =
                        subNode.ChildNodes.Cast<XmlNode>()
                               .Select(
                                   (outputNode, i) =>
                                       new
                                       {
                                           data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1)),
                                           idx = i
                                       });

                    foreach (var dataAndIdx in data)
                    {
                        if (OutPortData.Count > dataAndIdx.idx)
                            OutPortData[dataAndIdx.idx] = dataAndIdx.data;
                        else
                            OutPortData.Add(dataAndIdx.data);
                    }
                }
                else if (subNode.Name.Equals("Inputs"))
                {
                    var data =
                        subNode.ChildNodes.Cast<XmlNode>()
                               .Select(
                                   (inputNode, i) =>
                                       new
                                       {
                                           data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1)),
                                           idx = i
                                       });

                    foreach (var dataAndIdx in data)
                    {
                        if (InPortData.Count > dataAndIdx.idx)
                            InPortData[dataAndIdx.idx] = dataAndIdx.data;
                        else
                            InPortData.Add(dataAndIdx.data);
                    }
                }

                    #region Legacy output support

                else if (subNode.Name.Equals("Output"))
                {
                    var data = new PortData(subNode.Attributes[0].Value, "function output");

                    if (OutPortData.Any())
                        OutPortData[0] = data;
                    else
                        OutPortData.Add(data);
                }

                #endregion
            }

            if (!IsInSyncWithDefinition())
            {
                ResyncWithDefinition();
            }
            else
            {
                RegisterAllPorts();
            }

            //argument lacing on functions should be set to disabled
            //by default in the constructor, but for any workflow saved
            //before this was the case, we need to ensure it here.
            ArgumentLacing = LacingStrategy.Disabled;

            //if (Definition != null)
            //    ResyncWithDefinition();
        }
예제 #10
0
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType = portType;
            Owner = owner;

            SetPortData(data);

            MarginThickness = new Thickness(0);
            Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #11
0
파일: PortModel.cs 프로젝트: whztt07/Dynamo
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType = portType;
            Owner = owner;
            PortName = data.NickName;
            UsingDefaultValue = false;
            DefaultValueEnabled = false;
            MarginThickness = new Thickness(0);

            if (data.Height == 0)
                this.Height = Configurations.PortHeightInPixels;
            else
                this.Height = data.Height;
        }
예제 #12
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            base.DeserializeCore(element, context); //Base implementation must be called

            if (context == SaveContext.Undo)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                NickName = helper.ReadString("functionName");

                Symbol = helper.ReadString("functionId");
                Guid funcId;
                if (!VerifySymbol(out funcId))
                {
                    LoadProxyCustomNode(funcId);
                    return;
                }
                XmlNodeList inNodes = element.SelectNodes("functionInput");
                XmlNodeList outNodes = element.SelectNodes("functionOutput");
                int i = 0;
                foreach (XmlNode inputNode in inNodes)
                {
                    string name = inputNode.Attributes[0].Value;
                    var data = new PortData(name, "Input #" + (i + 1), typeof(object));
                    if (InPortData.Count > i)
                        InPortData[i] = data;
                    else
                        InPortData.Add(data);
                    i++;
                }
                i = 0;
                foreach (XmlNode outputNode in outNodes)
                {
                    string name = outputNode.Attributes[0].Value;
                    var data = new PortData(name, "Output #" + (i + 1), typeof(object));
                    if (OutPortData.Count > i)
                        OutPortData[i] = data;
                    else
                        OutPortData.Add(data);
                    i++;
                }

                //Added it the same way as LoadNode. But unsure of when 'Output' ChildNodes will
                //be added to element. As of now I dont think it is added during serialize

                #region Legacy output support

                foreach (XmlNode subNode in element.ChildNodes)
                {
                    if (subNode.Name.Equals("Output"))
                    {
                        var data = new PortData(
                            subNode.Attributes[0].Value, "function output", typeof(object));

                        if (OutPortData.Any())
                            OutPortData[0] = data;
                        else
                            OutPortData.Add(data);
                    }
                }

                #endregion

                RegisterAllPorts();

                Guid funId;
                try
                {
                    funId = Guid.Parse(Symbol);
                }
                catch
                {
                    funId = GuidUtility.Create(GuidUtility.UrlNamespace, NickName);
                    Symbol = funId.ToString();
                }

                Definition = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(funId);
                Description = helper.ReadString("functionDesc");
            }
        }
예제 #13
0
        public ScanList(WorkspaceModel workspace) : base(workspace)
        {
            reductorPort = new PortData(
                "reductor",
                "Reductor Function: accepts one item from each list being reduced, and the current accumulated value, result is the new accumulated value.");

            InPortData.Add(reductorPort);
            InPortData.Add(new PortData("seed", "Starting accumulated value, to be passed into the first call to the Reductor function."));
            InPortData.Add(new PortData("list1", "List #1"));

            OutPortData.Add(new PortData("scanned", "Scanned lists"));

            RegisterAllPorts();
        }
예제 #14
0
        public void SetPortData(PortData data)
        {
            portData = data;

            UsingDefaultValue = portData.DefaultValue != null;
            RaisePropertyChanged("DefaultValueEnabled");
            RaisePropertyChanged("PortName");
            RaisePropertyChanged("TooltipContent");
        }
예제 #15
0
 protected ReferenceSelectionBase(PortData outPortData)
     : base(outPortData)
 {
 }
예제 #16
0
        /// <summary>
        /// Add a port to this node. If the port already exists, return that port.
        /// </summary>
        /// <param name="portType"></param>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public PortModel AddPort(PortType portType, PortData data, int index)
        {
            PortModel p;
            switch (portType)
            {
                case PortType.INPUT:
                    if (inPorts.Count > index)
                    {
                        p = inPorts[index];

                        //update the name on the node
                        //e.x. when the node is being re-registered during a custom
                        //node save
                        p.PortName = data.NickName;
                        if (data.HasDefaultValue)
                        {
                            p.UsingDefaultValue = true;
                            p.DefaultValueEnabled = true;
                        }

                        return p;
                    }

                    p = new PortModel(index, portType, this, data.NickName)
                    {
                        UsingDefaultValue = data.HasDefaultValue,
                        DefaultValueEnabled = data.HasDefaultValue
                    };

                    p.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
                    {
                        if (args.PropertyName == "UsingDefaultValue")
                            RequiresRecalc = true;
                    };

                    InPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += p_PortConnected;
                    p.PortDisconnected += p_PortDisconnected;

                    return p;

                case PortType.OUTPUT:
                    if (outPorts.Count > index)
                    {
                        p = outPorts[index];
                        p.PortName = data.NickName;
                        return p;
                    }

                    p = new PortModel(index, portType, this, data.NickName)
                    {
                        UsingDefaultValue = false
                    };

                    OutPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += p_PortConnected;
                    p.PortDisconnected += p_PortDisconnected;

                    return p;
            }

            return null;
        }
예제 #17
0
        protected override void LoadNode(XmlNode nodeElement)
        {
            foreach (XmlNode subNode in nodeElement.ChildNodes)
            {
                if (subNode.Name.Equals("Name"))
                {
                    NickName = subNode.Attributes[0].Value;
                }
            }

            foreach (XmlNode subNode in nodeElement.ChildNodes)
            {
                if (subNode.Name.Equals("ID"))
                {
                    Symbol = subNode.Attributes[0].Value;
                    Guid funcId;
                    if (!VerifySymbol(out funcId))
                    {

                        LoadProxyCustomNode(funcId);
                        return;
                    }
                }
            }

            foreach (XmlNode subNode in nodeElement.ChildNodes)
            {
                if (subNode.Name.Equals("Outputs"))
                {
                    int i = 0;
                    foreach (XmlNode outputNode in subNode.ChildNodes)
                    {
                        var data = new PortData(
                            outputNode.Attributes[0].Value, "Output #" + (i + 1), typeof(object));

                        if (OutPortData.Count > i)
                        {
                            OutPortData[i] = data;
                        }
                        else
                        {
                            OutPortData.Add(data);
                        }

                        i++;
                    }
                }
                else if (subNode.Name.Equals("Inputs"))
                {
                    int i = 0;
                    foreach (XmlNode inputNode in subNode.ChildNodes)
                    {
                        var data = new PortData(
                            inputNode.Attributes[0].Value, "Input #" + (i + 1), typeof(object));

                        if (InPortData.Count > i)
                        {
                            InPortData[i] = data;
                        }
                        else
                        {
                            InPortData.Add(data);
                        }

                        i++;
                    }
                }
                    #region Legacy output support

                else if (subNode.Name.Equals("Output"))
                {
                    var data = new PortData(
                        subNode.Attributes[0].Value, "function output", typeof(object));

                    if (OutPortData.Any())
                        OutPortData[0] = data;
                    else
                        OutPortData.Add(data);
                }

                #endregion
            }

            RegisterAllPorts();

            //argument lacing on functions should be set to disabled
            //by default in the constructor, but for any workflow saved
            //before this was the case, we need to ensure it here.
            ArgumentLacing = LacingStrategy.Disabled;

            // we've found a custom node, we need to attempt to load its guid.
            // if it doesn't exist (i.e. its a legacy node), we need to assign it one
            // deterministically
            Guid funId;
            try
            {
                funId = Guid.Parse(Symbol);
            }
            catch (FormatException)
            {
                funId = GuidUtility.Create(
                    GuidUtility.UrlNamespace, nodeElement.Attributes["nickname"].Value);
                Symbol = funId.ToString();
            }

            Definition = dynSettings.Controller.CustomNodeManager.GetFunctionDefinition(funId);
        }
예제 #18
0
파일: Function.cs 프로젝트: khoaho/Dynamo
        protected override void LoadNode(XmlNode nodeElement)
        {
            Controller.LoadNode(nodeElement);

            List<XmlNode> childNodes = nodeElement.ChildNodes.Cast<XmlNode>().ToList();

            XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name"));
            if (nameNode != null && nameNode.Attributes != null)
                NickName = nameNode.Attributes[0].Value;

            foreach (XmlNode subNode in childNodes)
            {
                if (subNode.Name.Equals("Outputs"))
                {
                    var data =
                        subNode.ChildNodes.Cast<XmlNode>()
                               .Select(
                                   (outputNode, i) =>
                                       new
                                       {
                                           data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1)),
                                           idx = i
                                       });

                    foreach (var dataAndIdx in data)
                    {
                        if (OutPortData.Count > dataAndIdx.idx)
                            OutPortData[dataAndIdx.idx] = dataAndIdx.data;
                        else
                            OutPortData.Add(dataAndIdx.data);
                    }
                }
                else if (subNode.Name.Equals("Inputs"))
                {
                    var data =
                        subNode.ChildNodes.Cast<XmlNode>()
                               .Select(
                                   (inputNode, i) =>
                                       new
                                       {
                                           data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1)),
                                           idx = i
                                       });

                    foreach (var dataAndIdx in data)
                    {
                        if (InPortData.Count > dataAndIdx.idx)
                            InPortData[dataAndIdx.idx] = dataAndIdx.data;
                        else
                            InPortData.Add(dataAndIdx.data);
                    }
                }

                #region Legacy output support

                else if (subNode.Name.Equals("Output"))
                {
                    var data = new PortData(subNode.Attributes[0].Value, "function output");

                    if (OutPortData.Any())
                        OutPortData[0] = data;
                    else
                        OutPortData.Add(data);
                }

                #endregion
            }

            if (!Controller.IsInSyncWithNode(this))
            {
                Controller.SyncNodeWithDefinition(this);
            }
            else
            {
                RegisterAllPorts();
            }

            //argument lacing on functions should be set to disabled
            //by default in the constructor, but for any workflow saved
            //before this was the case, we need to ensure it here.
            ArgumentLacing = LacingStrategy.Disabled;
        }
예제 #19
0
파일: NodeModel.cs 프로젝트: w-fish/Dynamo
        /// <summary>
        ///     Add a port to this node. If the port already exists, return that port.
        /// </summary>
        /// <param name="portType"></param>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public PortModel AddPort(PortType portType, PortData data, int index)
        {
            PortModel p;
            switch (portType)
            {
                case PortType.Input:
                    if (inPorts.Count > index)
                    {
                        p = inPorts[index];
                        p.SetPortData(data);
                    }
                    else
                    {
                        p = new PortModel(portType, this, data);

                        p.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
                        {
                            if (args.PropertyName == "UsingDefaultValue")
                            {
                                OnNodeModified();
                            }
                        };

                        //register listeners on the port
                        p.PortConnected += PortConnected;
                        p.PortDisconnected += PortDisconnected;

                        InPorts.Add(p);
                    }
                    
                    return p;

                case PortType.Output:
                    if (outPorts.Count > index)
                    {
                        p = outPorts[index];
                        p.SetPortData(data);
                    }
                    else
                    {
                        p = new PortModel(portType, this, data);
                        OutPorts.Add(p);

                        //register listeners on the port
                        p.PortConnected += PortConnected;
                        p.PortDisconnected += PortDisconnected;
                    }

                    return p;
            }

            return null;
        }