/// <summary>
        /// Sets the format of a custom property.
        /// </summary>
        /// <param name="parameter">The <see cref="Parameter"/> instance that this extension method affects.</param>
        /// <param name="displayPrecision">The precision used to format the parameter's value.</param>
        /// <param name="showUnit">A value which indicates whether to display the parameter's unit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="parameter"/> is <c>null</c>.</exception>
        public static void SetCustomPropertyFormat(
            this Parameter parameter,
            CustomPropertyPrecisionEnum displayPrecision,
            bool showUnit,
            bool showTrailingZeros)
        {
            if (parameter == null)
                throw new ArgumentNullException(nameof(parameter));

            parameter.CustomPropertyFormat.PropertyType = CustomPropertyTypeEnum.kTextPropertyType;
            parameter.CustomPropertyFormat.Precision = displayPrecision;
            parameter.CustomPropertyFormat.ShowUnitsString = showUnit;
            parameter.CustomPropertyFormat.ShowTrailingZeros = showTrailingZeros;
        }
        /// <summary>
        /// Sets the format of a custom property.
        /// </summary>
        /// <param name="parameter">The <see cref="Parameter"/> instance that this extension method affects.</param>
        /// <param name="displayPrecision">The precision used to format the parameter's value.</param>
        /// <param name="showUnit">A value which indicates whether to display the parameter's unit.</param>
        /// <exception cref="ArgumentNullException"><paramref name="parameter"/> is <c>null</c>.</exception>
        public static void SetCustomPropertyFormat(
            this Parameter parameter,
            CustomPropertyPrecisionEnum displayPrecision,
            bool showUnit,
            bool showTrailingZeros)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            parameter.CustomPropertyFormat.PropertyType      = CustomPropertyTypeEnum.kTextPropertyType;
            parameter.CustomPropertyFormat.Precision         = displayPrecision;
            parameter.CustomPropertyFormat.ShowUnitsString   = showUnit;
            parameter.CustomPropertyFormat.ShowTrailingZeros = showTrailingZeros;
        }
        public void SetCustomPropertyFormat(CustomPropertyPrecisionEnum displayPrecision, bool showTrailingZeros)
        {
            foreach (var propertyName in CustomPropertyNames)
            {
                var parameter = Document.ComponentDefinition.Parameters.TryGetValue(propertyName);

                try
                {
                    parameter?.SetCustomPropertyFormat(
                        displayPrecision,
                        showUnit: false,
                        showTrailingZeros: showTrailingZeros
                    );
                }
                catch
                {
                }
            }
        }
Пример #4
0
        public void SetCustomPropertyFormat(CustomPropertyPrecisionEnum displayPrecision, bool showTrailingZeros)
        {
            foreach (var propertyName in CustomPropertyNames)
            {
                var parameter = Document.ComponentDefinition.Parameters.TryGetValue(propertyName);

                try
                {
                    parameter?.SetCustomPropertyFormat(
                        displayPrecision,
                        showUnit: false,
                        showTrailingZeros: showTrailingZeros
                        );
                }
                catch
                {
                }
            }
        }