Set Control Properties


Node Information
Sets properties to the specifed control. Click on the info button for available properties.
General Information
• This node has other options, you can view them by clicking on the info button, this also means according to the node you might be able to add more ports than what is already listed.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Set IN RUN MULTIPLE FALSE FALSE
Get IN Object ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Control
{
    [IsNode("Set Properties")]
    public class ControlSetProperties : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Set");
        Port objectRefIn = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "Get");
        public ControlSetProperties()
        {
            this.NodeType = NodeType.Method;
            this.Name = "Set Control Properties";
            this.OptionsAvilable = true;
            AddPort(run);
            AddPort(objectRefIn);
            Information = "Sets properties to the specifed control. Click on the info button for available properties.";
            CreateContextMenu();
        }
        public void CreateContextMenu()
        {
            if (ReferenceType == typeof(object))
            {
                return;
            }
            InfoContextMenu = GetObjectPropertiesMenu(ReferenceType, true);
        }
        public override void OnPropertiesMenuSelected(ObjectPropertyInfo opi)
        {
            Port newport = new Port(PortType.IN, opi.DataType, AcceptsLinks.ONE, opi.Name, true);
            newport.DataType = opi.DataType;
            newport.IsRemovable = true;
            AddPort(newport);
        }
        public override string Code()
        {
            string code = string.Empty;
            if (objectRefIn.IsConnected)
            {
                string objname = objectRefIn.ConnectedPorts[0].ParentNode.ReferenceName;
                foreach (var port in Ports)
                {
                    if (port.IsExtra)
                    {
                        code += objname + "." + port.Text + " = " + GetValue(port) + ";\r\n"; 
                    }
                }
            }
            return code;
        }
        public override void UpdateResults()
        {
            if (objectRefIn.IsConnected)
            {
                Port connectingport = objectRefIn.ConnectedPorts[0];
                if (connectingport.DataType != typeof(object))
                {
                    ReferenceType = connectingport.DataType;
                    if (string.IsNullOrWhiteSpace(connectingport.ParentNode.ReferenceName))
                    {
                        ReferenceName = connectingport.ID;
                    }
                    else
                    {
                        ReferenceName = connectingport.ParentNode.ReferenceName;
                    }
                }
                CreateContextMenu();
            }
            else
            {
                ReferenceName = string.Empty;
                if (InfoContextMenu != null)
                {
                    InfoContextMenu.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
    }
}