Пример #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}";
            }
        }
Пример #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);
            }
            NumberRangesAttribute attribute = obj as NumberRangesAttribute;

            if (attribute != null)
            {
                if (((attribute.minimum == this.minimum)) && ((attribute.maximum == this.maximum)))
                {
                    return(true);
                }
            }
            return(false);
        }