예제 #1
0
        public void SetupCastSettings(object obj)
        {
            if (obj != null && obj is Behaviac.Design.Nodes.Node)
            {
                Behaviac.Design.Nodes.Node assignNode = obj as Behaviac.Design.Nodes.Node;

                if (assignNode != null)
                {
                    bool bCasting = assignNode.IsCasting;

                    if (bCasting)
                    {
                        DesignerPropertyInfo leftPropInfo = DesignerProperty.GetDesignerProperty(assignNode.GetType(), "Opl");
                        VariableDef          opl          = (VariableDef)leftPropInfo.GetValue(assignNode);

                        Type leftType = opl.ValueType;

                        // if number
                        if (Plugin.IsIntergerNumberType(leftType) || Plugin.IsFloatType(leftType))
                        {
                            this.ValueType = ValueTypes.Int | ValueTypes.Float;

                            this.FilterType = null;
                        }
                        else if (Plugin.IsRefType(leftType))
                        {
                            //ref type/pointer type
                            this.ValueType = ValueTypes.RefType;

                            this.FilterType = leftType;
                        }
                        else
                        {
                            //
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Returns the property this one is linked to.
        /// </summary>
        /// <param name="linkBroken">Is true if a link was found but it does not work.</param>
        /// <returns>The info of the property this is linked to.</returns>
        public DesignerPropertyInfo GetLinkedProperty(object obj, out bool linkBroken)
        {
            linkBroken = false;

            if (string.IsNullOrEmpty(_linkedToProperty))
            {
                return(new DesignerPropertyInfo());
            }

            DesignerPropertyInfo dpi = DesignerProperty.GetDesignerProperty(obj.GetType(), _linkedToProperty);

            // if we are linked to a DesignerNodeProperty we get the information of its assigned property
            DesignerNodeProperty dnp = dpi.Attribute as DesignerNodeProperty;

            if (dnp == null)
            {
                return(dpi);
            }

            Attachments.Attachment attach = (Attachments.Attachment)obj;

            // check if a valid property is associated
            object objvalue = dpi.Property.GetValue(obj, null);

            string value = dnp.GetDisplayValue(objvalue);

            if (string.IsNullOrEmpty(value) || value == Resources.DesignerNodePropertyNone)
            {
                linkBroken = true;

                return(new DesignerPropertyInfo());
            }

            // return the property we are pointing at
            return(DesignerProperty.GetDesignerProperty(attach.Node.GetType(), value));
        }