Exemplo n.º 1
0
        private void UserControl_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                _min += 1;
                _max += 1;
            }
            else
            {
                _min -= 1;
                _max -= 1;
            }

            if (_min < 0)
            {
                _min = 0;
            }

            if (_max + cursorWidth > Width)
            {
                _max = Width - cursorWidth;
            }

            if (_min > _max)
            {
                _min = _max - cursorWidth;
            }

            Invalidate();

            if (RangeChangedEvent != null)
            {
                RangeChangedEvent.Invoke(this, _min, _max);
            }
        }
Exemplo n.º 2
0
        private void UserControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (TheMouseStateMachine == MouseStateMachine.LeftMove)
            {
                Min         += e.Location.X - clicPosition.X;
                clicPosition = e.Location;

                if (Min < 0)
                {
                    Min = 0;
                }

                if (Min + cursorWidth > Width)
                {
                    Min = Width - cursorWidth;
                }

                if (Min + cursorWidth > Max)
                {
                    Min = Max - cursorWidth;
                }
            }
            else if (TheMouseStateMachine == MouseStateMachine.RightMove)
            {
                Max         += e.Location.X - clicPosition.X;
                clicPosition = e.Location;

                if (Max < 0)
                {
                    Max = 0;
                }

                if (Max + cursorWidth > Width)
                {
                    Max = Width - cursorWidth;
                }

                if (Max < Min + cursorWidth)
                {
                    Max = Min + cursorWidth;
                }
            }

            if (RangeChangedEvent != null)
            {
                RangeChangedEvent.Invoke(this, _min, _max + cursorWidth);
            }
        }
Exemplo n.º 3
0
        private void Update()
        {
            var tickMax = Interval == -1 ? lastValue : Interval;

            if (timeSinceLastChange >= tickMax)
            {
                lastValue           = UnityEngine.Random.Range(MinValue, MaxValue);
                timeSinceLastChange = 0f;

                OnChanged.Invoke(lastValue);
            }
            else
            {
                timeSinceLastChange += Time.deltaTime;
            }
        }