Exemple #1
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="node">PropertyNode</param>
        public SliderValueEditorContext(PropertyNode node)
        {
            m_node = node;
            m_node.ValueChanged += new EventHandler(Node_ValueChanged);
            Update();

            NumberRangesAttribute numberRange
                = m_node.Descriptor.Attributes[typeof(NumberRangesAttribute)] as NumberRangesAttribute;

            if (numberRange != null)
            {
                Max = numberRange.Maximum;
                Min = numberRange.Minimum;
            }
            else
            {
                Max = double.MaxValue;
                Min = double.MinValue;
            }

            NumberIncrementsAttribute numberInc
                = m_node.Descriptor.Attributes[typeof(NumberIncrementsAttribute)] as NumberIncrementsAttribute;

            if (numberInc != null)
            {
                SmallChange = numberInc.SmallChange;
                LargeChange = numberInc.LargeChange;
            }
            else
            {
                SmallChange = 1;
                LargeChange = 10;
            }

            NumberFormatAttribute numberFormat
                = m_node.Descriptor.Attributes[typeof(NumberFormatAttribute)] as NumberFormatAttribute;

            if (numberFormat != null)
            {
                FormatString = numberFormat.FormatString;
            }
            else
            {
                FormatString = "{0:0.00}";
            }
        }
Exemple #2
0
        /// <summary>
        /// Tests equality to an object</summary>
        /// <param name="obj">Object to compare to</param>
        /// <returns>True iff objects are equal</returns>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            NumberFormatAttribute attribute = obj as NumberFormatAttribute;

            if (attribute != null)
            {
                if ((attribute.formatString == this.formatString) && (attribute.maxPrecision == this.maxPrecision))
                {
                    return(attribute.scale == this.scale);
                }
            }
            return(false);
        }