public ColorSlider(ColorSliderMode colorMode) { _colorMode = colorMode; _baseColor = new ColorHLS(255, 255, 0, 0); _currentColor = _baseColor.Clone(); _previusColor = _baseColor.Clone(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.FixedHeight | ControlStyles.FixedWidth | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); this.Size = new System.Drawing.Size(20, 256); _cursorRect = new Rectangle(0, 256 - 4, 20, 7); _onDrag = false; _pixBuffer = new PixelBuffer(20, 256); FillBuffer(); this.Invalidate(); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); _previusColor = _currentColor.Clone(); MouseEvent(e); _onDrag = true; }
private void FillBuffer() { ColorHLS startColor = new ColorHLS(255, 255, 255, 255); ColorHLS endColor = _baseColor.Clone(); float[,] colorsStepStart = ColorUtils.GetGradientColorSteps(startColor, new ColorHLS(255, 0, 0, 0), 256); float[,] colorsStepEnd = ColorUtils.GetGradientColorSteps(endColor, new ColorHLS(255, 0, 0, 0), 256); for (int i = 0; i < 256; i++) { startColor.SetRGB((byte)colorsStepStart[i, 0], (byte)colorsStepStart[i, 1], (byte)colorsStepStart[i, 2]); endColor.SetRGB((byte)colorsStepEnd[i, 0], (byte)colorsStepEnd[i, 1], (byte)colorsStepEnd[i, 2]); _pixBuffer.DrawLine(0, i, 256, i, startColor, endColor); } }
public ColorPicker() { _baseColor = new ColorHLS(255, 255, 0, 0); _currentColor = _baseColor.Clone(); _previusColor = _baseColor.Clone(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.FixedHeight | ControlStyles.FixedWidth | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); this.Size = new System.Drawing.Size(256, 256); _cursorRect = new Rectangle(252, -3, 9, 9); _onDrag = false; _pixBuffer = new PixelBuffer(256, 256); FillBuffer(); MouseEvent(new MouseEventArgs(MouseButtons.Left, 1, _cursorRect.X + 4, _cursorRect.Y + 4, 0)); }
public ColorSlider(ColorSliderMode colorMode, ColorSliderOrientation orientation) { _colorMode = colorMode; _orientation = orientation; _baseColor = new ColorHLS(255, 255, 0, 0); _currentColor = _baseColor.Clone(); _previusColor = _baseColor.Clone(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.FixedHeight | ControlStyles.FixedWidth | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); if (_orientation == ColorSliderOrientation.Vertical) { this.Size = new System.Drawing.Size(20, 256); _cursorRect = new Rectangle(0, 256 - 4, 20, 7); } else { this.Size = new System.Drawing.Size(256, 20); _cursorRect = new Rectangle(-3, 0, 7, 20); } _onDrag = false; //_pixBuffer = new PixelBuffer(this.Width, this.Height); //FillBuffer(); this.Invalidate(); }
public ColorSlider(ColorSliderMode colorMode,ColorSliderOrientation orientation) { _colorMode = colorMode; _orientation = orientation; _baseColor = new ColorHLS(255, 255, 0, 0); _currentColor = _baseColor.Clone(); _previusColor = _baseColor.Clone(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.FixedHeight | ControlStyles.FixedWidth | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); if (_orientation == ColorSliderOrientation.Vertical) { this.Size = new System.Drawing.Size(20, 256); _cursorRect = new Rectangle(0, 256 - 4, 20, 7); } else { this.Size = new System.Drawing.Size(256, 20); _cursorRect = new Rectangle(- 3,0 , 7, 20); } _onDrag = false; //_pixBuffer = new PixelBuffer(this.Width, this.Height); //FillBuffer(); this.Invalidate(); }