Пример #1
0
        /// <summary>
        /// Removes any connection using this property.
        /// </summary>
        /// <param name="property">The `KimonoProperty` to remove.</param>
        public virtual void RemoveProperty(KimonoProperty property)
        {
            // Remove any connection that is using this property
            for (int n = PropertyConnections.Count - 1; n >= 0; --n)
            {
                // Grab the connection
                var connection = PropertyConnections[n];

                // Found match?
                if (connection.ConnectedProperty == property)
                {
                    // Yes, break this connection
                    PropertyConnections.RemoveAt(n);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Clone this instance.
        /// </summary>
        /// <returns>The clone.</returns>
        public virtual KimonoProperty Clone()
        {
            // Make copy
            var newProperty = new KimonoProperty()
            {
                UniqueID            = this.UniqueID,
                Name                = this.Name,
                Usage               = this.Usage,
                IsObiScriptValue    = this.IsObiScriptValue,
                GetsValueFromScript = this.GetsValueFromScript,
                ObiScript           = this.ObiScript
            };

            // Return clone
            return(newProperty);
        }
Пример #3
0
        /// <summary>
        /// Adds a new parameter scoped supporting property.
        /// </summary>
        /// <returns>The element name of the newly added supporting property.</returns>
        /// <param name="property">The `KimonoProperty` to add.</param>
        public static string AddSupportingParameterProperty(KimonoProperty property)
        {
            // Scan all properties
            foreach (KimonoProperty supportProperty in ParameterProperties)
            {
                // Already in collection?
                if (supportProperty == property)
                {
                    return(supportProperty.ElementName);
                }
            }

            // Generate element name and add to collection
            property.ElementName = MakeElementName(property.Name);
            ParameterProperties.Add(property);

            // Return the new element name
            return(property.ElementName);
        }
Пример #4
0
        /// <summary>
        /// Adds the supporting property to the correct list based on its usage.
        /// </summary>
        /// <returns>The element name of the newly added supporting property.</returns>
        /// <param name="property">The `KimonoProperty` to add.</param>
        public static string AddSupportingProperty(KimonoProperty property)
        {
            var elementName = "";

            // Does this property have a script?
            if (property.ObiScript != "")
            {
                // Is this property's script using any sub colors?
                foreach (KimonoColor color in ObiScriptPortfolio.Portfolio.Colors)
                {
                    // Test for script
                    if (property.ObiScript.Contains(color.Name))
                    {
                        // Yes, add as supporting
                        AddSupportingColor(color);
                    }
                }

                // Is this property's script using any sub gradients?
                foreach (KimonoGradient gradient in ObiScriptPortfolio.Portfolio.Gradients)
                {
                    // Test for script
                    if (property.ObiScript.Contains(gradient.Name))
                    {
                        // Yes, add as supporting
                        AddSupportingGradient(gradient);
                    }
                }

                // Is this property's script using any sub styles?
                foreach (KimonoStyle style in ObiScriptPortfolio.Portfolio.Styles)
                {
                    // Test for script
                    if (property.ObiScript.Contains(style.Name))
                    {
                        // Yes, add as supporting
                        AddSupportingStyle(style);
                    }
                }

                // Is this property's script using any sub properties?
                foreach (KimonoProperty scanProperty in ObiScriptPortfolio.Portfolio.Properties)
                {
                    // Test for script
                    if (property.ObiScript.Contains(scanProperty.Name))
                    {
                        // Yes, add this as a supporting property
                        AddSupportingProperty(scanProperty);
                    }
                }
            }

            // Take action based on the property's scope
            switch (property.Usage)
            {
            case KimonoPropertyUsage.GlobalVariable:
                elementName = AddSupportingGlobalProperty(property);
                break;

            case KimonoPropertyUsage.LocalVariable:
                elementName = AddSupportingLocalProperty(property);
                break;

            case KimonoPropertyUsage.Parameter:
                elementName = AddSupportingParameterProperty(property);
                break;
            }

            // Return the new element name
            return(elementName);
        }
Пример #5
0
        /// <summary>
        /// Connects the given `KimonoProperty` to the given `KimonoPropertyConnectionPoint` on
        /// this `KimonoShape`.
        /// </summary>
        /// <param name="connectionPoint">The `KimonoPropertyConnectionPoint` to connect to.</param>
        /// <param name="property">The `KimonoProperty` to connect.</param>
        public virtual void AddPropertyConnection(KimonoPropertyConnectionPoint connectionPoint, KimonoProperty property)
        {
            // Is this connection point already used?
            foreach (KimonoPropertyConnection connection in PropertyConnections)
            {
                // Found?
                if (connection.ConnectionPoint == connectionPoint)
                {
                    // Yes, replace the connected property
                    connection.ConnectedProperty = property;
                    return;
                }
            }

            // Not found, add
            PropertyConnections.Add(new KimonoPropertyConnection(connectionPoint, property));
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:KimonoCore.KimonoPropertyConnection"/> class.
 /// </summary>
 /// <param name="connectionPoint">Connection point.</param>
 /// <param name="property">Property.</param>
 public KimonoPropertyConnection(KimonoPropertyConnectionPoint connectionPoint, KimonoProperty property)
 {
     // Initialize
     ConnectionPoint   = connectionPoint;
     ConnectedProperty = property;
 }