Ejemplo n.º 1
0
        public static void InjectCustomStyle(this DlogPort port)
        {
            var cap   = port.Q("cap");
            var width = cap.style.width;

            width.value     = new Length(8, LengthUnit.Pixel);
            cap.style.width = width;
            var height = cap.style.height;

            height.value     = new Length(12, LengthUnit.Pixel);
            cap.style.height = height;

            // Border color
            var bLColor = cap.style.borderLeftColor;

            bLColor.value             = port.portColor;
            cap.style.borderLeftColor = bLColor;

            var bTColor = cap.style.borderTopColor;

            bTColor.value            = port.portColor;
            cap.style.borderTopColor = bTColor;

            var bRColor = cap.style.borderRightColor;

            bRColor.value = port.portColor;
            cap.style.borderRightColor = bRColor;

            var bBColor = cap.style.borderBottomColor;

            bBColor.value = port.portColor;
            cap.style.borderBottomColor = bBColor;
        }
Ejemplo n.º 2
0
        public static DlogPort Create(string name, Orientation portOrientation, Direction portDirection, Capacity portCapacity, PortType type, bool required, EdgeConnectorListener edgeConnectorListener, bool hideLabel = false)
        {
            var port = new DlogPort(portOrientation, portDirection, portCapacity);

            if (edgeConnectorListener != null)
            {
                port.m_EdgeConnector = new EdgeConnector <Edge>(edgeConnectorListener);
                port.AddManipulator(port.m_EdgeConnector);
            }

            port.AddStyleSheet("Styles/Node/Port");
            if (!required)
            {
                port.AddToClassList("optional");
            }

            port.type        = type;
            port.portColor   = PortHelper.PortColor(port);
            port.viewDataKey = Guid.NewGuid().ToString();
            port.portName    = name;

            if (hideLabel)
            {
                var label = port.Q <Label>();
                var fs    = label.style.fontSize;
                fs.value             = -1;
                label.style.fontSize = fs;
                var color = label.style.color;
                color.value       = Color.clear;
                label.style.color = color;
            }


            port.InjectCustomStyle();

            return(port);
        }