예제 #1
0
        private void SetColor(Point point)
        {
            if (_pickType == PickerType.Rectangle)
            {
                LockUpdates = true;
                Color       = ColorManager.CurrentPointerColor();
                LockUpdates = false;
            }
            else
            {
                double dx         = Math.Abs(point.X - _centerPoint.X - Padding.Left);
                double dy         = Math.Abs(point.Y - _centerPoint.Y - Padding.Top);
                double angle      = (Math.Atan(dy / dx) / Math.PI) * 180;
                double distance   = Math.Pow(Math.Pow(dx, 2) + Math.Pow(dy, 2), 0.5);
                double saturation = distance / _radius;

                if (distance < 6)
                {
                    saturation = 0; // snap to center
                }

                if (point.X < _centerPoint.X)
                {
                    angle = 180 - angle;
                }

                if (point.Y > _centerPoint.Y)
                {
                    angle = 360 - angle;
                }

                LockUpdates = true;
                HslManager  = new HSLManager(angle, saturation, 0.5);
                Color       = HslManager.ToRgbColor();
                LockUpdates = false;
            }
        }