示例#1
0
 static HSLColourStructure()
 {
     Empty = new HSLColourStructure
     {
         IsEmpty = true
     };
 }
示例#2
0
        protected virtual void PaintColour(PaintEventArgs e, HSLColourStructure colour, bool includeFocus)
        {
            PointF location;

            location = this.GetColourLocation(colour);

            if (!float.IsNaN(location.X) && !float.IsNaN(location.Y))
            {
                int x;
                int y;

                x = (int)location.X - _selectionSize / 2;
                y = (int)location.Y - _selectionSize / 2;

                if (_selectionGlyph == null)
                {
                    e.Graphics.DrawRectangle(Pens.Black, x, y, _selectionSize, _selectionSize);
                }
                else
                {
                    e.Graphics.DrawImage(_selectionGlyph, x, y);
                }

                if (this.Focused && includeFocus)
                {
                    ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(x - 1, y - 1, _selectionSize + 2, _selectionSize + 2));
                }
            }
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColourWheelControl"/> class.
 /// </summary>
 public ColourWheelControl()
 {
     this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true);
     _colour        = Color.Black;
     _hslColour     = new HSLColourStructure(_colour);
     _colourStep    = 4;
     _selectionSize = 10;
     _smallChange   = 1;
     _largeChange   = 5;
 }
示例#4
0
        /// <summary>
        /// Gets the point within the wheel representing the source color.
        /// </summary>
        /// <param name="colour">The color.</param>
        protected virtual PointF GetColourLocation(HSLColourStructure colour)
        {
            double angle;
            double radius;

            angle  = colour.H * Math.PI / 180;
            radius = _radius * colour.S;

            return(this.GetColourLocation(angle, radius));
        }
示例#5
0
        protected virtual void CreateScale()
        {
            HSLColourStructure colour;

            colour = new HSLColourStructure(this.Colour);

            colour.L     = 0;
            this.Colour1 = colour.ToRgbColour();

            colour.L     = 1;
            this.Colour2 = colour.ToRgbColour();
        }
示例#6
0
        /// <summary>
        /// Raises the <see cref="ColourSlider.ValueChanged" /> event.
        /// </summary>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected override void OnValueChanged(EventArgs e)
        {
            if (!this.LockUpdates)
            {
                HSLColourStructure colour;

                this.LockUpdates = true;
                colour           = new HSLColourStructure(this.Colour);
                colour.L         = this.Value / 100D;
                _colour          = colour.ToRgbColour();
                this.OnColourChanged(e);
                this.LockUpdates = false;
            }

            base.OnValueChanged(e);
        }
示例#7
0
        protected virtual void SetColour(Point point)
        {
            double             dx;
            double             dy;
            double             angle;
            double             distance;
            double             saturation;
            Padding            padding;
            HSLColourStructure newColour;

            padding    = this.Padding;
            dx         = Math.Abs(point.X - _centerPoint.X - padding.Left);
            dy         = Math.Abs(point.Y - _centerPoint.Y - padding.Top);
            angle      = Math.Atan(dy / dx) / Math.PI * 180;
            distance   = Math.Pow(Math.Pow(dx, 2) + Math.Pow(dy, 2), 0.5);
            saturation = distance / _radius;

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

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

            newColour = new HSLColourStructure(angle, saturation, 0.5);

            if (_hslColour != newColour)
            {
                _lockUpdates   = true;
                this.HSLColour = newColour;
                this.Colour    = _hslColour.ToRgbColour();
                _lockUpdates   = false;
            }
        }
示例#8
0
 protected void PaintColour(PaintEventArgs e, HSLColourStructure colour)
 {
     this.PaintColour(e, colour, false);
 }