Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Tick event of the m_timer control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void m_timer_Tick(object sender, EventArgs e)
        {
            m_timer.Stop();

            if (!Enabled)
            {
                return;
            }

            // Actions according to mouse clicks
            switch (m_mouseEvent.Clicks)
            {
            case 1:
            {
                base.OnMouseClick(m_mouseEvent);

                int newValue = GetValueAt(m_mouseEvent.Location);

                if (newValue == -1)
                {
                    return;
                }

                if (newValue < m_baseValue)
                {
                    newValue = m_baseValue;
                }

                DeltaValue = newValue - m_value;

                if (DeltaValue == 0)
                {
                    return;
                }

                // Fires the value changing event
                ValueChanging?.ThreadSafeInvoke(this, new AttributeValueChangingEventArgs(DeltaValue));

                if (DeltaValue == 0)
                {
                    return;
                }

                Value += DeltaValue;
            }
            break;

            case 2:
            {
                base.OnMouseDoubleClick(m_mouseEvent);

                Value = m_baseValue;
            }
            break;
            }

            // Fires the value changed event
            ValueChanged?.ThreadSafeInvoke(this, new AttributeValueChangedEventArgs());
        }