Esempio n. 1
0
        public GradientPointsControl()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.Selectable, true);
            SetStyle(ControlStyles.DoubleBuffer, true);

            _gradientPoints = new GradientPointCollection(this);
            ResetGradientPoints();
            _startColor = c_DefStartColor;
            _endColor   = c_DefEndColor;
            Padding     = c_DefPadding;

            _selectedPoint = _gradientPoints[0];
        }
Esempio n. 2
0
        protected internal virtual void OnPointsChanged(
            GradientPointCollection points)
        {
            if (_selectedPoint != null)
            {
                // update selected item
                if (_gradientPoints.IndexOf(_selectedPoint) == -1)
                {
                    if (_gradientPoints.Count == 0)
                    {
                        SelectedPoint = null;
                    }
                    else
                    {
                        int i;
                        for (i = 0; i < _gradientPoints.Count && _gradientPoints[i].Position < _selectedPoint.Position; i++)
                        {
                            ;
                        }

                        if (i >= _gradientPoints.Count)
                        {
                            SelectedPoint = _gradientPoints[_gradientPoints.Count - 1];
                        }
                        else
                        {
                            SelectedPoint = _gradientPoints[i];
                        }
                    }
                    if (!UpdateLocked)
                    {
                        OnSelectedPointChanged();
                    }
                }
            }
            if (!UpdateLocked)
            {
                Refresh();
            }
        }